From 4a335f46cb999c6e7a7fedde202bcd4fa2707659 Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Thu, 31 Oct 2019 00:48:47 +0800
Subject: [PATCH] support for doc
---
.../attach/iconSwitchElement/index.md | 12 +++-
.../HandyControlDemo_Core30.csproj | 3 +
.../HandyControlDemo_Net_40.csproj | 3 +
.../HandyControlDemo_Net_GE45.csproj | 3 +
.../HandyControlDemo_Shared/App.xaml.cs | 55 ++++++++++++++++++
.../HandyControlDemo_Shared.projitems | 1 +
.../Resources/Registry.txt | Bin 0 -> 688 bytes
.../Tools/Helper/Win32Helper.cs | 11 ++++
8 files changed, 86 insertions(+), 2 deletions(-)
create mode 100644 src/Shared/HandyControlDemo_Shared/Resources/Registry.txt
create mode 100644 src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs
diff --git a/doc/source/handycontrol/attach/iconSwitchElement/index.md b/doc/source/handycontrol/attach/iconSwitchElement/index.md
index ca12ad623..adffe69d2 100644
--- a/doc/source/handycontrol/attach/iconSwitchElement/index.md
+++ b/doc/source/handycontrol/attach/iconSwitchElement/index.md
@@ -1,5 +1,13 @@
---
-title: 建设中
+title: IconSwitchElement 可切换图标的元素
---
-建设中
\ No newline at end of file
+{% note info no-icon %}
+继承自 [IconElement](https://handyorg.github.io/handycontrol/attach/iconElement/)
+{% endnote %}
+
+# 属性
+
+| 名称 | 用途 |
+|-|-|
+| GeometrySelected | 选中时的几何形状 |
\ No newline at end of file
diff --git a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
index 1b7528d84..01ca2c131 100644
--- a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
+++ b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
@@ -391,6 +391,9 @@
Resources\fabric-icons.ttf
+
+ Resources\Registry.txt
+
Resources\Img\LeftMainContent\brackets_Square_16xLG.png
diff --git a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
index 6ea014706..1df7079ea 100644
--- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
+++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
@@ -420,6 +420,9 @@
Resources\fabric-icons.ttf
+
+ Resources\Registry.txt
+
diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
index d7566d1bb..372bc73c3 100644
--- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
+++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
@@ -567,6 +567,9 @@
Resources\fabric-icons.ttf
+
+ Resources\Registry.txt
+
diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml.cs b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
index 1392706ab..167cef26c 100644
--- a/src/Shared/HandyControlDemo_Shared/App.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
@@ -1,6 +1,10 @@
using System;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
using System.Net;
using System.Security.Authentication;
+using System.Threading;
using System.Windows;
using HandyControl.Data;
using HandyControl.Tools;
@@ -11,10 +15,36 @@ namespace HandyControlDemo
{
public partial class App
{
+ // ReSharper disable once NotAccessedField.Local
+ [SuppressMessage("代码质量", "IDE0052:删除未读的私有成员", Justification = "<挂起>")]
+ private static Mutex AppMutex;
+
+ public App()
+ {
+ AppMutex = new Mutex(true, "HandyControlDemo", out var createdNew);
+
+ if (!createdNew)
+ {
+ var current = Process.GetCurrentProcess();
+
+ foreach (var process in Process.GetProcessesByName(current.ProcessName))
+ {
+ if (process.Id != current.Id)
+ {
+ Win32Helper.SetForegroundWindow(process.MainWindowHandle);
+ break;
+ }
+ }
+ Shutdown();
+ }
+ }
+
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
+ UpdateRegistry();
+
ShutdownMode = ShutdownMode.OnMainWindowClose;
GlobalData.Init();
ConfigHelper.Instance.SetLang(GlobalData.Config.Lang);
@@ -54,5 +84,30 @@ internal void UpdateSkin(SkinType skin)
});
Current.MainWindow?.OnApplyTemplate();
}
+
+ private void UpdateRegistry()
+ {
+ var processModule = Process.GetCurrentProcess().MainModule;
+ if (processModule != null)
+ {
+ var registryFilePath = $"{Path.GetDirectoryName(processModule.FileName)}\\Registry.reg";
+ if (!File.Exists(registryFilePath))
+ {
+ var streamResourceInfo = GetResourceStream(new Uri("pack://application:,,,/Resources/Registry.txt"));
+ if (streamResourceInfo != null)
+ {
+ using var reader = new StreamReader(streamResourceInfo.Stream);
+ var registryStr = reader.ReadToEnd();
+ var newRegistryStr = registryStr.Replace("#", processModule.FileName.Replace("\\", "\\\\"));
+ File.WriteAllText(registryFilePath, newRegistryStr);
+ Process.Start(new ProcessStartInfo("cmd", $"/c {registryFilePath}")
+ {
+ UseShellExecute = false,
+ CreateNoWindow = true
+ });
+ }
+ }
+ }
+ }
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
index 53ef32fcc..6128b1233 100644
--- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
+++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
@@ -33,6 +33,7 @@
+
Avatar.xaml
diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Registry.txt b/src/Shared/HandyControlDemo_Shared/Resources/Registry.txt
new file mode 100644
index 0000000000000000000000000000000000000000..70b4305057db31ce4af44457c43d34ee51be2d99
GIT binary patch
literal 688
zcmcIi%L>9U5S+8%Ka_YEFCGO&3yKBBCt{?C&q5#4R-`|#PPT~k+udzJJmEQ#+>(NwUE-h*H&LCL#}
z%5oHH(R$__cj`_t61MP1d4uZ9^+nV9D?RcVxkqJA^u^Y6?na)^JXN!3aWCN8=l`Pk
H{zVtxxiWDV
literal 0
HcmV?d00001
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs b/src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs
new file mode 100644
index 000000000..0f8aeb4b5
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace HandyControlDemo.Tools
+{
+ internal class Win32Helper
+ {
+ [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
+ public static extern bool SetForegroundWindow(IntPtr hWnd);
+ }
+}