✅ 优化代码
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<add key="Version" value="1.0.01" />
|
||||
<add key="LProportion" value="0.82" />
|
||||
<add key="TProportion" value="0.03" />
|
||||
<add key="DelayTime" value="800" />
|
||||
<add key="DelayTime" value="1500" />
|
||||
</ShowSecondsSettings>
|
||||
<SystemIcons>
|
||||
<add key="Calculator" value="计算器" />
|
||||
|
||||
@@ -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) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -283,6 +284,7 @@
|
||||
<WrapPanel Orientation="Horizontal" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
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">-->
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -75,6 +75,9 @@
|
||||
<PropertyGroup>
|
||||
<GenerateManifests>false</GenerateManifests>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CommonServiceLocator, Version=2.0.6.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
|
||||
<HintPath>packages\CommonServiceLocator.2.0.6\lib\net45\CommonServiceLocator.dll</HintPath>
|
||||
@@ -113,6 +116,7 @@
|
||||
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Drawing.Common.6.0.0-preview.6.21352.12\lib\net461\System.Drawing.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -267,6 +271,11 @@
|
||||
<Compile Include="Converts\HideTypeConvert.cs" />
|
||||
<Compile Include="Interface\IWindowCommon.cs" />
|
||||
<Compile Include="MyThread\RelativePathThread.cs" />
|
||||
<Compile Include="Plugins\ShowSeconds\Common\Constants.cs" />
|
||||
<Compile Include="Plugins\ShowSeconds\SecondsWindow.xaml.cs">
|
||||
<DependentUpon>SecondsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Plugins\ShowSeconds\ViewModel\SecondsDataContext.cs" />
|
||||
<Compile Include="Task\ShowSecondTask.cs" />
|
||||
<Compile Include="Task\ToDoTask.cs" />
|
||||
<Compile Include="MyThread\MouseHookThread.cs" />
|
||||
@@ -429,6 +438,10 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="Plugins\ShowSeconds\SecondsWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Resource\Dictionary\Geometry.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -462,6 +475,7 @@
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<Resource Include="Resource\Iconfont\iconfont.json" />
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Properties\app.manifest" />
|
||||
<None Include="Update.json" />
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -10,7 +10,7 @@ using GeekDesk.ViewModel;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using Microsoft.Win32;
|
||||
using NPinyin;
|
||||
//using ShowSeconds;
|
||||
using ShowSeconds;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
@@ -181,8 +181,6 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//SecondsWindow.ShowWindow();
|
||||
|
||||
BGSettingUtil.BGSetting();
|
||||
if (!appData.AppConfig.StartedShowPanel)
|
||||
{
|
||||
@@ -217,11 +215,17 @@ namespace GeekDesk
|
||||
}
|
||||
|
||||
//注册鼠标监听事件
|
||||
if (appData.AppConfig.MouseMiddleShow || appData.AppConfig.SecondsWindow == true)
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.Hook();
|
||||
}
|
||||
|
||||
//显秒插件
|
||||
if (appData.AppConfig.SecondsWindow == true)
|
||||
{
|
||||
SecondsWindow.ShowWindow();
|
||||
}
|
||||
|
||||
|
||||
//更新线程开启 检测更新
|
||||
UpdateThread.Update();
|
||||
|
||||
@@ -3,7 +3,6 @@ using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Gma.System.MouseKeyHook;
|
||||
//using ShowSeconds;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
@@ -31,24 +30,16 @@ namespace GeekDesk.MyThread
|
||||
hook.OnMouseWheelUp += OnMouseWheelUp;
|
||||
}
|
||||
|
||||
//if (appConfig.SecondsWindow == true)
|
||||
//{
|
||||
// hook.OnMouseLeftDown += OnMouseLeftDown;
|
||||
// hook.OnMouseLeftUp += OnMouseLeftUp;
|
||||
//}
|
||||
|
||||
hook.Start(true, false);
|
||||
}));
|
||||
}
|
||||
|
||||
private static void OnMouseLeftDown(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
//SecondsWindow.SecondsBakColorFun(sender, e);
|
||||
}
|
||||
|
||||
private static void OnMouseLeftUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
//SecondsWindow.SecondsHookSetFuc(sender, e);
|
||||
}
|
||||
|
||||
private static void OnMouseWheelUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
|
||||
39
Plugins/ShowSeconds/Common/Constants.cs
Normal file
39
Plugins/ShowSeconds/Common/Constants.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShowSeconds.Common
|
||||
{
|
||||
public class Constants
|
||||
{
|
||||
public readonly static string MY_UUID = "8400A17AEEF7C029";
|
||||
|
||||
//dark theam
|
||||
public readonly static System.Windows.Media.SolidColorBrush darkBG
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(46, 50, 54),
|
||||
Opacity = 0.8
|
||||
};
|
||||
public readonly static System.Windows.Media.SolidColorBrush darkFont
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(255, 255, 255)
|
||||
};
|
||||
|
||||
//light theam
|
||||
public readonly static System.Windows.Media.SolidColorBrush lightBG
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(236, 244, 251),
|
||||
Opacity = 1
|
||||
};
|
||||
public readonly static System.Windows.Media.SolidColorBrush lightFont
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(65, 63, 61),
|
||||
};
|
||||
}
|
||||
}
|
||||
32
Plugins/ShowSeconds/SecondsWindow.xaml
Normal file
32
Plugins/ShowSeconds/SecondsWindow.xaml
Normal file
@@ -0,0 +1,32 @@
|
||||
<Window x:Class="ShowSeconds.SecondsWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||
Height="90"
|
||||
Width="160"
|
||||
WindowStyle="None"
|
||||
Title=""
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False"
|
||||
Focusable="True"
|
||||
Loaded="Window_Loaded"
|
||||
>
|
||||
|
||||
<Grid Margin="20">
|
||||
<Grid.Effect>
|
||||
<DropShadowEffect BlurRadius="20" Direction="-90" Color="Gray"
|
||||
RenderingBias="Quality" ShadowDepth="2"/>
|
||||
</Grid.Effect>
|
||||
<Border x:Name="BGBorder" CornerRadius="8" xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndSlideFromRight}, Event=Visibility, Delay=0}">
|
||||
<TextBlock x:Name="SecondsText" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="25"
|
||||
FontWeight="Bold"
|
||||
Foreground="White"
|
||||
Text="{Binding Seconds}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
312
Plugins/ShowSeconds/SecondsWindow.xaml.cs
Normal file
312
Plugins/ShowSeconds/SecondsWindow.xaml.cs
Normal file
@@ -0,0 +1,312 @@
|
||||
using GeekDesk.Util;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using ShowSeconds.Common;
|
||||
using GeekDesk.Util;
|
||||
using ShowSeconds.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk;
|
||||
using System.Collections;
|
||||
|
||||
namespace ShowSeconds
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class SecondsWindow : Window
|
||||
{
|
||||
|
||||
private System.Drawing.Color beforeColor;
|
||||
private System.Drawing.Color topBeforeColor;
|
||||
|
||||
private bool expandClock = true; //是否展开时钟
|
||||
private System.Windows.Forms.Timer timer;
|
||||
|
||||
private static double lProportion = 0.82;
|
||||
private static double tProportion = 0.03;
|
||||
private static int sleepTime = 1000;
|
||||
public SecondsWindow()
|
||||
{
|
||||
SecondsDataContext dc = new SecondsDataContext
|
||||
{
|
||||
Seconds = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second)
|
||||
};
|
||||
InitializeComponent();
|
||||
SolidColorBrush scb = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 47, 52, 44))
|
||||
{
|
||||
Opacity = 0.8
|
||||
};
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Hashtable settings = (Hashtable)ConfigurationManager.GetSection("ShowSecondsSettings");
|
||||
|
||||
lProportion = Convert.ToDouble(settings["LProportion"]);
|
||||
tProportion = Convert.ToDouble(settings["TProportion"]);
|
||||
sleepTime = Convert.ToInt32(settings["DelayTime"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lProportion = 0.82;
|
||||
tProportion = 0.03;
|
||||
sleepTime = 1000;
|
||||
}
|
||||
|
||||
BGBorder.Background = scb;
|
||||
this.DataContext = dc;
|
||||
this.Topmost = true;
|
||||
BGBorder.Visibility = Visibility.Collapsed;
|
||||
this.Show();
|
||||
}
|
||||
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
timer = new System.Windows.Forms.Timer();
|
||||
timer.Interval = 1000;
|
||||
timer.Tick += Timer_Tick;
|
||||
|
||||
Dispatcher secondsDP = DispatcherBuild.Build();
|
||||
IKeyboardMouseEvents secondsHook = Hook.GlobalEvents();
|
||||
secondsDP.Invoke((Action)(() =>
|
||||
{
|
||||
secondsHook.MouseDownExt += SecondsBakColorFun;
|
||||
secondsHook.MouseUpExt += SecondsHookSetFuc;
|
||||
}));
|
||||
|
||||
HideWindowUtil.HideAltTab(this);
|
||||
}
|
||||
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
string str = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second);
|
||||
SecondsDataContext dc = this.DataContext as SecondsDataContext;
|
||||
dc.Seconds = str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static string FormatMS(int ms)
|
||||
{
|
||||
if (ms < 10)
|
||||
{
|
||||
return "0" + ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ms.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void SecondsHookSetFuc(object sender, MouseEventExtArgs e)
|
||||
{
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
||||
{
|
||||
if (ScreenUtil.IsPrimaryFullScreen()) return;
|
||||
|
||||
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
||||
{
|
||||
int x = e.X;
|
||||
int y = e.Y;
|
||||
double w = 1920;
|
||||
double h = 1080;
|
||||
double width = SystemParameters.PrimaryScreenWidth;
|
||||
double height = SystemParameters.PrimaryScreenHeight;
|
||||
if (x > 1843 / w * width
|
||||
&& x < 1907 / w * width
|
||||
&& y > 1037 / h * height
|
||||
&& y < 1074 / h * height)
|
||||
{
|
||||
|
||||
System.Drawing.Color c;
|
||||
int count = sleepTime;
|
||||
do
|
||||
{
|
||||
c = GetBottomBeforeColor();
|
||||
if (c.A != beforeColor.A
|
||||
|| c.R != beforeColor.R
|
||||
|| c.G != beforeColor.G
|
||||
|| c.B != beforeColor.B)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(50);
|
||||
count -= 50;
|
||||
} while (count > 0);
|
||||
|
||||
if (c.A != beforeColor.A
|
||||
|| c.R != beforeColor.R
|
||||
|| c.G != beforeColor.G
|
||||
|| c.B != beforeColor.B)
|
||||
{
|
||||
//判断是否展开时钟
|
||||
System.Drawing.Color ct = GetTopBeforeColor();
|
||||
if (ct.A != topBeforeColor.A
|
||||
|| ct.R != topBeforeColor.R
|
||||
|| ct.G != topBeforeColor.G
|
||||
|| ct.B != topBeforeColor.B)
|
||||
{
|
||||
expandClock = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
expandClock = false;
|
||||
}
|
||||
|
||||
if (!BGBorder.IsVisible)
|
||||
{
|
||||
|
||||
System.Drawing.Color theamColor = GetColor(1919, 1079);
|
||||
if (CalculateLight(theamColor) > 255 / 2)
|
||||
{
|
||||
//light
|
||||
BGBorder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(theamColor.A, theamColor.R, theamColor.G, theamColor.B));
|
||||
SecondsText.Foreground = Constants.lightFont;
|
||||
}
|
||||
else
|
||||
{
|
||||
// dark
|
||||
//BGBorder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(theamColor.A, theamColor.R, theamColor.G, theamColor.B));
|
||||
BGBorder.Background = Constants.darkBG;
|
||||
SecondsText.Foreground = Constants.darkFont;
|
||||
}
|
||||
|
||||
SecondsDataContext dc = this.DataContext as SecondsDataContext;
|
||||
dc.Seconds = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second);
|
||||
|
||||
int sx = (int)(SystemParameters.PrimaryScreenWidth * lProportion);
|
||||
int sMarginBottom = (int)(SystemParameters.WorkArea.Height * tProportion);
|
||||
Left = sx - Width;
|
||||
Top = SystemParameters.WorkArea.Height - Height;
|
||||
BGBorder.Visibility = Visibility.Visible;
|
||||
timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
BGBorder.Visibility= Visibility.Collapsed;
|
||||
timer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (true)
|
||||
{
|
||||
if ((expandClock && (x < 1574 / w * width
|
||||
|| x > 1906 / w * width
|
||||
|| y < 598 / h * height
|
||||
|| y > 1020 / h * height)
|
||||
)
|
||||
|| !expandClock && (x < 1574 / w * width
|
||||
|| x > 1906 / w * width
|
||||
|| y < 950 / h * height
|
||||
|| y > 1020 / h * height)
|
||||
)
|
||||
{
|
||||
BGBorder.Visibility = Visibility.Collapsed;
|
||||
timer.Stop();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static System.Windows.Window window = null;
|
||||
public static void ShowWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
window = new SecondsWindow();
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "打开显秒窗口异常!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void CloseWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
window.Close();
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, "关闭显秒窗口异常!");
|
||||
}
|
||||
}
|
||||
|
||||
private void SecondsBakColorFun(object sender, MouseEventExtArgs e)
|
||||
{
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
||||
{
|
||||
beforeColor = GetBottomBeforeColor();
|
||||
topBeforeColor = GetTopBeforeColor();
|
||||
}
|
||||
}
|
||||
|
||||
private static System.Drawing.Color GetBottomBeforeColor()
|
||||
{
|
||||
return GetColor(1760, 985);
|
||||
}
|
||||
|
||||
private static System.Drawing.Color GetTopBeforeColor()
|
||||
{
|
||||
return GetColor(1751, 693);
|
||||
}
|
||||
|
||||
private static System.Drawing.Color GetColor(int w2, int h2)
|
||||
{
|
||||
double w = 1920;
|
||||
double h = 1080;
|
||||
double width = SystemParameters.PrimaryScreenWidth;
|
||||
double height = SystemParameters.PrimaryScreenHeight;
|
||||
System.Drawing.Point p = new System.Drawing.Point((int)(w2 / w * width), (int)(h2 / h * height));
|
||||
return ScreenUtil.GetColorAt(p);
|
||||
}
|
||||
|
||||
|
||||
private static int CalculateLight(System.Drawing.Color color)
|
||||
{
|
||||
int[] colorArr = new int[] { color.R, color.G, color.B };
|
||||
|
||||
int max = 0;
|
||||
int min = 255;
|
||||
foreach (int i in colorArr)
|
||||
{
|
||||
max = Math.Max(max, i);
|
||||
min = Math.Min(min, i);
|
||||
}
|
||||
int avg = (max + min) / 2;
|
||||
return avg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
25
Plugins/ShowSeconds/ViewModel/SecondsDataContext.cs
Normal file
25
Plugins/ShowSeconds/ViewModel/SecondsDataContext.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
namespace ShowSeconds.ViewModel
|
||||
{
|
||||
public class SecondsDataContext : INotifyPropertyChanged
|
||||
{
|
||||
private string seconds;
|
||||
public string Seconds
|
||||
{
|
||||
set
|
||||
{
|
||||
seconds = value;
|
||||
OnPropertyChanged("Seconds");
|
||||
}
|
||||
get { return seconds; }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "GeekDesk版本更新",
|
||||
"subTitle": "V2.5.11",
|
||||
"subTitle": "V2.5.13",
|
||||
"msgTitle": "本次更新内容如下",
|
||||
"msg": "['依旧耗费了我大量精力开发,希望大家去给我点个免费的Star', '这个版本有一些优化点, 大家可以自行探索, 另外征集新Logo的设计, 要求美观并能体现\\'极客\\'风格','本次重新打包了程序文件(文件目录更清爽了,注意,这次不要使用覆盖升级(2.5.10可覆盖)), 可以将旧版本根目录下的Data文件复制到新版本根目录, 然后使用新版本启动','修复了2.5.10版本部分相对路径创建导致启动崩溃的bug','增加可拖动图标到其它菜单的功能,取消了拖动时的动画','增加了列表展开动画的开关','增加了数据备份功能','优化大部分动画','优化搜索功能(达到了可只用键盘或只用鼠标启动所需目标)','增加了相对路径(实验性,可能有bug)','增加列表加密功能(实验性,可能有bug)','其它已知问题修复']",
|
||||
"msg": "['求Star,求Star', '集成Win11显秒插件', '崩溃问题修复', '现在在右侧栏(快捷图标区域)也可以鼠标滚轮切换菜单了', '缩放屏幕截图问题修复(感谢@1062406901提的PR)', '其它已知问题修复']",
|
||||
"githubUrl": "https://github.com/BookerLiu/GeekDesk/releases",
|
||||
"giteeUrl": "https://gitee.com/BookerLiu/GeekDesk/releases",
|
||||
"version": "2.5.11"
|
||||
"version": "2.5.13"
|
||||
}
|
||||
79
app.manifest
Normal file
79
app.manifest
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC 清单选项
|
||||
如果想要更改 Windows 用户帐户控制级别,请使用
|
||||
以下节点之一替换 requestedExecutionLevel 节点。
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
|
||||
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
|
||||
元素。
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
|
||||
Windows 版本的列表。取消评论适当的元素,
|
||||
Windows 将自动选择最兼容的环境。 -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
|
||||
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
|
||||
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
|
||||
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
|
||||
|
||||
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
|
||||
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
||||
Reference in New Issue
Block a user