🐛 1修复程序崩溃, :boom:2添加时钟显秒
This commit is contained in:
11
App.config
11
App.config
@@ -2,9 +2,16 @@
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="SystemIcons" type="System.Configuration.DictionarySectionHandler" />
|
||||
<section name="ShowSecondsSettings" type="System.Configuration.DictionarySectionHandler" />
|
||||
<section name="SystemBGs" type="System.Collections.ObjectModel.ObservableCollection" />
|
||||
<section name="GradientBGParam" type="GeekDesk.ViewModel.GradientBGParam" />
|
||||
</configSections>
|
||||
<ShowSecondsSettings>
|
||||
<add key="Version" value="1.0.01" />
|
||||
<add key="LProportion" value="0.82"/>
|
||||
<add key="TProportion" value="0.03"/>
|
||||
<add key="DelayTime" value="800"/>
|
||||
</ShowSecondsSettings>
|
||||
<SystemIcons>
|
||||
<add key="Calculator" value="计算器" />
|
||||
<add key="Computer" value="此电脑" />
|
||||
@@ -54,7 +61,7 @@
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<appSettings>
|
||||
<add key="Version" value="2.5.11" />
|
||||
<add key="Version" value="2.5.12" />
|
||||
<add key="GitHubUrl" value="https://github.com/BookerLiu/GeekDesk" />
|
||||
<add key="GiteeUrl" value="https://gitee.com/BookerLiu/GeekDesk/tree/master" />
|
||||
<add key="GitHubUpdateUrl" value="https://raw.githubusercontent.com/BookerLiu/GeekDesk/master/Update.json" />
|
||||
@@ -62,7 +69,7 @@
|
||||
<!--<add key="GiteeUpdateUrl" value="file:///D:/WorkSpace/workspace-VS/GeekDesk/Update.json" />-->
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
|
||||
<add key="ShowPublicWeChat" value="Y"/>
|
||||
<add key="ShowPublicWeChat" value="Y" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace GeekDesk
|
||||
|
||||
private void App_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
|
||||
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out bool ret);
|
||||
if (!ret)
|
||||
{
|
||||
@@ -32,6 +31,10 @@ namespace GeekDesk
|
||||
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out ret);
|
||||
if (!ret)
|
||||
{
|
||||
MessageUtil.SendMsgByWName(
|
||||
"GeekDesk_Main_" + Constants.MY_UUID,
|
||||
"ShowApp"
|
||||
);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace GeekDesk.Constant
|
||||
|
||||
public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
|
||||
|
||||
|
||||
public static string MY_UUID = "8400A17AEEF7C029";
|
||||
/// <summary>
|
||||
/// app数据文件路径
|
||||
/// </summary>
|
||||
@@ -30,6 +30,12 @@ namespace GeekDesk.Constant
|
||||
|
||||
public static string ERROR_FILE_PATH = APP_DIR + "logs\\error.log"; // 错误日志
|
||||
|
||||
/// <summary>
|
||||
/// 插件文件夹
|
||||
/// </summary>
|
||||
public static string PLUGINS_PATH = APP_DIR + "plugins\\";
|
||||
|
||||
|
||||
public static int SHADOW_WIDTH = 20;
|
||||
|
||||
//系统图标
|
||||
|
||||
@@ -321,7 +321,7 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
}
|
||||
else
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
MouseHookThread.DisposeMiddle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:AppConfig}"
|
||||
mc:Ignorable="d"
|
||||
Background="Transparent"
|
||||
d:DesignHeight="400" d:DesignWidth="500"
|
||||
@@ -41,6 +41,20 @@
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Text="插件" Margin="0,20,0,0"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,6,0,0">
|
||||
<CheckBox Content="时钟显秒" Click="ShowSeconds_Click" IsChecked="{Binding SecondsWindow}"
|
||||
hc:Poptip.HitMode="None"
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="仅Win11有效"
|
||||
hc:Poptip.Placement="TopLeft">
|
||||
<CheckBox.Background>
|
||||
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
|
||||
<GradientStop Color="#FF9EA3A6"/>
|
||||
</LinearGradientBrush>
|
||||
</CheckBox.Background>
|
||||
</CheckBox>
|
||||
</hc:UniformSpacingPanel>
|
||||
<TextBlock Text="排序方式" Margin="0,25,0,0"/>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="20,8,0,0">
|
||||
|
||||
@@ -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) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,13 +161,17 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
|
||||
private void Lbi_Selected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
try
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
|
||||
SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
|
||||
SolidColorBrush fontColor = new SolidColorBrush(Colors.Black);
|
||||
|
||||
lbi.MouseLeave -= Lbi_MouseLeave;
|
||||
lbi.Background = bac;
|
||||
lbi.Foreground = fontColor;
|
||||
lbi.MouseLeave -= Lbi_MouseLeave;
|
||||
lbi.Background = bac;
|
||||
lbi.Foreground = fontColor;
|
||||
} catch { }
|
||||
|
||||
}
|
||||
|
||||
private void Lbi_MouseLeave(object sender, MouseEventArgs e)
|
||||
@@ -338,6 +342,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
}
|
||||
}
|
||||
MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible;
|
||||
//App.DoEvents();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
@@ -30,11 +33,8 @@
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -52,7 +52,7 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<OutputPath>bin\GeekDesk\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -61,7 +61,8 @@
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>GeekDesk.App</StartupObject>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignManifests>false</SignManifests>
|
||||
@@ -113,6 +114,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>
|
||||
@@ -265,7 +267,10 @@
|
||||
<Compile Include="Converts\HideTypeConvert.cs" />
|
||||
<Compile Include="Interface\IWindowCommon.cs" />
|
||||
<Compile Include="MyThread\RelativePathThread.cs" />
|
||||
<Compile Include="Task\ShowSecondTask.cs" />
|
||||
<Compile Include="Plugins\ShowSeconds\ViewModel\SecondsDataContext.cs" />
|
||||
<Compile Include="Plugins\ShowSeconds\SecondsWindow.xaml.cs">
|
||||
<DependentUpon>SecondsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Task\ToDoTask.cs" />
|
||||
<Compile Include="MyThread\MouseHookThread.cs" />
|
||||
<Compile Include="MyThread\DispatcherBuild.cs" />
|
||||
@@ -279,6 +284,7 @@
|
||||
<Compile Include="Util\CommonCode.cs" />
|
||||
<Compile Include="Util\FileIcon.cs" />
|
||||
<Compile Include="Util\FileUtil.cs" />
|
||||
<Compile Include="Util\HideWindowUtil.cs" />
|
||||
<Compile Include="Util\KeyUtil.cs" />
|
||||
<Compile Include="Util\ListBoxDragDropManager.cs" />
|
||||
<Compile Include="Util\LogUtil.cs" />
|
||||
@@ -287,9 +293,11 @@
|
||||
<Compile Include="Util\ImageUtil.cs" />
|
||||
<Compile Include="Converts\MenuWidthConvert.cs" />
|
||||
<Compile Include="Util\MD5Util.cs" />
|
||||
<Compile Include="Util\MessageUtil.cs" />
|
||||
<Compile Include="Util\MouseUtil.cs" />
|
||||
<Compile Include="Util\RegisterUtil.cs" />
|
||||
<Compile Include="Util\RelayCommand.cs" />
|
||||
<Compile Include="Util\ScreenUtil.cs" />
|
||||
<Compile Include="Util\ShellContextMenu.cs" />
|
||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||
<Compile Include="Util\StringUtil.cs" />
|
||||
@@ -416,6 +424,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>
|
||||
@@ -517,6 +529,7 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
x:Name="AppWindow"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:AppData}"
|
||||
Title="GeekDesk"
|
||||
Title="GeekDesk_Main_8400A17AEEF7C029"
|
||||
MinWidth="600"
|
||||
MinHeight="400"
|
||||
WindowStyle="None"
|
||||
|
||||
@@ -10,6 +10,7 @@ using GeekDesk.ViewModel;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using Microsoft.Win32;
|
||||
using NPinyin;
|
||||
using ShowSeconds;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
@@ -176,6 +177,7 @@ namespace GeekDesk
|
||||
/// <param name="e"></param>
|
||||
void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
BGSettingUtil.BGSetting();
|
||||
if (!appData.AppConfig.StartedShowPanel)
|
||||
{
|
||||
@@ -185,7 +187,6 @@ namespace GeekDesk
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
//ShowSecondTask.SHowSecond();
|
||||
//给任务栏图标一个名字
|
||||
BarIcon.Text = Constants.MY_NAME;
|
||||
|
||||
@@ -216,6 +217,12 @@ namespace GeekDesk
|
||||
MouseHookThread.MiddleHook();
|
||||
}
|
||||
|
||||
//启动显秒程序
|
||||
if (appData.AppConfig.SecondsWindow == true)
|
||||
{
|
||||
SecondsWindow.ShowWindow();
|
||||
}
|
||||
|
||||
//更新线程开启 检测更新
|
||||
UpdateThread.Update();
|
||||
|
||||
@@ -224,6 +231,8 @@ namespace GeekDesk
|
||||
|
||||
//毛玻璃 暂时未解决阴影问题
|
||||
//BlurGlassUtil.EnableBlur(this);
|
||||
|
||||
MessageUtil.ChangeWindowMessageFilter(MessageUtil.WM_COPYDATA, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -665,8 +674,9 @@ namespace GeekDesk
|
||||
{
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
MouseHookThread.DisposeMiddle();
|
||||
}
|
||||
SecondsWindow.Dispose();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
/// <summary>
|
||||
@@ -678,9 +688,11 @@ namespace GeekDesk
|
||||
{
|
||||
if (appData.AppConfig.MouseMiddleShow)
|
||||
{
|
||||
MouseHookThread.Dispose();
|
||||
MouseHookThread.DisposeMiddle();
|
||||
}
|
||||
|
||||
SecondsWindow.Dispose();
|
||||
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = Constants.APP_DIR + "GeekDesk.exe";
|
||||
p.StartInfo.WorkingDirectory = Constants.APP_DIR;
|
||||
@@ -838,6 +850,30 @@ namespace GeekDesk
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
|
||||
if (hwndSource != null)
|
||||
{
|
||||
IntPtr handle = hwndSource.Handle;
|
||||
hwndSource.AddHook(new HwndSourceHook(WndProc));
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg == MessageUtil.WM_COPYDATA)
|
||||
{
|
||||
MessageUtil.CopyDataStruct cds = (MessageUtil.CopyDataStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(lParam, typeof(MessageUtil.CopyDataStruct));
|
||||
if ("ShowApp".Equals(cds.msg))
|
||||
{
|
||||
ShowApp();
|
||||
}
|
||||
}
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
@@ -10,54 +14,90 @@ namespace GeekDesk.MyThread
|
||||
public class MouseHookThread
|
||||
{
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
|
||||
private static Dispatcher dispatcher;
|
||||
|
||||
|
||||
private static IKeyboardMouseEvents middleHook = null;
|
||||
private static Dispatcher middleDP;
|
||||
|
||||
public static void MiddleHook()
|
||||
{
|
||||
//使用dispatcher来单独监听UI线程 防止程序卡顿
|
||||
dispatcher = DispatcherBuild.Build();
|
||||
m_GlobalHook = Hook.GlobalEvents();
|
||||
dispatcher.BeginInvoke((Action)(() =>
|
||||
middleDP = DispatcherBuild.Build();
|
||||
middleHook = Hook.GlobalEvents();
|
||||
middleDP.Invoke((Action)(() =>
|
||||
{
|
||||
m_GlobalHook.MouseUpExt += M_GlobalHook_MouseUpExt;
|
||||
middleHook.MouseUpExt += MiddleHookFun;
|
||||
}));
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
|
||||
private static Color GetBottomBeforeColor()
|
||||
{
|
||||
m_GlobalHook.MouseUpExt -= M_GlobalHook_MouseUpExt;
|
||||
m_GlobalHook.Dispose();
|
||||
dispatcher.InvokeShutdown();
|
||||
return GetColor(1760, 985);
|
||||
}
|
||||
|
||||
private static Color GetTopBeforeColor()
|
||||
{
|
||||
return GetColor(1751, 693);
|
||||
}
|
||||
|
||||
private static 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标中键呼出
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private static void M_GlobalHook_MouseUpExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
private static void MiddleHookFun(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (appConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Middle)
|
||||
{
|
||||
if (MotionControl.hotkeyFinished)
|
||||
//中键打开App
|
||||
if (appConfig.MouseMiddleShow)
|
||||
{
|
||||
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
||||
if (MotionControl.hotkeyFinished)
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
|
||||
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
|
||||
{
|
||||
MainWindow.ShowApp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}));
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
|
||||
{
|
||||
MainWindow.ShowApp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void DisposeMiddle()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (middleHook != null)
|
||||
{
|
||||
middleHook.MouseUpExt -= MiddleHookFun;
|
||||
middleHook.Dispose();
|
||||
middleDP.InvokeShutdown();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,9 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.MyThread
|
||||
{
|
||||
@@ -18,24 +14,32 @@ namespace GeekDesk.MyThread
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
|
||||
|
||||
string myExePath = Constants.APP_DIR + "GeekDesk.exe";
|
||||
foreach (MenuInfo mi in menuList)
|
||||
try
|
||||
{
|
||||
ObservableCollection<IconInfo> iconList = mi.IconList;
|
||||
foreach (IconInfo icon in iconList)
|
||||
ObservableCollection<MenuInfo> menuList = MainWindow.appData.MenuList;
|
||||
|
||||
string myExePath = Constants.APP_DIR + "GeekDesk.exe";
|
||||
foreach (MenuInfo mi in menuList)
|
||||
{
|
||||
string relativePath = FileUtil.MakeRelativePath(myExePath, icon.Path);
|
||||
if (File.Exists(icon.Path)
|
||||
&& !string.IsNullOrEmpty(relativePath)
|
||||
&& !relativePath.Equals(icon.Path)) {
|
||||
icon.RelativePath_NoWrite = relativePath;
|
||||
ObservableCollection<IconInfo> iconList = mi.IconList;
|
||||
foreach (IconInfo icon in iconList)
|
||||
{
|
||||
if (icon == null) continue;
|
||||
string relativePath = FileUtil.MakeRelativePath(myExePath, icon.Path);
|
||||
if (File.Exists(icon.Path)
|
||||
&& !string.IsNullOrEmpty(relativePath)
|
||||
&& !relativePath.Equals(icon.Path))
|
||||
{
|
||||
icon.RelativePath_NoWrite = relativePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_BAK_PATH);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteErrorLog(ex, "init相对路径出错!");
|
||||
}
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
|
||||
CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_BAK_PATH);
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
34
Plugins/ShowSeconds/SecondsWindow.xaml
Normal file
34
Plugins/ShowSeconds/SecondsWindow.xaml
Normal file
@@ -0,0 +1,34 @@
|
||||
<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="ShowSeconds_Main_8400A17AEEF7C029"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ShowInTaskbar="False"
|
||||
Focusable="True"
|
||||
Loaded="Window_Loaded"
|
||||
ShowActivated="False"
|
||||
>
|
||||
|
||||
<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>
|
||||
391
Plugins/ShowSeconds/SecondsWindow.xaml.cs
Normal file
391
Plugins/ShowSeconds/SecondsWindow.xaml.cs
Normal file
@@ -0,0 +1,391 @@
|
||||
using GeekDesk;
|
||||
using GeekDesk.MyThread;
|
||||
using GeekDesk.Util;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using ShowSeconds.ViewModel;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
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.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ShowSeconds
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class SecondsWindow : Window
|
||||
{
|
||||
|
||||
private Color beforeColor;
|
||||
private Color topBeforeColor;
|
||||
|
||||
//dark theam
|
||||
private readonly static System.Windows.Media.SolidColorBrush darkBG
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(46, 50, 54),
|
||||
Opacity = 0.8
|
||||
};
|
||||
private readonly static System.Windows.Media.SolidColorBrush darkFont
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(255, 255, 255)
|
||||
};
|
||||
|
||||
//light theam
|
||||
private readonly static System.Windows.Media.SolidColorBrush lightBG
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(236, 244, 251),
|
||||
Opacity = 1
|
||||
};
|
||||
private readonly static System.Windows.Media.SolidColorBrush lightFont
|
||||
= new System.Windows.Media.SolidColorBrush
|
||||
{
|
||||
Color = System.Windows.Media.Color.FromRgb(65, 63, 61),
|
||||
};
|
||||
|
||||
private bool expandClock = true; //是否展开时钟
|
||||
private System.Windows.Forms.Timer timer;
|
||||
|
||||
Dispatcher secondsDP = DispatcherBuild.Build();
|
||||
IKeyboardMouseEvents secondsHook = Hook.GlobalEvents();
|
||||
|
||||
private double lProportion = 0.82;
|
||||
private double tProportion = 0.03;
|
||||
private int sleepTime = 800;
|
||||
public SecondsWindow()
|
||||
{
|
||||
SecondsDataContext dc = new SecondsDataContext
|
||||
{
|
||||
Seconds = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second)
|
||||
};
|
||||
|
||||
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 = 800;
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
this.DataContext = dc;
|
||||
this.Topmost = true;
|
||||
BGBorder.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
timer = new System.Windows.Forms.Timer();
|
||||
timer.Interval = 1000;
|
||||
timer.Tick += Timer_Tick;
|
||||
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;
|
||||
|
||||
this.DataContext = null;
|
||||
this.DataContext = dc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
//获取实际坐标 windows可能会有缩放
|
||||
IntPtr hdc = GetDC(IntPtr.Zero);
|
||||
double scale = GetScreenScalingFactor();
|
||||
|
||||
x = (int)(x / scale);
|
||||
y = (int)(y / scale);
|
||||
|
||||
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)
|
||||
{
|
||||
Thread.Sleep(sleepTime);
|
||||
Color c = GetBottomBeforeColor();
|
||||
if (c.A != beforeColor.A
|
||||
|| c.R != beforeColor.R
|
||||
|| c.G != beforeColor.G
|
||||
|| c.B != beforeColor.B)
|
||||
{
|
||||
//判断是否展开时钟
|
||||
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)
|
||||
{
|
||||
Color theamColor = GetColor(1919, 1079);
|
||||
if (CalculateLight(theamColor) > 255 / 2)
|
||||
{
|
||||
//light
|
||||
BGBorder.Background = lightBG;
|
||||
SecondsText.Foreground = lightFont;
|
||||
}
|
||||
else
|
||||
{
|
||||
// dark
|
||||
BGBorder.Background = darkBG;
|
||||
SecondsText.Foreground = darkFont;
|
||||
}
|
||||
|
||||
SecondsDataContext dc = this.DataContext as SecondsDataContext;
|
||||
dc.Seconds = (DateTime.Now.Hour).ToString() + ":" +
|
||||
FormatMS(DateTime.Now.Minute) + ":" +
|
||||
FormatMS(DateTime.Now.Second);
|
||||
|
||||
int sx = (int)(width * lProportion);
|
||||
int sMarginBottom = (int)(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 ((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 void SecondsBakColorFun(object sender, MouseEventExtArgs e)
|
||||
{
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
||||
{
|
||||
beforeColor = GetBottomBeforeColor();
|
||||
topBeforeColor = GetTopBeforeColor();
|
||||
}
|
||||
}
|
||||
|
||||
private static Color GetBottomBeforeColor()
|
||||
{
|
||||
return GetColor(1760, 985);
|
||||
}
|
||||
|
||||
private static Color GetTopBeforeColor()
|
||||
{
|
||||
return GetColor(1751, 693);
|
||||
}
|
||||
|
||||
private static Color GetColor(int w2, int h2)
|
||||
{
|
||||
double w = 1920;
|
||||
double h = 1080;
|
||||
double width = SystemParameters.PrimaryScreenWidth;
|
||||
double height = SystemParameters.PrimaryScreenHeight;
|
||||
double scale = GetScreenScalingFactor();
|
||||
|
||||
Console.WriteLine("bef:" + w2 / w * width);
|
||||
Console.WriteLine("af:" + w2 / w * width * scale);
|
||||
System.Drawing.Point p = new System.Drawing.Point((int)(w2 / w * width * scale), (int)(h2 / h * height * scale));
|
||||
return ScreenUtil.GetColorAt(p);
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
base.OnSourceInitialized(e);
|
||||
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
|
||||
if (hwndSource != null)
|
||||
{
|
||||
IntPtr handle = hwndSource.Handle;
|
||||
hwndSource.AddHook(new HwndSourceHook(WndProc));
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg == MessageUtil.WM_COPYDATA)
|
||||
{
|
||||
MessageUtil.CopyDataStruct cds = (MessageUtil.CopyDataStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(lParam, typeof(MessageUtil.CopyDataStruct));
|
||||
|
||||
if ("Shutdown".Equals(cds.msg))
|
||||
{
|
||||
Dispose();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (window.secondsHook != null)
|
||||
{
|
||||
window.secondsHook.MouseDownExt -= window.SecondsBakColorFun;
|
||||
window.secondsHook.MouseUpExt -= window.SecondsHookSetFuc;
|
||||
window.secondsHook.Dispose();
|
||||
window.secondsDP.InvokeShutdown();
|
||||
}
|
||||
window.Close();
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
}
|
||||
|
||||
private static int CalculateLight(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;
|
||||
}
|
||||
|
||||
private static SecondsWindow window = null;
|
||||
public static void ShowWindow()
|
||||
{
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
window = new SecondsWindow();
|
||||
}
|
||||
window.Show();
|
||||
Keyboard.Focus(window);
|
||||
}
|
||||
|
||||
|
||||
//#######################################################
|
||||
public const int HORZRES = 8;
|
||||
public const int VERTRES = 10;
|
||||
public const int DESKTOPVERTRES = 117;
|
||||
public const int DESKTOPHORZRES = 118;
|
||||
|
||||
private static double GetScreenScalingFactor()
|
||||
{
|
||||
var g = Graphics.FromHwnd(IntPtr.Zero);
|
||||
IntPtr desktop = g.GetHdc();
|
||||
var physicalScreenHeight = GetDeviceCaps(desktop, (int)DESKTOPVERTRES);
|
||||
|
||||
var screenScalingFactor =
|
||||
(double)physicalScreenHeight / SystemParameters.PrimaryScreenHeight;
|
||||
//SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
return screenScalingFactor;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,
|
||||
/// 以后可以在GDI函数中使用该句柄来在设备上下文环境中绘图。
|
||||
/// </summary>
|
||||
/// <param name="hWnd">设备上下文环境被检索的窗口的句柄,如果该值为NULL,GetDC则检索整个屏幕的设备上下文环境。</param>
|
||||
/// <returns>如果成功,返回指定窗口客户区的设备上下文环境;如果失败,返回值为Null。</returns>
|
||||
[DllImport("user32")]
|
||||
public static extern IntPtr GetDC(IntPtr hWnd);
|
||||
/// <summary>
|
||||
/// 该函数释放设备上下文环境(DC)供其他应用程序使用。函数的效果与设备上下文环境类型有关。
|
||||
/// 它只释放公用的和设备上下文环境,对于类或私有的则无效。
|
||||
/// </summary>
|
||||
/// <param name="hWnd">指向要释放的设备上下文环境所在的窗口的句柄。</param>
|
||||
/// <param name="hDC">指向要释放的设备上下文环境的句柄。</param>
|
||||
/// <returns>如果释放成功,则返回值为1;如果没有释放成功,则返回值为0。</returns>
|
||||
[DllImport("user32")]
|
||||
public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
[DllImport("user32")]
|
||||
public static extern bool GetCursorPos(out System.Drawing.Point pt);
|
||||
[DllImport("gdi32")]
|
||||
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||
}
|
||||
}
|
||||
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,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Task
|
||||
{
|
||||
internal class ShowSecondTask
|
||||
{
|
||||
|
||||
public static void SHowSecond()
|
||||
{
|
||||
System.Timers.Timer timer = new System.Timers.Timer
|
||||
{
|
||||
Enabled = true,
|
||||
Interval = 5000
|
||||
};
|
||||
timer.Start();
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
}
|
||||
|
||||
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
Process[] pcArr = Process.GetProcessesByName("ShellExperienceHost.exe");
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"title": "GeekDesk版本更新",
|
||||
"subTitle": "V2.5.11",
|
||||
"subTitle": "V2.5.12",
|
||||
"msgTitle": "本次更新内容如下",
|
||||
"msg": "['依旧耗费了我大量精力开发,希望大家去给我点个免费的Star', '这个版本有一些优化点, 大家可以自行探索, 另外征集新Logo的设计, 要求美观并能体现\\'极客\\'风格','本次重新打包了程序文件(文件目录更清爽了,注意,这次不要使用覆盖升级(2.5.10可覆盖)), 可以将旧版本根目录下的Data文件复制到新版本根目录, 然后使用新版本启动','修复了2.5.10版本部分相对路径创建导致启动崩溃的bug','增加可拖动图标到其它菜单的功能,取消了拖动时的动画','增加了列表展开动画的开关','增加了数据备份功能','优化大部分动画','优化搜索功能(达到了可只用键盘或只用鼠标启动所需目标)','增加了相对路径(实验性,可能有bug)','增加列表加密功能(实验性,可能有bug)','其它已知问题修复']",
|
||||
"msg": "['求Star,求Star', '添加Win11显秒插件', '崩溃问题修复', '其它已知问题修复']",
|
||||
"githubUrl": "https://github.com/BookerLiu/GeekDesk/releases",
|
||||
"giteeUrl": "https://gitee.com/BookerLiu/GeekDesk/releases",
|
||||
"version": "2.5.11"
|
||||
"version": "2.5.12"
|
||||
}
|
||||
@@ -142,26 +142,7 @@ namespace GeekDesk.Util
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断当前屏幕(鼠标最后活动屏幕)是否有全屏化应用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsPrimaryFullScreen()
|
||||
{
|
||||
RECT rect = new RECT();
|
||||
GetWindowRect(new HandleRef(null, GetForegroundWindow()), ref rect);
|
||||
|
||||
int windowHeight = rect.bottom - rect.top;
|
||||
int screenHeight = (int)SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
if (windowHeight >= screenHeight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据路径获取文件图标等信息
|
||||
@@ -263,21 +244,7 @@ namespace GeekDesk.Util
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool GetWindowRect(HandleRef hWnd, [In, Out] ref RECT rect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -179,5 +179,25 @@ namespace GeekDesk.Util
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
|
||||
public static FileInfo GetFileByNameWithDir(string name, string dir)
|
||||
{
|
||||
DirectoryInfo d = new DirectoryInfo(dir);
|
||||
FileInfo[] files = d.GetFiles();//文件
|
||||
foreach (FileInfo fi in files)
|
||||
{
|
||||
if (fi.Name.Equals(name))
|
||||
{
|
||||
return fi;
|
||||
}
|
||||
}
|
||||
DirectoryInfo[] directs = d.GetDirectories();
|
||||
foreach (DirectoryInfo direct in directs)
|
||||
{
|
||||
return GetFileByNameWithDir(name, direct.FullName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
227
Util/HideWindowUtil.cs
Normal file
227
Util/HideWindowUtil.cs
Normal file
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class HideWindowUtil
|
||||
{
|
||||
|
||||
public enum GetWindowLongFields
|
||||
{
|
||||
// ...
|
||||
GWL_EXSTYLE = (-20),
|
||||
// ...
|
||||
}
|
||||
|
||||
public static void HideAltTab(Window window)
|
||||
{
|
||||
try
|
||||
{
|
||||
WindowInteropHelper wndHelper = new WindowInteropHelper(window);
|
||||
int exStyle = (int)HideWindowUtil.GetWindowLong(wndHelper.Handle, (int)HideWindowUtil.GetWindowLongFields.GWL_EXSTYLE);
|
||||
exStyle |= (int)HideWindowUtil.ExtendedWindowStyles.WS_EX_TOOLWINDOW;
|
||||
HideWindowUtil.SetWindowLong(wndHelper.Handle, (int)HideWindowUtil.GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle);
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
||||
{
|
||||
int error = 0;
|
||||
IntPtr result = IntPtr.Zero;
|
||||
// Win32 SetWindowLong doesn't clear error on success
|
||||
SetLastError(0);
|
||||
|
||||
if (IntPtr.Size == 4)
|
||||
{
|
||||
// use SetWindowLong
|
||||
Int32 tempResult = IntSetWindowLong(hWnd, nIndex, IntPtrToInt32(dwNewLong));
|
||||
error = Marshal.GetLastWin32Error();
|
||||
result = new IntPtr(tempResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use SetWindowLongPtr
|
||||
result = IntSetWindowLongPtr(hWnd, nIndex, dwNewLong);
|
||||
error = Marshal.GetLastWin32Error();
|
||||
}
|
||||
|
||||
if ((result == IntPtr.Zero) && (error != 0))
|
||||
{
|
||||
throw new System.ComponentModel.Win32Exception(error);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)]
|
||||
private static extern IntPtr IntSetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)]
|
||||
private static extern Int32 IntSetWindowLong(IntPtr hWnd, int nIndex, Int32 dwNewLong);
|
||||
|
||||
private static int IntPtrToInt32(IntPtr intPtr)
|
||||
{
|
||||
return unchecked((int)intPtr.ToInt64());
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", EntryPoint = "SetLastError")]
|
||||
public static extern void SetLastError(int dwErrorCode);
|
||||
/// <summary>
|
||||
/// 扩展的窗口风格
|
||||
/// </summary>
|
||||
/// 代码:[Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
|
||||
/// code from [Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
|
||||
[Flags]
|
||||
public enum ExtendedWindowStyles : long
|
||||
{
|
||||
/// <summary>
|
||||
/// The window accepts drag-drop files
|
||||
/// </summary>
|
||||
WS_EX_ACCEPTFILES = 0x00000010L,
|
||||
|
||||
/// <summary>
|
||||
/// Forces a top-level window onto the taskbar when the window is visible
|
||||
/// </summary>
|
||||
WS_EX_APPWINDOW = 0x00040000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a border with a sunken edge.
|
||||
/// </summary>
|
||||
WS_EX_CLIENTEDGE = 0x00000200L,
|
||||
|
||||
/// <summary>
|
||||
/// Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 2000: This style is not supported.
|
||||
/// </summary>
|
||||
WS_EX_COMPOSITED = 0x02000000L,
|
||||
|
||||
/// <summary>
|
||||
/// The title bar of the window includes a question mark. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window.WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles.
|
||||
/// </summary>
|
||||
WS_EX_CONTEXTHELP = 0x00000400L,
|
||||
|
||||
/// <summary>
|
||||
/// The window itself contains child windows that should take part in dialog box navigation. If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic.
|
||||
/// </summary>
|
||||
WS_EX_CONTROLPARENT = 0x00010000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter.
|
||||
/// </summary>
|
||||
WS_EX_DLGMODALFRAME = 0x00000001L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.
|
||||
/// </summary>
|
||||
WS_EX_LAYERED = 0x00080000,
|
||||
|
||||
/// <summary>
|
||||
/// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the horizontal origin of the window is on the right edge. Increasing horizontal values advance to the left.
|
||||
/// </summary>
|
||||
WS_EX_LAYOUTRTL = 0x00400000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has generic left-aligned properties. This is the default.
|
||||
/// </summary>
|
||||
WS_EX_LEFT = 0x00000000L,
|
||||
|
||||
/// <summary>
|
||||
/// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored.
|
||||
/// </summary>
|
||||
WS_EX_LEFTSCROLLBAR = 0x00004000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window text is displayed using left-to-right reading-order properties. This is the default.
|
||||
/// </summary>
|
||||
WS_EX_LTRREADING = 0x00000000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is a MDI child window.
|
||||
/// </summary>
|
||||
WS_EX_MDICHILD = 0x00000040L,
|
||||
|
||||
/// <summary>
|
||||
/// A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.To activate the window, use the SetActiveWindow or SetForegroundWindow function.The window does not appear on the taskbar by default. To force the window to appear on the taskbar, use the WS_EX_APPWINDOW style.
|
||||
/// </summary>
|
||||
WS_EX_NOACTIVATE = 0x08000000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window does not pass its window layout to its child windows.
|
||||
/// </summary>
|
||||
WS_EX_NOINHERITLAYOUT = 0x00100000L,
|
||||
|
||||
/// <summary>
|
||||
/// The child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed.
|
||||
/// </summary>
|
||||
WS_EX_NOPARENTNOTIFY = 0x00000004L,
|
||||
|
||||
/// <summary>
|
||||
/// The window does not render to a redirection surface. This is for windows that do not have visible content or that use mechanisms other than surfaces to provide their visual.
|
||||
/// </summary>
|
||||
WS_EX_NOREDIRECTIONBITMAP = 0x00200000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is an overlapped window.
|
||||
/// </summary>
|
||||
WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE),
|
||||
|
||||
/// <summary>
|
||||
/// The window is palette window, which is a modeless dialog box that presents an array of commands.
|
||||
/// </summary>
|
||||
WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST),
|
||||
|
||||
/// <summary>
|
||||
/// The window has generic "right-aligned" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored.Using the WS_EX_RIGHT style for static or edit controls has the same effect as using the SS_RIGHT or ES_RIGHT style, respectively. Using this style with button controls has the same effect as using BS_RIGHT and BS_RIGHTBUTTON styles.
|
||||
/// </summary>
|
||||
WS_EX_RIGHT = 0x00001000L,
|
||||
|
||||
/// <summary>
|
||||
/// The vertical scroll bar (if present) is to the right of the client area. This is the default.
|
||||
/// </summary>
|
||||
WS_EX_RIGHTSCROLLBAR = 0x00000000L,
|
||||
|
||||
/// <summary>
|
||||
/// If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored.
|
||||
/// </summary>
|
||||
WS_EX_RTLREADING = 0x00002000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a three-dimensional border style intended to be used for items that do not accept user input.
|
||||
/// </summary>
|
||||
WS_EX_STATICEDGE = 0x00020000L,
|
||||
|
||||
/// <summary>
|
||||
/// The window is intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE.
|
||||
/// </summary>
|
||||
WS_EX_TOOLWINDOW = 0x00000080L,
|
||||
|
||||
/// <summary>
|
||||
/// The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function.
|
||||
/// </summary>
|
||||
WS_EX_TOPMOST = 0x00000008L,
|
||||
|
||||
/// <summary>
|
||||
/// The window should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted.To achieve transparency without these restrictions, use the SetWindowRgn function.
|
||||
/// </summary>
|
||||
WS_EX_TRANSPARENT = 0x00000020L,
|
||||
|
||||
/// <summary>
|
||||
/// The window has a border with a raised edge
|
||||
/// </summary>
|
||||
WS_EX_WINDOWEDGE = 0x00000100L
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
131
Util/MessageUtil.cs
Normal file
131
Util/MessageUtil.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class MessageUtil
|
||||
{
|
||||
|
||||
public const int WM_COPYDATA = 0x004A;
|
||||
public static bool SendMsgByPName(string processName, string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process[] processArr = Process.GetProcessesByName(processName);
|
||||
if (processArr != null && processArr.Length > 0)
|
||||
{
|
||||
foreach (Process process in processArr)
|
||||
{
|
||||
IntPtr windowHandle = process.MainWindowHandle;
|
||||
// 发送消息
|
||||
CopyDataStruct cds = new CopyDataStruct(IntPtr.Zero, msg);
|
||||
SendMessage(
|
||||
windowHandle,
|
||||
WM_COPYDATA,
|
||||
0, ref cds);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, processName + "P发送消息失败!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SendMsgByWName(string windowName, string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr hwnd = FindWindow(null, windowName);
|
||||
if (hwnd != IntPtr.Zero)
|
||||
{
|
||||
// 发送消息
|
||||
CopyDataStruct cds = new CopyDataStruct(IntPtr.Zero, msg);
|
||||
SendMessage(
|
||||
hwnd,
|
||||
WM_COPYDATA,
|
||||
0, ref cds);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, windowName + "W发送消息失败!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool CheckProcessIsRuning(string processName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process[] processArr = Process.GetProcessesByName(processName);
|
||||
return (processArr != null && processArr.Length > 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogUtil.WriteErrorLog(e, processName + "检查进程名失败!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckWindowIsRuning(string windowName)
|
||||
{
|
||||
try
|
||||
{
|
||||
IntPtr hwnd = FindWindow(null, windowName);
|
||||
return (hwnd != IntPtr.Zero);
|
||||
} catch(Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[DllImport("User32.dll", EntryPoint = "FindWindow")]
|
||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("User32.dll", EntryPoint = "SendMessage")]
|
||||
private static extern int SendMessage(
|
||||
IntPtr hWnd, //目标窗体句柄
|
||||
int Msg, //WM_COPYDATA
|
||||
int wParam, //自定义数值
|
||||
ref CopyDataStruct lParam //传递消息的结构体,
|
||||
);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct CopyDataStruct
|
||||
{
|
||||
public CopyDataStruct(IntPtr custom, string msg)
|
||||
{
|
||||
this.custom = custom;
|
||||
this.msg = msg;
|
||||
this.msgLength = msg.Length + 1;
|
||||
}
|
||||
public IntPtr custom;//用户定义数据
|
||||
public int msgLength;//字符串长度
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
public string msg;//字符串
|
||||
}
|
||||
|
||||
|
||||
[DllImport("user32")]
|
||||
public static extern bool ChangeWindowMessageFilter(uint msg, int flags);
|
||||
|
||||
}
|
||||
}
|
||||
124
Util/ScreenUtil.cs
Normal file
124
Util/ScreenUtil.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GeekDesk.Util
|
||||
{
|
||||
public class ScreenUtil
|
||||
{
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool GetCursorPos(ref System.Drawing.Point lpPoint);
|
||||
|
||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
||||
public static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
|
||||
//取得前台窗口句柄函数
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
//取得桌面窗口句柄函数
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetDesktopWindow();
|
||||
//取得Shell窗口句柄函数
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetShellWindow();
|
||||
//取得窗口大小函数
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern int GetWindowRect(IntPtr hwnd, out RECT rc);
|
||||
//获取窗口标题
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
private static extern int GetWindowText(
|
||||
IntPtr hWnd,//窗口句柄
|
||||
StringBuilder lpString,//标题
|
||||
int nMaxCount //最大值
|
||||
);
|
||||
|
||||
//获取类的名字
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetClassName(
|
||||
IntPtr hWnd,//句柄
|
||||
StringBuilder lpString, //类名
|
||||
int nMaxCount); //最大值
|
||||
|
||||
/// <summary>
|
||||
/// 判断当前屏幕(鼠标最后活动屏幕)是否有全屏化应用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool IsPrimaryFullScreen()
|
||||
{
|
||||
|
||||
//桌面窗口句柄
|
||||
IntPtr desktopHandle; //Window handle for the desktop
|
||||
//Shell窗口句柄
|
||||
IntPtr shellHandle; //Window handle for the shell 因为桌面窗口和Shell窗口也是全屏,要排除在其他全屏程序之外。 //取得桌面和Shell窗口句柄
|
||||
desktopHandle = GetDesktopWindow();
|
||||
shellHandle = GetShellWindow(); //取得前台窗口句柄并判断是否全屏
|
||||
bool runningFullScreen = false;
|
||||
RECT appBounds;
|
||||
Rectangle screenBounds;
|
||||
IntPtr hWnd;
|
||||
//取得前台窗口
|
||||
hWnd = GetForegroundWindow();
|
||||
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
try
|
||||
{
|
||||
GetClassName(hWnd, sb, sb.Capacity);
|
||||
}
|
||||
catch { }
|
||||
if (sb.ToString().ToLower().Equals("workerw")) return false;
|
||||
if (hWnd != null && !hWnd.Equals(IntPtr.Zero))
|
||||
{
|
||||
//判断是否桌面或shell
|
||||
if (!(hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle)))
|
||||
{
|
||||
//取得窗口大小
|
||||
GetWindowRect(hWnd, out appBounds);
|
||||
//判断是否全屏
|
||||
screenBounds = Screen.FromHandle(hWnd).Bounds;
|
||||
if ((appBounds.bottom - appBounds.top) == screenBounds.Height
|
||||
&& (appBounds.right - appBounds.left) == screenBounds.Width)
|
||||
runningFullScreen = true;
|
||||
}
|
||||
}
|
||||
return runningFullScreen;
|
||||
}
|
||||
|
||||
|
||||
public static Color GetColorAt(System.Drawing.Point location)
|
||||
{
|
||||
Bitmap screenPixel = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
|
||||
|
||||
using (Graphics gdest = Graphics.FromImage(screenPixel))
|
||||
{
|
||||
using (Graphics gsrc = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
IntPtr hSrcDC = gsrc.GetHdc();
|
||||
IntPtr hDC = gdest.GetHdc();
|
||||
int retval = BitBlt(hDC, 0, 0, 1, 1, hSrcDC, location.X, location.Y, (int)CopyPixelOperation.SourceCopy);
|
||||
gdest.ReleaseHdc();
|
||||
gsrc.ReleaseHdc();
|
||||
}
|
||||
}
|
||||
|
||||
return screenPixel.GetPixel(0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,24 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private bool itemSpradeAnimation; //列表展开动画
|
||||
|
||||
private bool? secondsWindow; //秒数窗口 默认打开
|
||||
|
||||
#region GetSet
|
||||
|
||||
public bool? SecondsWindow
|
||||
{
|
||||
get
|
||||
{
|
||||
if (secondsWindow == null) secondsWindow = true;
|
||||
return secondsWindow;
|
||||
}
|
||||
set
|
||||
{
|
||||
secondsWindow = value;
|
||||
OnPropertyChanged("SecondsWindow");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ItemSpradeAnimation
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user