2022-11-11 19:56:08 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Data.Common;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Net.Sockets;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
namespace FanControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class FanControlForm : Form
|
|
|
|
|
|
{
|
|
|
|
|
|
private FanControl fanControl = new FanControl();
|
|
|
|
|
|
|
|
|
|
|
|
public FanControlForm()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
propertyGrid1.SelectedObject = fanControl;
|
2022-11-12 10:14:09 +01:00
|
|
|
|
propertyGrid1.ExpandAllGridItems();
|
2022-11-11 19:56:08 +01:00
|
|
|
|
|
2022-11-12 10:14:09 +01:00
|
|
|
|
foreach (var item in Enum.GetValues(typeof(FanControl.FanMode)))
|
2022-11-11 19:56:08 +01:00
|
|
|
|
{
|
|
|
|
|
|
fanModeSelectMenu.Items.Add(item);
|
|
|
|
|
|
fanModeSelectNotifyMenu.Items.Add(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fanModeSelectMenu.SelectedIndex = 0;
|
2022-11-11 20:01:44 +01:00
|
|
|
|
fanModeSelectNotifyMenu.SelectedIndex = 0;
|
2022-11-11 19:56:08 +01:00
|
|
|
|
|
2022-11-11 20:01:44 +01:00
|
|
|
|
notifyIcon.ShowBalloonTip(3000, "Steam Deck Fan Control", "Fan Control Started", ToolTipIcon.Info);
|
2022-11-11 19:56:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void fanModeSelect_SelectedValueChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var comboBox = (ToolStripComboBox)sender;
|
|
|
|
|
|
var selectedMode = (FanControl.FanMode)comboBox.SelectedItem;
|
|
|
|
|
|
fanControl.SetMode(selectedMode);
|
|
|
|
|
|
fanModeSelectMenu.SelectedItem = selectedMode;
|
|
|
|
|
|
fanModeSelectNotifyMenu.SelectedItem = selectedMode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void FanControlForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.CloseReason == CloseReason.UserClosing && Visible)
|
|
|
|
|
|
{
|
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
|
Hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void formShow_Event(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Show();
|
2022-11-12 10:14:09 +01:00
|
|
|
|
propertyGrid1.Refresh();
|
2022-11-11 19:56:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void formClose_Event(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Hide();
|
|
|
|
|
|
Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void FanControlForm_FormClosed(object sender, FormClosedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Always revert to default on closing
|
|
|
|
|
|
fanControl.SetMode(FanControl.FanMode.Default);
|
|
|
|
|
|
}
|
2022-11-11 20:01:44 +01:00
|
|
|
|
|
2022-11-12 10:14:09 +01:00
|
|
|
|
private void fanLoopTimer_Tick(object sender, EventArgs e)
|
2022-11-11 20:01:44 +01:00
|
|
|
|
{
|
|
|
|
|
|
fanControl.Update();
|
2022-11-12 10:14:09 +01:00
|
|
|
|
}
|
2022-11-11 20:01:44 +01:00
|
|
|
|
|
2022-11-12 10:14:09 +01:00
|
|
|
|
private void propertyGridUpdateTimer_Tick(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!Visible)
|
|
|
|
|
|
return;
|
2022-11-11 20:01:44 +01:00
|
|
|
|
|
2022-11-12 10:14:09 +01:00
|
|
|
|
var item = propertyGrid1.SelectedGridItem;
|
|
|
|
|
|
propertyGrid1.Refresh();
|
|
|
|
|
|
propertyGrid1.SelectedGridItem = item;
|
2022-11-11 20:01:44 +01:00
|
|
|
|
notifyIcon.Text = String.Format("Fan: {0} RPM Mode: {1}", fanControl.CurrentRPM, fanControl.Mode);
|
|
|
|
|
|
}
|
2022-11-11 19:56:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|