forked from CyanLabs/RGBSync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.cs
120 lines (102 loc) · 4.65 KB
/
Settings.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.Linq;
using System.Windows.Forms;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair;
using RGB.NET.Devices.Logitech;
using RGB.NET.Devices.Asus;
using RGB.NET.Devices.Razer;
using RGB.NET.Devices.CorsairLink;
using RGB.NET.Groups;
using RGB.NET.Devices.CoolerMaster;
using RGB.NET.Devices.Novation;
using RGB.NET.Devices.Msi;
using System.Diagnostics;
using System.Threading;
namespace RGBSync
{
public partial class Settings : Form
{
private ILedGroup _ledGroup;
private const LedId SYNC_LED = LedId.Mainboard1;
public Settings()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.ShowInTaskbar = false;
this.WindowState = FormWindowState.Minimized;
this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
if (chkShowNotification.Checked) notifyIcon1.ShowBalloonTip(5000, "RGBSync", "Click the notification icon to configure RGB Devices.", ToolTipIcon.Info);
//Process.Start("C:\\Program Files (x86)\\ASUS\\AURA\\AURA.exe");
//Thread.Sleep(1000);
//Process.GetProcessesByName("Aura")[0].Kill();
tabCorsairLink.Enabled = false;
try
{
RGBSurface.Instance.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard, throwExceptions: true);
if (chkCorsairCue.Checked) { RGBSurface.Instance.LoadDevices(CorsairDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true); }
if (chkLogitech.Checked) { RGBSurface.Instance.LoadDevices(LogitechDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true); }
if (chkCM.Checked) { RGBSurface.Instance.LoadDevices(CoolerMasterDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true); }
if (chkNovation.Checked) { RGBSurface.Instance.LoadDevices(NovationDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true); }
if (chkCorsairLink.Checked) { RGBSurface.Instance.LoadDevices(CorsairLinkDeviceProvider.Instance, exclusiveAccessIfPossible: false, throwExceptions: true); }
if (chkMSI.Checked) { RGBSurface.Instance.LoadDevices(MsiDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true); }
if (chkRazer.Checked) { RGBSurface.Instance.LoadDevices(RazerDeviceProvider.Instance, exclusiveAccessIfPossible: true, throwExceptions: true); }
AsusMainboardRGBDevice mainboard = RGBSurface.Instance.GetDevices<AsusMainboardRGBDevice>().FirstOrDefault();
if (mainboard == null)
throw new ApplicationException("No mainboard to sync with is loaded.");
mainboard.UpdateMode = DeviceUpdateMode.SyncBack;
_ledGroup = new ListLedGroup(RGBSurface.Instance.Leds).Exclude(mainboard.ToArray());
_ledGroup.Brush = new SyncBrush(((IRGBDevice)mainboard)[SYNC_LED]);
TimerUpdateTrigger TimerTrigger = new TimerUpdateTrigger();
TimerTrigger.UpdateFrequency = 0.05;
RGBSurface.Instance.RegisterUpdateTrigger(TimerTrigger);
TimerTrigger.Start();
}
catch (Exception ex)
{
throw ex;
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Opacity = 100;
this.WindowState = FormWindowState.Normal;
this.Show();
this.Focus();
this.BringToFront();
}
private void BtnSave_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Save();
Application.Restart();
}
bool allowClosing = false;
private void Settings_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
if (!allowClosing)
{
notifyIcon1.ShowBalloonTip(3000);
this.Hide();
e.Cancel = true;
}
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
allowClosing = true;
Application.Exit();
}
private void settiingsToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Opacity = 100;
this.WindowState = FormWindowState.Normal;
this.Show();
this.Focus();
this.BringToFront();
}
}
}