优化代码

This commit is contained in:
BookerLiu
2022-09-01 15:23:44 +08:00
parent e82af431b5
commit d5e0dc98db
14 changed files with 576 additions and 83 deletions

View File

@@ -2,7 +2,7 @@
using GeekDesk.MyThread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
//using ShowSeconds;
using ShowSeconds;
using System;
using System.Diagnostics;
using System.IO;
@@ -121,21 +121,16 @@ namespace GeekDesk.Control.UserControls.Config
private void ShowSeconds_Click(object sender, RoutedEventArgs e)
{
//if (MainWindow.appData.AppConfig.SecondsWindow == true)
//{
// //StartSecondsWindow();
// //SecondsWindow.ShowWindow();
// MouseHookThread.Dispose();
// MouseHookThread.Hook();
//}
//else
//{
// MouseHookThread.Dispose();
// MouseHookThread.Hook();
//}
MouseHookThread.Dispose();
MouseHookThread.Hook();
if (MainWindow.appData.AppConfig.SecondsWindow == true)
{
//StartSecondsWindow();
SecondsWindow.ShowWindow();
}
else
{
SecondsWindow.CloseWindow();
//StopSecondsWindow();
}
}
public static void StopSecondsWindow()
@@ -149,47 +144,47 @@ namespace GeekDesk.Control.UserControls.Config
}
}
//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();
// }
// }
// }
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) { }
//}
}
}
}
}
}
catch (Exception ex) { }
}

View File

@@ -154,6 +154,7 @@
<StackPanel Panel.ZIndex="1" Margin="0,-10,-0,0"/>
<WrapPanel Orientation="Horizontal"
Margin="10"
VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
@@ -281,9 +282,10 @@
</hc:Card.BorderBrush>
<Grid>
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
>
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsContainerVirtualizable="True"
Margin="10"
>
<UniformGrid x:Name="VerticalUFG" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, OffsetY= -10, Event=Visibility}">
<!--<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">-->
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"

View File

@@ -39,11 +39,11 @@ namespace GeekDesk.Control.Windows
{
InitializeComponent();
this.colorPicker = colorPicker;
//try
//{
// SetProcessDPIAware();
//}
//catch (Exception e) { }
try
{
SetProcessDPIAware();
}
catch (Exception e) { }
ColorPickerWindow_Init();
}
@@ -87,6 +87,7 @@ namespace GeekDesk.Control.Windows
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions()
);
DesktopBG.Source = bs;
VisualBrush b = (VisualBrush)PixelBG.Fill;
b.Visual = DesktopBG;
@@ -213,6 +214,7 @@ namespace GeekDesk.Control.Windows
/// <param name="e"></param>
private void Window_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
Mouse.OverrideCursor = null;
GlobalColorPickerWindow.ShowOrHide();
//关闭
this.Close();

View File

@@ -111,9 +111,7 @@ namespace GeekDesk.Control.Windows
private static System.Windows.Window window = null;
#pragma warning disable CS0108 // “ToDoWindow.Show()”隐藏继承的成员“Window.Show()”。如果是有意隐藏,请使用关键字 new。
public static void Show()
#pragma warning restore CS0108 // “ToDoWindow.Show()”隐藏继承的成员“Window.Show()”。如果是有意隐藏,请使用关键字 new。
{
if (window == null || !window.Activate())
{