Skip to content

Commit c04cfce

Browse files
committed
Refactor using wpf
1 parent ff0d191 commit c04cfce

File tree

133 files changed

+6744
-12711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+6744
-12711
lines changed

clashN/clashN.sln

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.32002.261
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32811.315
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clashN", "clashN\clashN.csproj", "{0A9785E6-D256-4B73-9757-4EF59955FD1E}"
7-
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clashUpgrade", "clashUpgrade\clashUpgrade.csproj", "{F82BE52A-155C-492C-9E0A-1E917EC62C78}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clashN", "clashN\clashN.csproj", "{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}"
97
EndProject
108
Global
119
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1210
Debug|Any CPU = Debug|Any CPU
13-
Debug|x86 = Debug|x86
1411
Release|Any CPU = Release|Any CPU
15-
Release|x86 = Release|x86
1612
EndGlobalSection
1713
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18-
{0A9785E6-D256-4B73-9757-4EF59955FD1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19-
{0A9785E6-D256-4B73-9757-4EF59955FD1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
20-
{0A9785E6-D256-4B73-9757-4EF59955FD1E}.Debug|x86.ActiveCfg = Debug|Any CPU
21-
{0A9785E6-D256-4B73-9757-4EF59955FD1E}.Debug|x86.Build.0 = Debug|Any CPU
22-
{0A9785E6-D256-4B73-9757-4EF59955FD1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{0A9785E6-D256-4B73-9757-4EF59955FD1E}.Release|Any CPU.Build.0 = Release|Any CPU
24-
{0A9785E6-D256-4B73-9757-4EF59955FD1E}.Release|x86.ActiveCfg = Release|Any CPU
25-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|Any CPU.Build.0 = Debug|Any CPU
27-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|x86.ActiveCfg = Debug|Any CPU
28-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Debug|x86.Build.0 = Debug|Any CPU
29-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|Any CPU.ActiveCfg = Release|Any CPU
30-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|Any CPU.Build.0 = Release|Any CPU
31-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|x86.ActiveCfg = Release|Any CPU
32-
{F82BE52A-155C-492C-9E0A-1E917EC62C78}.Release|x86.Build.0 = Release|Any CPU
14+
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|Any CPU.Build.0 = Release|Any CPU
3318
EndGlobalSection
3419
GlobalSection(SolutionProperties) = preSolution
3520
HideSolutionNode = FALSE
3621
EndGlobalSection
3722
GlobalSection(ExtensibilityGlobals) = postSolution
38-
SolutionGuid = {56B88873-C9CC-4069-A1E5-DABD6C6E865E}
39-
RESX_SortFileContentOnSave = True
23+
SolutionGuid = {43E06CBD-3DA9-40A3-8E4D-F0943CB0DD32}
4024
EndGlobalSection
4125
EndGlobal

clashN/clashN/App.xaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Application
2+
x:Class="clashN.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="clr-namespace:clashN"
6+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
7+
StartupUri="Views/MainWindow.xaml">
8+
<Application.Resources>
9+
<ResourceDictionary>
10+
<ResourceDictionary.MergedDictionaries>
11+
<materialDesign:BundledTheme
12+
BaseTheme="Dark"
13+
PrimaryColor="DeepPurple"
14+
SecondaryColor="Lime" />
15+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
16+
</ResourceDictionary.MergedDictionaries>
17+
18+
<Style x:Key="ModuleTitle" TargetType="{x:Type TextBlock}">
19+
<Setter Property="FontSize" Value="28" />
20+
</Style>
21+
<Style TargetType="{x:Type TextElement}">
22+
<Setter Property="FontWeight" Value="Regular" />
23+
</Style>
24+
<Style x:Key="lvItemSelected" TargetType="{x:Type ListViewItem}">
25+
<Setter Property="Margin" Value="1" />
26+
<Style.Triggers>
27+
<Trigger Property="IsSelected" Value="true">
28+
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightBrush}" />
29+
</Trigger>
30+
</Style.Triggers>
31+
</Style>
32+
</ResourceDictionary>
33+
34+
</Application.Resources>
35+
36+
</Application>

clashN/clashN/App.xaml.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using clashN.Tool;
2+
using System.Windows;
3+
using System.Windows.Threading;
4+
5+
namespace clashN
6+
{
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
public static EventWaitHandle ProgramStarted;
13+
14+
public App()
15+
{
16+
// Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());
17+
18+
19+
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
20+
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
21+
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
22+
}
23+
24+
/// <summary>
25+
/// 只打开一个进程
26+
/// </summary>
27+
/// <param name="e"></param>
28+
protected override void OnStartup(StartupEventArgs e)
29+
{
30+
foreach (string arg in e.Args)
31+
{
32+
Utils.SetClipboardData(arg);
33+
}
34+
35+
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "ProgramStartedEvent", out bool bCreatedNew);
36+
if (!bCreatedNew)
37+
{
38+
ProgramStarted.Set();
39+
App.Current.Shutdown();
40+
Environment.Exit(-1);
41+
return;
42+
}
43+
Global.processJob = new Job();
44+
45+
Logging.Setup();
46+
Utils.SaveLog($"clashN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
47+
Logging.ClearLogs();
48+
49+
string lang = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, Global.Languages[0]);
50+
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);
51+
52+
base.OnStartup(e);
53+
}
54+
55+
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
56+
{
57+
Utils.SaveLog("App_DispatcherUnhandledException", e.Exception);
58+
e.Handled = true;
59+
}
60+
61+
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
62+
{
63+
if (e.ExceptionObject != null)
64+
{
65+
Utils.SaveLog("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject!);
66+
}
67+
}
68+
69+
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
70+
{
71+
Utils.SaveLog("TaskScheduler_UnobservedTaskException", e.Exception);
72+
}
73+
}
74+
}

