diff --git a/ControlMyMonitorManagement.sln b/ControlMyMonitorManagement.sln
index 918ed15..dfd99ed 100644
--- a/ControlMyMonitorManagement.sln
+++ b/ControlMyMonitorManagement.sln
@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Language", "Language\Langua
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tester", "Tester\Tester.csproj", "{0D34DD73-3282-40EB-8F59-DF190944BF12}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DellMonitorControl", "DellMonitorControl\DellMonitorControl.csproj", "{64E96610-D431-40B9-A00B-55CE195B4B58}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
{0D34DD73-3282-40EB-8F59-DF190944BF12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D34DD73-3282-40EB-8F59-DF190944BF12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D34DD73-3282-40EB-8F59-DF190944BF12}.Release|Any CPU.Build.0 = Release|Any CPU
+ {64E96610-D431-40B9-A00B-55CE195B4B58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {64E96610-D431-40B9-A00B-55CE195B4B58}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {64E96610-D431-40B9-A00B-55CE195B4B58}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {64E96610-D431-40B9-A00B-55CE195B4B58}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/DellMonitorControl/App.xaml b/DellMonitorControl/App.xaml
new file mode 100644
index 0000000..aceae59
--- /dev/null
+++ b/DellMonitorControl/App.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DellMonitorControl/App.xaml.cs b/DellMonitorControl/App.xaml.cs
new file mode 100644
index 0000000..aa03a85
--- /dev/null
+++ b/DellMonitorControl/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace DellMonitorControl
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/DellMonitorControl/AssemblyInfo.cs b/DellMonitorControl/AssemblyInfo.cs
new file mode 100644
index 0000000..8b5504e
--- /dev/null
+++ b/DellMonitorControl/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/DellMonitorControl/ControlPanel.xaml b/DellMonitorControl/ControlPanel.xaml
new file mode 100644
index 0000000..9f5ac20
--- /dev/null
+++ b/DellMonitorControl/ControlPanel.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DellMonitorControl/ControlPanel.xaml.cs b/DellMonitorControl/ControlPanel.xaml.cs
new file mode 100644
index 0000000..413ff3e
--- /dev/null
+++ b/DellMonitorControl/ControlPanel.xaml.cs
@@ -0,0 +1,40 @@
+using CMM.Library.Method;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+
+namespace DellMonitorControl;
+
+///
+/// Interaction logic for ControlPanel.xaml
+///
+public partial class ControlPanel : UserControl
+{
+ public ControlPanel()
+ {
+ InitializeComponent();
+ }
+
+ private void Border_MouseLeave(object sender, MouseEventArgs e)
+ {
+
+ }
+
+ private async void ToggleButton_Checked(object sender, RoutedEventArgs e)
+ {
+ var toggle = sender as Button;
+ var tag = toggle?.Tag.ToString();
+ var content = toggle?.Content as string;
+ if (content == "Sleep")
+ {
+ await CMMCommand.Sleep(tag);
+ toggle!.Content = "PowerOn";
+ }
+ else
+ {
+ await CMMCommand.PowerOn(tag);
+ toggle!.Content = "Sleep";
+ }
+ }
+}
diff --git a/DellMonitorControl/DellLogo.ico b/DellMonitorControl/DellLogo.ico
new file mode 100644
index 0000000..f68e734
Binary files /dev/null and b/DellMonitorControl/DellLogo.ico differ
diff --git a/DellMonitorControl/DellMonitorControl.csproj b/DellMonitorControl/DellMonitorControl.csproj
new file mode 100644
index 0000000..525a830
--- /dev/null
+++ b/DellMonitorControl/DellMonitorControl.csproj
@@ -0,0 +1,29 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ DellMonitorControl
+ DellMonitorControl
+ DellMonitorControl
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DellMonitorControl/Images/icons.xaml b/DellMonitorControl/Images/icons.xaml
new file mode 100644
index 0000000..b81aee9
--- /dev/null
+++ b/DellMonitorControl/Images/icons.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DellMonitorControl/MainWindow.xaml b/DellMonitorControl/MainWindow.xaml
new file mode 100644
index 0000000..8c4b6ec
--- /dev/null
+++ b/DellMonitorControl/MainWindow.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/DellMonitorControl/MainWindow.xaml.cs b/DellMonitorControl/MainWindow.xaml.cs
new file mode 100644
index 0000000..b9034fb
--- /dev/null
+++ b/DellMonitorControl/MainWindow.xaml.cs
@@ -0,0 +1,15 @@
+using System.Windows;
+
+namespace DellMonitorControl;
+
+///
+/// Interaction logic for MainWindow.xaml
+///
+public partial class MainWindow : Window
+{
+ public MainWindow()
+ {
+ InitializeComponent();
+ this.Hide();
+ }
+}
diff --git a/DellMonitorControl/Style/Btn.xaml b/DellMonitorControl/Style/Btn.xaml
new file mode 100644
index 0000000..bc42bc8
--- /dev/null
+++ b/DellMonitorControl/Style/Btn.xaml
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DellMonitorControl/Style/Color.xaml b/DellMonitorControl/Style/Color.xaml
new file mode 100644
index 0000000..b5bf546
--- /dev/null
+++ b/DellMonitorControl/Style/Color.xaml
@@ -0,0 +1,37 @@
+
+ #C1272C
+ #66424242
+ #535353
+
+ #232323
+ #8A3D40
+ #FFFFFF
+
+ #B2626262
+ #CCADADAD
+
+ #FF686868
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DellMonitorControl/Style/Main.xaml b/DellMonitorControl/Style/Main.xaml
new file mode 100644
index 0000000..a67033c
--- /dev/null
+++ b/DellMonitorControl/Style/Main.xaml
@@ -0,0 +1,58 @@
+
+
+ 26
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DellMonitorControl/Style/Slider.xaml b/DellMonitorControl/Style/Slider.xaml
new file mode 100644
index 0000000..4599684
--- /dev/null
+++ b/DellMonitorControl/Style/Slider.xaml
@@ -0,0 +1,283 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Library/Method/CMMCommand.cs b/Library/Method/CMMCommand.cs
index 453029f..f09a2f9 100644
--- a/Library/Method/CMMCommand.cs
+++ b/Library/Method/CMMCommand.cs
@@ -1,177 +1,180 @@
using CMM.Library.Base;
using CMM.Library.Helpers;
using CMM.Library.ViewModel;
-using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-namespace CMM.Library.Method
+namespace CMM.Library.Method;
+
+///
+/// Control My Monitor Management Command
+///
+public static class CMMCommand
{
- ///
- /// Control My Monitor Management Command
- ///
- public static class CMMCommand
+ static readonly string CMMTmpFolder = Path.Combine(Path.GetTempPath(), $"CMM");
+ static readonly string CMMexe = Path.Combine(CMMTmpFolder, "ControlMyMonitor.exe");
+ static readonly string CMMsMonitors = Path.Combine(CMMTmpFolder, "smonitors.tmp");
+ static readonly string CMMcfg = Path.Combine(CMMTmpFolder, "ControlMyMonitor.cfg");
+
+ public static async Task ScanMonitor()
{
- static readonly string CMMTmpFolder = Path.Combine(Path.GetTempPath(), $"CMM");
- static readonly string CMMexe = Path.Combine(CMMTmpFolder, "ControlMyMonitor.exe");
- static readonly string CMMsMonitors = Path.Combine(CMMTmpFolder, "smonitors.tmp");
- static readonly string CMMcfg = Path.Combine(CMMTmpFolder, "ControlMyMonitor.cfg");
+ await BytesToFileAsync(new(CMMexe));
+ await ConsoleHelper.CmdCommandAsync($"{CMMexe} /smonitors {CMMsMonitors}");
+ }
- public static async Task ScanMonitor()
+ public static async Task PowerOn(string MonitorSn)
+ {
+ await ConsoleHelper.CmdCommandAsync($"{CMMexe} /SetValue {MonitorSn} D6 1");
+ }
+
+ public static async Task Sleep(string MonitorSn)
+ {
+ await ConsoleHelper.CmdCommandAsync($"{CMMexe} /SetValue {MonitorSn} D6 4");
+ }
+
+ public static async Task ScanMonitorInterfaces(IEnumerable monitors)
+ {
+ var taskList = new List();
+ foreach (var mon in monitors)
{
- await BytesToFileAsync(new(CMMexe));
- await ConsoleHelper.CmdCommandAsync($"{CMMexe} /smonitors {CMMsMonitors}");
+ taskList.Add(Task.Run(async () => await
+ ScanMonitorInterfaces($"{CMMTmpFolder}\\{mon.SerialNumber}.tmp", mon)));
}
- public static async Task ScanMonitorInterfaces(IEnumerable monitors)
- {
- var taskList = new List();
- foreach (var mon in monitors)
- {
- taskList.Add(Task.Run(async () => await
- ScanMonitorInterfaces($"{CMMTmpFolder}\\{mon.SerialNumber}.tmp", mon)));
- }
+ await Task.WhenAll(taskList.ToArray());
+ }
- await Task.WhenAll(taskList.ToArray());
+ static async Task ScanMonitorInterfaces(string savePath, XMonitor mon)
+ {
+ await ConsoleHelper.CmdCommandAsync($"{CMMexe} /scomma {savePath} {mon.MonitorID}");
+ await mon.ReadMonitorStatus(savePath);
+ }
+
+ ///
+ /// 取得螢幕狀態
+ ///
+ public static async Task ReadMonitorStatus(this XMonitor @this, string filePath)
+ {
+ var statusColle = new ObservableRangeCollection();
+
+ if (!File.Exists(filePath)) return;
+
+ foreach (var line in await File.ReadAllLinesAsync(filePath))
+ {
+ var sp = line.Split(",");
+ if (sp.Length < 6) continue;
+
+ statusColle.Add(new XMonitorStatus
+ {
+ VCP_Code = StrTrim(sp[0]),
+ VCPCodeName = StrTrim(sp[1]),
+ Read_Write = StrTrim(sp[2]),
+ CurrentValue = TryGetInt(sp[3]),
+ MaximumValue = TryGetInt(sp[4]),
+ PossibleValues = TryGetArrStr(sp),
+ });
}
- static async Task ScanMonitorInterfaces(string savePath, XMonitor mon)
+ @this.Status = statusColle;
+
+ string StrTrim(string str)
{
- //await ConsoleHelper.CmdCommandAsync($"{CMMexe} /scomma {savePath} {mon.MonitorID}");
- await mon.ReadMonitorStatus(savePath);
+ if (string.IsNullOrEmpty(str)) return null;
+ return str;
}
- ///
- /// 取得螢幕狀態
- ///
- public static async Task ReadMonitorStatus(this XMonitor @this, string filePath)
+ string TryGetArrStr(string[] strArr)
{
- var statusColle = new ObservableRangeCollection();
+ if (strArr.Length < 7) return null;
- if (!File.Exists(filePath)) return;
+ var outStr = string.Join(",", strArr[5..]);
+ outStr = outStr.Substring(1, outStr.Length - 2);
+ return outStr;
+ }
- foreach (var line in await File.ReadAllLinesAsync(filePath))
+ int? TryGetInt(string str)
+ {
+ if (int.TryParse(str, out var value)) return value;
+ return null;
+ }
+ }
+
+ ///
+ /// 取得螢幕清單
+ ///
+ public static async Task> ReadMonitorsData()
+ {
+ var monitors = new List();
+
+ if (!File.Exists(CMMsMonitors)) return monitors;
+
+ XMonitor mon = null;
+ string context;
+ foreach (var line in await File.ReadAllLinesAsync(CMMsMonitors))
+ {
+ var sp = line.Split(":", StringSplitOptions.RemoveEmptyEntries);
+ try
{
- var sp = line.Split(",");
- if (sp.Length < 6) continue;
-
- statusColle.Add(new XMonitorStatus
- {
- VCP_Code = StrTrim(sp[0]),
- VCPCodeName = StrTrim(sp[1]),
- Read_Write = StrTrim(sp[2]),
- CurrentValue = TryGetInt(sp[3]),
- MaximumValue = TryGetInt(sp[4]),
- PossibleValues = TryGetArrStr(sp),
- });
+ if (sp.Length != 2 || string.IsNullOrEmpty(sp[1])) continue;
+
+ context = sp[1].Substring(2, sp[1].Length - 3);
+ }
+ catch
+ {
+ continue;
}
- @this.Status = statusColle;
-
- string StrTrim(string str)
+ if (sp[0].StartsWith("Monitor Device Name"))
{
- if (string.IsNullOrEmpty(str)) return null;
- return str;
+ mon = new XMonitor();
+ mon.MonitorDeviceName = context;
+ continue;
}
- string TryGetArrStr(string[] strArr)
+ if (sp[0].StartsWith("Monitor Name"))
{
- if (strArr.Length < 7) return null;
-
- var outStr = string.Join(",", strArr[5..]);
- outStr = outStr.Substring(1, outStr.Length - 2);
- return outStr;
+ mon.MonitorName = context;
+ continue;
}
- int? TryGetInt(string str)
+ if (sp[0].StartsWith("Serial Number"))
{
- if (int.TryParse(str, out var value)) return value;
- return null;
+ mon.SerialNumber = context;
+ continue;
+ }
+
+ if (sp[0].StartsWith("Adapter Name"))
+ {
+ mon.AdapterName = context;
+ continue;
+ }
+
+ if (sp[0].StartsWith("Monitor ID"))
+ {
+ mon.MonitorID = context;
+ monitors.Add(mon);
+ continue;
}
}
- ///
- /// 取得螢幕清單
- ///
- public static async Task> ReadMonitorsData()
- {
- var monitors = new List();
+ return monitors;
+ }
- if (!File.Exists(CMMsMonitors)) return monitors;
+ static void BytesToFile(FileInfo fi)
+ {
+ fi.Refresh();
+ if (fi.Exists) return;
+ if (!fi.Directory.Exists) fi.Directory.Create();
- XMonitor mon = null;
- string context;
- foreach (var line in await File.ReadAllLinesAsync(CMMsMonitors))
- {
- var sp = line.Split(":", StringSplitOptions.RemoveEmptyEntries);
- try
- {
- if (sp.Length != 2 || string.IsNullOrEmpty(sp[1])) continue;
+ File.WriteAllBytes(fi.FullName, fi.Name.ResourceToByteArray());
+ }
- context = sp[1].Substring(2, sp[1].Length - 3);
- }
- catch
- {
- continue;
- }
-
- if (sp[0].StartsWith("Monitor Device Name"))
- {
- mon = new XMonitor();
- mon.MonitorDeviceName = context;
- continue;
- }
-
- if (sp[0].StartsWith("Monitor Name"))
- {
- mon.MonitorName = context;
- continue;
- }
-
- if (sp[0].StartsWith("Serial Number"))
- {
- mon.SerialNumber = context;
- continue;
- }
-
- if (sp[0].StartsWith("Adapter Name"))
- {
- mon.AdapterName = context;
- continue;
- }
-
- if (sp[0].StartsWith("Monitor ID"))
- {
- mon.MonitorID = context;
- monitors.Add(mon);
- continue;
- }
- }
-
- return monitors;
- }
-
- static void BytesToFile(FileInfo fi)
- {
- fi.Refresh();
- if (fi.Exists) return;
- if (!fi.Directory.Exists) fi.Directory.Create();
-
- File.WriteAllBytes(fi.FullName, fi.Name.ResourceToByteArray());
- }
-
- static async Task BytesToFileAsync(FileInfo fi)
- {
- fi.Refresh();
- if (fi.Exists) return;
- if (!fi.Directory.Exists) fi.Directory.Create();
-
- await File.WriteAllBytesAsync(fi.FullName, fi.Name.ResourceToByteArray());
- }
+ static async Task BytesToFileAsync(FileInfo fi)
+ {
+ fi.Refresh();
+ if (fi.Exists) return;
+ if (!fi.Directory.Exists) fi.Directory.Create();
+ await File.WriteAllBytesAsync(fi.FullName, fi.Name.ResourceToByteArray());
}
}