mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Split into smaller projects, now uses plugins.
This commit is contained in:
11
RainmeterStudio/Rainmeter/DataTypes/Action.cs
Normal file
11
RainmeterStudio/Rainmeter/DataTypes/Action.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterStudio.Rainmeter.DataTypes
|
||||
{
|
||||
public class Action
|
||||
{
|
||||
}
|
||||
}
|
63
RainmeterStudio/Rainmeter/DataTypes/Bang.cs
Normal file
63
RainmeterStudio/Rainmeter/DataTypes/Bang.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
67
RainmeterStudio/Rainmeter/Group.cs
Normal file
67
RainmeterStudio/Rainmeter/Group.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
11
RainmeterStudio/Rainmeter/Measure.cs
Normal file
11
RainmeterStudio/Rainmeter/Measure.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RainmeterStudio.Rainmeter
|
||||
{
|
||||
public class Measure
|
||||
{
|
||||
}
|
||||
}
|
15
RainmeterStudio/Rainmeter/Meter.cs
Normal file
15
RainmeterStudio/Rainmeter/Meter.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
174
RainmeterStudio/Rainmeter/Section.cs
Normal file
174
RainmeterStudio/Rainmeter/Section.cs
Normal 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.");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user