浏览代码

:white_check_mark: 优化时钟显示功能

Booker 1 年之前
父节点
当前提交
8fea77c304
共有 5 个文件被更改,包括 50 次插入15 次删除
  1. 1 1
      Constant/Constants.cs
  2. 1 0
      GeekDesk.csproj
  3. 15 1
      Plugins/ShowSeconds/SecondsWindow.xaml.cs
  4. 15 11
      Util/WindowUtil.cs
  5. 18 2
      ViewModel/AppConfig.cs

+ 1 - 1
Constant/Constants.cs

@@ -9,7 +9,7 @@ namespace GeekDesk.Constant
         public static string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim();
         public static string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim();
 
 
         // 是否为开发模式
         // 是否为开发模式
-        public static bool DEV = false;
+        public static bool DEV = true;
 
 
         public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
         public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk";
 
 

+ 1 - 0
GeekDesk.csproj

@@ -274,6 +274,7 @@
     <Compile Include="Converts\BGStyleConvert.cs" />
     <Compile Include="Converts\BGStyleConvert.cs" />
     <Compile Include="Converts\UpdateTypeConvert.cs" />
     <Compile Include="Converts\UpdateTypeConvert.cs" />
     <Compile Include="Converts\ReverseBoolConvert.cs" />
     <Compile Include="Converts\ReverseBoolConvert.cs" />
+    <Compile Include="Converts\Boolean2VisibilityConverter.cs" />
     <Compile Include="Converts\Visibility2BooleanConverter.cs" />
     <Compile Include="Converts\Visibility2BooleanConverter.cs" />
     <Compile Include="CustomComponent\DraggAnimatedPanel\DraggAnimatedPanel.cs" />
     <Compile Include="CustomComponent\DraggAnimatedPanel\DraggAnimatedPanel.cs" />
     <Compile Include="CustomComponent\DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
     <Compile Include="CustomComponent\DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />

+ 15 - 1
Plugins/ShowSeconds/SecondsWindow.xaml.cs

@@ -122,9 +122,23 @@ namespace ShowSeconds
             }
             }
         }
         }
 
 
+
         private void SecondsHookSetFuc(object sender, MouseEventExtArgs e)
         private void SecondsHookSetFuc(object sender, MouseEventExtArgs e)
         {
         {
-           
+
+            IntPtr taskBarWnd = WindowUtil.FindWindow("Shell_TrayWnd", null);
+            IntPtr tray = WindowUtil.FindWindowEx(taskBarWnd, IntPtr.Zero, "TrayNotifyWnd", null);
+            //IntPtr trayclock = WindowUtil.FindWindowEx(tray, IntPtr.Zero, "TrayClockWClass", null);
+            IntPtr trayclock = WindowUtil.GetForegroundWindow();
+            StringBuilder title = new StringBuilder(256);
+            WindowUtil.GetWindowText(trayclock, title, title.Capacity);//得到窗口的标题
+            Console.WriteLine(title.ToString());
+            if (title.Equals("通知中心"))
+            {
+                
+            }
+
+
             if (e.Button == System.Windows.Forms.MouseButtons.Left)
             if (e.Button == System.Windows.Forms.MouseButtons.Left)
             {
             {
                 if (ScreenUtil.IsPrimaryFullScreen()) return;
                 if (ScreenUtil.IsPrimaryFullScreen()) return;

+ 15 - 11
Util/WindowUtil.cs

@@ -44,29 +44,33 @@ namespace GeekDesk.Util
 
 
         //取得前台窗口句柄函数 
         //取得前台窗口句柄函数 
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        private static extern IntPtr GetForegroundWindow();
+        public static extern IntPtr GetForegroundWindow();
         //取得桌面窗口句柄函数 
         //取得桌面窗口句柄函数 
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        private static extern IntPtr GetDesktopWindow();
+        public static extern IntPtr GetDesktopWindow();
         [DllImport("user32.dll", CharSet = CharSet.Auto)]
         [DllImport("user32.dll", CharSet = CharSet.Auto)]
-        private static extern IntPtr FindWindow(string className, string windowName);
+        public static extern IntPtr FindWindow(string className, string windowName);
+
+        [DllImport("user32.dll")]
+        public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string className, string windowName);
+
         [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
         [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
-        private static extern IntPtr GetWindow(HandleRef hWnd, int nCmd);
+        public static extern IntPtr GetWindow(HandleRef hWnd, int nCmd);
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        private static extern IntPtr SetParent(IntPtr child, IntPtr parent);
+        public static extern IntPtr SetParent(IntPtr child, IntPtr parent);
         [DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)]
         [DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)]
-        private static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);
+        public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);
         [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
         [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
-        private static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter, int x, int y, int cx, int cy, int flags);
+        public static extern bool SetWindowPos(HandleRef hWnd, HandleRef hWndInsertAfter, int x, int y, int cx, int cy, int flags);
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        private static extern int ReleaseDC(IntPtr window, IntPtr handle);
+        public static extern int ReleaseDC(IntPtr window, IntPtr handle);
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
+        public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
 
 
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
+        public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
         [DllImport("user32.dll")]
         [DllImport("user32.dll")]
-        private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
+        public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
 
 
 
 
         private const int GWL_STYLE = -16;
         private const int GWL_STYLE = -16;

+ 18 - 2
ViewModel/AppConfig.cs

@@ -105,10 +105,26 @@ namespace GeekDesk.ViewModel
 
 
         private bool? secondsWindow; //秒数窗口 默认打开
         private bool? secondsWindow; //秒数窗口 默认打开
 
 
-        private bool? enableEveryThing;
+        private bool? enableEveryThing; //开启everything
 
 
-        private bool? alwaysTopmost;
+        private bool? alwaysTopmost; //是否置顶
 
 
+        private bool? showIconTitle = true; //是否显示iconTitle
+
+
+        public bool? ShowIconTitle
+        {
+            get
+            {
+                if (showIconTitle == null) showIconTitle = false;
+                return showIconTitle;
+            }
+            set
+            {
+                showIconTitle = value;
+                OnPropertyChanged("ShowIconTitle");
+            }
+        }
 
 
         public bool? AlwaysTopmost
         public bool? AlwaysTopmost
         {
         {