mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Improved resource manager, plugin manager
This commit is contained in:
parent
dc7eff73b4
commit
03d9848b50
@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace RainmeterStudio.Core.Model
|
||||
{
|
||||
|
@ -43,6 +43,7 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="RainmeterStudioPluginAttribute.cs" />
|
||||
<Compile Include="PluginExportAttribute.cs" />
|
||||
<Compile Include="Documents\DocumentEditorFeatures\ICustomDocumentTitleProvider.cs" />
|
||||
<Compile Include="Documents\DocumentEditorFeatures\ISelectionPropertiesProvider.cs" />
|
||||
|
16
RainmeterStudio.Core/RainmeterStudioPluginAttribute.cs
Normal file
16
RainmeterStudio.Core/RainmeterStudioPluginAttribute.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterStudio.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// The assembly will be loaded as a plug-in.
|
||||
/// </summary>
|
||||
/// <remarks>RainmeterStudio will load assemblies with this flag as plugins.</remarks>
|
||||
[AttributeUsage(AttributeTargets.Assembly)]
|
||||
public class RainmeterStudioPluginAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
36
RainmeterStudio.Rainmeter/Properties/AssemblyInfo.cs
Normal file
36
RainmeterStudio.Rainmeter/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RainmeterStudio.Rainmeter")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("RainmeterStudio.Rainmeter")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8a34d129-3bf6-4218-b29f-d353ad8640c9")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
65
RainmeterStudio.Rainmeter/RainmeterStudio.Rainmeter.csproj
Normal file
65
RainmeterStudio.Rainmeter/RainmeterStudio.Rainmeter.csproj
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C641D7F8-DDDC-4EC6-8F5E-233520290642}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RainmeterStudio.Rainmeter</RootNamespace>
|
||||
<AssemblyName>RainmeterStudio.Rainmeter</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DataTypes\Action.cs" />
|
||||
<Compile Include="DataTypes\Bang.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Measure.cs" />
|
||||
<Compile Include="Meter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Section.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\RainmeterStudio.Core\RainmeterStudio.Core.csproj">
|
||||
<Project>{1d2a4896-af31-4e82-a84f-4e218067701f}</Project>
|
||||
<Name>RainmeterStudio.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@ -1,6 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using RainmeterStudio.Core;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
@ -13,6 +14,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: RainmeterStudioPlugin]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
|
@ -16,7 +16,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\Plugins\</OutputPath>
|
||||
<OutputPath>..\x32-Debug\StudioPlugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -25,7 +25,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\Plugins\</OutputPath>
|
||||
<OutputPath>bin\Release\StudioPlugins\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -45,6 +45,21 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resources\Graphics.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Graphics.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources\Icons.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Icons.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources\Strings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Strings.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SkinDesigner.cs" />
|
||||
<Compile Include="SkinDesignerControl.xaml.cs">
|
||||
<DependentUpon>SkinDesignerControl.xaml</DependentUpon>
|
||||
@ -53,7 +68,7 @@
|
||||
<Compile Include="SkinDocument.cs" />
|
||||
<Compile Include="SkinMetadata.cs" />
|
||||
<Compile Include="SkinStorage.cs" />
|
||||
<Compile Include="SkinTemplate.cs" />
|
||||
<Compile Include="SkinDocumentTemplate.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="SkinDesignerControl.xaml">
|
||||
@ -65,8 +80,26 @@
|
||||
<ProjectReference Include="..\RainmeterStudio.Core\RainmeterStudio.Core.csproj">
|
||||
<Project>{1d2a4896-af31-4e82-a84f-4e218067701f}</Project>
|
||||
<Name>RainmeterStudio.Core</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\Graphics\transparent_background.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Graphics.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Graphics.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Icons.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Icons.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Strings.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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.
|
||||
|
72
RainmeterStudio.SkinDesigner/Resources/Graphics.Designer.cs
generated
Normal file
72
RainmeterStudio.SkinDesigner/Resources/Graphics.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace RainmeterStudio.SkinDesignerPlugin.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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 Graphics {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Graphics() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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.SkinDesignerPlugin.Resources.Graphics", typeof(Graphics).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to /Resources/Graphics/transparent_background.png.
|
||||
/// </summary>
|
||||
public static string TransparentBackground {
|
||||
get {
|
||||
return ResourceManager.GetString("TransparentBackground", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
RainmeterStudio.SkinDesigner/Resources/Graphics.resx
Normal file
123
RainmeterStudio.SkinDesigner/Resources/Graphics.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="TransparentBackground" xml:space="preserve">
|
||||
<value>/Resources/Graphics/transparent_background.png</value>
|
||||
</data>
|
||||
</root>
|
Binary file not shown.
After Width: | Height: | Size: 150 B |
63
RainmeterStudio.SkinDesigner/Resources/Icons.Designer.cs
generated
Normal file
63
RainmeterStudio.SkinDesigner/Resources/Icons.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace RainmeterStudio.SkinDesignerPlugin.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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 Icons {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Icons() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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.SkinDesignerPlugin.Resources.Icons", typeof(Icons).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
101
RainmeterStudio.SkinDesigner/Resources/Icons.resx
Normal file
101
RainmeterStudio.SkinDesigner/Resources/Icons.resx
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
72
RainmeterStudio.SkinDesigner/Resources/Strings.Designer.cs
generated
Normal file
72
RainmeterStudio.SkinDesigner/Resources/Strings.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace RainmeterStudio.SkinDesignerPlugin.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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.SkinDesignerPlugin.Resources.Strings", typeof(Strings).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Test value.
|
||||
/// </summary>
|
||||
public static string Test {
|
||||
get {
|
||||
return ResourceManager.GetString("Test", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
RainmeterStudio.SkinDesigner/Resources/Strings.resx
Normal file
123
RainmeterStudio.SkinDesigner/Resources/Strings.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Test" xml:space="preserve">
|
||||
<value>Test value</value>
|
||||
</data>
|
||||
</root>
|
@ -5,13 +5,14 @@ using System.Text;
|
||||
using System.Windows;
|
||||
using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using RainmeterStudio.Core.Documents.DocumentEditorFeatures;
|
||||
|
||||
namespace RainmeterStudio.SkinDesignerPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Skin designer document editor
|
||||
/// </summary>
|
||||
public class SkinDesigner : IDocumentEditor
|
||||
public class SkinDesigner : IDocumentEditor //TODO: , ISelectionPropertiesProvider, IToolboxProvider, IUndoSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the document attached to this editor instance
|
||||
@ -46,6 +47,7 @@ namespace RainmeterStudio.SkinDesignerPlugin
|
||||
public SkinDesigner(SkinDocument document)
|
||||
{
|
||||
AttachedDocument = document;
|
||||
EditorUI = new SkinDesignerControl(document);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,23 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:r="clr-namespace:RainmeterStudio.SkinDesignerPlugin.Resources"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300"
|
||||
d:DesignHeight="300" d:DesignWidth="500"
|
||||
Title="SkinDesignerControl">
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Column="0">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="/Resources/Graphics/transparent_background.png"
|
||||
Stretch="None" TileMode="Tile" />
|
||||
</Border.Background>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
|
@ -19,7 +19,7 @@ namespace RainmeterStudio.SkinDesignerPlugin
|
||||
/// </summary>
|
||||
public partial class SkinDesignerControl : Page
|
||||
{
|
||||
public SkinDesignerControl()
|
||||
public SkinDesignerControl(SkinDocument document)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace RainmeterStudio.SkinDesignerPlugin
|
||||
/// <returns>A new document editor</returns>
|
||||
public IDocumentEditor CreateEditor(IDocument document)
|
||||
{
|
||||
return new SkinDesigner(document as SkinDocument);
|
||||
return new SkinDesigner((SkinDocument)document);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -31,7 +31,7 @@ namespace RainmeterStudio.SkinDesignerPlugin
|
||||
/// <returns>True if the editor can edit the document type</returns>
|
||||
public bool CanEdit(Type type)
|
||||
{
|
||||
return (type == typeof(SkinDocument));
|
||||
return type.Equals(typeof(SkinDocument));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RainmeterStudio.Core;
|
||||
using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.Core.Model;
|
||||
|
||||
@ -10,12 +11,13 @@ namespace RainmeterStudio.SkinDesignerPlugin
|
||||
/// <summary>
|
||||
/// Template of a skin which will be opened in the designer
|
||||
/// </summary>
|
||||
public class SkinTemplate : DocumentTemplate
|
||||
[PluginExport]
|
||||
public class SkinDocumentTemplate : DocumentTemplate
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes this skin template
|
||||
/// </summary>
|
||||
public SkinTemplate()
|
||||
public SkinDocumentTemplate()
|
||||
: base("Skin", "ini")
|
||||
{
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using RainmeterStudio.Core;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
@ -13,6 +14,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: RainmeterStudioPlugin]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
|
@ -16,7 +16,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\Plugins\</OutputPath>
|
||||
<OutputPath>..\x32-Debug\StudioPlugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -25,7 +25,7 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\Plugins\</OutputPath>
|
||||
<OutputPath>bin\Release\StudioPlugins\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -58,6 +58,7 @@
|
||||
<ProjectReference Include="..\RainmeterStudio.Core\RainmeterStudio.Core.csproj">
|
||||
<Project>{1d2a4896-af31-4e82-a84f-4e218067701f}</Project>
|
||||
<Name>RainmeterStudio.Core</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -70,6 +70,11 @@ EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginWindowMessage", "Plugins\PluginWindowMessage\PluginWindowMessage.vcxproj", "{B9184DBA-C6B7-44FE-8BBD-0852DB22D2E4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainmeterStudio", "RainmeterStudio\RainmeterStudio.csproj", "{438D0136-4A27-4E4D-A617-FFACE4554236}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{9A644478-2F1B-4145-8B31-6F8DBD42EC38} = {9A644478-2F1B-4145-8B31-6F8DBD42EC38}
|
||||
{E8BD25E9-3055-4688-9E83-ECF684EF30C6} = {E8BD25E9-3055-4688-9E83-ECF684EF30C6}
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642} = {C641D7F8-DDDC-4EC6-8F5E-233520290642}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainmeterStudio.Tests", "RainmeterStudio.Tests\RainmeterStudio.Tests.csproj", "{845F4BD4-6822-4D92-9DDB-15FD18A47E5A}"
|
||||
EndProject
|
||||
@ -85,6 +90,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{4CCE
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RainmeterPlugins", "RainmeterPlugins", "{53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Native", "Native", "{DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainmeterStudio.Rainmeter", "RainmeterStudio.Rainmeter\RainmeterStudio.Rainmeter.csproj", "{C641D7F8-DDDC-4EC6-8F5E-233520290642}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -559,15 +568,31 @@ Global
|
||||
{9A644478-2F1B-4145-8B31-6F8DBD42EC38}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{9A644478-2F1B-4145-8B31-6F8DBD42EC38}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{9A644478-2F1B-4145-8B31-6F8DBD42EC38}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{C641D7F8-DDDC-4EC6-8F5E-233520290642}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A} = {8469BE7E-BCDB-4AA8-9541-719E8BFB19A7}
|
||||
{E8BD25E9-3055-4688-9E83-ECF684EF30C6} = {4CCE6052-F43E-4360-B3E2-C046C6C0D86C}
|
||||
{9A644478-2F1B-4145-8B31-6F8DBD42EC38} = {4CCE6052-F43E-4360-B3E2-C046C6C0D86C}
|
||||
{EE8EC522-8430-4B46-86A3-D943D77F9E4B} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
{2FCFBFD2-2720-4BDD-B620-4BDD3DBB8D3D} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{BE9D2400-7F1C-49D6-8498-5CE495491AD6} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{BC25C5DC-AEFB-49F9-8188-3C1B8C8929E6} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{6D61FBE9-6913-4885-A95D-1A8C0C223D82} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{6F5D4C4A-C8C3-41DA-BF44-6D42B76464DA} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{2D8F1DDB-6470-45A1-B95A-3E2960641314} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{53D952E0-CFD2-4EFF-BAD4-5969E760EFA1} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{19312085-AA51-4BD6-BE92-4B6098CCA539} = {DBBF3BDB-60DB-4FD2-B9D6-226E63549DA2}
|
||||
{F32FA418-8DF4-4E94-B92B-EBD502F5DC07} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
{64FDEE97-6B7E-40E5-A489-ECA322825BC8} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
{A221819D-4263-42AA-B22A-C022924842A7} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
@ -589,5 +614,9 @@ Global
|
||||
{45A34285-56DD-4521-912B-3F884D36FA35} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
{B9184DBA-C6B7-44FE-8BBD-0852DB22D2E4} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
{EE8EC522-8430-4B46-86A3-D943D77F9E4B} = {53D952E0-CFD2-4EFF-BAD4-5969E760EFA1}
|
||||
{845F4BD4-6822-4D92-9DDB-15FD18A47E5A} = {8469BE7E-BCDB-4AA8-9541-719E8BFB19A7}
|
||||
{9A644478-2F1B-4145-8B31-6F8DBD42EC38} = {4CCE6052-F43E-4360-B3E2-C046C6C0D86C}
|
||||
{E8BD25E9-3055-4688-9E83-ECF684EF30C6} = {4CCE6052-F43E-4360-B3E2-C046C6C0D86C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -47,6 +47,11 @@ namespace RainmeterStudio.Business
|
||||
/// </summary>
|
||||
public IEnumerable<IDocumentStorage> Storages { get { return _storages; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of document templates
|
||||
/// </summary>
|
||||
public IEnumerable<DocumentTemplate> DocumentTemplates { get { return _templates; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private fields
|
||||
|
@ -4,10 +4,12 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
using RainmeterStudio.Core;
|
||||
using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.Core.Utils;
|
||||
using RainmeterStudio.Resources;
|
||||
|
||||
namespace RainmeterStudio.Business
|
||||
{
|
||||
@ -16,31 +18,84 @@ namespace RainmeterStudio.Business
|
||||
/// </summary>
|
||||
public class PluginManager
|
||||
{
|
||||
public delegate void RegisterMethod(object objectToRegister);
|
||||
#region Private fields
|
||||
|
||||
List<Assembly> _loadedPlugins = new List<Assembly>();
|
||||
Dictionary<Type, RegisterMethod> _registerTypes = new Dictionary<Type,RegisterMethod>();
|
||||
|
||||
Dictionary<Type, RegisterExportHandler> _registerExportTypes = new Dictionary<Type, RegisterExportHandler>();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerable of the loaded plugins
|
||||
/// </summary>
|
||||
public IEnumerable<Assembly> LoadedPlugins
|
||||
{
|
||||
get
|
||||
{
|
||||
return _loadedPlugins;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method which registers an object that was exported by a plugin.
|
||||
/// </summary>
|
||||
/// <param name="objectToRegister">Object to register</param>
|
||||
public delegate void RegisterExportHandler(object objectToRegister);
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the plugin manager
|
||||
/// </summary>
|
||||
public PluginManager()
|
||||
{
|
||||
}
|
||||
|
||||
public void AddRegisterType(Type interfaceType, RegisterMethod method)
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Adds a handler that registers exported objects of a specific type.
|
||||
/// </summary>
|
||||
/// <param name="interfaceType">The data type</param>
|
||||
/// <param name="method">Handler that does the registring</param>
|
||||
public void AddRegisterExportTypeHandler(Type interfaceType, RegisterExportHandler method)
|
||||
{
|
||||
_registerTypes.Add(interfaceType, method);
|
||||
_registerExportTypes.Add(interfaceType, method);
|
||||
}
|
||||
|
||||
public void LoadPlugins()
|
||||
/// <summary>
|
||||
/// Initializes the plugin manager
|
||||
/// </summary>
|
||||
/// <remarks>This will load all the plugins from the "StudioPlugins" folder</remarks>
|
||||
public void Initialize()
|
||||
{
|
||||
// Get "Plugins" folder path
|
||||
var location = Assembly.GetExecutingAssembly().Location;
|
||||
var pluginsPath = Path.Combine(Path.GetDirectoryName(location), "Plugins");
|
||||
// Initialize the executing assembly
|
||||
InitializePlugin(Assembly.GetExecutingAssembly());
|
||||
|
||||
// Load plugins from StudioPlugins folder
|
||||
var location = Assembly.GetExecutingAssembly().Location;
|
||||
var pluginsPath = Path.Combine(Path.GetDirectoryName(location), "StudioPlugins");
|
||||
|
||||
LoadPlugins(pluginsPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads all the plugins from the specified directory.
|
||||
/// </summary>
|
||||
/// <param name="pluginsPath">Directory path</param>
|
||||
public void LoadPlugins(string pluginsPath)
|
||||
{
|
||||
// Load all DLLs from "Plugins" folder
|
||||
foreach (var file in Directory.EnumerateFiles(pluginsPath, "*.dll"))
|
||||
LoadPlugin(file);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to load the plugin.
|
||||
/// </summary>
|
||||
/// <param name="file">File name</param>
|
||||
/// <remarks>If plugin is not loaded, the function fails silently.</remarks>
|
||||
public void LoadPlugin(string file)
|
||||
{
|
||||
Assembly assembly = null;
|
||||
@ -58,17 +113,19 @@ namespace RainmeterStudio.Business
|
||||
// Loaded, do initialization stuff
|
||||
if (assembly != null)
|
||||
{
|
||||
_loadedPlugins.Add(assembly);
|
||||
|
||||
Initialize(assembly);
|
||||
|
||||
Debug.WriteLine("Loaded plugin: {0}", assembly.FullName);
|
||||
// Check for the RainmeterStudioPlugin attribute
|
||||
if (assembly.GetCustomAttributes(typeof(RainmeterStudioPluginAttribute), false).Count() > 0)
|
||||
{
|
||||
_loadedPlugins.Add(assembly);
|
||||
InitializePlugin(assembly);
|
||||
Debug.WriteLine("Loaded plugin: {0}", (object)assembly.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Initialize(Assembly assembly)
|
||||
private void InitializePlugin(Assembly assembly)
|
||||
{
|
||||
// Register factories and stuff
|
||||
// Register exports
|
||||
assembly.GetTypes()
|
||||
|
||||
// Select only the classes
|
||||
@ -80,7 +137,7 @@ namespace RainmeterStudio.Business
|
||||
// Perform register
|
||||
.ForEach((type) =>
|
||||
{
|
||||
foreach (var pair in _registerTypes)
|
||||
foreach (var pair in _registerExportTypes)
|
||||
{
|
||||
if (pair.Key.IsAssignableFrom(type))
|
||||
{
|
||||
@ -91,13 +148,13 @@ namespace RainmeterStudio.Business
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<Assembly> LoadedPlugins
|
||||
{
|
||||
get
|
||||
// Register .resource files
|
||||
foreach (var resourceName in assembly.GetManifestResourceNames())
|
||||
{
|
||||
return _loadedPlugins;
|
||||
var name = Path.GetFileNameWithoutExtension(resourceName);
|
||||
ResourceManager manager = new ResourceManager(name, assembly);
|
||||
ResourceProvider.RegisterManager(manager, assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ namespace RainmeterStudio
|
||||
|
||||
// Initialize plugin manager
|
||||
PluginManager pluginManager = new PluginManager();
|
||||
pluginManager.AddRegisterType(typeof(IDocumentStorage), obj => documentManager.RegisterStorage((IDocumentStorage)obj));
|
||||
pluginManager.AddRegisterType(typeof(DocumentTemplate), obj => documentManager.RegisterTemplate((DocumentTemplate)obj));
|
||||
pluginManager.AddRegisterType(typeof(IDocumentEditorFactory), obj => documentManager.RegisterEditorFactory((IDocumentEditorFactory)obj));
|
||||
pluginManager.LoadPlugins();
|
||||
pluginManager.AddRegisterExportTypeHandler(typeof(IDocumentStorage), obj => documentManager.RegisterStorage((IDocumentStorage)obj));
|
||||
pluginManager.AddRegisterExportTypeHandler(typeof(DocumentTemplate), obj => documentManager.RegisterTemplate((DocumentTemplate)obj));
|
||||
pluginManager.AddRegisterExportTypeHandler(typeof(IDocumentEditorFactory), obj => documentManager.RegisterEditorFactory((IDocumentEditorFactory)obj));
|
||||
pluginManager.Initialize();
|
||||
|
||||
// Create & run app
|
||||
var uiManager = new UIManager(projectManager, documentManager);
|
||||
|
@ -8,7 +8,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RainmeterStudio</RootNamespace>
|
||||
<AssemblyName>RainmeterEditor</AssemblyName>
|
||||
<AssemblyName>RainmeterStudio</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
@ -73,17 +73,12 @@
|
||||
<Compile Include="MainClass.cs" />
|
||||
<Compile Include="Interop\NativeLibrary.cs" />
|
||||
<Compile Include="Rainmeter.cs" />
|
||||
<Compile Include="Rainmeter\DataTypes\Action.cs" />
|
||||
<Compile Include="Rainmeter\DataTypes\Bang.cs" />
|
||||
<Compile Include="Rainmeter\Group.cs" />
|
||||
<Compile Include="Rainmeter\Measure.cs" />
|
||||
<Compile Include="Rainmeter\Meter.cs" />
|
||||
<Compile Include="Rainmeter\Section.cs" />
|
||||
<Compile Include="Resources\Icons.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Icons.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources\ResourceProvider.cs" />
|
||||
<Compile Include="Resources\Strings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
|
126
RainmeterStudio/Resources/ResourceProvider.cs
Normal file
126
RainmeterStudio/Resources/ResourceProvider.cs
Normal file
@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace RainmeterStudio.Resources
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages and provides resources
|
||||
/// </summary>
|
||||
public static class ResourceProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds information about a resource manager
|
||||
/// </summary>
|
||||
private struct ResourceManagerInfo
|
||||
{
|
||||
public ResourceManager Manager;
|
||||
public Assembly Assembly;
|
||||
}
|
||||
|
||||
private static List<ResourceManagerInfo> _resourceManagers = new List<ResourceManagerInfo>();
|
||||
private static Dictionary<string, string> _cacheStrings = new Dictionary<string, string>();
|
||||
private static Dictionary<string, ImageSource> _cacheImages = new Dictionary<string, ImageSource>();
|
||||
|
||||
/// <summary>
|
||||
/// Registers a resource manager
|
||||
/// </summary>
|
||||
/// <param name="manager">The resource manager</param>
|
||||
/// <param name="ownerAssembly">The assembly which will contain the non-string resources</param>
|
||||
public static void RegisterManager(ResourceManager manager, Assembly ownerAssembly)
|
||||
{
|
||||
_resourceManagers.Add(new ResourceManagerInfo()
|
||||
{
|
||||
Manager = manager,
|
||||
Assembly = ownerAssembly
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string from the resource managers
|
||||
/// </summary>
|
||||
/// <param name="key">Identifier of the resource</param>
|
||||
/// <param name="bypassCache">By default, strings are cached. Setting this to true will bypass the cache.</param>
|
||||
/// <param name="keepInCache">If this parameter is set to true, the obtained string will be cached.</param>
|
||||
/// <returns>The string, or null if not found</returns>
|
||||
public static string GetString(string key, bool bypassCache = false, bool keepInCache = true)
|
||||
{
|
||||
string value = null;
|
||||
|
||||
// Look up in cache
|
||||
if (bypassCache || !_cacheStrings.TryGetValue(key, out value))
|
||||
{
|
||||
// Not found, query resource managers
|
||||
foreach (var info in _resourceManagers)
|
||||
{
|
||||
// Try to get resource
|
||||
var str = info.Manager.GetString(key);
|
||||
|
||||
// Found?
|
||||
if (str != null)
|
||||
{
|
||||
value = str;
|
||||
|
||||
if (keepInCache)
|
||||
_cacheStrings[key] = str;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Resource not found
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an image from the resource manager.
|
||||
/// </summary>
|
||||
/// <param name="key">Identifier of the resource</param>
|
||||
/// <param name="bypassCache">By default, images are cached. Setting this to true will bypass the cache.</param>
|
||||
/// <param name="keepInCache">If this parameter is set to true, the obtained image will be cached.</param>
|
||||
/// <returns>The image source, or null if not found</returns>
|
||||
public static ImageSource GetImage(string key, bool bypassCache = false, bool keepInCache = true)
|
||||
{
|
||||
ImageSource image = null;
|
||||
|
||||
// Look up in cache
|
||||
if (bypassCache || !_cacheImages.TryGetValue(key, out image))
|
||||
{
|
||||
// Not found, query resource managers
|
||||
foreach (var info in _resourceManagers)
|
||||
{
|
||||
// Try to get resource
|
||||
var path = info.Manager.GetString(key);
|
||||
|
||||
// Found
|
||||
if (path != null)
|
||||
{
|
||||
Uri fullPath = new Uri("/" + info.Assembly.GetName().Name + ";component" + path, UriKind.Relative);
|
||||
image = new BitmapImage(fullPath);
|
||||
|
||||
if (keepInCache)
|
||||
_cacheImages[key] = image;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Resource not found
|
||||
return image;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the cache
|
||||
/// </summary>
|
||||
public static void ClearCache()
|
||||
{
|
||||
_cacheImages.Clear();
|
||||
_cacheStrings.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Linq;
|
||||
using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.Core.Model.Events;
|
||||
using RainmeterStudio.UI.Dialogs;
|
||||
using RainmeterStudio.UI.ViewModel;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
@ -60,7 +63,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
public void CreateWindow(DocumentTemplate defaultFormat = null, string defaultPath = "")
|
||||
{
|
||||
// Show dialog
|
||||
var dialog = new CreateDocumentDialog()
|
||||
var dialog = new CreateDocumentDialog(this)
|
||||
{
|
||||
Owner = OwnerWindow,
|
||||
SelectedTemplate = defaultFormat,
|
||||
@ -84,5 +87,15 @@ namespace RainmeterStudio.UI.Controller
|
||||
DocumentManager.Create(format);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of document templates view models
|
||||
/// </summary>
|
||||
public IEnumerable<DocumentTemplateViewModel> DocumentTemplates
|
||||
{
|
||||
get
|
||||
{
|
||||
return DocumentManager.DocumentTemplates.Select(t => new DocumentTemplateViewModel(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,29 +7,30 @@ using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using RainmeterStudio.Resources;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides icons
|
||||
/// </summary>
|
||||
public static class IconProvider
|
||||
{
|
||||
private static Dictionary<string, ImageSource> _loadedImages = new Dictionary<string, ImageSource>();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an icon by resource name
|
||||
/// </summary>
|
||||
/// <param name="key">Resource name</param>
|
||||
/// <returns>The icon</returns>
|
||||
public static ImageSource GetIcon(string key)
|
||||
{
|
||||
if (!_loadedImages.ContainsKey(key))
|
||||
{
|
||||
// Try to get the icon file name
|
||||
string iconPath = Resources.Icons.ResourceManager.GetString(key);
|
||||
if (iconPath == null)
|
||||
return null;
|
||||
|
||||
// Load the image
|
||||
var uri = new Uri(iconPath, UriKind.RelativeOrAbsolute);
|
||||
_loadedImages.Add(key, new BitmapImage(uri));
|
||||
}
|
||||
return _loadedImages[key];
|
||||
return ResourceProvider.GetImage(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an icon by reference
|
||||
/// </summary>
|
||||
/// <param name="item">The reference</param>
|
||||
/// <returns>The icon</returns>
|
||||
public static ImageSource GetProjectItemIcon(Reference item)
|
||||
{
|
||||
// Resource name
|
||||
@ -51,6 +52,9 @@ namespace RainmeterStudio.UI.Controller
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Icon provider converter, for use in xaml
|
||||
/// </summary>
|
||||
public class IconProviderConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
|
@ -3,16 +3,29 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Create..." Height="250" Width="400"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
WindowStyle="ToolWindow" ShowInTaskbar="False">
|
||||
WindowStyle="ToolWindow" ShowInTaskbar="False"
|
||||
Background="WhiteSmoke" >
|
||||
|
||||
<Grid Margin="2px">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="2" />
|
||||
<ColumnDefinition Width="3*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Background="WhiteSmoke">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ListView Name="listFormats" Grid.Row="0">
|
||||
<ListView Name="listCategories" Grid.Row="0" Grid.Column="0"
|
||||
SelectionChanged="listCategories_SelectionChanged"
|
||||
Margin="1px"/>
|
||||
|
||||
<GridSplitter Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
|
||||
<ListView Name="listFormats" Grid.Row="0" Grid.Column="2" Margin="1px">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel>
|
||||
@ -26,18 +39,9 @@
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock FontWeight="Bold" FontSize="13pt" Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ListView.GroupStyle>
|
||||
</ListView>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid Grid.Row="1" Grid.ColumnSpan="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
@ -49,15 +53,15 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0">Path:</TextBlock>
|
||||
<TextBox Name="textPath" Grid.Row="0" Grid.Column="1"></TextBox>
|
||||
<TextBox Name="textPath" Grid.Row="0" Grid.Column="1" Margin="1px"></TextBox>
|
||||
<Button Grid.Row="0" Grid.Column="2">...</Button>
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal"
|
||||
<StackPanel Grid.Row="2" Grid.ColumnSpan="3" Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
<Button Name="buttonCreate" Click="buttonCreate_Click" IsDefault="True">Create</Button>
|
||||
<Button Name="buttonCancel" Click="buttonCancel_Click" IsCancel="True">Cancel</Button>
|
||||
<Button Name="buttonCreate" Click="buttonCreate_Click" IsDefault="True" Margin="1px">Create</Button>
|
||||
<Button Name="buttonCancel" Click="buttonCancel_Click" IsCancel="True" Margin="1px">Cancel</Button>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.UI.Controller;
|
||||
|
||||
namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
@ -21,6 +22,8 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// </summary>
|
||||
public partial class CreateDocumentDialog : Window
|
||||
{
|
||||
private DocumentController _documentController;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the currently selected file format
|
||||
/// </summary>
|
||||
@ -54,20 +57,34 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// <summary>
|
||||
/// Creates a new instance of CreateDocumentDialog
|
||||
/// </summary>
|
||||
public CreateDocumentDialog()
|
||||
public CreateDocumentDialog(DocumentController docCtrl)
|
||||
{
|
||||
InitializeComponent();
|
||||
_documentController = docCtrl;
|
||||
|
||||
PopulateFormats();
|
||||
PopulateCategories();
|
||||
RepopulateFormats();
|
||||
Validate();
|
||||
}
|
||||
|
||||
private void PopulateFormats()
|
||||
private void PopulateCategories()
|
||||
{
|
||||
//listFormats.ItemsSource = DocumentManager.Instance.DocumentFormats;
|
||||
listCategories.ItemsSource = _documentController.DocumentTemplates
|
||||
.Select(template => template.Category)
|
||||
.Where(cat => cat != null)
|
||||
.Distinct()
|
||||
.Concat(new[] { "All" });
|
||||
|
||||
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listFormats.ItemsSource);
|
||||
view.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
|
||||
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));
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, RoutedEventArgs e)
|
||||
@ -90,5 +107,10 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
|
||||
buttonCreate.IsEnabled = res;
|
||||
}
|
||||
|
||||
private void listCategories_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
RepopulateFormats();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user