Skip to content

Commit

Permalink
support for doc
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Oct 30, 2019
1 parent d15dda0 commit 4a335f4
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 2 deletions.
12 changes: 10 additions & 2 deletions doc/source/handycontrol/attach/iconSwitchElement/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
---
title: 建设中
title: IconSwitchElement 可切换图标的元素
---

建设中
{% note info no-icon %}
继承自 [IconElement](https://handyorg.github.io/handycontrol/attach/iconElement/)
{% endnote %}

# 属性

| 名称 | 用途 |
|-|-|
| GeometrySelected | 选中时的几何形状 |
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf">
<Link>Resources\fabric-icons.ttf</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Registry.txt">
<Link>Resources\Registry.txt</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\brackets_Square_16xLG.png">
<Link>Resources\Img\LeftMainContent\brackets_Square_16xLG.png</Link>
</Resource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf">
<Link>Resources\fabric-icons.ttf</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Registry.txt">
<Link>Resources\Registry.txt</Link>
</Resource>
</ItemGroup>
<ItemGroup>
<Content Include="..\..\Shared\HandyControlDemo_Shared\Data\MessageToken.tt">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf">
<Link>Resources\fabric-icons.ttf</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Registry.txt">
<Link>Resources\Registry.txt</Link>
</Resource>
</ItemGroup>
<Import Project="..\..\Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
55 changes: 55 additions & 0 deletions src/Shared/HandyControlDemo_Shared/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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
});
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\AssemblyHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\CommonHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ExternDllHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\Win32Helper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Basic\Avatar.xaml.cs">
<DependentUpon>Avatar.xaml</DependentUpon>
</Compile>
Expand Down
Binary file not shown.
11 changes: 11 additions & 0 deletions src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 4a335f4

Please sign in to comment.