diff --git a/PowerPlanSwitcher/App.config b/PowerPlanSwitcher/App.config
index 9f4c3bd..1d18558 100644
--- a/PowerPlanSwitcher/App.config
+++ b/PowerPlanSwitcher/App.config
@@ -34,6 +34,12 @@
False
+
+ 00000000-0000-0000-0000-000000000000
+
+
+ 00000000-0000-0000-0000-000000000000
+
\ No newline at end of file
diff --git a/PowerPlanSwitcher/BatteryMonitor.cs b/PowerPlanSwitcher/BatteryMonitor.cs
index 84f4179..c7f15f7 100644
--- a/PowerPlanSwitcher/BatteryMonitor.cs
+++ b/PowerPlanSwitcher/BatteryMonitor.cs
@@ -1,90 +1,80 @@
-namespace PowerPlanSwitcher
+namespace PowerPlanSwitcher
{
- using System.Runtime.InteropServices;
-
+ using PowerPlanSwitcher.Properties;
+ using static Vanara.PInvoke.Kernel32;
+
public class BatteryMonitor
{
- // 定义SYSTEM_POWER_STATUS结构体
- [StructLayout(LayoutKind.Sequential)]
- public struct SYSTEM_POWER_STATUS
- {
- public byte ACLineStatus; // AC 电源线状态:0 表示离线(电池供电),1 表示在线(插电)
- public byte BatteryFlag; // 电池标志
- public byte BatteryLifePercent; // 电池剩余百分比
- public byte Reserved1; // 保留
- public int BatteryLifeTime; // 电池剩余时间(以秒为单位)
- public int BatteryFullLifeTime; // 电池满电使用时间(以秒为单位)
- }
-
- // 引入GetSystemPowerStatus函数
- [DllImport("kernel32.dll")] //和GetSystemPowerStatus有关
- private static extern bool GetSystemPowerStatus(out SYSTEM_POWER_STATUS lpSystemPowerStatus);
- private static bool ToggleMark = true; // 切换标记
- // private static PowerRule ACListData;
- // private static PowerRule BatteryListData;
- private static Guid? BatteryGuid; // 电池供电时的电源计划GUID
- private static Guid? AcPowerGuid; // 插电时的电源计划GUID
- public static PowerStatus BatteryNull;
- private static SYSTEM_POWER_STATUS powerStatus;
-
- public static void PlanValue()
+ private static Guid AcPowerSchemeGuid =>
+ Settings.Default.AcPowerSchemeGuid;
+ private static Guid BatterPowerSchemeGuid =>
+ Settings.Default.BatterPowerSchemeGuid;
+
+ private static bool toggleMark = true;
+
+ public static bool HasSystemBattery() =>
+ SystemInformation.PowerStatus.BatteryChargeStatus
+ != BatteryChargeStatus.NoSystemBattery;
+
+ public static void Initialize()
{
- BatteryNull = SystemInformation.PowerStatus;
- if (BatteryNull.BatteryChargeStatus != BatteryChargeStatus.NoSystemBattery)
- {
- // 调用SettingsHelper.GetGuidsWithVisibility()方法并解构返回的元组
- var (_acGuid, _batteryGuid) = PowerSchemeSettings.GetGuidsWithVisibility();
-
- // 将解构得到的GUID值赋给对应的静态字段
- AcPowerGuid = _acGuid;
- BatteryGuid = _batteryGuid;
+ if (!GetSystemPowerStatus(out var powerStatus))
+ {
+ return;
}
- }
-
- public static void BatteryMonitorInitialization()
- {
- PlanValue();
- MonitorBatterySwitcInitialization();
- }
-
- private static void MonitorBatterySwitcInitialization()
- {
- if (!ToggleMark && BatteryGuid != Guid.Empty && AcPowerGuid == Guid.Empty && powerStatus.ACLineStatus == 1) // 插电状态 02
+
+ if (!toggleMark
+ && BatterPowerSchemeGuid != Guid.Empty
+ && AcPowerSchemeGuid == Guid.Empty
+ && powerStatus.ACLineStatus == AC_STATUS.AC_ONLINE)
{
- ToggleMark = true;
+ toggleMark = true;
}
- else if (ToggleMark && AcPowerGuid != Guid.Empty && BatteryGuid == Guid.Empty && powerStatus.ACLineStatus == 0) //电池供电 01
+
+ if (toggleMark
+ && AcPowerSchemeGuid != Guid.Empty
+ && BatterPowerSchemeGuid == Guid.Empty
+ && powerStatus.ACLineStatus == AC_STATUS.AC_OFFLINE)
{
- ToggleMark = false;
- }
+ toggleMark = false;
+ }
}
-
- // 监测电池状态并切换电源计划的方法
- public static void MonitorBatterySwitc()
+
+ public static Guid GetPowerPlanGuid()
{
- if (BatteryNull.BatteryChargeStatus != BatteryChargeStatus.NoSystemBattery)
+ if (!HasSystemBattery())
{
- GetSystemPowerStatus(out powerStatus);
- var PMGAPSG = PowerManager.GetActivePowerSchemeGuid();
-
- if (!ToggleMark && AcPowerGuid != Guid.Empty && powerStatus.ACLineStatus == 1 && PMGAPSG != AcPowerGuid) // 插电状态 01 03
- {
- PowerManager.SetActivePowerScheme(AcPowerGuid.Value); // 激活插电时的电源计划
- ProcessMonitor.baselinePowerSchemeGuid = AcPowerGuid.Value; // 电池供电时的电源计划GUID
- ToggleMark = true;
- }
- else if (ToggleMark && BatteryGuid != Guid.Empty && powerStatus.ACLineStatus == 0 && PMGAPSG != BatteryGuid) //电池供电 02 03
- {
- PowerManager.SetActivePowerScheme(BatteryGuid.Value); // 激活电池供电时的电源计划
- ProcessMonitor.baselinePowerSchemeGuid = BatteryGuid.Value;
- ToggleMark = false;
- }
- else
- {
- MonitorBatterySwitcInitialization();
- }
+ return Guid.Empty;
+ }
+ if (!GetSystemPowerStatus(out var powerStatus))
+ {
+ return Guid.Empty;
}
+
+ var activePowerSchemeGuid = PowerManager.GetActivePowerSchemeGuid();
+
+ if (!toggleMark
+ && AcPowerSchemeGuid != Guid.Empty
+ && powerStatus.ACLineStatus == AC_STATUS.AC_ONLINE
+ && activePowerSchemeGuid != AcPowerSchemeGuid)
+ {
+ toggleMark = true;
+ return AcPowerSchemeGuid;
+ }
+
+ if (toggleMark
+ && BatterPowerSchemeGuid != Guid.Empty
+ && powerStatus.ACLineStatus == AC_STATUS.AC_OFFLINE
+ && activePowerSchemeGuid != BatterPowerSchemeGuid)
+ {
+ toggleMark = false;
+ return BatterPowerSchemeGuid;
+ }
+
+ Initialize();
+
+ return Guid.Empty;
}
}
}
diff --git a/PowerPlanSwitcher/PowerSchemeSettings.cs b/PowerPlanSwitcher/PowerSchemeSettings.cs
index b7f50ff..849e6f7 100644
--- a/PowerPlanSwitcher/PowerSchemeSettings.cs
+++ b/PowerPlanSwitcher/PowerSchemeSettings.cs
@@ -62,8 +62,6 @@ public override bool CanConvert(Type objectType) =>
public class Setting
{
- public bool AcPowerVisible { get; set; } = false;
- public bool BatteryVisible { get; set; } = false;
public bool Visible { get; set; } = true;
[JsonConverter(typeof(ImageConverter))]
public Image? Icon { get; set; }
@@ -95,26 +93,14 @@ public class Setting
}
return null;
}
-
- public static (Guid? AcPowerGuid, Guid? BatteryGuid) GetGuidsWithVisibility()
- {
- LoadSettings(); // 确保设置已经被加载
-
- Guid? acPowerGuid = settings
- .Where(kvp => kvp.Value != null && kvp.Value.AcPowerVisible)
- .Select(kvp => kvp.Key)
- .FirstOrDefault();
-
- Guid? batteryGuid = settings
- .Where(kvp => kvp.Value != null && kvp.Value.BatteryVisible)
- .Select(kvp => kvp.Key)
- .FirstOrDefault();
-
- return (acPowerGuid, batteryGuid);
- }
public static void SetSetting(Guid schemaGuid, Setting setting)
{
+ if (schemaGuid == Guid.Empty)
+ {
+ return;
+ }
+
LoadSettings();
settings![schemaGuid] = setting;
}
diff --git a/PowerPlanSwitcher/ProcessMonitor.cs b/PowerPlanSwitcher/ProcessMonitor.cs
index 11d8ce9..2fac216 100644
--- a/PowerPlanSwitcher/ProcessMonitor.cs
+++ b/PowerPlanSwitcher/ProcessMonitor.cs
@@ -11,7 +11,7 @@ internal class ProcessMonitor : IDisposable
private DateTime lastUpdate;
private readonly Timer? updateTimer;
private bool disposedValue;
- public static Guid baselinePowerSchemeGuid;
+ private static Guid baselinePowerSchemeGuid;
private PowerRule? previouslyAppliedPowerRule;
@@ -32,8 +32,8 @@ private void HandleUpdateTimerTick(object? _)
{
try
{
- BatteryMonitor.MonitorBatterySwitc();
-
+ baselinePowerSchemeGuid = BatteryMonitor.GetPowerPlanGuid();
+
if (DateTime.Now - lastUpdate <
TimeSpan.FromSeconds(Settings.Default.PowerRuleCheckInterval))
{
diff --git a/PowerPlanSwitcher/Program.cs b/PowerPlanSwitcher/Program.cs
index 56faac5..fa7b92d 100644
--- a/PowerPlanSwitcher/Program.cs
+++ b/PowerPlanSwitcher/Program.cs
@@ -112,7 +112,6 @@ private static void Main()
RegisterHotkeys();
HotkeyManager.HotkeyPressed += HotkeyManager_HotkeyPressed;
- BatteryMonitor.PlanValue();
using var trayIcon = new TrayIcon();
SystemEvents.EventsThreadShutdown += (s, e) => Application.Exit();
diff --git a/PowerPlanSwitcher/Properties/Settings.Designer.cs b/PowerPlanSwitcher/Properties/Settings.Designer.cs
index b96c627..ced5487 100644
--- a/PowerPlanSwitcher/Properties/Settings.Designer.cs
+++ b/PowerPlanSwitcher/Properties/Settings.Designer.cs
@@ -130,5 +130,29 @@ public bool CycleOnlyVisible {
this["CycleOnlyVisible"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("00000000-0000-0000-0000-000000000000")]
+ public global::System.Guid AcPowerSchemeGuid {
+ get {
+ return ((global::System.Guid)(this["AcPowerSchemeGuid"]));
+ }
+ set {
+ this["AcPowerSchemeGuid"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("00000000-0000-0000-0000-000000000000")]
+ public global::System.Guid BatterPowerSchemeGuid {
+ get {
+ return ((global::System.Guid)(this["BatterPowerSchemeGuid"]));
+ }
+ set {
+ this["BatterPowerSchemeGuid"] = value;
+ }
+ }
}
}
diff --git a/PowerPlanSwitcher/Properties/Settings.settings b/PowerPlanSwitcher/Properties/Settings.settings
index 637a025..621056a 100644
--- a/PowerPlanSwitcher/Properties/Settings.settings
+++ b/PowerPlanSwitcher/Properties/Settings.settings
@@ -29,5 +29,11 @@
False
+
+ 00000000-0000-0000-0000-000000000000
+
+
+ 00000000-0000-0000-0000-000000000000
+
\ No newline at end of file
diff --git a/PowerPlanSwitcher/SettingsDlg.Designer.cs b/PowerPlanSwitcher/SettingsDlg.Designer.cs
index fcb2fd0..e82ee9b 100644
--- a/PowerPlanSwitcher/SettingsDlg.Designer.cs
+++ b/PowerPlanSwitcher/SettingsDlg.Designer.cs
@@ -28,14 +28,12 @@ protected override void Dispose(bool disposing)
///
private void InitializeComponent()
{
- var dataGridViewCellStyle5 = new DataGridViewCellStyle();
+ var dataGridViewCellStyle1 = new DataGridViewCellStyle();
var resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsDlg));
DgvPowerSchemes = new DataGridView();
DgcVisible = new DataGridViewCheckBoxColumn();
DgcIcon = new DataGridViewImageColumn();
DgcName = new DataGridViewTextBoxColumn();
- AcPowerCheckBox = new DataGridViewCheckBoxColumn();
- BatteryCheckBox = new DataGridViewCheckBoxColumn();
DgcHotkey = new DataGridViewTextBoxColumn();
BtnOk = new Button();
BtnCancel = new Button();
@@ -57,14 +55,17 @@ private void InitializeComponent()
CmbColorTheme = new ComboBox();
tableLayoutPanel1 = new TableLayoutPanel();
tableLayoutPanel2 = new TableLayoutPanel();
- BtnSetHotkey = new Button();
+ ChbActivateInitialPowerScheme = new CheckBox();
+ BtnRemoveIcon = new Button();
BtnSetIcon = new Button();
+ BtnSetHotkey = new Button();
BtnRemoveHotkey = new Button();
- BtnRemoveIcon = new Button();
+ CmbInitialPowerScheme = new ComboBox();
tabControl1 = new TabControl();
tabPage1 = new TabPage();
tabPage2 = new TabPage();
tabPage3 = new TabPage();
+ tableLayoutPanel5 = new TableLayoutPanel();
groupBox4 = new GroupBox();
tableLayoutPanel4 = new TableLayoutPanel();
RdbCycleAll = new RadioButton();
@@ -72,13 +73,16 @@ private void InitializeComponent()
RdbCycleVisible = new RadioButton();
BtnRemoveCycleHotkey = new Button();
BtnSetCycleHotkey = new Button();
- ChbActivateInitialPowerScheme = new CheckBox();
- CmbInitialPowerScheme = new ComboBox();
- tableLayoutPanel5 = new TableLayoutPanel();
groupBox1 = new GroupBox();
tableLayoutPanel6 = new TableLayoutPanel();
groupBox2 = new GroupBox();
tableLayoutPanel7 = new TableLayoutPanel();
+ GrbBatteryManagement = new GroupBox();
+ tableLayoutPanel3 = new TableLayoutPanel();
+ CmbAcPowerScheme = new ComboBox();
+ label1 = new Label();
+ label3 = new Label();
+ CmbBatteryPowerScheme = new ComboBox();
((System.ComponentModel.ISupportInitialize)DgvPowerSchemes).BeginInit();
((System.ComponentModel.ISupportInitialize)DgvPowerRules).BeginInit();
((System.ComponentModel.ISupportInitialize)NudPowerRuleCheckInterval).BeginInit();
@@ -88,13 +92,15 @@ private void InitializeComponent()
tabPage1.SuspendLayout();
tabPage2.SuspendLayout();
tabPage3.SuspendLayout();
+ tableLayoutPanel5.SuspendLayout();
groupBox4.SuspendLayout();
tableLayoutPanel4.SuspendLayout();
- tableLayoutPanel5.SuspendLayout();
groupBox1.SuspendLayout();
tableLayoutPanel6.SuspendLayout();
groupBox2.SuspendLayout();
tableLayoutPanel7.SuspendLayout();
+ GrbBatteryManagement.SuspendLayout();
+ tableLayoutPanel3.SuspendLayout();
SuspendLayout();
//
// DgvPowerSchemes
@@ -104,7 +110,7 @@ private void InitializeComponent()
DgvPowerSchemes.AllowUserToResizeColumns = false;
DgvPowerSchemes.AllowUserToResizeRows = false;
DgvPowerSchemes.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- DgvPowerSchemes.Columns.AddRange(new DataGridViewColumn[] { DgcVisible, DgcIcon, DgcName, AcPowerCheckBox, BatteryCheckBox, DgcHotkey });
+ DgvPowerSchemes.Columns.AddRange(new DataGridViewColumn[] { DgcVisible, DgcIcon, DgcName, DgcHotkey });
tableLayoutPanel2.SetColumnSpan(DgvPowerSchemes, 2);
DgvPowerSchemes.Dock = DockStyle.Fill;
DgvPowerSchemes.Location = new Point(3, 3);
@@ -114,7 +120,7 @@ private void InitializeComponent()
tableLayoutPanel2.SetRowSpan(DgvPowerSchemes, 2);
DgvPowerSchemes.RowTemplate.Height = 26;
DgvPowerSchemes.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- DgvPowerSchemes.Size = new Size(455, 154);
+ DgvPowerSchemes.Size = new Size(455, 195);
DgvPowerSchemes.TabIndex = 0;
DgvPowerSchemes.CellMouseDown += HandleDgvPowerSchemesCellMouseDown;
//
@@ -143,27 +149,11 @@ private void InitializeComponent()
DgcName.Name = "DgcName";
DgcName.ReadOnly = true;
//
- // AcPowerCheckBox
- //
- AcPowerCheckBox.HeaderText = "AC";
- AcPowerCheckBox.Name = "AcPowerCheckBox";
- AcPowerCheckBox.Resizable = DataGridViewTriState.True;
- AcPowerCheckBox.SortMode = DataGridViewColumnSortMode.Automatic;
- AcPowerCheckBox.Width = 30;
- //
- // BatteryCheckBox
- //
- BatteryCheckBox.HeaderText = "BA";
- BatteryCheckBox.Name = "BatteryCheckBox";
- BatteryCheckBox.Resizable = DataGridViewTriState.True;
- BatteryCheckBox.SortMode = DataGridViewColumnSortMode.Automatic;
- BatteryCheckBox.Width = 30;
- //
// DgcHotkey
//
DgcHotkey.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
- dataGridViewCellStyle5.Alignment = DataGridViewContentAlignment.MiddleCenter;
- DgcHotkey.DefaultCellStyle = dataGridViewCellStyle5;
+ dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleCenter;
+ DgcHotkey.DefaultCellStyle = dataGridViewCellStyle1;
DgcHotkey.HeaderText = "Hotkey";
DgcHotkey.Name = "DgcHotkey";
DgcHotkey.ReadOnly = true;
@@ -172,7 +162,7 @@ private void InitializeComponent()
// BtnOk
//
BtnOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
- BtnOk.Location = new Point(537, 243);
+ BtnOk.Location = new Point(537, 284);
BtnOk.Name = "BtnOk";
BtnOk.Size = new Size(75, 23);
BtnOk.TabIndex = 1;
@@ -184,7 +174,7 @@ private void InitializeComponent()
//
BtnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
BtnCancel.DialogResult = DialogResult.Cancel;
- BtnCancel.Location = new Point(618, 243);
+ BtnCancel.Location = new Point(618, 284);
BtnCancel.Name = "BtnCancel";
BtnCancel.Size = new Size(75, 23);
BtnCancel.TabIndex = 2;
@@ -194,7 +184,7 @@ private void InitializeComponent()
// BtnCreateRuleFromProcess
//
BtnCreateRuleFromProcess.Image = (Image)resources.GetObject("BtnCreateRuleFromProcess.Image");
- BtnCreateRuleFromProcess.Location = new Point(118, 126);
+ BtnCreateRuleFromProcess.Location = new Point(118, 167);
BtnCreateRuleFromProcess.Name = "BtnCreateRuleFromProcess";
BtnCreateRuleFromProcess.Size = new Size(109, 74);
BtnCreateRuleFromProcess.TabIndex = 6;
@@ -219,7 +209,7 @@ private void InitializeComponent()
DgvPowerRules.RowHeadersVisible = false;
DgvPowerRules.RowTemplate.Height = 26;
DgvPowerRules.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- DgvPowerRules.Size = new Size(685, 117);
+ DgvPowerRules.Size = new Size(685, 158);
DgvPowerRules.TabIndex = 7;
//
// DgcRuleIndex
@@ -273,7 +263,7 @@ private void InitializeComponent()
// BtnAddPowerRule
//
BtnAddPowerRule.Image = (Image)resources.GetObject("BtnAddPowerRule.Image");
- BtnAddPowerRule.Location = new Point(3, 126);
+ BtnAddPowerRule.Location = new Point(3, 167);
BtnAddPowerRule.Name = "BtnAddPowerRule";
BtnAddPowerRule.Size = new Size(109, 74);
BtnAddPowerRule.TabIndex = 8;
@@ -285,7 +275,7 @@ private void InitializeComponent()
// BtnEditPowerRule
//
BtnEditPowerRule.Image = (Image)resources.GetObject("BtnEditPowerRule.Image");
- BtnEditPowerRule.Location = new Point(233, 126);
+ BtnEditPowerRule.Location = new Point(233, 167);
BtnEditPowerRule.Name = "BtnEditPowerRule";
BtnEditPowerRule.Size = new Size(109, 74);
BtnEditPowerRule.TabIndex = 9;
@@ -297,7 +287,7 @@ private void InitializeComponent()
// BtnAscentPowerRule
//
BtnAscentPowerRule.Image = (Image)resources.GetObject("BtnAscentPowerRule.Image");
- BtnAscentPowerRule.Location = new Point(463, 126);
+ BtnAscentPowerRule.Location = new Point(463, 167);
BtnAscentPowerRule.Name = "BtnAscentPowerRule";
BtnAscentPowerRule.Size = new Size(109, 74);
BtnAscentPowerRule.TabIndex = 10;
@@ -309,7 +299,7 @@ private void InitializeComponent()
// BtnDescentPowerRule
//
BtnDescentPowerRule.Image = (Image)resources.GetObject("BtnDescentPowerRule.Image");
- BtnDescentPowerRule.Location = new Point(578, 126);
+ BtnDescentPowerRule.Location = new Point(578, 167);
BtnDescentPowerRule.Name = "BtnDescentPowerRule";
BtnDescentPowerRule.Size = new Size(109, 74);
BtnDescentPowerRule.TabIndex = 10;
@@ -321,7 +311,7 @@ private void InitializeComponent()
// BtnDeletePowerRule
//
BtnDeletePowerRule.Image = (Image)resources.GetObject("BtnDeletePowerRule.Image");
- BtnDeletePowerRule.Location = new Point(348, 126);
+ BtnDeletePowerRule.Location = new Point(348, 167);
BtnDeletePowerRule.Name = "BtnDeletePowerRule";
BtnDeletePowerRule.Size = new Size(109, 74);
BtnDeletePowerRule.TabIndex = 9;
@@ -333,7 +323,7 @@ private void InitializeComponent()
// NudPowerRuleCheckInterval
//
NudPowerRuleCheckInterval.Anchor = AnchorStyles.Right;
- NudPowerRuleCheckInterval.Location = new Point(80, 22);
+ NudPowerRuleCheckInterval.Location = new Point(80, 8);
NudPowerRuleCheckInterval.Maximum = new decimal(new int[] { 600, 0, 0, 0 });
NudPowerRuleCheckInterval.Name = "NudPowerRuleCheckInterval";
NudPowerRuleCheckInterval.Size = new Size(84, 23);
@@ -343,7 +333,7 @@ private void InitializeComponent()
//
label2.Anchor = AnchorStyles.Left;
label2.AutoSize = true;
- label2.Location = new Point(170, 26);
+ label2.Location = new Point(170, 12);
label2.Name = "label2";
label2.Size = new Size(51, 15);
label2.TabIndex = 13;
@@ -354,7 +344,7 @@ private void InitializeComponent()
CmbColorTheme.Anchor = AnchorStyles.None;
CmbColorTheme.DropDownStyle = ComboBoxStyle.DropDownList;
CmbColorTheme.FormattingEnabled = true;
- CmbColorTheme.Location = new Point(65, 22);
+ CmbColorTheme.Location = new Point(65, 8);
CmbColorTheme.Name = "CmbColorTheme";
CmbColorTheme.Size = new Size(202, 23);
CmbColorTheme.TabIndex = 17;
@@ -382,7 +372,7 @@ private void InitializeComponent()
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
- tableLayoutPanel1.Size = new Size(691, 203);
+ tableLayoutPanel1.Size = new Size(691, 244);
tableLayoutPanel1.TabIndex = 0;
//
// tableLayoutPanel2
@@ -406,20 +396,32 @@ private void InitializeComponent()
tableLayoutPanel2.RowStyles.Add(new RowStyle());
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel2.RowStyles.Add(new RowStyle());
- tableLayoutPanel2.Size = new Size(691, 203);
+ tableLayoutPanel2.Size = new Size(691, 244);
tableLayoutPanel2.TabIndex = 1;
//
- // BtnSetHotkey
+ // ChbActivateInitialPowerScheme
//
- BtnSetHotkey.Image = (Image)resources.GetObject("BtnSetHotkey.Image");
- BtnSetHotkey.Location = new Point(464, 83);
- BtnSetHotkey.Name = "BtnSetHotkey";
- BtnSetHotkey.Size = new Size(109, 74);
- BtnSetHotkey.TabIndex = 6;
- BtnSetHotkey.Text = "Set Hotkey";
- BtnSetHotkey.TextImageRelation = TextImageRelation.ImageAboveText;
- BtnSetHotkey.UseVisualStyleBackColor = true;
- BtnSetHotkey.Click += BtnSetHotkey_Click;
+ ChbActivateInitialPowerScheme.AutoSize = true;
+ ChbActivateInitialPowerScheme.Dock = DockStyle.Fill;
+ ChbActivateInitialPowerScheme.Location = new Point(10, 211);
+ ChbActivateInitialPowerScheme.Margin = new Padding(10);
+ ChbActivateInitialPowerScheme.Name = "ChbActivateInitialPowerScheme";
+ ChbActivateInitialPowerScheme.Size = new Size(199, 23);
+ ChbActivateInitialPowerScheme.TabIndex = 24;
+ ChbActivateInitialPowerScheme.Text = "Activate this Power Plan on start:";
+ ChbActivateInitialPowerScheme.UseVisualStyleBackColor = true;
+ //
+ // BtnRemoveIcon
+ //
+ BtnRemoveIcon.Image = (Image)resources.GetObject("BtnRemoveIcon.Image");
+ BtnRemoveIcon.Location = new Point(579, 3);
+ BtnRemoveIcon.Name = "BtnRemoveIcon";
+ BtnRemoveIcon.Size = new Size(109, 74);
+ BtnRemoveIcon.TabIndex = 21;
+ BtnRemoveIcon.Text = "Remove Icon";
+ BtnRemoveIcon.TextImageRelation = TextImageRelation.ImageAboveText;
+ BtnRemoveIcon.UseVisualStyleBackColor = true;
+ BtnRemoveIcon.Click += BtnRemoveIcon_Click;
//
// BtnSetIcon
//
@@ -433,6 +435,18 @@ private void InitializeComponent()
BtnSetIcon.UseVisualStyleBackColor = true;
BtnSetIcon.Click += BtnSetIcon_Click;
//
+ // BtnSetHotkey
+ //
+ BtnSetHotkey.Image = (Image)resources.GetObject("BtnSetHotkey.Image");
+ BtnSetHotkey.Location = new Point(464, 83);
+ BtnSetHotkey.Name = "BtnSetHotkey";
+ BtnSetHotkey.Size = new Size(109, 74);
+ BtnSetHotkey.TabIndex = 6;
+ BtnSetHotkey.Text = "Set Hotkey";
+ BtnSetHotkey.TextImageRelation = TextImageRelation.ImageAboveText;
+ BtnSetHotkey.UseVisualStyleBackColor = true;
+ BtnSetHotkey.Click += BtnSetHotkey_Click;
+ //
// BtnRemoveHotkey
//
BtnRemoveHotkey.Image = (Image)resources.GetObject("BtnRemoveHotkey.Image");
@@ -445,17 +459,17 @@ private void InitializeComponent()
BtnRemoveHotkey.UseVisualStyleBackColor = true;
BtnRemoveHotkey.Click += BtnRemoveHotkey_Click;
//
- // BtnRemoveIcon
+ // CmbInitialPowerScheme
//
- BtnRemoveIcon.Image = (Image)resources.GetObject("BtnRemoveIcon.Image");
- BtnRemoveIcon.Location = new Point(579, 3);
- BtnRemoveIcon.Name = "BtnRemoveIcon";
- BtnRemoveIcon.Size = new Size(109, 74);
- BtnRemoveIcon.TabIndex = 21;
- BtnRemoveIcon.Text = "Remove Icon";
- BtnRemoveIcon.TextImageRelation = TextImageRelation.ImageAboveText;
- BtnRemoveIcon.UseVisualStyleBackColor = true;
- BtnRemoveIcon.Click += BtnRemoveIcon_Click;
+ CmbInitialPowerScheme.Anchor = AnchorStyles.Left;
+ tableLayoutPanel2.SetColumnSpan(CmbInitialPowerScheme, 2);
+ CmbInitialPowerScheme.DropDownStyle = ComboBoxStyle.DropDownList;
+ CmbInitialPowerScheme.FormattingEnabled = true;
+ CmbInitialPowerScheme.Location = new Point(229, 211);
+ CmbInitialPowerScheme.Margin = new Padding(10);
+ CmbInitialPowerScheme.Name = "CmbInitialPowerScheme";
+ CmbInitialPowerScheme.Size = new Size(269, 23);
+ CmbInitialPowerScheme.TabIndex = 25;
//
// tabControl1
//
@@ -466,7 +480,7 @@ private void InitializeComponent()
tabControl1.Location = new Point(0, 0);
tabControl1.Name = "tabControl1";
tabControl1.SelectedIndex = 0;
- tabControl1.Size = new Size(705, 237);
+ tabControl1.Size = new Size(705, 278);
tabControl1.TabIndex = 21;
//
// tabPage1
@@ -475,7 +489,7 @@ private void InitializeComponent()
tabPage1.Location = new Point(4, 24);
tabPage1.Name = "tabPage1";
tabPage1.Padding = new Padding(3);
- tabPage1.Size = new Size(697, 209);
+ tabPage1.Size = new Size(697, 250);
tabPage1.TabIndex = 0;
tabPage1.Text = "Power Plans";
tabPage1.UseVisualStyleBackColor = true;
@@ -486,7 +500,7 @@ private void InitializeComponent()
tabPage2.Location = new Point(4, 24);
tabPage2.Name = "tabPage2";
tabPage2.Padding = new Padding(3);
- tabPage2.Size = new Size(697, 209);
+ tabPage2.Size = new Size(697, 250);
tabPage2.TabIndex = 1;
tabPage2.Text = "Rules";
tabPage2.UseVisualStyleBackColor = true;
@@ -497,11 +511,30 @@ private void InitializeComponent()
tabPage3.Location = new Point(4, 24);
tabPage3.Name = "tabPage3";
tabPage3.Padding = new Padding(3);
- tabPage3.Size = new Size(697, 209);
+ tabPage3.Size = new Size(697, 250);
tabPage3.TabIndex = 2;
tabPage3.Text = "Other Settings";
tabPage3.UseVisualStyleBackColor = true;
//
+ // tableLayoutPanel5
+ //
+ tableLayoutPanel5.ColumnCount = 2;
+ tableLayoutPanel5.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
+ tableLayoutPanel5.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
+ tableLayoutPanel5.Controls.Add(groupBox4, 0, 0);
+ tableLayoutPanel5.Controls.Add(groupBox1, 0, 1);
+ tableLayoutPanel5.Controls.Add(groupBox2, 1, 1);
+ tableLayoutPanel5.Controls.Add(GrbBatteryManagement, 0, 2);
+ tableLayoutPanel5.Dock = DockStyle.Fill;
+ tableLayoutPanel5.Location = new Point(3, 3);
+ tableLayoutPanel5.Name = "tableLayoutPanel5";
+ tableLayoutPanel5.RowCount = 3;
+ tableLayoutPanel5.RowStyles.Add(new RowStyle());
+ tableLayoutPanel5.RowStyles.Add(new RowStyle());
+ tableLayoutPanel5.RowStyles.Add(new RowStyle());
+ tableLayoutPanel5.Size = new Size(691, 244);
+ tableLayoutPanel5.TabIndex = 30;
+ //
// groupBox4
//
tableLayoutPanel5.SetColumnSpan(groupBox4, 2);
@@ -530,8 +563,8 @@ private void InitializeComponent()
tableLayoutPanel4.Location = new Point(3, 19);
tableLayoutPanel4.Name = "tableLayoutPanel4";
tableLayoutPanel4.RowCount = 2;
- tableLayoutPanel4.RowStyles.Add(new RowStyle());
- tableLayoutPanel4.RowStyles.Add(new RowStyle());
+ tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
+ tableLayoutPanel4.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel4.Size = new Size(679, 80);
tableLayoutPanel4.TabIndex = 0;
//
@@ -541,7 +574,7 @@ private void InitializeComponent()
RdbCycleAll.Dock = DockStyle.Left;
RdbCycleAll.Location = new Point(433, 3);
RdbCycleAll.Name = "RdbCycleAll";
- RdbCycleAll.Size = new Size(226, 19);
+ RdbCycleAll.Size = new Size(226, 34);
RdbCycleAll.TabIndex = 26;
RdbCycleAll.TabStop = true;
RdbCycleAll.Text = "Cycle through all existing Power Plans";
@@ -565,9 +598,9 @@ private void InitializeComponent()
//
RdbCycleVisible.AutoSize = true;
RdbCycleVisible.Dock = DockStyle.Left;
- RdbCycleVisible.Location = new Point(433, 28);
+ RdbCycleVisible.Location = new Point(433, 43);
RdbCycleVisible.Name = "RdbCycleVisible";
- RdbCycleVisible.Size = new Size(229, 49);
+ RdbCycleVisible.Size = new Size(229, 34);
RdbCycleVisible.TabIndex = 27;
RdbCycleVisible.TabStop = true;
RdbCycleVisible.Text = "Cycle only through visible Power Plans";
@@ -599,54 +632,13 @@ private void InitializeComponent()
BtnSetCycleHotkey.TextImageRelation = TextImageRelation.ImageAboveText;
BtnSetCycleHotkey.UseVisualStyleBackColor = true;
//
- // ChbActivateInitialPowerScheme
- //
- ChbActivateInitialPowerScheme.AutoSize = true;
- ChbActivateInitialPowerScheme.Dock = DockStyle.Fill;
- ChbActivateInitialPowerScheme.Location = new Point(10, 170);
- ChbActivateInitialPowerScheme.Margin = new Padding(10);
- ChbActivateInitialPowerScheme.Name = "ChbActivateInitialPowerScheme";
- ChbActivateInitialPowerScheme.Size = new Size(199, 23);
- ChbActivateInitialPowerScheme.TabIndex = 24;
- ChbActivateInitialPowerScheme.Text = "Activate this Power Plan on start:";
- ChbActivateInitialPowerScheme.UseVisualStyleBackColor = true;
- //
- // CmbInitialPowerScheme
- //
- CmbInitialPowerScheme.Anchor = AnchorStyles.Left;
- tableLayoutPanel2.SetColumnSpan(CmbInitialPowerScheme, 2);
- CmbInitialPowerScheme.DropDownStyle = ComboBoxStyle.DropDownList;
- CmbInitialPowerScheme.FormattingEnabled = true;
- CmbInitialPowerScheme.Location = new Point(229, 170);
- CmbInitialPowerScheme.Margin = new Padding(10);
- CmbInitialPowerScheme.Name = "CmbInitialPowerScheme";
- CmbInitialPowerScheme.Size = new Size(269, 23);
- CmbInitialPowerScheme.TabIndex = 25;
- //
- // tableLayoutPanel5
- //
- tableLayoutPanel5.ColumnCount = 2;
- tableLayoutPanel5.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
- tableLayoutPanel5.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
- tableLayoutPanel5.Controls.Add(groupBox4, 0, 0);
- tableLayoutPanel5.Controls.Add(groupBox1, 0, 1);
- tableLayoutPanel5.Controls.Add(groupBox2, 1, 1);
- tableLayoutPanel5.Dock = DockStyle.Fill;
- tableLayoutPanel5.Location = new Point(3, 3);
- tableLayoutPanel5.Name = "tableLayoutPanel5";
- tableLayoutPanel5.RowCount = 2;
- tableLayoutPanel5.RowStyles.Add(new RowStyle());
- tableLayoutPanel5.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
- tableLayoutPanel5.Size = new Size(691, 203);
- tableLayoutPanel5.TabIndex = 30;
- //
// groupBox1
//
groupBox1.Controls.Add(tableLayoutPanel6);
groupBox1.Dock = DockStyle.Fill;
groupBox1.Location = new Point(3, 111);
groupBox1.Name = "groupBox1";
- groupBox1.Size = new Size(339, 89);
+ groupBox1.Size = new Size(339, 62);
groupBox1.TabIndex = 30;
groupBox1.TabStop = false;
groupBox1.Text = "Color Theme";
@@ -663,7 +655,7 @@ private void InitializeComponent()
tableLayoutPanel6.RowCount = 1;
tableLayoutPanel6.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel6.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
- tableLayoutPanel6.Size = new Size(333, 67);
+ tableLayoutPanel6.Size = new Size(333, 40);
tableLayoutPanel6.TabIndex = 0;
//
// groupBox2
@@ -672,7 +664,7 @@ private void InitializeComponent()
groupBox2.Dock = DockStyle.Fill;
groupBox2.Location = new Point(348, 111);
groupBox2.Name = "groupBox2";
- groupBox2.Size = new Size(340, 89);
+ groupBox2.Size = new Size(340, 62);
groupBox2.TabIndex = 31;
groupBox2.TabStop = false;
groupBox2.Text = "Check for Rules to apply every";
@@ -690,24 +682,99 @@ private void InitializeComponent()
tableLayoutPanel7.RowCount = 1;
tableLayoutPanel7.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel7.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
- tableLayoutPanel7.Size = new Size(334, 67);
+ tableLayoutPanel7.Size = new Size(334, 40);
tableLayoutPanel7.TabIndex = 0;
//
+ // GrbBatteryManagement
+ //
+ tableLayoutPanel5.SetColumnSpan(GrbBatteryManagement, 2);
+ GrbBatteryManagement.Controls.Add(tableLayoutPanel3);
+ GrbBatteryManagement.Dock = DockStyle.Fill;
+ GrbBatteryManagement.Location = new Point(3, 179);
+ GrbBatteryManagement.Name = "GrbBatteryManagement";
+ GrbBatteryManagement.Size = new Size(685, 62);
+ GrbBatteryManagement.TabIndex = 32;
+ GrbBatteryManagement.TabStop = false;
+ GrbBatteryManagement.Text = "Battery Management";
+ //
+ // tableLayoutPanel3
+ //
+ tableLayoutPanel3.ColumnCount = 4;
+ tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
+ tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
+ tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
+ tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
+ tableLayoutPanel3.Controls.Add(CmbAcPowerScheme, 1, 0);
+ tableLayoutPanel3.Controls.Add(label1, 0, 0);
+ tableLayoutPanel3.Controls.Add(label3, 2, 0);
+ tableLayoutPanel3.Controls.Add(CmbBatteryPowerScheme, 3, 0);
+ tableLayoutPanel3.Dock = DockStyle.Fill;
+ tableLayoutPanel3.Location = new Point(3, 19);
+ tableLayoutPanel3.Name = "tableLayoutPanel3";
+ tableLayoutPanel3.RowCount = 1;
+ tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
+ tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
+ tableLayoutPanel3.Size = new Size(679, 40);
+ tableLayoutPanel3.TabIndex = 0;
+ //
+ // CmbAcPowerScheme
+ //
+ CmbAcPowerScheme.Anchor = AnchorStyles.Left;
+ CmbAcPowerScheme.DropDownStyle = ComboBoxStyle.DropDownList;
+ CmbAcPowerScheme.FormattingEnabled = true;
+ CmbAcPowerScheme.Location = new Point(179, 10);
+ CmbAcPowerScheme.Margin = new Padding(10);
+ CmbAcPowerScheme.Name = "CmbAcPowerScheme";
+ CmbAcPowerScheme.Size = new Size(149, 23);
+ CmbAcPowerScheme.TabIndex = 26;
+ //
+ // label1
+ //
+ label1.Anchor = AnchorStyles.Right;
+ label1.AutoSize = true;
+ label1.Location = new Point(10, 5);
+ label1.Name = "label1";
+ label1.Size = new Size(156, 30);
+ label1.TabIndex = 0;
+ label1.Text = "Default Power Plan when on AC:";
+ label1.TextAlign = ContentAlignment.MiddleRight;
+ //
+ // label3
+ //
+ label3.Anchor = AnchorStyles.Right;
+ label3.AutoSize = true;
+ label3.Location = new Point(348, 5);
+ label3.Name = "label3";
+ label3.Size = new Size(156, 30);
+ label3.TabIndex = 0;
+ label3.Text = "Default Power Plan when on Battery:";
+ label3.TextAlign = ContentAlignment.MiddleRight;
+ //
+ // CmbBatteryPowerScheme
+ //
+ CmbBatteryPowerScheme.Anchor = AnchorStyles.Left;
+ CmbBatteryPowerScheme.DropDownStyle = ComboBoxStyle.DropDownList;
+ CmbBatteryPowerScheme.FormattingEnabled = true;
+ CmbBatteryPowerScheme.Location = new Point(517, 10);
+ CmbBatteryPowerScheme.Margin = new Padding(10);
+ CmbBatteryPowerScheme.Name = "CmbBatteryPowerScheme";
+ CmbBatteryPowerScheme.Size = new Size(152, 23);
+ CmbBatteryPowerScheme.TabIndex = 26;
+ //
// SettingsDlg
//
AcceptButton = BtnOk;
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
CancelButton = BtnCancel;
- ClientSize = new Size(705, 278);
+ ClientSize = new Size(705, 319);
Controls.Add(tabControl1);
Controls.Add(BtnCancel);
Controls.Add(BtnOk);
Icon = (Icon)resources.GetObject("$this.Icon");
- MinimumSize = new Size(721, 317);
+ MinimumSize = new Size(721, 358);
Name = "SettingsDlg";
Text = "PowerPlanSwitcher - Settings";
- Load += SettingsDlg_Load;
((System.ComponentModel.ISupportInitialize)DgvPowerSchemes).EndInit();
((System.ComponentModel.ISupportInitialize)DgvPowerRules).EndInit();
((System.ComponentModel.ISupportInitialize)NudPowerRuleCheckInterval).EndInit();
@@ -718,15 +785,18 @@ private void InitializeComponent()
tabPage1.ResumeLayout(false);
tabPage2.ResumeLayout(false);
tabPage3.ResumeLayout(false);
+ tableLayoutPanel5.ResumeLayout(false);
groupBox4.ResumeLayout(false);
tableLayoutPanel4.ResumeLayout(false);
tableLayoutPanel4.PerformLayout();
- tableLayoutPanel5.ResumeLayout(false);
groupBox1.ResumeLayout(false);
tableLayoutPanel6.ResumeLayout(false);
groupBox2.ResumeLayout(false);
tableLayoutPanel7.ResumeLayout(false);
tableLayoutPanel7.PerformLayout();
+ GrbBatteryManagement.ResumeLayout(false);
+ tableLayoutPanel3.ResumeLayout(false);
+ tableLayoutPanel3.PerformLayout();
ResumeLayout(false);
}
@@ -757,12 +827,6 @@ private void InitializeComponent()
private DataGridViewImageColumn DgcRuleSchemeIcon;
private DataGridViewTextBoxColumn DgcRuleSchemeName;
private DataGridViewCheckBoxColumn DgcActive;
- private DataGridViewCheckBoxColumn DgcVisible;
- private DataGridViewImageColumn DgcIcon;
- private DataGridViewTextBoxColumn DgcName;
- private DataGridViewCheckBoxColumn AcPowerCheckBox;
- private DataGridViewCheckBoxColumn BatteryCheckBox;
- private DataGridViewTextBoxColumn DgcHotkey;
private TabControl tabControl1;
private TabPage tabPage1;
private TabPage tabPage2;
@@ -781,5 +845,15 @@ private void InitializeComponent()
private TableLayoutPanel tableLayoutPanel6;
private GroupBox groupBox2;
private TableLayoutPanel tableLayoutPanel7;
+ private GroupBox GrbBatteryManagement;
+ private TableLayoutPanel tableLayoutPanel3;
+ private ComboBox CmbAcPowerScheme;
+ private Label label1;
+ private Label label3;
+ private ComboBox CmbBatteryPowerScheme;
+ private DataGridViewCheckBoxColumn DgcVisible;
+ private DataGridViewImageColumn DgcIcon;
+ private DataGridViewTextBoxColumn DgcName;
+ private DataGridViewTextBoxColumn DgcHotkey;
}
}
diff --git a/PowerPlanSwitcher/SettingsDlg.cs b/PowerPlanSwitcher/SettingsDlg.cs
index d8c4c3d..62921a6 100644
--- a/PowerPlanSwitcher/SettingsDlg.cs
+++ b/PowerPlanSwitcher/SettingsDlg.cs
@@ -13,66 +13,7 @@ public partial class SettingsDlg : Form
.Cast<(Guid schemeGuid, string name)>()
.ToList();
- public SettingsDlg()
- {
- InitializeComponent();
- this.DgvPowerSchemes.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvPowerSchemes_CellClick);
- }
-
- private void dgvPowerSchemes_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- // 确保点击的是复选框列
- if (e.ColumnIndex == this.DgvPowerSchemes.Columns["AcPowerCheckBox"].Index ||
- e.ColumnIndex == this.DgvPowerSchemes.Columns["BatteryCheckBox"].Index)
- {
- // 获取被点击的列名
- string columnName = this.DgvPowerSchemes.Columns[e.ColumnIndex].Name;
-
- // 遍历该列的所有单元格
- foreach (DataGridViewRow row in this.DgvPowerSchemes.Rows)
- {
- // 忽略未绑定的行或Header行
- if (!row.IsNewRow && e.RowIndex != row.Index)
- {
- // 检查单元格是否在同一个列,并且是否被选中
- if (row.Cells[columnName] is DataGridViewCheckBoxCell checkBoxCell &&
- (bool)checkBoxCell.FormattedValue == true)
- {
- // 取消选中除了被点击的单元格之外的所有单元格
- row.Cells[columnName].Value = false;
- }
- }
- }
-
- // 确保被点击的单元格被选中
- this.DgvPowerSchemes.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true;
- }
- }
-
- private void SettingsDlg_Load(object sender, EventArgs e)
- {
- // 检查电池状态并隐藏复选框列
- if (BatteryMonitor.BatteryNull.BatteryChargeStatus == BatteryChargeStatus.NoSystemBattery)
- {
- // 隐藏 AcPowerCheckBox 列
- this.DgvPowerSchemes.Columns["AcPowerCheckBox"].Visible = false;
- // 隐藏 BatteryCheckBox 列
- this.DgvPowerSchemes.Columns["BatteryCheckBox"].Visible = false;
-
- // foreach (DataGridViewRow row in this.DgvPowerSchemes.Rows)
- // {
- // // 忽略未绑定的行或Header行
- // if (!row.IsNewRow)
- // {
- // DataGridViewCheckBoxCell acCheckBox = (DataGridViewCheckBoxCell)row.Cells["AcPowerCheckBox"];
- // acCheckBox.Value = false; // 取消勾选
-
- // DataGridViewCheckBoxCell batteryCheckBox = (DataGridViewCheckBoxCell)row.Cells["BatteryCheckBox"];
- // batteryCheckBox.Value = false; // 取消勾选
- // }
- // }
- }
- }
+ public SettingsDlg() => InitializeComponent();
protected override void OnLoad(EventArgs e)
{
@@ -125,6 +66,37 @@ protected override void OnLoad(EventArgs e)
CmbColorTheme.SelectedIndex = 0;
}
+ GrbBatteryManagement.Visible = BatteryMonitor.HasSystemBattery();
+
+ CmbAcPowerScheme.Items.AddRange(powerSchemes
+ .Select(scheme => scheme.name)
+ .Cast