🐛 1修复程序崩溃, :boom:2添加时钟显秒

This commit is contained in:
BookerLiu
2022-07-25 17:57:57 +08:00
parent 6f62e6b2a0
commit a50d88f2c2
23 changed files with 1239 additions and 131 deletions

View File

@@ -1,6 +1,12 @@
using GeekDesk.Constant;
using GeekDesk.MyThread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using ShowSeconds;
using System;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -112,5 +118,74 @@ namespace GeekDesk.Control.UserControls.Config
{
CommonCode.BakAppData();
}
private void ShowSeconds_Click(object sender, RoutedEventArgs e)
{
if (MainWindow.appData.AppConfig.SecondsWindow == true)
{
//StartSecondsWindow();
SecondsWindow.ShowWindow();
}
else
{
SecondsWindow.Dispose();
}
}
public static void StopSecondsWindow()
{
if (MessageUtil.CheckWindowIsRuning("ShowSeconds_Main_" + Constants.MY_UUID))
{
MessageUtil.SendMsgByWName(
"ShowSeconds_Main_" + Constants.MY_UUID,
"Shutdown"
);
}
}
public static void StartSecondsWindow()
{
try
{
using (var objOS = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"))
{
foreach (ManagementObject objMgmt in objOS.Get())
{
if (objMgmt.Properties["Caption"].Value != null)
{
string caption = objMgmt.Properties["Caption"].Value.ToString(); ;
LogUtil.WriteLog("获取的系统版本号为:" + caption);
if (caption.Contains("Windows 11"))
{
//找到ShowSeconds插件
FileInfo fi = FileUtil.GetFileByNameWithDir("ShowSeconds.exe", Constants.PLUGINS_PATH);
if (fi == null)
{
HandyControl.Controls.MessageBox.Show("未安装程序插件:ShowSeconds");
}
else
{
//检查是否在运行
if (!MessageUtil.CheckWindowIsRuning("ShowSeconds_Main_" + Constants.MY_UUID))
{
using (Process p = new Process())
{
p.StartInfo.FileName = fi.FullName;
p.StartInfo.WorkingDirectory = fi.FullName.Substring(0, fi.FullName.LastIndexOf("\\"));
p.Start();
}
}
}
}
}
}
}
}
catch (Exception ex) { }
}
}
}