Improved resource manager, plugin manager

This commit is contained in:
2014-08-14 10:06:20 +03:00
parent dc7eff73b4
commit 03d9848b50
37 changed files with 1071 additions and 89 deletions

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RainmeterStudio.Rainmeter.DataTypes
{
public class Action
{
}
}

View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RainmeterStudio.Rainmeter.DataTypes
{
public abstract class Bang
{
/// <summary>
/// Argument info
/// </summary>
public class ArgumentInfo
{
public string Name { get; set; }
public Type DataType { get; set; }
public ArgumentInfo(string name, Type dataType)
{
Name = name;
DataType = dataType;
}
}
/// <summary>
/// Gets the function name of the bang
/// </summary>
public abstract string FunctionName { get; }
/// <summary>
/// Gets the list of arguments
/// </summary>
public abstract IEnumerable<ArgumentInfo> Arguments { get; }
/// <summary>
/// Executes the bang
/// </summary>
public void Execute(params object[] args)
{
}
/// <summary>
/// Gets the string representation of this bang
/// </summary>
/// <returns>String representation</returns>
public override string ToString()
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat("!{0}", FunctionName);
foreach (var arg in Arguments.Select(x => x.ToString()))
{
if (arg.Any(Char.IsWhiteSpace))
builder.AppendFormat(@" ""{0}""", arg);
else builder.AppendFormat(" {0}", arg);
}
return builder.ToString();
}
}
}

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace RainmeterStudio.Rainmeter
{
/// <summary>
/// Represents a group
/// </summary>
/// <remarks>
/// Skins, meters, and measures can be categorized into groups to allow
/// easier control with group bangs. For example, the !HideMeterGroup
/// bang may be used to hide multiple meters in a single bang (compared
/// to !HideMeter statements for each meter).
/// </remarks>
public abstract class Group
{
#region Imports
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern bool Group_BelongsToGroup(out bool result, Int32 handle, string group);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern bool Group_Destroy(Int32 handle);
#endregion
/// <summary>
/// Gets or sets the associated handle of this object
/// </summary>
protected Int32 Handle { get; private set; }
/// <summary>
/// Tests if belongs to a group
/// </summary>
/// <param name="group">Group name</param>
/// <returns>True if belongs</returns>
public bool BelongsToGroup(string group)
{
bool result;
if (!Group_BelongsToGroup(out result, Handle, group))
throw new ExternalException("Belongs to group failed.");
return result;
}
/// <summary>
/// Initializes this group
/// </summary>
/// <param name="handle">The handle</param>
protected Group(Int32 handle)
{
Handle = handle;
}
/// <summary>
/// Finalizer
/// </summary>
~Group()
{
Group_Destroy(Handle);
}
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RainmeterStudio.Rainmeter
{
public class Measure
{
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RainmeterStudio.Rainmeter
{
public abstract class Meter : Group
{
public Meter(int handle)
: base(handle)
{
}
}
}

View 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")]

View 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>

View File

@ -0,0 +1,174 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace RainmeterStudio.Rainmeter
{
public abstract class Section : Group
{
#region Imports
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_GetName(out string result, Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_GetOriginalName(out string result, Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_HasDynamicVariables(out bool result, Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_SetDynamicVariables(Int32 handle, bool value);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_ResetUpdateCounter(Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_GetUpdateCounter(out int result, Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_GetUpdateDivider(out int result, Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_GetOnUpdateAction(out string result, Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_DoUpdateAction(Int32 handle);
[DllImport("Rainmeter.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool Section_Destroy(Int32 handle);
#endregion
protected Section(Int32 handle)
: base(handle)
{
}
~Section()
{
Section_Destroy(Handle);
}
/// <summary>
/// Gets the name of the section
/// </summary>
public string Name
{
get
{
string name;
if (!Section_GetName(out name, Handle))
throw new ExternalException("Get name failed.");
return name;
}
}
/// <summary>
/// Gets the original name of the section
/// </summary>
public string OriginalName
{
get
{
string name;
if (!Section_GetOriginalName(out name, Handle))
throw new ExternalException("Get original name failed.");
return name;
}
}
/// <summary>
/// Gets a value indicating if this section has dynamic variables
/// </summary>
public bool HasDynamicVariables
{
get
{
bool result;
if (!Section_HasDynamicVariables(out result, Handle))
throw new ExternalException("Get dynamic variables has failed.");
return result;
}
set
{
if (!Section_SetDynamicVariables(Handle, value))
throw new ExternalException("Set dynamic variables has failed.");
}
}
/// <summary>
/// Resets the update counter
/// </summary>
public void ResetUpdateCounter()
{
if (!Section_ResetUpdateCounter(Handle))
throw new ExternalException("Reset update counter has failed.");
}
/// <summary>
/// Gets the update counter
/// </summary>
public int UpdateCounter
{
get
{
int result;
if (!Section_GetUpdateCounter(out result, Handle))
throw new ExternalException("Get update counter has failed.");
return result;
}
}
/// <summary>
/// Gets the update divider
/// </summary>
public int UpdateDivider
{
get
{
int result;
if (!Section_GetUpdateDivider(out result, Handle))
throw new ExternalException("Get update divider has failed.");
return result;
}
}
/// <summary>
/// Gets the update divider
/// </summary>
public string OnUpdateAction
{
get
{
string result;
if (!Section_GetOnUpdateAction(out result, Handle))
throw new ExternalException("Get on update action has failed.");
return result;
}
}
/// <summary>
/// Executes the update action
/// </summary>
public void DoUpdateAction()
{
if (!Section_DoUpdateAction(Handle))
throw new ExternalException("Do update action has failed.");
}
}
}