Skip to content

Commit 9883ab7

Browse files
committed
Migrated the dynamic assembly loading method to Fody, refactored some initialization logic, and adjusted parts of the code structure.
1 parent c1bc982 commit 9883ab7

11 files changed

+222
-345
lines changed

CMWTAT_DIGITAL/App.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Application x:Class="CMWTAT_DIGITAL.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:local="clr-namespace:CMWTAT_KMS"
4+
xmlns:local="clr-namespace:CMWTAT_DIGITAL"
55
StartupUri="MainWindow.xaml"
66
>
77
<Application.Resources>

CMWTAT_DIGITAL/App.xaml.cs

+41-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,51 @@
1-
using CMWTAT_DIGITAL;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Configuration;
5-
using System.Data;
6-
using System.Linq;
1+
using System;
72
using System.Windows;
83

9-
namespace CMWTAT_KMS
4+
namespace CMWTAT_DIGITAL
105
{
116
/// <summary>
127
/// App.xaml 的交互逻辑
138
/// </summary>
149
public partial class App : Application
1510
{
11+
public static bool autoact = false;
12+
public static bool hiderun = false;
13+
public static bool expact = false;
14+
public static bool log2file = false;
15+
public static bool showhelp = false;
16+
17+
protected override void OnStartup(StartupEventArgs e)
18+
{
19+
foreach (string arg in e.Args)
20+
{
21+
Console.WriteLine("arg: " + arg);
22+
if (arg == "-a" || arg == "--auto")
23+
{
24+
Console.WriteLine("AUTO: True");
25+
autoact = true;
26+
}
27+
if (arg == "-h" || arg == "--hide")
28+
{
29+
Console.WriteLine("HIDE: True");
30+
hiderun = true;
31+
}
32+
if (arg == "-e" || arg == "--expact")
33+
{
34+
Console.WriteLine("EXPACT: True");
35+
expact = true;
36+
}
37+
if (arg == "-l" || arg == "--log")
38+
{
39+
Console.WriteLine("LOG: True");
40+
log2file = true;
41+
}
42+
if (arg == "-?" || arg == "--help")
43+
{
44+
Console.WriteLine("SHOWHELP: True");
45+
showhelp = true;
46+
}
47+
}
48+
base.OnStartup(e);
49+
}
1650
}
1751
}

CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj

+18-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" />
34
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
45
<PropertyGroup>
56
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
@@ -60,12 +61,12 @@
6061
<ApplicationIcon>CMWTAT.ico</ApplicationIcon>
6162
</PropertyGroup>
6263
<PropertyGroup>
63-
<StartupObject>CMWTAT_DIGITAL.Program</StartupObject>
64+
<StartupObject>
65+
</StartupObject>
6466
</PropertyGroup>
6567
<ItemGroup>
66-
<Reference Include="LibGatherOsState, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
67-
<SpecificVersion>False</SpecificVersion>
68-
<HintPath>Res\LibGatherOsState.dll</HintPath>
68+
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
69+
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
6970
</Reference>
7071
<Reference Include="MaterialDesignColors, Version=2.0.6.0, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
7172
<HintPath>..\packages\MaterialDesignColors.2.0.6\lib\net452\MaterialDesignColors.dll</HintPath>
@@ -77,20 +78,24 @@
7778
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
7879
</Reference>
7980
<Reference Include="System" />
80-
<Reference Include="System.Data" />
81+
<Reference Include="System.ComponentModel.Composition" />
8182
<Reference Include="System.Drawing" />
83+
<Reference Include="System.IO.Compression" />
84+
<Reference Include="System.Net.Http" />
85+
<Reference Include="System.Numerics" />
8286
<Reference Include="System.Runtime" />
87+
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
88+
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
89+
</Reference>
8390
<Reference Include="System.Runtime.InteropServices.WindowsRuntime" />
8491
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
85-
<Reference Include="System.Windows.Forms" />
86-
<Reference Include="System.Xml" />
8792
<Reference Include="Microsoft.CSharp" />
88-
<Reference Include="System.Core" />
89-
<Reference Include="System.Xml.Linq" />
90-
<Reference Include="System.Data.DataSetExtensions" />
93+
<Reference Include="System.Windows.Forms" />
9194
<Reference Include="System.Xaml">
9295
<RequiredTargetFramework>4.0</RequiredTargetFramework>
9396
</Reference>
97+
<Reference Include="System.Xml" />
98+
<Reference Include="System.Xml.Linq" />
9499
<Reference Include="Windows.Data" />
95100
<Reference Include="Windows.Foundation" />
96101
<Reference Include="Windows.UI" />
@@ -141,7 +146,6 @@
141146
</ItemGroup>
142147
<ItemGroup>
143148
<Compile Include="OSVersionInfoClass.cs" />
144-
<Compile Include="Program.cs" />
145149
<Compile Include="Properties\AssemblyInfo.cs">
146150
<SubType>Code</SubType>
147151
</Compile>
@@ -173,17 +177,6 @@
173177
<ItemGroup>
174178
<Resource Include="CMWTAT.ico" />
175179
</ItemGroup>
176-
<ItemGroup>
177-
<EmbeddedResource Include="..\packages\MaterialDesignColors.2.0.6\lib\net452\MaterialDesignColors.dll">
178-
<Link>Res\MaterialDesignColors.dll</Link>
179-
</EmbeddedResource>
180-
<EmbeddedResource Include="..\packages\MaterialDesignThemes.4.5.0\lib\net452\MaterialDesignThemes.Wpf.dll">
181-
<Link>Res\MaterialDesignThemes.Wpf.dll</Link>
182-
</EmbeddedResource>
183-
<EmbeddedResource Include="..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll">
184-
<Link>Res\Newtonsoft.Json.dll</Link>
185-
</EmbeddedResource>
186-
</ItemGroup>
187180
<ItemGroup>
188181
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
189182
<Visible>False</Visible>
@@ -207,5 +200,8 @@
207200
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
208201
</PropertyGroup>
209202
<Error Condition="!Exists('..\packages\MaterialDesignThemes.4.5.0\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MaterialDesignThemes.4.5.0\build\MaterialDesignThemes.targets'))" />
203+
<Error Condition="!Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
204+
<Error Condition="!Exists('..\packages\Fody.6.9.1\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.9.1\build\Fody.targets'))" />
210205
</Target>
206+
<Import Project="..\packages\Fody.6.9.1\build\Fody.targets" Condition="Exists('..\packages\Fody.6.9.1\build\Fody.targets')" />
211207
</Project>

CMWTAT_DIGITAL/Domain/IsSN.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Globalization;
1+
using System.Globalization;
32
using System.Text.RegularExpressions;
43
using System.Windows.Controls;
54

CMWTAT_DIGITAL/Domain/NotifyPropertyChangedExtension.cs

-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4-
using System.Linq;
54
using System.Runtime.CompilerServices;
6-
using System.Text;
7-
using System.Threading.Tasks;
85

96
namespace CMWTAT_DIGITAL.Domain
107
{

CMWTAT_DIGITAL/Domain/ViewModel.cs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
75

86
namespace CMWTAT_DIGITAL.Domain
97
{

CMWTAT_DIGITAL/FodyWeavers.xml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2+
<Costura />
3+
</Weavers>

CMWTAT_DIGITAL/MainWindow.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
FontFamily="{DynamicResource Font}"
2222
Activated="Window_Activated"
2323
WindowStartupLocation="CenterScreen"
24+
Loaded="Window_Loaded"
2425
>
2526
<!--FontFamily="{DynamicResource MaterialDesignFont}"-->
2627
<Grid>

0 commit comments

Comments
 (0)