clashN/clashN/AssemblyInfo.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]

clashN/clashN/Base/HttpClientHelper.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Net;
1+
using System.IO;
62
using System.Net.Http;
73
using System.Net.Http.Headers;
8-
using System.Threading;
9-
using System.Threading.Tasks;
104

115
namespace clashN.Base
126
{
@@ -42,7 +36,7 @@ public static HttpClientHelper GetInstance()
4236
}
4337
public async Task<string> GetAsync(string url)
4438
{
45-
if (string.IsNullOrEmpty(url))
39+
if (Utils.IsNullOrEmpty(url))
4640
{
4741
return null;
4842
}
@@ -59,7 +53,7 @@ public async Task<string> GetAsync(string url)
5953
}
6054
public async Task<string> GetAsync(HttpClient client, string url, CancellationToken token)
6155
{
62-
if (string.IsNullOrEmpty(url))
56+
if (Utils.IsNullOrEmpty(url))
6357
{
6458
return null;
6559
}
@@ -91,14 +85,23 @@ public async Task PatchAsync(string url, Dictionary<string, string> headers)
9185

9286
await httpClient.PatchAsync(url, byteContent);
9387
}
88+
public async Task DeleteAsync(string url)
89+
{
90+
//var myContent = Utils.ToJson(headers);
91+
//var buffer = System.Text.Encoding.UTF8.GetBytes(myContent);
92+
//var byteContent = new ByteArrayContent(buffer);
93+
//byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
94+
95+
await httpClient.DeleteAsync(url);
96+
}
9497

9598
public async Task DownloadFileAsync(HttpClient client, string url, string fileName, IProgress<double> progress, CancellationToken token)
9699
{
97-
if (string.IsNullOrEmpty(url))
100+
if (Utils.IsNullOrEmpty(url))
98101
{
99102
throw new ArgumentNullException("url");
100103
}
101-
if (string.IsNullOrEmpty(fileName))
104+
if (Utils.IsNullOrEmpty(fileName))
102105
{
103106
throw new ArgumentNullException("fileName");
104107
}

clashN/clashN/Base/ListViewFlickerFree.cs

Lines changed: 0 additions & 113 deletions
This file was deleted.

clashN/clashN/Base/StringEx.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Collections.Generic;
2-
using System.IO;
3-
using System.Linq;
1+
using System.IO;
42

53
namespace clashN.Base
64
{
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Windows.Data;
2+
using System.Windows.Media;
3+
4+
namespace clashN.Converters
5+
{
6+
public class DelayColorConverter : IValueConverter
7+
{
8+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
9+
{
10+
var temp = (int)value;
11+
12+
if (temp <= 200)
13+
return new SolidColorBrush(Colors.Green);
14+
else
15+
return new SolidColorBrush(Colors.IndianRed);
16+
}
17+
18+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
19+
{
20+
return null;
21+
}
22+
}
23+
}

clashN/clashN/FodyWeavers.xml

Lines changed: 3 additions & 0 deletions
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+
<ReactiveUI />
3+
</Weavers>

0 commit comments

Comments
 (0)