Added project templates, work on document template

This commit is contained in:
Tiberiu Chibici 2014-08-16 00:39:31 +03:00
parent ef8aec25b7
commit 5f4dead9ec
30 changed files with 373 additions and 130 deletions

View File

@ -1,51 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using RainmeterStudio.Core.Model;
namespace RainmeterStudio.Core.Documents
{
/// <summary>
/// Represents a document template
/// </summary>
public abstract class DocumentTemplate
{
/// <summary>
/// Gets the document template name
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Gets the default extension of this template
/// </summary>
public string DefaultExtension { get; private set; }
/// <summary>
/// Gets or sets the properties of this template
/// </summary>
/// <remarks>Properties are used to display a form dialog after the "New item" dialog closes.</remarks>
public virtual IEnumerable<Property> Properties
{
get
{
return Enumerable.Empty<Property>();
}
}
/// <summary>
/// Initializes the document template
/// </summary>
/// <param name="name">Name of template</param>
/// <param name="defaultExtension">Default extension</param>
public DocumentTemplate(string name, string defaultExtension)
{
Name = name;
DefaultExtension = defaultExtension;
}
/// <summary>
/// Creates a document using this template
/// </summary>
/// <returns></returns>
public abstract IDocument CreateDocument();
}
}

View File

@ -0,0 +1,34 @@
using System.Collections.Generic;
using System.Linq;
using RainmeterStudio.Core.Model;
namespace RainmeterStudio.Core.Model
{
/// <summary>
/// Represents a document template
/// </summary>
public interface IDocumentTemplate
{
/// <summary>
/// Gets the document template name
/// </summary>
string Name { get; }
/// <summary>
/// Gets the default extension of this template
/// </summary>
string DefaultExtension { get; }
/// <summary>
/// Gets or sets the properties of this template
/// </summary>
/// <remarks>Properties are used to display a form dialog after the "New item" dialog closes.</remarks>
IEnumerable<Property> Properties { get; }
/// <summary>
/// Creates a document using this template
/// </summary>
/// <returns>Created document.</returns>
IDocument CreateDocument();
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RainmeterStudio.Core.Model
{
/// <summary>
/// Project template interface
/// </summary>
public interface IProjectTemplate
{
/// <summary>
/// Gets or sets the name of the template
/// </summary>
string Name { get; }
/// <summary>
/// Gets or sets the properties of this template
/// </summary>
/// <remarks>Properties are used to display a form dialog after the "New project" dialog closes.</remarks>
IEnumerable<Property> Properties { get; }
/// <summary>
/// Creates a project.
/// </summary>
/// <returns>Created project</returns>
Project CreateProject();
}
}

View File

@ -44,13 +44,14 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Model\IProjectTemplate.cs" />
<Compile Include="RainmeterStudioPluginAttribute.cs" /> <Compile Include="RainmeterStudioPluginAttribute.cs" />
<Compile Include="PluginExportAttribute.cs" /> <Compile Include="PluginExportAttribute.cs" />
<Compile Include="Documents\DocumentEditorFeatures\ICustomDocumentTitleProvider.cs" /> <Compile Include="Documents\DocumentEditorFeatures\ICustomDocumentTitleProvider.cs" />
<Compile Include="Documents\DocumentEditorFeatures\ISelectionPropertiesProvider.cs" /> <Compile Include="Documents\DocumentEditorFeatures\ISelectionPropertiesProvider.cs" />
<Compile Include="Documents\DocumentEditorFeatures\IToolboxProvider.cs" /> <Compile Include="Documents\DocumentEditorFeatures\IToolboxProvider.cs" />
<Compile Include="Documents\DocumentEditorFeatures\IUndoSupport.cs" /> <Compile Include="Documents\DocumentEditorFeatures\IUndoSupport.cs" />
<Compile Include="Documents\DocumentTemplate.cs" /> <Compile Include="Model\IDocumentTemplate.cs" />
<Compile Include="Documents\IDocumentEditor.cs" /> <Compile Include="Documents\IDocumentEditor.cs" />
<Compile Include="Documents\IDocumentEditorFactory.cs" /> <Compile Include="Documents\IDocumentEditorFactory.cs" />
<Compile Include="Storage\IDocumentStorage.cs" /> <Compile Include="Storage\IDocumentStorage.cs" />

View File

@ -12,21 +12,37 @@ namespace RainmeterStudio.SkinDesignerPlugin
/// Template of a skin which will be opened in the designer /// Template of a skin which will be opened in the designer
/// </summary> /// </summary>
[PluginExport] [PluginExport]
public class SkinDocumentTemplate : DocumentTemplate public class SkinDocumentTemplate : IDocumentTemplate
{ {
/// <summary> /// <summary>
/// Initializes this skin template /// Gets the document template name
/// </summary> /// </summary>
public SkinDocumentTemplate() public string Name
: base("Skin", "rsskin")
{ {
get { return "Skin"; }
}
/// <summary>
/// Gets the default extension of this template
/// </summary>
public string DefaultExtension
{
get { return "rsskin"; }
}
/// <summary>
/// Gets or sets the properties of this template
/// </summary>
public IEnumerable<Property> Properties
{
get { return Enumerable.Empty<Property>(); }
} }
/// <summary> /// <summary>
/// Creates a new document using this template /// Creates a new document using this template
/// </summary> /// </summary>
/// <returns>Newly created document</returns> /// <returns>Newly created document</returns>
public override IDocument CreateDocument() public IDocument CreateDocument()
{ {
return new SkinDocument(); return new SkinDocument();
} }

View File

@ -63,9 +63,9 @@ namespace RainmeterStudio.TextEditorPlugin.Resources {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
public static System.Drawing.Bitmap ProjectItem_txt { public static System.Drawing.Bitmap DocumentTemplate_Text_Icon {
get { get {
object obj = ResourceManager.GetObject("ProjectItem_txt", resourceCulture); object obj = ResourceManager.GetObject("DocumentTemplate_Text_Icon", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
@ -73,9 +73,9 @@ namespace RainmeterStudio.TextEditorPlugin.Resources {
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
public static System.Drawing.Bitmap Template_Text_Icon { public static System.Drawing.Bitmap ProjectItem_txt {
get { get {
object obj = ResourceManager.GetObject("Template_Text_Icon", resourceCulture); object obj = ResourceManager.GetObject("ProjectItem_txt", resourceCulture);
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }

View File

@ -118,10 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="DocumentTemplate_Text_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons\32\text_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ProjectItem_txt" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="ProjectItem_txt" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons\16\text_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>icons\16\text_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Template_Text_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons\32\text_generic.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

View File

@ -63,18 +63,18 @@ namespace RainmeterStudio.TextEditorPlugin.Resources {
/// <summary> /// <summary>
/// Looks up a localized string similar to Blank text file. /// Looks up a localized string similar to Blank text file.
/// </summary> /// </summary>
public static string Template_Text_Description { public static string DocumentTemplate_Text_Description {
get { get {
return ResourceManager.GetString("Template_Text_Description", resourceCulture); return ResourceManager.GetString("DocumentTemplate_Text_Description", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Text file. /// Looks up a localized string similar to Text file.
/// </summary> /// </summary>
public static string Template_Text_DisplayText { public static string DocumentTemplate_Text_DisplayText {
get { get {
return ResourceManager.GetString("Template_Text_DisplayText", resourceCulture); return ResourceManager.GetString("DocumentTemplate_Text_DisplayText", resourceCulture);
} }
} }
} }

View File

@ -117,10 +117,10 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="Template_Text_Description" xml:space="preserve"> <data name="DocumentTemplate_Text_Description" xml:space="preserve">
<value>Blank text file</value> <value>Blank text file</value>
</data> </data>
<data name="Template_Text_DisplayText" xml:space="preserve"> <data name="DocumentTemplate_Text_DisplayText" xml:space="preserve">
<value>Text file</value> <value>Text file</value>
</data> </data>
</root> </root>

View File

@ -12,14 +12,37 @@ namespace RainmeterStudio.TextEditorPlugin
/// A blank text document template /// A blank text document template
/// </summary> /// </summary>
[PluginExport] [PluginExport]
public class TextDocumentTemplate : DocumentTemplate public class TextDocumentTemplate : IDocumentTemplate
{ {
public TextDocumentTemplate() /// <summary>
: base("Text", "txt") /// Gets the document template name
/// </summary>
public string Name
{ {
get { return "Text"; }
} }
public override IDocument CreateDocument() /// <summary>
/// Gets the default extension of this template
/// </summary>
public string DefaultExtension
{
get { return "txt"; }
}
/// <summary>
/// Gets or sets the properties of this template
/// </summary>
public IEnumerable<Property> Properties
{
get { return Enumerable.Empty<Property>(); }
}
/// <summary>
/// Creates a document using this template
/// </summary>
/// <returns>Created document.</returns>
public IDocument CreateDocument()
{ {
return new TextDocument(); return new TextDocument();
} }

View File

@ -50,7 +50,7 @@ namespace RainmeterStudio.Business
/// <summary> /// <summary>
/// Gets a list of document templates /// Gets a list of document templates
/// </summary> /// </summary>
public IEnumerable<DocumentTemplate> DocumentTemplates { get { return _templates; } } public IEnumerable<IDocumentTemplate> DocumentTemplates { get { return _templates; } }
#endregion #endregion
@ -59,7 +59,7 @@ namespace RainmeterStudio.Business
private List<IDocumentEditorFactory> _factories = new List<IDocumentEditorFactory>(); private List<IDocumentEditorFactory> _factories = new List<IDocumentEditorFactory>();
private List<IDocumentEditor> _editors = new List<IDocumentEditor>(); private List<IDocumentEditor> _editors = new List<IDocumentEditor>();
private List<IDocumentStorage> _storages = new List<IDocumentStorage>(); private List<IDocumentStorage> _storages = new List<IDocumentStorage>();
private List<DocumentTemplate> _templates = new List<DocumentTemplate>(); private List<IDocumentTemplate> _templates = new List<IDocumentTemplate>();
#endregion #endregion
@ -94,7 +94,7 @@ namespace RainmeterStudio.Business
/// Registers a document template /// Registers a document template
/// </summary> /// </summary>
/// <param name="template">The document template</param> /// <param name="template">The document template</param>
public void RegisterTemplate(DocumentTemplate template) public void RegisterTemplate(IDocumentTemplate template)
{ {
_templates.Add(template); _templates.Add(template);
} }
@ -108,7 +108,7 @@ namespace RainmeterStudio.Business
/// </summary> /// </summary>
/// <param name="format"></param> /// <param name="format"></param>
/// <param name="path"></param> /// <param name="path"></param>
public IDocumentEditor Create(DocumentTemplate format) public IDocumentEditor Create(IDocumentTemplate format)
{ {
// Create document // Create document
var document = format.CreateDocument(); var document = format.CreateDocument();

View File

@ -11,6 +11,8 @@ namespace RainmeterStudio.Business
{ {
public class ProjectManager public class ProjectManager
{ {
private List<IProjectTemplate> _projectTemplates = new List<IProjectTemplate>();
#region Properties #region Properties
/// <summary> /// <summary>
@ -112,5 +114,16 @@ namespace RainmeterStudio.Business
if (ActiveProjectChanged != null) if (ActiveProjectChanged != null)
ActiveProjectChanged(this, new EventArgs()); ActiveProjectChanged(this, new EventArgs());
} }
/// <summary>
/// Registers a project template
/// </summary>
/// <param name="template">Project template</param>
public void RegisterProjectTemplate(IProjectTemplate template)
{
_projectTemplates.Add(template);
}
public IEnumerable<IProjectTemplate> ProjectTemplates { get { return _projectTemplates; } }
} }
} }

View File

@ -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
{
/// <summary>
/// An empty project template
/// </summary>
[PluginExport]
public class EmptyProjectTemplate : IProjectTemplate
{
/// <summary>
/// Gets or sets the name of the template
/// </summary>
public string Name
{
get { return "EmptyProject"; }
}
/// <summary>
/// Gets or sets the properties of this template
/// </summary>
public IEnumerable<Property> Properties
{
get { return Enumerable.Empty<Property>(); }
}
/// <summary>
/// Creates a project.
/// </summary>
/// <returns>Created project</returns>
public Project CreateProject()
{
return new Project();
}
}
}

View File

@ -6,6 +6,7 @@ using System.Text;
using System.Windows; using System.Windows;
using RainmeterStudio.Business; using RainmeterStudio.Business;
using RainmeterStudio.Core.Documents; using RainmeterStudio.Core.Documents;
using RainmeterStudio.Core.Model;
using RainmeterStudio.Core.Storage; using RainmeterStudio.Core.Storage;
using RainmeterStudio.Storage; using RainmeterStudio.Storage;
using RainmeterStudio.UI; using RainmeterStudio.UI;
@ -32,8 +33,9 @@ namespace RainmeterStudio
// Initialize plugin manager // Initialize plugin manager
PluginManager pluginManager = new PluginManager(); PluginManager pluginManager = new PluginManager();
pluginManager.AddRegisterExportTypeHandler(typeof(IDocumentStorage), obj => documentManager.RegisterStorage((IDocumentStorage)obj)); 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(IDocumentEditorFactory), obj => documentManager.RegisterEditorFactory((IDocumentEditorFactory)obj));
pluginManager.AddRegisterExportTypeHandler(typeof(IProjectTemplate), obj => projectManager.RegisterProjectTemplate((IProjectTemplate)obj));
pluginManager.Initialize(); pluginManager.Initialize();
// Create & run app // Create & run app

View File

@ -27,12 +27,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+N")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+N")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string ProjectCreateCommand_Shortcut { public string Command_ProjectCreateCommand_Shortcut {
get { get {
return ((string)(this["ProjectCreateCommand_Shortcut"])); return ((string)(this["Command_ProjectCreateCommand_Shortcut"]));
} }
set { set {
this["ProjectCreateCommand_Shortcut"] = value; this["Command_ProjectCreateCommand_Shortcut"] = value;
} }
} }
@ -40,12 +40,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("F5")] [global::System.Configuration.DefaultSettingValueAttribute("F5")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string ProjectPanel_RefreshCommand_Shortcut { public string Command_ProjectPanel_RefreshCommand_Shortcut {
get { get {
return ((string)(this["ProjectPanel_RefreshCommand_Shortcut"])); return ((string)(this["Command_ProjectPanel_RefreshCommand_Shortcut"]));
} }
set { 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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+N")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+N")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string DocumentCreateCommand_Shortcut { public string Command_DocumentCreateCommand_Shortcut {
get { get {
return ((string)(this["DocumentCreateCommand_Shortcut"])); return ((string)(this["Command_DocumentCreateCommand_Shortcut"]));
} }
set { set {
this["DocumentCreateCommand_Shortcut"] = value; this["Command_DocumentCreateCommand_Shortcut"] = value;
} }
} }
@ -66,12 +66,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+O")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+Shift+O")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string ProjectOpenCommand_Shortcut { public string Command_ProjectOpenCommand_Shortcut {
get { get {
return ((string)(this["ProjectOpenCommand_Shortcut"])); return ((string)(this["Command_ProjectOpenCommand_Shortcut"]));
} }
set { set {
this["ProjectOpenCommand_Shortcut"] = value; this["Command_ProjectOpenCommand_Shortcut"] = value;
} }
} }
@ -79,12 +79,12 @@ namespace RainmeterStudio.Properties {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Ctrl+W")] [global::System.Configuration.DefaultSettingValueAttribute("Ctrl+W")]
[global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)] [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]
public string DocumentCloseCommand_Shortcut { public string Command_DocumentCloseCommand_Shortcut {
get { get {
return ((string)(this["DocumentCloseCommand_Shortcut"])); return ((string)(this["Command_DocumentCloseCommand_Shortcut"]));
} }
set { set {
this["DocumentCloseCommand_Shortcut"] = value; this["Command_DocumentCloseCommand_Shortcut"] = value;
} }
} }

View File

@ -2,19 +2,19 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RainmeterStudio.Properties" GeneratedClassName="Settings"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RainmeterStudio.Properties" GeneratedClassName="Settings">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="ProjectCreateCommand_Shortcut" Roaming="true" Type="System.String" Scope="User"> <Setting Name="Command_ProjectCreateCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)">Ctrl+Shift+N</Value> <Value Profile="(Default)">Ctrl+Shift+N</Value>
</Setting> </Setting>
<Setting Name="ProjectPanel_RefreshCommand_Shortcut" Roaming="true" Type="System.String" Scope="User"> <Setting Name="Command_ProjectPanel_RefreshCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)">F5</Value> <Value Profile="(Default)">F5</Value>
</Setting> </Setting>
<Setting Name="DocumentCreateCommand_Shortcut" Roaming="true" Type="System.String" Scope="User"> <Setting Name="Command_DocumentCreateCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)">Ctrl+N</Value> <Value Profile="(Default)">Ctrl+N</Value>
</Setting> </Setting>
<Setting Name="ProjectOpenCommand_Shortcut" Roaming="true" Type="System.String" Scope="User"> <Setting Name="Command_ProjectOpenCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)">Ctrl+Shift+O</Value> <Value Profile="(Default)">Ctrl+Shift+O</Value>
</Setting> </Setting>
<Setting Name="DocumentCloseCommand_Shortcut" Roaming="true" Type="System.String" Scope="User"> <Setting Name="Command_DocumentCloseCommand_Shortcut" Roaming="true" Type="System.String" Scope="User">
<Value Profile="(Default)">Ctrl+W</Value> <Value Profile="(Default)">Ctrl+W</Value>
</Setting> </Setting>
<Setting Name="MainWindow_Width" Type="System.Double" Scope="User"> <Setting Name="MainWindow_Width" Type="System.Double" Scope="User">

View File

@ -70,6 +70,7 @@
<Compile Include="Business\DocumentManager.cs" /> <Compile Include="Business\DocumentManager.cs" />
<Compile Include="Business\PluginManager.cs" /> <Compile Include="Business\PluginManager.cs" />
<Compile Include="Business\ProjectManager.cs" /> <Compile Include="Business\ProjectManager.cs" />
<Compile Include="Documents\EmptyProjectTemplate.cs" />
<Compile Include="MainClass.cs" /> <Compile Include="MainClass.cs" />
<Compile Include="Interop\NativeLibrary.cs" /> <Compile Include="Interop\NativeLibrary.cs" />
<Compile Include="Rainmeter.cs" /> <Compile Include="Rainmeter.cs" />
@ -101,6 +102,7 @@
</Compile> </Compile>
<Compile Include="UI\UIManager.cs" /> <Compile Include="UI\UIManager.cs" />
<Compile Include="UI\ViewModel\DocumentTemplateViewModel.cs" /> <Compile Include="UI\ViewModel\DocumentTemplateViewModel.cs" />
<Compile Include="UI\ViewModel\ProjectTemplateViewModel.cs" />
<Compile Include="UI\ViewModel\ReferenceViewModel.cs" /> <Compile Include="UI\ViewModel\ReferenceViewModel.cs" />
<Page Include="UI\Dialogs\CreateDocumentDialog.xaml"> <Page Include="UI\Dialogs\CreateDocumentDialog.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
@ -224,6 +226,9 @@
<Name>RainmeterStudio.Core</Name> <Name>RainmeterStudio.Core</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\Icons\32\project_empty.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -179,5 +179,15 @@ namespace RainmeterStudio.Resources {
return ((System.Drawing.Bitmap)(obj)); return ((System.Drawing.Bitmap)(obj));
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap ProjectTemplate_EmptyProject_Icon {
get {
object obj = ResourceManager.GetObject("ProjectTemplate_EmptyProject_Icon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
} }
} }

View File

@ -154,4 +154,7 @@
<data name="ProjectItem_rsproj" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="ProjectItem_rsproj" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons\16\project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>icons\16\project.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="ProjectTemplate_EmptyProject_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons\32\project_empty.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -401,5 +401,23 @@ namespace RainmeterStudio.Resources {
return ResourceManager.GetString("MainWindow_Title", resourceCulture); return ResourceManager.GetString("MainWindow_Title", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Creates a new empty project..
/// </summary>
public static string ProjectTemplate_EmptyProject_Description {
get {
return ResourceManager.GetString("ProjectTemplate_EmptyProject_Description", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Empty project.
/// </summary>
public static string ProjectTemplate_EmptyProject_DisplayText {
get {
return ResourceManager.GetString("ProjectTemplate_EmptyProject_DisplayText", resourceCulture);
}
}
} }
} }

View File

@ -231,4 +231,10 @@
<data name="MainWindow_Title" xml:space="preserve"> <data name="MainWindow_Title" xml:space="preserve">
<value>Rainmeter Studio</value> <value>Rainmeter Studio</value>
</data> </data>
<data name="ProjectTemplate_EmptyProject_Description" xml:space="preserve">
<value>Creates a new empty project.</value>
</data>
<data name="ProjectTemplate_EmptyProject_DisplayText" xml:space="preserve">
<value>Empty project</value>
</data>
</root> </root>

View File

@ -7,6 +7,7 @@ using RainmeterStudio.Core.Documents;
using RainmeterStudio.Core.Model.Events; using RainmeterStudio.Core.Model.Events;
using RainmeterStudio.UI.Dialogs; using RainmeterStudio.UI.Dialogs;
using RainmeterStudio.UI.ViewModel; using RainmeterStudio.UI.ViewModel;
using RainmeterStudio.Core.Model;
namespace RainmeterStudio.UI.Controller namespace RainmeterStudio.UI.Controller
{ {
@ -60,7 +61,7 @@ namespace RainmeterStudio.UI.Controller
DocumentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow()); DocumentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow());
} }
public void CreateWindow(DocumentTemplate defaultFormat = null, string defaultPath = "") public void CreateWindow(IDocumentTemplate defaultFormat = null, string defaultPath = "")
{ {
// Show dialog // Show dialog
var dialog = new CreateDocumentDialog(this) var dialog = new CreateDocumentDialog(this)
@ -81,7 +82,7 @@ namespace RainmeterStudio.UI.Controller
DocumentManager.Create(format.Template); DocumentManager.Create(format.Template);
} }
public void Create(DocumentTemplate format) public void Create(IDocumentTemplate format)
{ {
// Call manager // Call manager
DocumentManager.Create(format); DocumentManager.Create(format);

View File

@ -1,10 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Linq;
using Microsoft.Win32; using Microsoft.Win32;
using RainmeterStudio.Business; using RainmeterStudio.Business;
using RainmeterStudio.Core.Model; using RainmeterStudio.Core.Model;
using RainmeterStudio.UI.Dialogs; using RainmeterStudio.UI.Dialogs;
using RainmeterStudio.UI.ViewModel;
namespace RainmeterStudio.UI.Controller namespace RainmeterStudio.UI.Controller
{ {
@ -44,6 +47,17 @@ namespace RainmeterStudio.UI.Controller
} }
} }
/// <summary>
/// Gets the project templates
/// </summary>
public IEnumerable<ProjectTemplateViewModel> ProjectTemplates
{
get
{
return Manager.ProjectTemplates.Select(pt => new ProjectTemplateViewModel(pt));
}
}
#endregion #endregion
#region Callbacks #region Callbacks
@ -91,7 +105,7 @@ namespace RainmeterStudio.UI.Controller
public void CreateProject(string name = null, string path = null) public void CreateProject(string name = null, string path = null)
{ {
// Create dialog // Create dialog
var dialog = new CreateProjectDialog(); var dialog = new CreateProjectDialog(this);
dialog.Owner = OwnerWindow; dialog.Owner = OwnerWindow;
dialog.SelectedLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Rainmeter Studio Projects"); dialog.SelectedLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Rainmeter Studio Projects");

View File

@ -23,7 +23,7 @@
Width="32" Height="32" Margin="2" Width="32" Height="32" Margin="2"
Stretch="Uniform" VerticalAlignment="Top" /> Stretch="Uniform" VerticalAlignment="Top" />
<StackPanel Orientation="Vertical" VerticalAlignment="Center"> <StackPanel Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="{Binding Name}" FontWeight="Bold" /> <TextBlock Text="{Binding DisplayText}" FontWeight="Bold" />
<TextBlock Text="{Binding Description}" /> <TextBlock Text="{Binding Description}" />
</StackPanel> </StackPanel>
</DockPanel> </DockPanel>

View File

@ -13,9 +13,8 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ListView Name="listTemplates" Grid.Row="0" SelectedIndex="0" <ListView Name="listTemplates" Grid.Row="0" Margin="1px"
IsEnabled="False"> SelectionChanged="listTemplates_SelectionChanged">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<DockPanel> <DockPanel>
@ -23,21 +22,12 @@
Width="32" Height="32" Margin="2" Width="32" Height="32" Margin="2"
Stretch="Uniform" VerticalAlignment="Top" /> Stretch="Uniform" VerticalAlignment="Top" />
<StackPanel Orientation="Vertical" VerticalAlignment="Center"> <StackPanel Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="{Binding Name}" FontWeight="Bold" /> <TextBlock Text="{Binding DisplayText}" FontWeight="Bold" />
<TextBlock Text="{Binding Description}" /> <TextBlock Text="{Binding Description}" />
</StackPanel> </StackPanel>
</DockPanel> </DockPanel>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock FontWeight="Bold" FontSize="13pt" Text="{Binding Name}" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView> </ListView>
<Grid Grid.Row="1"> <Grid Grid.Row="1">

View File

@ -13,6 +13,8 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using RainmeterStudio.Business; using RainmeterStudio.Business;
using RainmeterStudio.Core.Documents; using RainmeterStudio.Core.Documents;
using RainmeterStudio.Core.Model;
using RainmeterStudio.UI.Controller;
namespace RainmeterStudio.UI.Dialogs namespace RainmeterStudio.UI.Dialogs
{ {
@ -54,11 +56,11 @@ namespace RainmeterStudio.UI.Dialogs
/// <summary> /// <summary>
/// Gets or sets the currently selected file format /// Gets or sets the currently selected file format
/// </summary> /// </summary>
public DocumentTemplate SelectedTemplate public IDocumentTemplate SelectedTemplate
{ {
get get
{ {
return listTemplates.SelectedItem as DocumentTemplate; return listTemplates.SelectedItem as IDocumentTemplate;
} }
set set
{ {
@ -121,7 +123,7 @@ namespace RainmeterStudio.UI.Dialogs
#endregion #endregion
public CreateProjectDialog() public CreateProjectDialog(ProjectController projectController)
{ {
InitializeComponent(); InitializeComponent();
@ -132,6 +134,9 @@ namespace RainmeterStudio.UI.Dialogs
// Set data context // Set data context
DataContext = this; DataContext = this;
// Populate templates
listTemplates.ItemsSource = projectController.ProjectTemplates.OrderBy(x => x.DisplayText);
// Focus on name textbox // Focus on name textbox
textName.Focus(); textName.Focus();
} }
@ -208,5 +213,9 @@ namespace RainmeterStudio.UI.Dialogs
{ {
UpdatePath(); UpdatePath();
} }
private void listTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
} }
} }

View File

@ -1,15 +1,18 @@
using System.Windows.Media; using System.Windows.Media;
using RainmeterStudio.Business; using RainmeterStudio.Business;
using RainmeterStudio.Core.Documents; using RainmeterStudio.Core.Model;
namespace RainmeterStudio.UI.ViewModel namespace RainmeterStudio.UI.ViewModel
{ {
/// <summary>
/// View model for document templates
/// </summary>
public class DocumentTemplateViewModel public class DocumentTemplateViewModel
{ {
/// <summary> /// <summary>
/// Gets the document template /// Gets the document template
/// </summary> /// </summary>
public DocumentTemplate Template { get; private set; } public IDocumentTemplate Template { get; private set; }
/// <summary> /// <summary>
/// Gets the document template name /// Gets the document template name
@ -23,7 +26,7 @@ namespace RainmeterStudio.UI.ViewModel
{ {
get get
{ {
return ResourceProvider.GetImage("Template_" + Name + "_Icon"); return ResourceProvider.GetImage("DocumentTemplate_" + Name + "_Icon");
} }
} }
@ -34,7 +37,7 @@ namespace RainmeterStudio.UI.ViewModel
{ {
get get
{ {
return ResourceProvider.GetString("Template_" + Name + "_DisplayText"); return ResourceProvider.GetString("DocumentTemplate_" + Name + "_DisplayText");
} }
} }
@ -45,7 +48,7 @@ namespace RainmeterStudio.UI.ViewModel
{ {
get get
{ {
return ResourceProvider.GetString("Template_" + Name + "_Description"); return ResourceProvider.GetString("DocumentTemplate_" + Name + "_Description");
} }
} }
@ -53,7 +56,7 @@ namespace RainmeterStudio.UI.ViewModel
/// Initializes the document template view model /// Initializes the document template view model
/// </summary> /// </summary>
/// <param name="template">The document template</param> /// <param name="template">The document template</param>
public DocumentTemplateViewModel(DocumentTemplate template) public DocumentTemplateViewModel(IDocumentTemplate template)
{ {
this.Template = template; this.Template = template;
} }

View File

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using RainmeterStudio.Business;
using RainmeterStudio.Core.Model;
namespace RainmeterStudio.UI.ViewModel
{
/// <summary>
/// View model for project templates
/// </summary>
public class ProjectTemplateViewModel
{
/// <summary>
/// Gets the project template
/// </summary>
public IProjectTemplate Template { get; private set; }
/// <summary>
/// Gets the name of the template
/// </summary>
public string Name
{
get
{
return Template.Name;
}
}
/// <summary>
/// Gets the display text
/// </summary>
public string DisplayText
{
get
{
return ResourceProvider.GetString("ProjectTemplate_" + Name + "_DisplayText");
}
}
/// <summary>
/// Gets the description
/// </summary>
public string Description
{
get
{
return ResourceProvider.GetString("ProjectTemplate_" + Name + "_Description");
}
}
/// <summary>
/// Gets the icon
/// </summary>
public ImageSource Icon
{
get
{
return ResourceProvider.GetImage("ProjectTemplate_" + Name + "_Icon");
}
}
/// <summary>
/// Initializes the project template view model
/// </summary>
/// <param name="template">A project template</param>
public ProjectTemplateViewModel(IProjectTemplate template)
{
Template = template;
}
}
}

View File

@ -7,19 +7,20 @@
</configSections> </configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><userSettings> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><userSettings>
<RainmeterStudio.Properties.Settings> <RainmeterStudio.Properties.Settings>
<setting name="ProjectCreateCommand_Shortcut" serializeAs="String"> <setting name="Command_ProjectCreateCommand_Shortcut" serializeAs="String">
<value>Ctrl+Shift+N</value> <value>Ctrl+Shift+N</value>
</setting> </setting>
<setting name="ProjectPanel_RefreshCommand_Shortcut" serializeAs="String"> <setting name="Command_ProjectPanel_RefreshCommand_Shortcut"
serializeAs="String">
<value>F5</value> <value>F5</value>
</setting> </setting>
<setting name="DocumentCreateCommand_Shortcut" serializeAs="String"> <setting name="Command_DocumentCreateCommand_Shortcut" serializeAs="String">
<value>Ctrl+N</value> <value>Ctrl+N</value>
</setting> </setting>
<setting name="ProjectOpenCommand_Shortcut" serializeAs="String"> <setting name="Command_ProjectOpenCommand_Shortcut" serializeAs="String">
<value>Ctrl+Shift+O</value> <value>Ctrl+Shift+O</value>
</setting> </setting>
<setting name="DocumentCloseCommand_Shortcut" serializeAs="String"> <setting name="Command_DocumentCloseCommand_Shortcut" serializeAs="String">
<value>Ctrl+W</value> <value>Ctrl+W</value>
</setting> </setting>
<setting name="MainWindow_Width" serializeAs="String"> <setting name="MainWindow_Width" serializeAs="String">