mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Work on project panel, trees, added settings
This commit is contained in:
@@ -23,10 +23,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
if (_documentCreateCommand == null)
|
||||
{
|
||||
_documentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow())
|
||||
{
|
||||
Shortcut = new KeyGesture(Key.N, ModifierKeys.Control)
|
||||
};
|
||||
_documentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow());
|
||||
}
|
||||
|
||||
return _documentCreateCommand;
|
||||
|
@@ -55,10 +55,10 @@ namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tree = value as Tree<Reference>;
|
||||
if (tree != null)
|
||||
var reference = value as Reference;
|
||||
if (reference != null)
|
||||
{
|
||||
return IconProvider.GetProjectItemIcon(tree.Data);
|
||||
return IconProvider.GetProjectItemIcon(reference);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Microsoft.Win32;
|
||||
using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Model;
|
||||
using RainmeterStudio.UI.Dialogs;
|
||||
@@ -71,22 +72,9 @@ namespace RainmeterStudio.UI.Controller
|
||||
|
||||
#region Commands
|
||||
|
||||
private Command _projectCreateCommand;
|
||||
public Command ProjectCreateCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_projectCreateCommand == null)
|
||||
{
|
||||
_projectCreateCommand = new Command("ProjectCreateCommand", () => CreateProject())
|
||||
{
|
||||
Shortcut = new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift)
|
||||
};
|
||||
}
|
||||
public Command ProjectCreateCommand { get; private set; }
|
||||
|
||||
return _projectCreateCommand;
|
||||
}
|
||||
}
|
||||
public Command ProjectOpenCommand { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -97,6 +85,9 @@ namespace RainmeterStudio.UI.Controller
|
||||
public ProjectController(ProjectManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
|
||||
ProjectCreateCommand = new Command("ProjectCreateCommand", () => CreateProject());
|
||||
ProjectOpenCommand = new Command("ProjectOpenCommand", () => OpenProject());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -133,7 +124,21 @@ namespace RainmeterStudio.UI.Controller
|
||||
/// <param name="path"></param>
|
||||
public void OpenProject(string path = null)
|
||||
{
|
||||
// Open dialog
|
||||
OpenFileDialog dialog = new OpenFileDialog();
|
||||
dialog.Filter = Resources.Strings.Dialog_FileType_Project + "|*.rsproj|"
|
||||
+ Resources.Strings.Dialog_FileType_AllFiles + "|*.*";
|
||||
dialog.Title = Resources.Strings.Dialog_OpenProject_Title;
|
||||
dialog.Multiselect = false;
|
||||
|
||||
// Show dialog
|
||||
bool? res = dialog.ShowDialog(OwnerWindow);
|
||||
if (!res.HasValue || !res.Value)
|
||||
return;
|
||||
|
||||
// Call manager
|
||||
string filename = dialog.FileName;
|
||||
Manager.OpenProject(filename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
49
RainmeterStudio/UI/Controller/SettingsProvider.cs
Normal file
49
RainmeterStudio/UI/Controller/SettingsProvider.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
public static class SettingsProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to retrieve the setting of type T, where T is class
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Any class type</typeparam>
|
||||
/// <param name="name">Name of setting</param>
|
||||
/// <returns>Retrieved setting, or null if not found</returns>
|
||||
public static T GetSetting<T> (string name) where T : class
|
||||
{
|
||||
var property = Properties.Settings.Default.Properties
|
||||
.OfType<SettingsProperty>()
|
||||
.FirstOrDefault(x => String.Equals(x.Name, name));
|
||||
|
||||
return (property == null) ? null : (property.DefaultValue as T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to retrieve the setting of type T
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Any type</typeparam>
|
||||
/// <param name="name">Name of setting</param>
|
||||
/// <param name="value">Output value</param>
|
||||
/// <returns>True if attempt was successful</returns>
|
||||
public static bool TryGetSetting<T>(string name, out T value)
|
||||
{
|
||||
var property = Properties.Settings.Default.Properties.OfType<SettingsProperty>().FirstOrDefault(x => x.Name.Equals(name));
|
||||
|
||||
if (property != null)
|
||||
{
|
||||
value = (T)property.DefaultValue;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user