diff --git a/RainmeterStudio.Core/Documents/DocumentTemplate.cs b/RainmeterStudio.Core/Documents/DocumentTemplate.cs deleted file mode 100644 index 9591cbe0..00000000 --- a/RainmeterStudio.Core/Documents/DocumentTemplate.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using RainmeterStudio.Core.Model; - -namespace RainmeterStudio.Core.Documents -{ - /// - /// Represents a document template - /// - public abstract class DocumentTemplate - { - /// - /// Gets the document template name - /// - public string Name { get; private set; } - - /// - /// Gets the default extension of this template - /// - 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 - /// - /// Name of template - /// Default extension - public DocumentTemplate(string name, string defaultExtension) - { - Name = name; - DefaultExtension = defaultExtension; - } - - /// - /// Creates a document using this template - /// - /// - public abstract IDocument CreateDocument(); - } -} diff --git a/RainmeterStudio.Core/Model/IDocumentTemplate.cs b/RainmeterStudio.Core/Model/IDocumentTemplate.cs new file mode 100644 index 00000000..afb6a099 --- /dev/null +++ b/RainmeterStudio.Core/Model/IDocumentTemplate.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.Linq; +using RainmeterStudio.Core.Model; + +namespace RainmeterStudio.Core.Model +{ + /// + /// Represents a document template + /// + public interface IDocumentTemplate + { + /// + /// Gets the document template name + /// + string Name { get; } + + /// + /// Gets the default extension of this template + /// + string DefaultExtension { get; } + + /// + /// Gets or sets the properties of this template + /// + /// Properties are used to display a form dialog after the "New item" dialog closes. + IEnumerable Properties { get; } + + /// + /// Creates a document using this template + /// + /// Created document. + IDocument CreateDocument(); + } +} diff --git a/RainmeterStudio.Core/Model/IProjectTemplate.cs b/RainmeterStudio.Core/Model/IProjectTemplate.cs new file mode 100644 index 00000000..cc484cc3 --- /dev/null +++ b/RainmeterStudio.Core/Model/IProjectTemplate.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RainmeterStudio.Core.Model +{ + /// + /// Project template interface + /// + public interface IProjectTemplate + { + /// + /// Gets or sets the name of the template + /// + string Name { get; } + + /// + /// Gets or sets the properties of this template + /// + /// Properties are used to display a form dialog after the "New project" dialog closes. + IEnumerable Properties { get; } + + /// + /// Creates a project. + /// + /// Created project + Project CreateProject(); + } +} diff --git a/RainmeterStudio.Core/RainmeterStudio.Core.csproj b/RainmeterStudio.Core/RainmeterStudio.Core.csproj index 75f0bd28..b57220d8 100644 --- a/RainmeterStudio.Core/RainmeterStudio.Core.csproj +++ b/RainmeterStudio.Core/RainmeterStudio.Core.csproj @@ -44,13 +44,14 @@ + - + diff --git a/RainmeterStudio.SkinDesigner/SkinDocumentTemplate.cs b/RainmeterStudio.SkinDesigner/SkinDocumentTemplate.cs index 9f0e37a2..58ccc7ef 100644 --- a/RainmeterStudio.SkinDesigner/SkinDocumentTemplate.cs +++ b/RainmeterStudio.SkinDesigner/SkinDocumentTemplate.cs @@ -12,21 +12,37 @@ namespace RainmeterStudio.SkinDesignerPlugin /// Template of a skin which will be opened in the designer /// [PluginExport] - public class SkinDocumentTemplate : DocumentTemplate + public class SkinDocumentTemplate : IDocumentTemplate { /// - /// Initializes this skin template + /// Gets the document template name /// - public SkinDocumentTemplate() - : base("Skin", "rsskin") + public string Name { + get { return "Skin"; } + } + + /// + /// Gets the default extension of this template + /// + public string DefaultExtension + { + get { return "rsskin"; } + } + + /// + /// Gets or sets the properties of this template + /// + public IEnumerable Properties + { + get { return Enumerable.Empty(); } } /// /// Creates a new document using this template /// /// Newly created document - public override IDocument CreateDocument() + public IDocument CreateDocument() { return new SkinDocument(); } diff --git a/RainmeterStudio.TextEditor/Resources/Icons.Designer.cs b/RainmeterStudio.TextEditor/Resources/Icons.Designer.cs index 67efe46c..d37a1e35 100644 --- a/RainmeterStudio.TextEditor/Resources/Icons.Designer.cs +++ b/RainmeterStudio.TextEditor/Resources/Icons.Designer.cs @@ -63,9 +63,9 @@ namespace RainmeterStudio.TextEditorPlugin.Resources { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - public static System.Drawing.Bitmap ProjectItem_txt { + public static System.Drawing.Bitmap DocumentTemplate_Text_Icon { get { - object obj = ResourceManager.GetObject("ProjectItem_txt", resourceCulture); + object obj = ResourceManager.GetObject("DocumentTemplate_Text_Icon", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -73,9 +73,9 @@ namespace RainmeterStudio.TextEditorPlugin.Resources { /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - public static System.Drawing.Bitmap Template_Text_Icon { + public static System.Drawing.Bitmap ProjectItem_txt { get { - object obj = ResourceManager.GetObject("Template_Text_Icon", resourceCulture); + object obj = ResourceManager.GetObject("ProjectItem_txt", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/RainmeterStudio.TextEditor/Resources/Icons.resx b/RainmeterStudio.TextEditor/Resources/Icons.resx index a9936e9c..63b4d0a4 100644 --- a/RainmeterStudio.TextEditor/Resources/Icons.resx +++ b/RainmeterStudio.TextEditor/Resources/Icons.resx @@ -118,10 +118,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + icons\32\text_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + 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.TextEditor/Resources/Strings.Designer.cs b/RainmeterStudio.TextEditor/Resources/Strings.Designer.cs index 518d074d..1c8a80f5 100644 --- a/RainmeterStudio.TextEditor/Resources/Strings.Designer.cs +++ b/RainmeterStudio.TextEditor/Resources/Strings.Designer.cs @@ -63,18 +63,18 @@ namespace RainmeterStudio.TextEditorPlugin.Resources { /// /// Looks up a localized string similar to Blank text file. /// - public static string Template_Text_Description { + public static string DocumentTemplate_Text_Description { get { - return ResourceManager.GetString("Template_Text_Description", resourceCulture); + return ResourceManager.GetString("DocumentTemplate_Text_Description", resourceCulture); } } /// /// Looks up a localized string similar to Text file. /// - public static string Template_Text_DisplayText { + public static string DocumentTemplate_Text_DisplayText { get { - return ResourceManager.GetString("Template_Text_DisplayText", resourceCulture); + return ResourceManager.GetString("DocumentTemplate_Text_DisplayText", resourceCulture); } } } diff --git a/RainmeterStudio.TextEditor/Resources/Strings.resx b/RainmeterStudio.TextEditor/Resources/Strings.resx index 0c7b5470..2a7bc2b4 100644 --- a/RainmeterStudio.TextEditor/Resources/Strings.resx +++ b/RainmeterStudio.TextEditor/Resources/Strings.resx @@ -117,10 +117,10 @@ 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 21ea3dca..37917af3 100644 --- a/RainmeterStudio.TextEditor/TextDocumentTemplate.cs +++ b/RainmeterStudio.TextEditor/TextDocumentTemplate.cs @@ -12,14 +12,37 @@ namespace RainmeterStudio.TextEditorPlugin /// A blank text document template /// [PluginExport] - public class TextDocumentTemplate : DocumentTemplate + public class TextDocumentTemplate : IDocumentTemplate { - public TextDocumentTemplate() - : base("Text", "txt") + /// + /// Gets the document template name + /// + public string Name { + get { return "Text"; } } - public override IDocument CreateDocument() + /// + /// Gets the default extension of this template + /// + public string DefaultExtension + { + get { return "txt"; } + } + + /// + /// Gets or sets the properties of this template + /// + public IEnumerable Properties + { + get { return Enumerable.Empty(); } + } + + /// + /// Creates a document using this template + /// + /// Created document. + public IDocument CreateDocument() { return new TextDocument(); } diff --git a/RainmeterStudio/Business/DocumentManager.cs b/RainmeterStudio/Business/DocumentManager.cs index 70cc4c4b..4f667fd0 100644 --- a/RainmeterStudio/Business/DocumentManager.cs +++ b/RainmeterStudio/Business/DocumentManager.cs @@ -50,7 +50,7 @@ namespace RainmeterStudio.Business /// /// Gets a list of document templates /// - public IEnumerable DocumentTemplates { get { return _templates; } } + public IEnumerable DocumentTemplates { get { return _templates; } } #endregion @@ -59,7 +59,7 @@ namespace RainmeterStudio.Business private List _factories = new List(); private List _editors = new List(); private List _storages = new List(); - private List _templates = new List(); + private List _templates = new List(); #endregion @@ -94,7 +94,7 @@ namespace RainmeterStudio.Business /// Registers a document template /// /// The document template - public void RegisterTemplate(DocumentTemplate template) + public void RegisterTemplate(IDocumentTemplate template) { _templates.Add(template); } @@ -108,7 +108,7 @@ namespace RainmeterStudio.Business /// /// /// - public IDocumentEditor Create(DocumentTemplate format) + public IDocumentEditor Create(IDocumentTemplate format) { // Create document var document = format.CreateDocument(); diff --git a/RainmeterStudio/Business/ProjectManager.cs b/RainmeterStudio/Business/ProjectManager.cs index 45d8fecf..614768a0 100644 --- a/RainmeterStudio/Business/ProjectManager.cs +++ b/RainmeterStudio/Business/ProjectManager.cs @@ -11,6 +11,8 @@ namespace RainmeterStudio.Business { public class ProjectManager { + private List _projectTemplates = new List(); + #region Properties /// @@ -112,5 +114,16 @@ namespace RainmeterStudio.Business if (ActiveProjectChanged != null) ActiveProjectChanged(this, new EventArgs()); } + + /// + /// Registers a project template + /// + /// Project template + public void RegisterProjectTemplate(IProjectTemplate template) + { + _projectTemplates.Add(template); + } + + public IEnumerable ProjectTemplates { get { return _projectTemplates; } } } } diff --git a/RainmeterStudio/Documents/EmptyProjectTemplate.cs b/RainmeterStudio/Documents/EmptyProjectTemplate.cs new file mode 100644 index 00000000..c8cabfb4 --- /dev/null +++ b/RainmeterStudio/Documents/EmptyProjectTemplate.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RainmeterStudio.Core; +using RainmeterStudio.Core.Model; + +namespace RainmeterStudio.Documents +{ + /// + /// An empty project template + /// + [PluginExport] + public class EmptyProjectTemplate : IProjectTemplate + { + /// + /// Gets or sets the name of the template + /// + public string Name + { + get { return "EmptyProject"; } + } + + /// + /// Gets or sets the properties of this template + /// + public IEnumerable Properties + { + get { return Enumerable.Empty(); } + } + + /// + /// Creates a project. + /// + /// Created project + public Project CreateProject() + { + return new Project(); + } + } +} diff --git a/RainmeterStudio/MainClass.cs b/RainmeterStudio/MainClass.cs index 1e8d825b..635be1a9 100644 --- a/RainmeterStudio/MainClass.cs +++ b/RainmeterStudio/MainClass.cs @@ -6,6 +6,7 @@ using System.Text; using System.Windows; using RainmeterStudio.Business; using RainmeterStudio.Core.Documents; +using RainmeterStudio.Core.Model; using RainmeterStudio.Core.Storage; using RainmeterStudio.Storage; using RainmeterStudio.UI; @@ -32,8 +33,9 @@ namespace RainmeterStudio // Initialize plugin manager PluginManager pluginManager = new PluginManager(); pluginManager.AddRegisterExportTypeHandler(typeof(IDocumentStorage), obj => documentManager.RegisterStorage((IDocumentStorage)obj)); - pluginManager.AddRegisterExportTypeHandler(typeof(DocumentTemplate), obj => documentManager.RegisterTemplate((DocumentTemplate)obj)); + pluginManager.AddRegisterExportTypeHandler(typeof(IDocumentTemplate), obj => documentManager.RegisterTemplate((IDocumentTemplate)obj)); pluginManager.AddRegisterExportTypeHandler(typeof(IDocumentEditorFactory), obj => documentManager.RegisterEditorFactory((IDocumentEditorFactory)obj)); + pluginManager.AddRegisterExportTypeHandler(typeof(IProjectTemplate), obj => projectManager.RegisterProjectTemplate((IProjectTemplate)obj)); pluginManager.Initialize(); // Create & run app diff --git a/RainmeterStudio/Properties/Settings.Designer.cs b/RainmeterStudio/Properties/Settings.Designer.cs index b0da8675..d8922d43 100644 --- a/RainmeterStudio/Properties/Settings.Designer.cs +++ b/RainmeterStudio/Properties/Settings.Designer.cs @@ -27,12 +27,12 @@ namespace RainmeterStudio.Properties { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+N")] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] - public string ProjectCreateCommand_Shortcut { + public string Command_ProjectCreateCommand_Shortcut { get { - return ((string)(this["ProjectCreateCommand_Shortcut"])); + return ((string)(this["Command_ProjectCreateCommand_Shortcut"])); } set { - this["ProjectCreateCommand_Shortcut"] = value; + this["Command_ProjectCreateCommand_Shortcut"] = value; } } @@ -40,12 +40,12 @@ namespace RainmeterStudio.Properties { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("F5")] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] - public string ProjectPanel_RefreshCommand_Shortcut { + public string Command_ProjectPanel_RefreshCommand_Shortcut { get { - return ((string)(this["ProjectPanel_RefreshCommand_Shortcut"])); + return ((string)(this["Command_ProjectPanel_RefreshCommand_Shortcut"])); } set { - this["ProjectPanel_RefreshCommand_Shortcut"] = value; + this["Command_ProjectPanel_RefreshCommand_Shortcut"] = value; } } @@ -53,12 +53,12 @@ namespace RainmeterStudio.Properties { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+N")] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] - public string DocumentCreateCommand_Shortcut { + public string Command_DocumentCreateCommand_Shortcut { get { - return ((string)(this["DocumentCreateCommand_Shortcut"])); + return ((string)(this["Command_DocumentCreateCommand_Shortcut"])); } set { - this["DocumentCreateCommand_Shortcut"] = value; + this["Command_DocumentCreateCommand_Shortcut"] = value; } } @@ -66,12 +66,12 @@ namespace RainmeterStudio.Properties { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+O")] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] - public string ProjectOpenCommand_Shortcut { + public string Command_ProjectOpenCommand_Shortcut { get { - return ((string)(this["ProjectOpenCommand_Shortcut"])); + return ((string)(this["Command_ProjectOpenCommand_Shortcut"])); } set { - this["ProjectOpenCommand_Shortcut"] = value; + this["Command_ProjectOpenCommand_Shortcut"] = value; } } @@ -79,12 +79,12 @@ namespace RainmeterStudio.Properties { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+W")] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] - public string DocumentCloseCommand_Shortcut { + public string Command_DocumentCloseCommand_Shortcut { get { - return ((string)(this["DocumentCloseCommand_Shortcut"])); + return ((string)(this["Command_DocumentCloseCommand_Shortcut"])); } set { - this["DocumentCloseCommand_Shortcut"] = value; + this["Command_DocumentCloseCommand_Shortcut"] = value; } } diff --git a/RainmeterStudio/Properties/Settings.settings b/RainmeterStudio/Properties/Settings.settings index 5eea773c..2e4c6840 100644 --- a/RainmeterStudio/Properties/Settings.settings +++ b/RainmeterStudio/Properties/Settings.settings @@ -2,19 +2,19 @@ - + Ctrl+Shift+N - + F5 - + Ctrl+N - + Ctrl+Shift+O - + Ctrl+W diff --git a/RainmeterStudio/RainmeterStudio.csproj b/RainmeterStudio/RainmeterStudio.csproj index d0764069..7f8faf8a 100644 --- a/RainmeterStudio/RainmeterStudio.csproj +++ b/RainmeterStudio/RainmeterStudio.csproj @@ -70,6 +70,7 @@ + @@ -101,6 +102,7 @@ + Designer @@ -224,6 +226,9 @@ RainmeterStudio.Core + + +