-
Notifications
You must be signed in to change notification settings - Fork 0
/
SourceCode.cs
61 lines (53 loc) · 1.5 KB
/
SourceCode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Drawing;
using Rainmeter;
namespace MousePositionPlugin
{
public class Measure
{
private string type;
internal void Reload(API api, ref double maxValue)
{
type = api.ReadString("MeasureType", "MouseX").ToLowerInvariant();
}
internal double Update()
{
if (type == "mousex")
{
return Cursor.Position.X;
}
else if (type == "mousey")
{
return Cursor.Position.Y;
}
return 0.0;
}
}
public static class Plugin
{
[DllExport]
public static void Initialize(ref IntPtr data, IntPtr rm)
{
data = GCHandle.ToIntPtr(GCHandle.Alloc(new Measure()));
}
[DllExport]
public static void Finalize(IntPtr data)
{
GCHandle.FromIntPtr(data).Free();
}
[DllExport]
public static void Reload(IntPtr data, IntPtr rm, ref double maxValue)
{
Measure measure = (Measure)GCHandle.FromIntPtr(data).Target;
measure.Reload(new API(rm), ref maxValue);
}
[DllExport]
public static double Update(IntPtr data)
{
Measure measure = (Measure)GCHandle.FromIntPtr(data).Target;
return measure.Update();
}
}
}