Work on project manager and project panel

This commit is contained in:
2014-07-27 16:21:06 +03:00
parent 48972dfb52
commit 5e526fa48c
40 changed files with 961 additions and 139 deletions

View File

@ -25,9 +25,6 @@ namespace RainmeterStudio.UI.Controller
{
_documentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow())
{
DisplayText = Resources.Strings.DocumentCreateCommand_DisplayText,
Tooltip = Resources.Strings.DocumentCreateCommand_ToolTip,
Icon = new BitmapImage(new Uri(Resources.Icons.DocumentCreateCommand_Icon, UriKind.RelativeOrAbsolute)),
Shortcut = new KeyGesture(Key.N, ModifierKeys.Control)
};
}

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using RainmeterStudio.Model;
namespace RainmeterStudio.UI.Controller
{
public static class IconProvider
{
private static Dictionary<string, ImageSource> _loadedImages = new Dictionary<string, ImageSource>();
public static ImageSource GetIcon(string key)
{
if (!_loadedImages.ContainsKey(key))
{
// Try to get the icon file name
string iconPath = Resources.Icons.ResourceManager.GetString(key);
if (iconPath == null)
return null;
// Load the image
var uri = new Uri(iconPath, UriKind.RelativeOrAbsolute);
_loadedImages.Add(key, new BitmapImage(uri));
}
return _loadedImages[key];
}
public static ImageSource GetProjectItemIcon(Reference item)
{
// Resource name
string key = "ProjectItem";
if (Directory.Exists(item.Path))
key += "Directory";
else if (File.Exists(item.Path))
key += "_" + Path.GetExtension(item.Path).Substring(1);
else key += "None";
// Get icon
var icon = GetIcon(key);
if (icon == null)
return GetIcon("ProjectItemUnknown");
return icon;
}
}
public class IconProviderConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var tree = value as Tree<Reference>;
if (tree != null)
{
return IconProvider.GetProjectItemIcon(tree.Data);
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@ -44,7 +44,7 @@ namespace RainmeterStudio.UI.Controller
{
get
{
return Manager.ActiveProjectPath;
return Manager.ActiveProject.Path;
}
}
@ -78,11 +78,8 @@ namespace RainmeterStudio.UI.Controller
{
if (_projectCreateCommand == null)
{
_projectCreateCommand = new Command("ProjectCreateComand", () => CreateProject())
_projectCreateCommand = new Command("ProjectCreateCommand", () => CreateProject())
{
DisplayText = Resources.Strings.ProjectCreateCommand_DisplayText,
Tooltip = Resources.Strings.ProjectCreateCommand_ToolTip,
Icon = new BitmapImage(new Uri(Resources.Icons.ProjectCreateCommand_Icon, UriKind.RelativeOrAbsolute)),
Shortcut = new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift)
};
}
@ -123,10 +120,11 @@ namespace RainmeterStudio.UI.Controller
if (!res.HasValue || !res.Value)
return;
string selectedName = dialog.SelectedName;
string selectedPath = dialog.SelectedPath;
// Call manager
Manager.CreateProject(name, selectedPath); // TODO
Manager.CreateProject(selectedName, selectedPath);
}
/// <summary>