diff --git a/Docs/RainmeterStudio Plugin Documentation.odt b/Docs/RainmeterStudio Plugin Documentation.odt new file mode 100644 index 00000000..d86306b1 Binary files /dev/null and b/Docs/RainmeterStudio Plugin Documentation.odt differ diff --git a/RainmeterStudio.Core/Documents/DocumentTemplate.cs b/RainmeterStudio.Core/Documents/DocumentTemplate.cs index 6085aba9..9591cbe0 100644 --- a/RainmeterStudio.Core/Documents/DocumentTemplate.cs +++ b/RainmeterStudio.Core/Documents/DocumentTemplate.cs @@ -1,4 +1,6 @@ -using RainmeterStudio.Core.Model; +using System.Collections.Generic; +using System.Linq; +using RainmeterStudio.Core.Model; namespace RainmeterStudio.Core.Documents { @@ -17,6 +19,18 @@ namespace RainmeterStudio.Core.Documents /// public string DefaultExtension { get; private set; } + /// + /// Gets or sets the properties of this template + /// + /// Properties are used to display a form dialog after the "New item" dialog closes. + public virtual IEnumerable Properties + { + get + { + return Enumerable.Empty(); + } + } + /// /// Initializes the document template /// diff --git a/RainmeterStudio.Core/RainmeterStudio.Core.csproj b/RainmeterStudio.Core/RainmeterStudio.Core.csproj index 654404fe..75f0bd28 100644 --- a/RainmeterStudio.Core/RainmeterStudio.Core.csproj +++ b/RainmeterStudio.Core/RainmeterStudio.Core.csproj @@ -35,6 +35,7 @@ + @@ -62,7 +63,9 @@ + + diff --git a/RainmeterStudio.Core/Utils/BitmapHelper.cs b/RainmeterStudio.Core/Utils/BitmapHelper.cs new file mode 100644 index 00000000..b6818d06 --- /dev/null +++ b/RainmeterStudio.Core/Utils/BitmapHelper.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace RainmeterStudio.Core.Utils +{ + public static class BitmapHelper + { + public static ImageSource GetImageSource(this System.Drawing.Bitmap image) + { + BitmapSource destination; + IntPtr bitmapHandle = image.GetHbitmap(); + BitmapSizeOptions sizeOptions = BitmapSizeOptions.FromEmptyOptions(); + destination = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmapHandle, IntPtr.Zero, Int32Rect.Empty, sizeOptions); + destination.Freeze(); + return destination; + } + } + + public class BitmapToImageSourceConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + var bitmap = value as System.Drawing.Bitmap; + if (bitmap != null) + { + return bitmap.GetImageSource(); + } + + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/RainmeterStudio.Core/Utils/InputHelper.cs b/RainmeterStudio.Core/Utils/InputHelper.cs new file mode 100644 index 00000000..30677bcf --- /dev/null +++ b/RainmeterStudio.Core/Utils/InputHelper.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace RainmeterStudio.Core.Utils +{ + /// + /// Helper methods for key gestures + /// + public static class InputHelper + { + /// + /// Converts a key gesture into its string representation + /// + /// Key gesture + /// The string representation + public static string ConvertToString(this KeyGesture gesture) + { + // Safety check + if (gesture == null) + return null; + + // Build string + string text = String.Empty; + + if ((gesture.Modifiers & ModifierKeys.Windows) != 0) + text += "Win+"; + + if ((gesture.Modifiers & ModifierKeys.Control) != 0) + text += "Ctrl+"; + + if ((gesture.Modifiers & ModifierKeys.Alt) != 0) + text += "Alt+"; + + if ((gesture.Modifiers & ModifierKeys.Shift) != 0) + text += "Shift+"; + + text += Enum.GetName(typeof(Key), gesture.Key); + return text; + } + + /// + /// Obtains a key gesture from a string representation + /// + /// The key gesture string + /// A key gesture object + public static KeyGesture GetKeyGesture(string keyGesture) + { + // Safety check + if (keyGesture == null) + return null; + + // Variables + ModifierKeys mods = ModifierKeys.None; + Key key = Key.None; + + // Parse each field + foreach (var field in keyGesture.Split('+')) + { + // Trim surrounding white space + string trimmed = field.Trim(); + + // Parse + if (trimmed.Equals("Win", StringComparison.InvariantCultureIgnoreCase)) + mods |= ModifierKeys.Windows; + if (trimmed.Equals("Ctrl", StringComparison.InvariantCultureIgnoreCase)) + mods |= ModifierKeys.Control; + if (trimmed.Equals("Alt", StringComparison.InvariantCultureIgnoreCase)) + mods |= ModifierKeys.Alt; + if (trimmed.Equals("Shift", StringComparison.InvariantCultureIgnoreCase)) + mods |= ModifierKeys.Shift; + else Enum.TryParse(field, out key); + } + + return new KeyGesture(key, mods); + } + } +} diff --git a/RainmeterStudio.SkinDesigner/RainmeterStudio.SkinDesignerPlugin.csproj b/RainmeterStudio.SkinDesigner/RainmeterStudio.SkinDesignerPlugin.csproj index b2948dbf..32179032 100644 --- a/RainmeterStudio.SkinDesigner/RainmeterStudio.SkinDesignerPlugin.csproj +++ b/RainmeterStudio.SkinDesigner/RainmeterStudio.SkinDesignerPlugin.csproj @@ -35,6 +35,7 @@ + @@ -84,7 +85,7 @@ - + @@ -100,6 +101,9 @@ Strings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + icons\16\text_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + icons\32\text_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/RainmeterStudio/Resources/Icons/16/text_generic.png b/RainmeterStudio.TextEditor/Resources/Icons/16/text_generic.png similarity index 100% rename from RainmeterStudio/Resources/Icons/16/text_generic.png rename to RainmeterStudio.TextEditor/Resources/Icons/16/text_generic.png diff --git a/RainmeterStudio/Resources/Icons/32/text_generic.png b/RainmeterStudio.TextEditor/Resources/Icons/32/text_generic.png similarity index 100% rename from RainmeterStudio/Resources/Icons/32/text_generic.png rename to RainmeterStudio.TextEditor/Resources/Icons/32/text_generic.png diff --git a/RainmeterStudio.TextEditor/Resources/Strings.Designer.cs b/RainmeterStudio.TextEditor/Resources/Strings.Designer.cs new file mode 100644 index 00000000..518d074d --- /dev/null +++ b/RainmeterStudio.TextEditor/Resources/Strings.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34014 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RainmeterStudio.TextEditorPlugin.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Strings { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Strings() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RainmeterStudio.TextEditorPlugin.Resources.Strings", typeof(Strings).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Blank text file. + /// + public static string Template_Text_Description { + get { + return ResourceManager.GetString("Template_Text_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Text file. + /// + public static string Template_Text_DisplayText { + get { + return ResourceManager.GetString("Template_Text_DisplayText", resourceCulture); + } + } + } +} diff --git a/RainmeterStudio.TextEditor/Resources/Strings.resx b/RainmeterStudio.TextEditor/Resources/Strings.resx new file mode 100644 index 00000000..0c7b5470 --- /dev/null +++ b/RainmeterStudio.TextEditor/Resources/Strings.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Blank text file + + + Text file + + \ No newline at end of file diff --git a/RainmeterStudio.TextEditor/TextDocumentTemplate.cs b/RainmeterStudio.TextEditor/TextDocumentTemplate.cs index 721ecbe0..21ea3dca 100644 --- a/RainmeterStudio.TextEditor/TextDocumentTemplate.cs +++ b/RainmeterStudio.TextEditor/TextDocumentTemplate.cs @@ -15,7 +15,7 @@ namespace RainmeterStudio.TextEditorPlugin public class TextDocumentTemplate : DocumentTemplate { public TextDocumentTemplate() - : base("TextDocument", "txt") + : base("Text", "txt") { } diff --git a/RainmeterStudio/Resources/ResourceProvider.cs b/RainmeterStudio/Business/ResourceProvider.cs similarity index 88% rename from RainmeterStudio/Resources/ResourceProvider.cs rename to RainmeterStudio/Business/ResourceProvider.cs index 8b29904c..37d39d5d 100644 --- a/RainmeterStudio/Resources/ResourceProvider.cs +++ b/RainmeterStudio/Business/ResourceProvider.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Reflection; using System.Resources; using System.Windows.Media; -using System.Windows.Media.Imaging; +using RainmeterStudio.Core.Utils; -namespace RainmeterStudio.Resources +namespace RainmeterStudio.Business { /// /// Manages and provides resources @@ -19,6 +19,11 @@ namespace RainmeterStudio.Resources { public ResourceManager Manager; public Assembly Assembly; + + public override string ToString() + { + return String.Format("{{{0}; {1}}}", Manager, Assembly); + } } private static List _resourceManagers = new List(); @@ -94,13 +99,12 @@ namespace RainmeterStudio.Resources foreach (var info in _resourceManagers) { // Try to get resource - var path = info.Manager.GetString(key); + var bitmap = info.Manager.GetObject(key) as System.Drawing.Bitmap; // Found - if (path != null) + if (bitmap != null) { - Uri fullPath = new Uri("/" + info.Assembly.GetName().Name + ";component" + path, UriKind.Relative); - image = new BitmapImage(fullPath); + image = bitmap.GetImageSource(); if (keepInCache) _cacheImages[key] = image; diff --git a/RainmeterStudio/UI/Controller/SettingsProvider.cs b/RainmeterStudio/Business/SettingsProvider.cs similarity index 76% rename from RainmeterStudio/UI/Controller/SettingsProvider.cs rename to RainmeterStudio/Business/SettingsProvider.cs index e6902f77..461ea424 100644 --- a/RainmeterStudio/UI/Controller/SettingsProvider.cs +++ b/RainmeterStudio/Business/SettingsProvider.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Generic; using System.Configuration; using System.Linq; -using System.Text; -namespace RainmeterStudio.UI.Controller +namespace RainmeterStudio.Business { public static class SettingsProvider { @@ -45,5 +43,21 @@ namespace RainmeterStudio.UI.Controller return false; } } + + /// + /// Saves the settings + /// + public static void SaveSettings() + { + Properties.Settings.Default.Save(); + } + + /// + /// Resets settings to default + /// + public static void ResetSettings() + { + Properties.Settings.Default.Reset(); + } } } diff --git a/RainmeterStudio/MainClass.cs b/RainmeterStudio/MainClass.cs index f0717720..1e8d825b 100644 --- a/RainmeterStudio/MainClass.cs +++ b/RainmeterStudio/MainClass.cs @@ -39,6 +39,9 @@ namespace RainmeterStudio // Create & run app var uiManager = new UIManager(projectManager, documentManager); uiManager.Run(); + + // Run finished, persist settings + SettingsProvider.SaveSettings(); } } } diff --git a/RainmeterStudio/Properties/Settings.Designer.cs b/RainmeterStudio/Properties/Settings.Designer.cs index 287a887e..b0da8675 100644 --- a/RainmeterStudio/Properties/Settings.Designer.cs +++ b/RainmeterStudio/Properties/Settings.Designer.cs @@ -87,5 +87,65 @@ namespace RainmeterStudio.Properties { this["DocumentCloseCommand_Shortcut"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("800")] + public double MainWindow_Width { + get { + return ((double)(this["MainWindow_Width"])); + } + set { + this["MainWindow_Width"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("600")] + public double MainWindow_Height { + get { + return ((double)(this["MainWindow_Height"])); + } + set { + this["MainWindow_Height"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Normal")] + public global::System.Windows.WindowState MainWindow_WindowState { + get { + return ((global::System.Windows.WindowState)(this["MainWindow_WindowState"])); + } + set { + this["MainWindow_WindowState"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("10")] + public double MainWindow_Left { + get { + return ((double)(this["MainWindow_Left"])); + } + set { + this["MainWindow_Left"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("10")] + public double MainWindow_Top { + get { + return ((double)(this["MainWindow_Top"])); + } + set { + this["MainWindow_Top"] = value; + } + } } } diff --git a/RainmeterStudio/Properties/Settings.settings b/RainmeterStudio/Properties/Settings.settings index 83ff4d8d..5eea773c 100644 --- a/RainmeterStudio/Properties/Settings.settings +++ b/RainmeterStudio/Properties/Settings.settings @@ -17,5 +17,20 @@ Ctrl+W + + 800 + + + 600 + + + Normal + + + 10 + + + 10 + \ No newline at end of file diff --git a/RainmeterStudio/RainmeterStudio.csproj b/RainmeterStudio/RainmeterStudio.csproj index 2ebca134..d0764069 100644 --- a/RainmeterStudio/RainmeterStudio.csproj +++ b/RainmeterStudio/RainmeterStudio.csproj @@ -78,7 +78,7 @@ True Icons.resx - + True True @@ -88,7 +88,7 @@ - + CreateDocumentDialog.xaml @@ -156,6 +156,7 @@ ResXFileCodeGenerator Icons.Designer.cs + Designer PublicResXFileCodeGenerator @@ -169,56 +170,50 @@ - - - - + - + - - + + - + - - + + - + - + - + - + - + + - - + - + - - - - + diff --git a/RainmeterStudio/Resources/Icons.Designer.cs b/RainmeterStudio/Resources/Icons.Designer.cs index 14e5332a..e554dee6 100644 --- a/RainmeterStudio/Resources/Icons.Designer.cs +++ b/RainmeterStudio/Resources/Icons.Designer.cs @@ -61,128 +61,122 @@ namespace RainmeterStudio.Resources { } /// - /// Looks up a localized string similar to /Resources/Icons/16/page_white_star.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string DocumentCreateCommand { + internal static System.Drawing.Bitmap Command_DocumentCreateCommand_Icon { get { - return ResourceManager.GetString("DocumentCreateCommand", resourceCulture); + object obj = ResourceManager.GetObject("Command_DocumentCreateCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/32/text_generic.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string DocumentTemplate_Text { + internal static System.Drawing.Bitmap Command_ProjectCreateCommand_Icon { get { - return ResourceManager.GetString("DocumentTemplate_Text", resourceCulture); + object obj = ResourceManager.GetObject("Command_ProjectCreateCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/project_star.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectCreateCommand { + internal static System.Drawing.Bitmap Command_ProjectOpenCommand_Icon { get { - return ResourceManager.GetString("ProjectCreateCommand", resourceCulture); + object obj = ResourceManager.GetObject("Command_ProjectOpenCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/project.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectItem_rsproj { + internal static System.Drawing.Bitmap Command_ProjectPanel_CollapseAllCommand_Icon { get { - return ResourceManager.GetString("ProjectItem_rsproj", resourceCulture); + object obj = ResourceManager.GetObject("Command_ProjectPanel_CollapseAllCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/text_generic.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectItem_txt { + internal static System.Drawing.Bitmap Command_ProjectPanel_ExpandAllCommand_Icon { get { - return ResourceManager.GetString("ProjectItem_txt", resourceCulture); + object obj = ResourceManager.GetObject("Command_ProjectPanel_ExpandAllCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/folder.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectItemDirectory { + internal static System.Drawing.Bitmap Command_ProjectPanel_RefreshCommand_Icon { get { - return ResourceManager.GetString("ProjectItemDirectory", resourceCulture); + object obj = ResourceManager.GetObject("Command_ProjectPanel_RefreshCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/page_white_delete.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectItemNone { + internal static System.Drawing.Bitmap Command_ProjectPanel_ShowAllFilesCommand_Icon { get { - return ResourceManager.GetString("ProjectItemNone", resourceCulture); + object obj = ResourceManager.GetObject("Command_ProjectPanel_ShowAllFilesCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/file_generic.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectItemUnknown { + internal static System.Drawing.Bitmap Command_ProjectPanel_SyncWithActiveViewCommand_Icon { get { - return ResourceManager.GetString("ProjectItemUnknown", resourceCulture); + object obj = ResourceManager.GetObject("Command_ProjectPanel_SyncWithActiveViewCommand_Icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/folder_project.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectOpenCommand { + internal static System.Drawing.Bitmap ProjectItem_rsproj { get { - return ResourceManager.GetString("ProjectOpenCommand", resourceCulture); + object obj = ResourceManager.GetObject("ProjectItem_rsproj", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/minus.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectPanel_CollapseAllCommand { + internal static System.Drawing.Bitmap ProjectItemDirectory { get { - return ResourceManager.GetString("ProjectPanel_CollapseAllCommand", resourceCulture); + object obj = ResourceManager.GetObject("ProjectItemDirectory", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/plus.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectPanel_ExpandAllCommand { + internal static System.Drawing.Bitmap ProjectItemNone { get { - return ResourceManager.GetString("ProjectPanel_ExpandAllCommand", resourceCulture); + object obj = ResourceManager.GetObject("ProjectItemNone", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } /// - /// Looks up a localized string similar to /Resources/Icons/16/view-refresh.png. + /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static string ProjectPanel_RefreshCommand { + internal static System.Drawing.Bitmap ProjectItemUnknown { get { - return ResourceManager.GetString("ProjectPanel_RefreshCommand", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to /Resources/Icons/16/folder_explore.png. - /// - internal static string ProjectPanel_ShowAllFilesCommand { - get { - return ResourceManager.GetString("ProjectPanel_ShowAllFilesCommand", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to /Resources/Icons/16/arrow_refresh_small.png. - /// - internal static string ProjectPanel_SyncWithActiveViewCommand { - get { - return ResourceManager.GetString("ProjectPanel_SyncWithActiveViewCommand", resourceCulture); + object obj = ResourceManager.GetObject("ProjectItemUnknown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); } } } diff --git a/RainmeterStudio/Resources/Icons.resx b/RainmeterStudio/Resources/Icons.resx index 5ca75648..a8540d9a 100644 --- a/RainmeterStudio/Resources/Icons.resx +++ b/RainmeterStudio/Resources/Icons.resx @@ -117,46 +117,41 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - /Resources/Icons/16/page_white_star.png + + + icons\16\page_white_star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/32/text_generic.png + + icons\16\project_star.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/project_star.png + + icons\16\folder_project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/folder.png + + icons\16\minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/page_white_delete.png + + icons\16\plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/file_generic.png + + icons\16\view-refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/project.png + + icons\16\folder_explore.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/text_generic.png + + icons\16\arrow_refresh_small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/folder_project.png + + icons\16\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/minus.png + + icons\16\file_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/plus.png + + icons\16\page_white_delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - /Resources/Icons/16/view-refresh.png - - - /Resources/Icons/16/folder_explore.png - - - /Resources/Icons/16/arrow_refresh_small.png + + icons\16\project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/RainmeterStudio/Resources/Strings.Designer.cs b/RainmeterStudio/Resources/Strings.Designer.cs index 3e273e9d..ab9b89c1 100644 --- a/RainmeterStudio/Resources/Strings.Designer.cs +++ b/RainmeterStudio/Resources/Strings.Designer.cs @@ -61,11 +61,245 @@ namespace RainmeterStudio.Resources { } /// - /// Looks up a localized string similar to Utility. + /// Looks up a localized string similar to _Close. /// - public static string Category_Utility { + public static string Command_DocumentCloseCommand_DisplayText { get { - return ResourceManager.GetString("Category_Utility", resourceCulture); + return ResourceManager.GetString("Command_DocumentCloseCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Close active document. + /// + public static string Command_DocumentCloseCommand_ToolTip { + get { + return ResourceManager.GetString("Command_DocumentCloseCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _File.... + /// + public static string Command_DocumentCreateCommand_DisplayText { + get { + return ResourceManager.GetString("Command_DocumentCreateCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create a new file. + /// + public static string Command_DocumentCreateCommand_ToolTip { + get { + return ResourceManager.GetString("Command_DocumentCreateCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Project.... + /// + public static string Command_ProjectCreateCommand_DisplayText { + get { + return ResourceManager.GetString("Command_ProjectCreateCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create a new project. + /// + public static string Command_ProjectCreateCommand_ToolTip { + get { + return ResourceManager.GetString("Command_ProjectCreateCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to _Project.... + /// + public static string Command_ProjectOpenCommand_DisplayText { + get { + return ResourceManager.GetString("Command_ProjectOpenCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open existing project. + /// + public static string Command_ProjectOpenCommand_ToolTip { + get { + return ResourceManager.GetString("Command_ProjectOpenCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Collapse all. + /// + public static string Command_ProjectPanel_CollapseAllCommand_DisplayText { + get { + return ResourceManager.GetString("Command_ProjectPanel_CollapseAllCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Collapse all. + /// + public static string Command_ProjectPanel_CollapseAllCommand_ToolTip { + get { + return ResourceManager.GetString("Command_ProjectPanel_CollapseAllCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expand all. + /// + public static string Command_ProjectPanel_ExpandAllCommand_DisplayText { + get { + return ResourceManager.GetString("Command_ProjectPanel_ExpandAllCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Expand all. + /// + public static string Command_ProjectPanel_ExpandAllCommand_ToolTip { + get { + return ResourceManager.GetString("Command_ProjectPanel_ExpandAllCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Refresh. + /// + public static string Command_ProjectPanel_RefreshCommand_DisplayText { + get { + return ResourceManager.GetString("Command_ProjectPanel_RefreshCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Refresh. + /// + public static string Command_ProjectPanel_RefreshCommand_ToolTip { + get { + return ResourceManager.GetString("Command_ProjectPanel_RefreshCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show all files. + /// + public static string Command_ProjectPanel_ShowAllFilesCommand_DisplayText { + get { + return ResourceManager.GetString("Command_ProjectPanel_ShowAllFilesCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show all files. + /// + public static string Command_ProjectPanel_ShowAllFilesCommand_ToolTip { + get { + return ResourceManager.GetString("Command_ProjectPanel_ShowAllFilesCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sync with active view. + /// + public static string Command_ProjectPanel_SyncWithActiveViewCommand_DisplayText { + get { + return ResourceManager.GetString("Command_ProjectPanel_SyncWithActiveViewCommand_DisplayText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sync with active view. + /// + public static string Command_ProjectPanel_SyncWithActiveViewCommand_ToolTip { + get { + return ResourceManager.GetString("Command_ProjectPanel_SyncWithActiveViewCommand_ToolTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Name:. + /// + public static string CreateDocumentDialog_Name { + get { + return ResourceManager.GetString("CreateDocumentDialog_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Path:. + /// + public static string CreateDocumentDialog_Path { + get { + return ResourceManager.GetString("CreateDocumentDialog_Path", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New item. + /// + public static string CreateDocumentDialog_Title { + get { + return ResourceManager.GetString("CreateDocumentDialog_Title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Location:. + /// + public static string CreateProjectDialog_Location { + get { + return ResourceManager.GetString("CreateProjectDialog_Location", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set location as default. + /// + public static string CreateProjectDialog_LocationDefault { + get { + return ResourceManager.GetString("CreateProjectDialog_LocationDefault", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Name:. + /// + public static string CreateProjectDialog_Name { + get { + return ResourceManager.GetString("CreateProjectDialog_Name", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Path:. + /// + public static string CreateProjectDialog_Path { + get { + return ResourceManager.GetString("CreateProjectDialog_Path", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create directory for project. + /// + public static string CreateProjectDialog_PathCreateFolder { + get { + return ResourceManager.GetString("CreateProjectDialog_PathCreateFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create project. + /// + public static string CreateProjectDialog_Title { + get { + return ResourceManager.GetString("CreateProjectDialog_Title", resourceCulture); } } @@ -132,69 +366,6 @@ namespace RainmeterStudio.Resources { } } - /// - /// Looks up a localized string similar to _Close. - /// - public static string DocumentCloseCommand_DisplayText { - get { - return ResourceManager.GetString("DocumentCloseCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close active document. - /// - public static string DocumentCloseCommand_ToolTip { - get { - return ResourceManager.GetString("DocumentCloseCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to _File.... - /// - public static string DocumentCreateCommand_DisplayText { - get { - return ResourceManager.GetString("DocumentCreateCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create a new file. - /// - public static string DocumentCreateCommand_ToolTip { - get { - return ResourceManager.GetString("DocumentCreateCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Text Editor. - /// - public static string DocumentEditor_Text_Name { - get { - return ResourceManager.GetString("DocumentEditor_Text_Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Blank text file. - /// - public static string DocumentFormat_TextFile_Description { - get { - return ResourceManager.GetString("DocumentFormat_TextFile_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Text file. - /// - public static string DocumentFormat_TextFile_Name { - get { - return ResourceManager.GetString("DocumentFormat_TextFile_Name", resourceCulture); - } - } - /// /// Looks up a localized string similar to _File. /// @@ -223,191 +394,11 @@ namespace RainmeterStudio.Resources { } /// - /// Looks up a localized string similar to _Project.... + /// Looks up a localized string similar to Rainmeter Studio. /// - public static string ProjectCreateCommand_DisplayText { + public static string MainWindow_Title { get { - return ResourceManager.GetString("ProjectCreateCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create a new project. - /// - public static string ProjectCreateCommand_ToolTip { - get { - return ResourceManager.GetString("ProjectCreateCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Location:. - /// - public static string ProjectCreateDialog_Location { - get { - return ResourceManager.GetString("ProjectCreateDialog_Location", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set location as default. - /// - public static string ProjectCreateDialog_LocationDefault { - get { - return ResourceManager.GetString("ProjectCreateDialog_LocationDefault", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name:. - /// - public static string ProjectCreateDialog_Name { - get { - return ResourceManager.GetString("ProjectCreateDialog_Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Path:. - /// - public static string ProjectCreateDialog_Path { - get { - return ResourceManager.GetString("ProjectCreateDialog_Path", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create directory for project. - /// - public static string ProjectCreateDialog_PathCreateFolder { - get { - return ResourceManager.GetString("ProjectCreateDialog_PathCreateFolder", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create project. - /// - public static string ProjectCreateDialog_Title { - get { - return ResourceManager.GetString("ProjectCreateDialog_Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to _Project.... - /// - public static string ProjectOpenCommand_DisplayText { - get { - return ResourceManager.GetString("ProjectOpenCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Open existing project. - /// - public static string ProjectOpenCommand_ToolTip { - get { - return ResourceManager.GetString("ProjectOpenCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Collapse all. - /// - public static string ProjectPanel_CollapseAllCommand_DisplayText { - get { - return ResourceManager.GetString("ProjectPanel_CollapseAllCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Collapse all. - /// - public static string ProjectPanel_CollapseAllCommand_ToolTip { - get { - return ResourceManager.GetString("ProjectPanel_CollapseAllCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expand all. - /// - public static string ProjectPanel_ExpandAllCommand_DisplayText { - get { - return ResourceManager.GetString("ProjectPanel_ExpandAllCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expand all. - /// - public static string ProjectPanel_ExpandAllCommand_ToolTip { - get { - return ResourceManager.GetString("ProjectPanel_ExpandAllCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Refresh. - /// - public static string ProjectPanel_RefreshCommand_DisplayText { - get { - return ResourceManager.GetString("ProjectPanel_RefreshCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Refresh. - /// - public static string ProjectPanel_RefreshCommand_ToolTip { - get { - return ResourceManager.GetString("ProjectPanel_RefreshCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Show all files. - /// - public static string ProjectPanel_ShowAllFilesCommand_DisplayText { - get { - return ResourceManager.GetString("ProjectPanel_ShowAllFilesCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Show all files. - /// - public static string ProjectPanel_ShowAllFilesCommand_ToolTip { - get { - return ResourceManager.GetString("ProjectPanel_ShowAllFilesCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sync with active view. - /// - public static string ProjectPanel_SyncWithActiveViewCommand_DisplayText { - get { - return ResourceManager.GetString("ProjectPanel_SyncWithActiveViewCommand_DisplayText", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sync with active view. - /// - public static string ProjectPanel_SyncWithActiveViewCommand_ToolTip { - get { - return ResourceManager.GetString("ProjectPanel_SyncWithActiveViewCommand_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Utility. - /// - public static string TemplateCategory_Utility { - get { - return ResourceManager.GetString("TemplateCategory_Utility", resourceCulture); + return ResourceManager.GetString("MainWindow_Title", resourceCulture); } } } diff --git a/RainmeterStudio/Resources/Strings.resx b/RainmeterStudio/Resources/Strings.resx index f483277d..5153e4a8 100644 --- a/RainmeterStudio/Resources/Strings.resx +++ b/RainmeterStudio/Resources/Strings.resx @@ -117,8 +117,14 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Utility + + Name: + + + Path: + + + New item Browse @@ -141,27 +147,18 @@ Open project... - + _Close - + Close active document - + _File... - + Create a new file - - Text Editor - - - Blank text file - - - Text file - _File @@ -171,67 +168,67 @@ _Open - + _Project... - + Create a new project - + Location: - + Set location as default - + Name: - + Path: - + Create directory for project - + Create project - + _Project... - + Open existing project - + Collapse all - + Collapse all - + Expand all - + Expand all - + Refresh - + Refresh - + Show all files - + Show all files - + Sync with active view - + Sync with active view - - Utility + + Rainmeter Studio \ No newline at end of file diff --git a/RainmeterStudio/UI/Command.cs b/RainmeterStudio/UI/Command.cs index 451cee07..913bb3d9 100644 --- a/RainmeterStudio/UI/Command.cs +++ b/RainmeterStudio/UI/Command.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows.Input; using System.Windows.Media; -using RainmeterStudio.UI.Controller; +using RainmeterStudio.Business; +using RainmeterStudio.Core.Utils; namespace RainmeterStudio.UI { @@ -26,9 +24,6 @@ namespace RainmeterStudio.UI /// public string Name { get; set; } - #region Display text property - private string _displayText = null; - /// /// Gets or sets the display text of the command /// @@ -36,22 +31,10 @@ namespace RainmeterStudio.UI { get { - if (_displayText == null) - return Resources.Strings.ResourceManager.GetString(Name + "_DisplayText"); - - return _displayText; - } - set - { - _displayText = value; + return ResourceProvider.GetString("Command_" + Name + "_DisplayText"); } } - #endregion - - #region ToolTip property - private string _toolTip = null; - /// /// Gets or sets the tooltip /// @@ -59,20 +42,9 @@ namespace RainmeterStudio.UI { get { - if (_toolTip == null) - return Resources.Strings.ResourceManager.GetString(Name + "_ToolTip"); - - return _toolTip; - } - set - { - _toolTip = value; + return ResourceProvider.GetString("Command_" + Name + "_ToolTip"); } } - #endregion - - #region Icon property - private ImageSource _icon = null; /// /// Gets or sets the command's icon @@ -81,21 +53,9 @@ namespace RainmeterStudio.UI { get { - if (_icon == null) - return IconProvider.GetIcon(Name); - - return _icon; - } - set - { - _icon = value; + return ResourceProvider.GetImage("Command_" + Name + "_Icon"); } } - #endregion - - #region Keyboard shortcut property - - private KeyGesture _shortcut; /// /// Gets or sets the keyboard shortcut of this command @@ -104,17 +64,8 @@ namespace RainmeterStudio.UI { get { - if (_shortcut == null) - { - string str = SettingsProvider.GetSetting(Name + "_Shortcut"); - return GetKeyGestureFromString(str); - } - - return _shortcut; - } - set - { - _shortcut = value; + string str = SettingsProvider.GetSetting("Command_" + Name + "_Shortcut"); + return InputHelper.GetKeyGesture(str); } } @@ -125,73 +76,20 @@ namespace RainmeterStudio.UI { get { - // Safety check - if (Shortcut == null) - return null; - - // Build string - string text = String.Empty; - - if ((Shortcut.Modifiers & ModifierKeys.Windows) != 0) - text += "Win+"; - - if ((Shortcut.Modifiers & ModifierKeys.Control) != 0) - text += "Ctrl+"; - - if ((Shortcut.Modifiers & ModifierKeys.Alt) != 0) - text += "Alt+"; - - if ((Shortcut.Modifiers & ModifierKeys.Shift) != 0) - text += "Shift+"; - - text += Enum.GetName(typeof(Key), Shortcut.Key); - return text; + return SettingsProvider.GetSetting("Command_" + Name + "_Shortcut"); } - set - { - Shortcut = GetKeyGestureFromString(value); - } - } - - private KeyGesture GetKeyGestureFromString(string k) - { - // Safety check - if (k == null) - return null; - - // Variables - ModifierKeys mods = ModifierKeys.None; - Key key = Key.None; - - // Parse each field - foreach (var field in k.Split('+')) - { - // Trim surrounding white space - string trimmed = field.Trim(); - - // Parse - if (trimmed.Equals("Win", StringComparison.InvariantCultureIgnoreCase)) - mods |= ModifierKeys.Windows; - if (trimmed.Equals("Ctrl", StringComparison.InvariantCultureIgnoreCase)) - mods |= ModifierKeys.Control; - if (trimmed.Equals("Alt", StringComparison.InvariantCultureIgnoreCase)) - mods |= ModifierKeys.Alt; - if (trimmed.Equals("Shift", StringComparison.InvariantCultureIgnoreCase)) - mods |= ModifierKeys.Shift; - else Enum.TryParse(field, out key); - } - - return new KeyGesture(key, mods); } #endregion - #endregion - - - + /// + /// Event triggered when the command execution status changes + /// public event EventHandler CanExecuteChanged; + /// + /// Triggers the can execute changed event + /// public void NotifyCanExecuteChanged() { if (CanExecuteChanged != null) @@ -252,7 +150,7 @@ namespace RainmeterStudio.UI } } - public static class UIElementExtensions + public static partial class UIElementExtensions { /// /// Adds a keyboard shortcut to an UI element diff --git a/RainmeterStudio/UI/Controller/DocumentController.cs b/RainmeterStudio/UI/Controller/DocumentController.cs index 1bc347ea..27af9194 100644 --- a/RainmeterStudio/UI/Controller/DocumentController.cs +++ b/RainmeterStudio/UI/Controller/DocumentController.cs @@ -66,7 +66,7 @@ namespace RainmeterStudio.UI.Controller var dialog = new CreateDocumentDialog(this) { Owner = OwnerWindow, - SelectedTemplate = defaultFormat, + SelectedTemplate = new DocumentTemplateViewModel(defaultFormat), SelectedPath = defaultPath }; bool? res = dialog.ShowDialog(); @@ -78,7 +78,7 @@ namespace RainmeterStudio.UI.Controller var path = dialog.SelectedPath; // Call manager - DocumentManager.Create(format); + DocumentManager.Create(format.Template); } public void Create(DocumentTemplate format) diff --git a/RainmeterStudio/UI/Controller/IconProvider.cs b/RainmeterStudio/UI/Controller/IconProvider.cs index 5004ff4e..a0fbf2b6 100644 --- a/RainmeterStudio/UI/Controller/IconProvider.cs +++ b/RainmeterStudio/UI/Controller/IconProvider.cs @@ -1,13 +1,9 @@ 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.Business; using RainmeterStudio.Core.Model; -using RainmeterStudio.Resources; namespace RainmeterStudio.UI.Controller { diff --git a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml index 6cd39e2a..20b821d0 100644 --- a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml +++ b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml @@ -1,31 +1,21 @@  - - - - - - - + - - - - - + @@ -41,7 +31,7 @@ - + @@ -52,13 +42,16 @@ - Path: + - + Path: + + + - diff --git a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs index 2787fcae..d17819cb 100644 --- a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs +++ b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs @@ -1,19 +1,9 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Linq; -using System.Text; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using RainmeterStudio.Business; -using RainmeterStudio.Core.Documents; using RainmeterStudio.UI.Controller; +using RainmeterStudio.UI.ViewModel; namespace RainmeterStudio.UI.Dialogs { @@ -27,15 +17,15 @@ namespace RainmeterStudio.UI.Dialogs /// /// Gets or sets the currently selected file format /// - public DocumentTemplate SelectedTemplate + public DocumentTemplateViewModel SelectedTemplate { get { - return listFormats.SelectedItem as DocumentTemplate; + return listTemplates.SelectedItem as DocumentTemplateViewModel; } set { - listFormats.SelectedItem = value; + listTemplates.SelectedItem = value; } } @@ -62,29 +52,13 @@ namespace RainmeterStudio.UI.Dialogs InitializeComponent(); _documentController = docCtrl; - PopulateCategories(); - RepopulateFormats(); + PopulateFormats(); Validate(); } - private void PopulateCategories() + private void PopulateFormats() { - listCategories.ItemsSource = _documentController.DocumentTemplates - .Select(template => template.Category) - .Where(cat => cat != null) - .Distinct() - .Concat(new[] { "All" }); - - listCategories.SelectedIndex = listCategories.Items.Count - 1; - } - - private void RepopulateFormats() - { - if (Object.Equals(listCategories.SelectedItem, "All")) - listFormats.ItemsSource = _documentController.DocumentTemplates; - - else - listFormats.ItemsSource = _documentController.DocumentTemplates.Where(x => Object.Equals(x.Category, listCategories.SelectedItem)); + listTemplates.ItemsSource = _documentController.DocumentTemplates; } private void buttonCreate_Click(object sender, RoutedEventArgs e) @@ -102,15 +76,17 @@ namespace RainmeterStudio.UI.Dialogs private void Validate() { bool res = true; + res &= !String.IsNullOrWhiteSpace(textPath.Text); - res &= (listFormats.SelectedItem != null); + res &= !textPath.Text.Intersect(System.IO.Path.GetInvalidFileNameChars()).Any(); + res &= (listTemplates.SelectedItem != null); buttonCreate.IsEnabled = res; } - private void listCategories_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void listFormats_SelectionChanged(object sender, SelectionChangedEventArgs e) { - RepopulateFormats(); + Validate(); } } } diff --git a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml index b968b28c..fe3c0635 100644 --- a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml +++ b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:r="clr-namespace:RainmeterStudio.Resources" - Title="{x:Static r:Strings.ProjectCreateDialog_Title}" Height="320" Width="480" + Title="{x:Static r:Strings.CreateProjectDialog_Title}" Height="320" Width="480" WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow" ShowInTaskbar="False"> @@ -55,31 +55,31 @@ - + - + public string Name { get { return Template.Name; } } - #region Icon property - - private ImageSource _icon = null; - /// /// Gets or sets the icon of this document template /// - public virtual ImageSource Icon + public ImageSource Icon { get { - if (_icon == null) - return IconProvider.GetIcon("Template_" + Name); - - return _icon; - } - set - { - _icon = value; + return ResourceProvider.GetImage("Template_" + Name + "_Icon"); } } - #endregion - - #region Display text property - - private string _displayText = null; - /// /// Gets or sets the display text /// @@ -55,23 +34,10 @@ namespace RainmeterStudio.UI.ViewModel { get { - if (_displayText == null) - return Resources.Strings.ResourceManager.GetString("Template_" + Name + "_DisplayText"); - - return _displayText; - } - set - { - _displayText = value; + return ResourceProvider.GetString("Template_" + Name + "_DisplayText"); } } - #endregion - - #region Description property - - private string _description = null; - /// /// Gets or sets the description of this document template /// @@ -79,43 +45,10 @@ namespace RainmeterStudio.UI.ViewModel { get { - if (_description == null) - return Resources.Strings.ResourceManager.GetString("Template_" + Name + "_Description"); - - return _description; - } - set - { - _description = value; + return ResourceProvider.GetString("Template_" + Name + "_Description"); } } - #endregion - - #region Category property - - private string _category = null; - - /// - /// Gets or sets the category of this template - /// - public string Category - { - get - { - if (_category == null) - return Resources.Strings.ResourceManager.GetString("Template_" + Name + "_Category"); - - return _category; - } - set - { - _category = value; - } - } - - #endregion - /// /// Initializes the document template view model /// diff --git a/RainmeterStudio/app.config b/RainmeterStudio/app.config index 8ed0c457..8ac1aab4 100644 --- a/RainmeterStudio/app.config +++ b/RainmeterStudio/app.config @@ -22,6 +22,21 @@ Ctrl+W + + 800 + + + 600 + + + Normal + + + 10 + + + 10 +