Skip to content

Commit c435a22

Browse files
committed
添加项目文件。
1 parent 38b9b8d commit c435a22

11 files changed

+437
-0
lines changed

StartUpAsAdmin.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.11.35201.85
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUpAsAdmin", "StartUpAsAdmin\StartUpAsAdmin.csproj", "{1CBDE6C9-9050-48B7-9F7A-AD5589C2BDB0}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{1CBDE6C9-9050-48B7-9F7A-AD5589C2BDB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1CBDE6C9-9050-48B7-9F7A-AD5589C2BDB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1CBDE6C9-9050-48B7-9F7A-AD5589C2BDB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{1CBDE6C9-9050-48B7-9F7A-AD5589C2BDB0}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {9A7F779C-D84D-4CB4-B8C4-56ECE2508DCB}
24+
EndGlobalSection
25+
EndGlobal

StartUpAsAdmin/AdminHelper.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Security.Principal;
2+
3+
namespace StartUpAsAdmin;
4+
5+
public static class AdminHelper
6+
{
7+
public static bool IsRunningInAdmin()
8+
{
9+
var id = WindowsIdentity.GetCurrent();
10+
var principal = new WindowsPrincipal(id);
11+
return principal.IsInRole(WindowsBuiltInRole.Administrator);
12+
}
13+
}

StartUpAsAdmin/Plugin.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
using ClassIsland.Core.Abstractions;
3+
using ClassIsland.Core.Attributes;
4+
using ClassIsland.Core.Controls.CommonDialog;
5+
using ClassIsland.Core.Extensions.Registry;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.Hosting;
8+
9+
namespace StartUpAsAdmin;
10+
11+
[PluginEntrance]
12+
public class Plugin : PluginBase
13+
{
14+
public override void Initialize(HostBuilderContext context, IServiceCollection services)
15+
{
16+
services.AddSettingsPage<StartUpAsAdminSettingsPage>();
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"profiles": {
3+
"ClassIsland 插件": {
4+
"commandName": "Executable",
5+
"executablePath": "$(ClassIsland_DebugBinaryFile)",
6+
"commandLineArgs": "-epp $(TargetDir)",
7+
"workingDirectory": "$(ClassIsland_DebugBinaryDirectory)"
8+
}
9+
}
10+
}

StartUpAsAdmin/README.md

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# 插件自述文件
2+
3+
本文件会在插件市场上显示。在安装插件后,本自述文件也会在【应用设置】->【插件】页面中显示。因此,本文件也将会是用户了解你的插件功能的重要途径,建议好好写 README。
4+
5+
**注意事项:**
6+
7+
- 嵌入图片时请使用网络图床。
8+
- 支持在这里直接调用 ClassIsland 内部的 Uri,例如[classisland://app/test/](classisland://app/test/)
9+
- 本文件一般会在 ClassIsland 内置的 Markdown 渲染器(基于 [MdXaml](https://github.com/whistyun/MdXaml))中渲染,仅支持部分 Markdown 语法。
10+
11+
***
12+
13+
**支持的 Markdown 语法:**
14+
15+
> 本示例魔改自 [Leanote 博客](http://leanote.leanote.com/post/markdown-source-code)
16+
17+
# Welcome to ClassIsland! 欢迎来到ClassIsland!
18+
19+
## 1. 排版
20+
21+
**粗体** *斜体*
22+
23+
~~这是一段错误的文本。~~
24+
25+
引用:
26+
27+
> 123123123123
28+
29+
有充列表:
30+
1. 支持Vim
31+
2. 支持Emacs
32+
33+
无序列表:
34+
35+
- 项目1
36+
- 项目2
37+
38+
39+
## 2. 图片与链接
40+
41+
网络图片:
42+
![Banner](https://github.com/user-attachments/assets/a815dd7d-8343-4da5-aee4-3f754aa297e4)
43+
44+
WPF 资源图片:
45+
46+
![1690356161339](pack://application:,,,/ClassIsland;component/Assets/AppLogo.png)
47+
48+
链接:
49+
50+
[ClassIsland 官网](http://classisland.tech)
51+
52+
## 3. 标题
53+
54+
以下是各级标题, 最多支持5级标题
55+
56+
```
57+
# h1
58+
## h2
59+
### h3
60+
#### h4
61+
##### h4
62+
###### h5
63+
```
64+
65+
## 4. 代码
66+
67+
示例:
68+
69+
function get(key) {
70+
return m[key];
71+
}
72+
73+
代码高亮示例:
74+
75+
``` javascript
76+
/**
77+
* nth element in the fibonacci series.
78+
* @param n >= 0
79+
* @return the nth element, >= 0.
80+
*/
81+
function fib(n) {
82+
var a = 1, b = 1;
83+
var tmp;
84+
while (--n >= 0) {
85+
tmp = a;
86+
a += b;
87+
b = tmp;
88+
}
89+
return a;
90+
}
91+
92+
document.write(fib(10));
93+
```
94+
95+
```python
96+
class Employee:
97+
empCount = 0
98+
99+
def __init__(self, name, salary):
100+
self.name = name
101+
self.salary = salary
102+
Employee.empCount += 1
103+
```
104+
105+
# 5. Markdown 扩展
106+
107+
Markdown 扩展支持:
108+
109+
* 表格
110+
111+
## 5.1 表格
112+
113+
Item | Value
114+
-------- | ---
115+
Computer | \$1600
116+
Phone | \$12
117+
Pipe | \$1
118+

StartUpAsAdmin/StartUpAsAdmin.csproj

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0-windows</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<UseWPF>true</UseWPF>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<PlatformTarget>x64</PlatformTarget>
9+
<EnableDynamicLoading>True</EnableDynamicLoading>
10+
</PropertyGroup>
11+
12+
<PropertyGroup>
13+
<ClassIslandPluginSdkVersion>1.5.0.*</ClassIslandPluginSdkVersion>
14+
</PropertyGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="ClassIsland.PluginSdk" Version="$(ClassIslandPluginSdkVersion)">
18+
<ExcludeAssets>runtime; native</ExcludeAssets>
19+
</PackageReference>
20+
<PackageReference Include="TaskScheduler" Version="2.11.0" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<None Update="manifest.yml">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
</None>
27+
<None Update="README.md">
28+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
29+
</None>
30+
<None Update="icon.png">
31+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
32+
</None>
33+
</ItemGroup>
34+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<ci:SettingsPageBase x:Class="StartUpAsAdmin.StartUpAsAdminSettingsPage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:StartUpAsAdmin"
7+
xmlns:ci="http://classisland.tech/schemas/xaml/core"
8+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
9+
mc:Ignorable="d"
10+
d:DesignHeight="450" d:DesignWidth="800"
11+
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
12+
Background="{DynamicResource MaterialDesignPaper}"
13+
FontFamily="{StaticResource HarmonyOsSans}"
14+
TextElement.FontWeight="Regular"
15+
TextElement.FontSize="14"
16+
TextOptions.TextFormattingMode="Ideal"
17+
TextOptions.TextRenderingMode="Auto"
18+
Title="StartUpAsAdminSettingsPage"
19+
d:DataContext="{d:DesignInstance local:StartUpAsAdminSettingsPage}">
20+
21+
<ci:SettingsPageBase.Resources>
22+
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
23+
<ci:BooleanToVisibilityReConverter x:Key="BooleanToVisibilityReConverter" />
24+
25+
</ci:SettingsPageBase.Resources>
26+
<StackPanel MaxWidth="750" Margin="6">
27+
<materialDesign:ColorZone Background="#22FF0000"
28+
Margin="0 0 0 6"
29+
Visibility="{Binding ViewModel.IsRunningAsAdmin, Converter={StaticResource BooleanToVisibilityReConverter}}">
30+
<Grid TextElement.FontSize="14">
31+
<DockPanel Margin="8 4 4 4">
32+
<materialDesign:PackIcon Kind="Administrator"
33+
Margin="0 0 4 0"
34+
VerticalAlignment="Center"/>
35+
<TextBlock Text="你需要以管理员身份运行 ClassIsland 才能更改此处的设置。"
36+
TextWrapping="Wrap"
37+
VerticalAlignment="Center"/>
38+
<Button Style="{StaticResource MaterialDesignFlatButton}"
39+
Foreground="{DynamicResource MaterialDesignBody}"
40+
Margin="0 -4"
41+
Padding="8 0"
42+
materialDesign:RippleAssist.Feedback="{DynamicResource MaterialDesignBody}"
43+
HorizontalAlignment="Right"
44+
Click="ButtonRestartAsAdmin_OnClick">
45+
<ci:IconText Kind="Restart" Text="以管理员身份重启"/>
46+
</Button>
47+
</DockPanel>
48+
</Grid>
49+
</materialDesign:ColorZone>
50+
51+
<!-- 以管理员身份自启动 -->
52+
<materialDesign:Card Margin="0 0 0 6"
53+
IsEnabled="{Binding ViewModel.IsRunningAsAdmin}">
54+
<Expander Background="Transparent"
55+
IsExpanded="True"
56+
TextBlock.Foreground="{DynamicResource MaterialDesignBody}">
57+
<Expander.Header>
58+
<ci:SettingsControl IconGlyph="Administrator"
59+
Foreground="{DynamicResource MaterialDesignBody}"
60+
Header="以管理员身份自启动"
61+
Description="ClassIsland 将创建一个计划任务以实现以管理员身份自启动,并禁用应用内置的自启动方式。"
62+
HasSwitcher="False"
63+
Margin="-12 0" />
64+
</Expander.Header>
65+
<StackPanel Margin="36 0 48 12">
66+
<WrapPanel>
67+
<Button Click="ButtonCreateTask_OnClick" Style="{StaticResource MaterialDesignFlatButton}">
68+
<ci:IconText Kind="Add" Text="创建/更新计划任务" />
69+
</Button>
70+
<Button Click="ButtonRemoveTask_OnClick" Style="{StaticResource MaterialDesignFlatButton}"
71+
Margin="4 0 0 0">
72+
<ci:IconText Kind="Remove" Text="删除计划任务" />
73+
</Button>
74+
</WrapPanel>
75+
</StackPanel>
76+
</Expander>
77+
</materialDesign:Card>
78+
79+
80+
</StackPanel>
81+
</ci:SettingsPageBase>

0 commit comments

Comments
 (0)