Compare commits

...

42 Commits

Author SHA1 Message Date
mjsoftware
4747fd2daf 增加 恢复默认TCP端口(5555) 2025-03-11 14:35:49 +08:00
mjsoftware
e74a519b41 更新 2025-02-21 09:24:34 +08:00
mjsoftware
f836c2e07b 1.1.1 2025-02-20 13:36:43 +08:00
mjsoftware
5fcff70218 1.1.1 2025-02-20 13:31:30 +08:00
mjsoftware
ec91f656ad 提交 2025-02-20 11:57:03 +08:00
mjsoftware
77456d35a5 增加菜单项 2025-02-20 11:46:07 +08:00
mjsoftware
e711becff3 修复bug 2025-02-18 16:28:49 +08:00
mjsoftware
afd5d768b6 更新 2025-02-18 10:59:43 +08:00
mjsoftware
1205990e44 Merge branch 'master' of https://github.com/zsjy/AdbTools 2025-02-18 09:54:11 +08:00
mjsoftware
11e53b6949 修复取消更新程序启动提示错误的问题 2025-02-18 09:54:02 +08:00
宏尘
b50bf2c1c3
Update README.md 2025-02-17 14:49:29 +08:00
宏尘
a3fa66e1af
Update README.md 2025-02-17 14:48:04 +08:00
mjsoftware
8e1c7c5299 文档 2025-02-17 13:46:49 +08:00
j m
555271d623 1.0.9 2025-02-15 13:44:13 +08:00
j m
161d772354 依赖4.6 2025-02-15 13:24:47 +08:00
j m
c32d70de3b Merge branch 'master' of github.com:zsjy/AdbTools 2025-02-15 13:11:33 +08:00
j m
5b9d2f5c91 提交 2025-02-15 13:11:25 +08:00
j m
52cbde8cc3 版本提示改为按钮 2025-02-15 12:53:10 +08:00
宏尘
6fba5bbd68
Update README.md 2025-02-14 13:12:13 +08:00
mjsoftware
70b0a5acf5 1.0.8 2025-02-14 11:12:38 +08:00
mjsoftware
0ea420f011 1.0.8 2025-02-14 11:08:28 +08:00
mjsoftware
7d42b647f5 1.0.8 2025-02-14 10:59:48 +08:00
mjsoftware
efac1d2a1e 添加检查更新 2025-02-14 10:51:20 +08:00
mjsoftware
474af19694 提交 2025-02-13 18:02:10 +08:00
mjsoftware
0a9d80f052 添加查看日志,菜单调整为二级菜单 2025-02-13 13:11:16 +08:00
mjsoftware
3573948c0e 调整设备名包含“._adb-tls-connect._tcp”时,记为WiFi连接 2025-02-10 16:47:33 +08:00
mjsoftware
806d2eb6ec 移除自动高度 2025-01-23 15:41:21 +08:00
mjsoftware
e10ec9f4eb 支持有线连接 2025-01-23 15:26:32 +08:00
mjsoftware
91244793e5 提交 2025-01-21 16:46:33 +08:00
mjsoftware
17bc13d42d 提交 2025-01-21 16:42:24 +08:00
mjsoftware
3684e82e4b 添加快捷键 2025-01-21 16:25:16 +08:00
mjsoftware
298babd536 连接列表支持显示设备名 2025-01-21 16:01:21 +08:00
mjsoftware
1dfc9b488a 1.0.3 2025-01-17 15:39:09 +08:00
mjsoftware
0b2cc65480 增加恢复默认DPI和默认分辨率功能 2025-01-17 15:32:09 +08:00
mjsoftware
6c7bbdd686 提交 2025-01-17 11:43:54 +08:00
mjsoftware
8e8cb0baae 更新 2025-01-15 11:55:12 +08:00
mjsoftware
299dc66709 更新错误描述 2025-01-15 11:52:19 +08:00
mjsoftware
93823ef73b 提交 2025-01-15 11:17:47 +08:00
mjsoftware
1507364758 提交 2025-01-15 11:06:57 +08:00
mjsoftware
9c69be9b78 提交 2025-01-15 10:14:56 +08:00
mjsoftware
5acadddafd 提交 2025-01-14 16:51:42 +08:00
宏尘
61b2ada56b
添加许可 2025-01-10 18:02:20 +08:00
49 changed files with 7739 additions and 172 deletions

2
.gitignore vendored
View File

@ -33,6 +33,8 @@ bld/
[Ll]og/
[Ll]ogs/
Autosave/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot

View File

@ -5,16 +5,42 @@ VisualStudioVersion = 16.0.34407.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdbTools", "AdbTools\AdbTools.csproj", "{D80557CC-6756-4A53-BE06-2A0B21224607}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "AdbToolsSetup", "AdbToolsSetup\AdbToolsSetup.vdproj", "{22559873-B825-4CCF-816B-F0C0BC1FBA06}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D80557CC-6756-4A53-BE06-2A0B21224607}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D80557CC-6756-4A53-BE06-2A0B21224607}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D80557CC-6756-4A53-BE06-2A0B21224607}.Debug|x64.ActiveCfg = Debug|x64
{D80557CC-6756-4A53-BE06-2A0B21224607}.Debug|x64.Build.0 = Debug|x64
{D80557CC-6756-4A53-BE06-2A0B21224607}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D80557CC-6756-4A53-BE06-2A0B21224607}.Release|Any CPU.Build.0 = Release|Any CPU
{D80557CC-6756-4A53-BE06-2A0B21224607}.Release|x64.ActiveCfg = Release|x64
{D80557CC-6756-4A53-BE06-2A0B21224607}.Release|x64.Build.0 = Release|x64
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Debug|Any CPU.ActiveCfg = Debug
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Debug|Any CPU.Build.0 = Debug
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Debug|x64.ActiveCfg = Debug
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Debug|x64.Build.0 = Debug
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Release|Any CPU.ActiveCfg = Release
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Release|Any CPU.Build.0 = Release
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Release|x64.ActiveCfg = Release
{22559873-B825-4CCF-816B-F0C0BC1FBA06}.Release|x64.Build.0 = Release
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Debug|x64.ActiveCfg = Debug|Any CPU
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Debug|x64.Build.0 = Debug|Any CPU
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Release|Any CPU.Build.0 = Release|Any CPU
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Release|x64.ActiveCfg = Release|Any CPU
{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Web.Script.Serialization;
using System.Configuration;
using AdbTools.bean;
using System.Threading;
using System.Windows;
using System.IO;
using System.Windows.Controls;
namespace AdbTools.AccessInterface
{
public delegate void UpdateInfo(GithubReleases githubReleases);
/// <summary>
/// post请求
/// </summary>
public static class RequestJson
{
public const string ApiUrl = @"https://api.github.com/repos/zsjy/AdbTools/releases";
public const string ApiUrlMirror = @"https://code.hcjike.com/api/v1/repos/hcjike/AdbTools/releases";
public const string UpdateFileName = "update.zip";
private static JavaScriptSerializer jss = new JavaScriptSerializer();
public static void UpdateCheck(MainWindow mainWindow, Image updateVersion)
{
UpdateCheck(mainWindow, githubReleases =>
{
updateVersion.Visibility = Visibility.Visible;
updateVersion.Tag = githubReleases;
});
}
public static void UpdateCheck(MainWindow mainWindow, UpdateInfo action)
{
Thread thread = new Thread(new ThreadStart(() =>
{
GithubReleases githubReleases = Request();
if (null == githubReleases || App.Version.Equals(githubReleases.Name))
{
return;
}
GithubReleasesAssets githubReleasesAssets = null;
foreach (GithubReleasesAssets assets in githubReleases.Assets)
{
if (UpdateFileName.Equals(assets.Name, StringComparison.CurrentCultureIgnoreCase))
{
githubReleasesAssets = assets;
}
}
if (null == githubReleasesAssets)
{
return;
}
mainWindow.Dispatcher.Invoke(new Action(() =>
{
action.Invoke(githubReleases);
}));
}));
thread.Start();
}
/// <summary>
/// 执行请求,返回返回类型对象
/// </summary>
/// <typeparam name="T">请求的类型</typeparam>
/// <typeparam name="S">返回的类型</typeparam>
/// <param name="requestType">接口名称</param>
/// <param name="obj">请求的参数Json对象</param>
/// <returns>返回的类型的对象</returns>
public static GithubReleases Request()
{
try
{
string strURL = ApiUrlMirror;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
request.UserAgent = "User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1";
request.ContentType = "application/x-www-form-urlencoded";
request.Credentials = CredentialCache.DefaultCredentials;
request.Method = "GET";
request.Proxy = null;
request.Timeout = 60000;
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
System.IO.StreamReader myreader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8);
string responseText = myreader.ReadToEnd();
myreader.Close();
//return responseText;
List<GithubReleases> s = jss.Deserialize<List<GithubReleases>>(responseText);
return s[0];
}
catch (Exception e)
{
return null;
}
}
public static void DownloadFile(string url, string savePath)
{
try
{
// 创建 HttpWebRequest 对象
HttpWebRequest request = (HttpWebRequest)WebRequest.Create($"{Globals.AppSettings.GITHUB_PROXY}{url}");
request.Method = "GET";
// 发送请求并获取响应
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (FileStream fileStream = new FileStream(savePath, FileMode.Create, FileAccess.Write))
{
// 缓冲区大小(可以根据需要调整)
byte[] buffer = new byte[4096];
int bytesRead;
// 从响应流中读取数据并写入文件
while ((bytesRead = responseStream.Read(buffer, 0, buffer.Length)) > 0)
{
fileStream.Write(buffer, 0, bytesRead);
}
}
Console.WriteLine($"File downloaded and saved to: {savePath}");
}
catch (WebException ex)
{
Console.WriteLine($"WebException: {ex.Message}");
if (ex.Response != null)
{
using (var errorResponse = (HttpWebResponse)ex.Response)
using (var reader = new StreamReader(errorResponse.GetResponseStream()))
{
string errorText = reader.ReadToEnd();
Console.WriteLine($"Error details: {errorText}");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}

View File

@ -8,12 +8,13 @@
<OutputType>WinExe</OutputType>
<RootNamespace>AdbTools</RootNamespace>
<AssemblyName>AdbTools</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -28,7 +29,6 @@
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.1</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@ -40,6 +40,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
@ -49,6 +50,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
@ -57,10 +59,10 @@
<StartupObject>AdbTools.App</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>ico.ico</ApplicationIcon>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>1B0D79BFE5D45799D0892F29742D83306C8BFE72</ManifestCertificateThumbprint>
<ManifestCertificateThumbprint>737999CE000B08BB39DC1FD926B611A4EA3D170C</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>
@ -70,21 +72,45 @@
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>AdbTools_TemporaryKey.pfx</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -102,6 +128,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AccessInterface\RequestJson.cs" />
<Page Include="CustomControl\HintComboBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -130,6 +157,9 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="bean\Device.cs" />
<Compile Include="bean\GithubReleasesAssets.cs" />
<Compile Include="bean\GithubReleases.cs" />
<Compile Include="CmdExecutor.cs" />
<Compile Include="CustomControl\HintComboBox.xaml.cs">
<DependentUpon>HintComboBox.xaml</DependentUpon>
@ -151,6 +181,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="resource\ControlStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@ -170,7 +204,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="AdbTools_TemporaryKey.pfx" />
<None Include="App.config" />
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
@ -188,10 +221,8 @@
<Content Include="AdbWinUsbApi.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dotNetFx40 在线安装包.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="ico.ico" />
<Resource Include="resource\imgs\new_version.png" />
<Resource Include="icon.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
@ -200,5 +231,11 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Update\Update.csproj">
<Project>{f22c4131-d4cc-426e-8fc4-5c2e60c6b0ce}</Project>
<Name>Update</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>

View File

@ -4,6 +4,25 @@
xmlns:local="clr-namespace:AdbTools"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="resource/ControlStyle.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<!--所有button应用-->
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource UserButtonStyle}"/>
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource UserMenuItemStyle}"/>
<!--<Style TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource UserComboBoxItem}"/>-->
<!--<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource UserComboBox}"/>-->
<!--<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource UserTextBox}"/>-->
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@ -2,7 +2,11 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
namespace AdbTools
@ -12,5 +16,82 @@ namespace AdbTools
/// </summary>
public partial class App : Application
{
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(System.IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(System.IntPtr hWnd);
public static string Version => Assembly.GetExecutingAssembly().GetName().Version.ToString(3);
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
try
{
Process current = Process.GetCurrentProcess();
Process[] createMeetingProcess = Process.GetProcessesByName(current.ProcessName);
if (createMeetingProcess.Count() > 1)
{
HandleRunningInstance(createMeetingProcess[0]);
Application.Current.Shutdown();
return;
}
}
catch { }
//UI线程未捕获异常处理事件UI主线程
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
//非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
//Task线程内未捕获异常处理事件
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
}
private void HandleRunningInstance(Process instance)
{
ShowWindowAsync(instance.MainWindowHandle, 1); //调用api函数正常显示窗口
SetForegroundWindow(instance.MainWindowHandle); //将窗口放置最前端
}
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("未捕获Task线程异常" + e.ToString() + "\r\n异常消息" + e.Exception.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}));
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
Environment.Exit(0);
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("未捕获非UI线程异常" + e.ToString() + "\r\n对象" + e.ExceptionObject, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}));
}
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
var comException = e.Exception as System.Runtime.InteropServices.COMException;
if (comException != null && comException.ErrorCode == -2147221040)
{
e.Handled = true;
return;
}
e.Handled = true;
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("未捕获UI线程异常" + e.ToString() + "\r\n异常消息" + e.Exception.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}));
}
}
}

View File

@ -1,45 +1,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
namespace AdbTools
{
public delegate void ExecuteResult(string result);
public delegate bool ExecuteErrResult(string err);
public class CmdExecutor
{
public static string ExecuteCommandAndReturn(string command)
{
return ExecuteCommandAndReturn(new string[] { command });
}
public static string ExecuteCommandAndReturn(string[] command)
{
using (Process process = new Process())
{
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
foreach (string com in command)
{
process.StandardInput.WriteLine(com);
Thread.Sleep(150);
}
process.StandardInput.WriteLine("exit");
return process.StandardOutput.ReadToEnd();
}
}
public static void ExecuteCommandAndReturnAsync(string command)
{
@ -51,7 +22,12 @@ namespace AdbTools
ExecuteCommandAndReturnAsync(new string[] { command }, executeResult, null);
}
public static void ExecuteCommandAndReturnAsync(string[] command, ExecuteResult executeResult, ExecuteResult errorResult)
public static void ExecuteCommandAndReturnAsync(string command, ExecuteResult executeResult, ExecuteErrResult errorResult)
{
ExecuteCommandAndReturnAsync(new string[] { command }, executeResult, errorResult);
}
public static void ExecuteCommandAndReturnAsync(string[] command, ExecuteResult executeResult, ExecuteErrResult errorResult, int timeout = 5)
{
new Thread(() =>
{
@ -69,21 +45,36 @@ namespace AdbTools
foreach (string com in command)
{
process.StandardInput.WriteLine(com);
Thread.Sleep(150);
Thread.Sleep(50);
}
process.StandardInput.WriteLine("exit");
process.StandardInput.Close(); // 关闭输入流
string ret = process.StandardOutput.ReadToEnd();
string err = process.StandardError.ReadToEnd();
Console.WriteLine($"result : {ret}");
Console.WriteLine($"err : {err}");
if (!process.WaitForExit(timeout * 1000)) // 等待5秒
{
process.Kill(); // 强制终止进程
}
Application.Current.Dispatcher.Invoke(new Action(() =>
{
bool dispose = false;
if (!string.IsNullOrWhiteSpace(err))
{
errorResult?.Invoke(err);
if (null != errorResult)
{
dispose = errorResult.Invoke(err);
}
}
if (!dispose)
{
executeResult?.Invoke(ret);
}
executeResult?.Invoke(ret);
}));
}
}).Start();
@ -103,5 +94,38 @@ namespace AdbTools
}
}
public static bool StartExe(string exePath)
{
return StartExe(exePath, new List<string>());
}
public static bool StartExe(string exePath, List<string> cmdArges)
{
string args = "";
foreach (string a in cmdArges)
{
args += a + " ";
}
// 创建ProcessStartInfo对象
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = exePath,
Arguments = args,
UseShellExecute = true // 使用操作系统shell启动
};
try
{
// 启动外部程序
Process.Start(startInfo);
return true;
}
catch (Exception ex)
{
//MessageBox.Show("启动程序时出错: " + ex.Message);
return false;
}
}
}
}

View File

@ -20,6 +20,7 @@ namespace AdbTools
{
private static string _LAST_DEVICE_ADDRESS = null;
private static List<string> _DEVICE_ADDRESS_HISTORY = null;
private static string _GITHUB_PROXY = null;
/// <summary>
///
/// </summary>
@ -73,6 +74,42 @@ namespace AdbTools
}
}
/// <summary>
///
/// </summary>
public static string GITHUB_PROXY
{
get
{
if (null == _GITHUB_PROXY)
{
_GITHUB_PROXY = GetKeyVlaue("GITHUB_PROXY");
}
if (null == _GITHUB_PROXY)
{
_GITHUB_PROXY = "https://ghfast.top/";
}
return _GITHUB_PROXY;
}
set
{
UpdateAppConfig("GITHUB_PROXY", value);
_GITHUB_PROXY = value;
}
}
/// <summary>
///
/// </summary>
public static bool IS_GITHUB_PROXY
{
get
{
string v = GetKeyVlaue("GITHUB_PROXY");
return null != v;
}
}
/// <summary>
/// 获取配置的值
/// </summary>

View File

@ -5,55 +5,120 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AdbTools" xmlns:customcontrol="clr-namespace:AdbTools.CustomControl"
mc:Ignorable="d"
Title="Adb无线连接工具" Height="450" Width="350" FontSize="16" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Unloaded="Window_Unloaded">
Title="Adb连接工具" Height="460" Width="350" FontSize="16" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" Unloaded="Window_Unloaded" >
<Window.Resources>
<ContextMenu x:Key="ListBoxItemContextMenu" FontSize="16">
<ContextMenu x:Key="ListBoxItemContextMenu" FontSize="13">
<MenuItem x:Name="installApkItem" Header="安装应用" Click="installApkItem_Click" Cursor="Hand" Margin="0,2" />
<MenuItem x:Name="disconnectDeviceItem" Header="断开设备" Click="disconnectDeviceItem_Click" Cursor="Hand" Margin="0,2"/>
<Separator Margin="0,5"/>
<MenuItem Header="查看日志" Cursor="Hand" Margin="0,2" >
<MenuItem x:Name="logcatItem" Header="实时日志" Cursor="Hand" Margin="0,2" Click="logcatItem_Click" />
<MenuItem x:Name="logcatDebugItem" Header="Debug日志" Cursor="Hand" Margin="0,2" Click="logcatDebugItem_Click" />
</MenuItem>
<Separator Margin="0,5"/>
<MenuItem Header="恢复默认" Cursor="Hand" Margin="0,2" >
<MenuItem x:Name="resetPortItem" Header="恢复默认TCP端口" Cursor="Hand" Margin="0,2" Click="resetPortItem_Click" />
<MenuItem x:Name="resetPXItem" Header="恢复默认分辨率" Cursor="Hand" Margin="0,2" Click="resetPXItem_Click" />
<MenuItem x:Name="resetDPIItem" Header="恢复默认DPI" Cursor="Hand" Margin="0,2" Click="resetDPIItem_Click"/>
</MenuItem>
<Separator Margin="0,5"/>
<MenuItem x:Name="disconnectAllDeviceItem" Header="断开所有设备" Click="disconnectAllDeviceItem_Click" Cursor="Hand" Margin="0,2" />
</ContextMenu>
<ContextMenu x:Key="ComboBoxItemContextMenu" FontSize="16">
<ContextMenu x:Key="ComboBoxItemContextMenu" FontSize="13">
<MenuItem x:Name="deleteHistory" Header="删除记录" Cursor="Hand" Margin="0,2" Click="deleteHistory_Click"/>
<Separator Margin="0,5"/>
<MenuItem x:Name="deleteAllHistory" Header="清空所有记录" Click="deleteAllHistory_Click" Cursor="Hand" Margin="0,2"/>
</ContextMenu>
</Window.Resources>
<Window.InputBindings>
<KeyBinding Command="{x:Static local:MainWindow.CommandF5}"
Key="F5"/>
<KeyBinding Command="{x:Static local:MainWindow.CommandF8}"
Key="F8"/>
</Window.InputBindings>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.ColumnSpan="3" Margin="0,0,0,10">
<Label Content="IP和端口" Margin="10,10,249,0" VerticalAlignment="Top" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="deviceAddress" IsEditable="True" ToolTip="示例192.168.0.1:5555使用英文【:】连接IP和端口" Margin="100,10,10,0" IsSynchronizedWithCurrentItem="False" Height="30" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >
<Grid Grid.Row="0" x:Name="menuHeader" Background="#FFF6F6F6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Button x:Name="setup" Content="设置" Cursor="Hand" Background="{x:Null}" Margin="10,0,0,0" Click="setup_Click"/>
<Popup x:Name="setup_popup" Placement="Bottom" PlacementTarget="{Binding ElementName=setup}" StaysOpen="False" HorizontalOffset="0" VerticalOffset="0" AllowsTransparency="True">
<Border Background="{Binding ElementName=menuHeader,Path=Background}" Padding="10" CornerRadius="0,0,5,5" BorderBrush="#FF06AB26" BorderThickness="1,0,1,1">
<StackPanel>
<CheckBox IsChecked="False" x:Name="topmastCB" Content="置顶显示" Cursor="Hand" Click="topmastCB_Click" VerticalContentAlignment="Center" HorizontalAlignment="Left" FontSize="14"/>
</StackPanel>
</Border>
</Popup>
<Button x:Name="about" Content="关于" Cursor="Hand" Background="{x:Null}" Margin="10,0,0,0" Click="about_Click"/>
<Popup x:Name="about_popup" Placement="Bottom" PlacementTarget="{Binding ElementName=about}" StaysOpen="False" HorizontalOffset="0" VerticalOffset="0" AllowsTransparency="True">
<Border Background="{Binding ElementName=menuHeader,Path=Background}" Padding="10" CornerRadius="0,0,5,5" BorderBrush="#FF06AB26" BorderThickness="1,0,1,1">
<StackPanel Cursor="">
<Button x:Name="projectAddress" Content="项目地址" Background="{x:Null}" Click="projectAddress_Click" HorizontalAlignment="Left" Cursor="Hand" FontSize="14"/>
<Button x:Name="cheackUpdate" Content="检查更新" Margin="0,10,0,0" Background="{x:Null}" Click="cheackUpdate_Click" HorizontalAlignment="Left" Cursor="Hand" FontSize="14"/>
</StackPanel>
</Border>
</Popup>
</StackPanel>
<Image x:Name="updateVersion" Grid.Column="1" Visibility="Collapsed" Source="/resource/imgs/new_version.png" VerticalAlignment="Center" HorizontalAlignment="Center" Width="25" Height="25" MouseDown="updateVersion_MouseDown" />
</Grid>
<Grid Grid.Row="1" Grid.ColumnSpan="3" Margin="0,0,0,10">
<Label Content="IP和端口" Margin="10,10,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="85"/>
<ComboBox x:Name="deviceAddress" IsEditable="True" ToolTip="示例192.168.0.1:5555使用英文【:】连接IP和端口" Margin="100,10,10,0" IsSynchronizedWithCurrentItem="False" Height="30" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderBrush="{x:Null}" Background="{x:Null}" TabIndex="0" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" ContextMenu="{StaticResource ComboBoxItemContextMenu}" Cursor="Hand" Margin="0,0,0,0"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label Content="配对码" Margin="10,50,249,0" VerticalAlignment="Top" HorizontalContentAlignment="Center"/>
<TextBox x:Name="pairCode" Margin="100,50,10,0" Height="30" ToolTip="配对设备时输入配对码" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" MaxLength="10"/>
<Button x:Name="connectDevice" IsDefault="True" Content="连接设备" ToolTip="输入连接的IP和端口进行连接" Margin="10,90,0,0" VerticalAlignment="Top" Height="30" HorizontalAlignment="Left" Width="90" Click="connectDevice_Click" Cursor="Hand"/>
<Button x:Name="pairDevice" Content="配对设备" ToolTip="输入配对的IP和端口进行配对" Margin="0,90,10,0" VerticalAlignment="Top" Height="30" HorizontalAlignment="Right" Width="90" Click="pairDevice_Click" Cursor="Hand"/>
<Label Content="配对码" Margin="10,50,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="85"/>
<TextBox x:Name="pairCode" Margin="100,50,10,0" Height="30" ToolTip="配对设备时输入配对码" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" MaxLength="10" TabIndex="1"/>
<Button x:Name="connectDevice" IsDefault="True" Content="连接(Enter)" ToolTip="输入连接的IP和端口进行连接" Foreground="White" Background="#FF2A9FFF" Margin="10,90,0,0" VerticalAlignment="Top" Height="30" HorizontalAlignment="Left" Width="100" Click="connectDevice_Click" Cursor="Hand" TabIndex="2"/>
<Button x:Name="refreshList" Content="刷新(F5)" ToolTip="刷新已连接列表" Margin="0,90,0,10" Width="100" Cursor="Hand" Height="30" VerticalAlignment="Bottom" Click="refreshList_Click" Foreground="White" BorderBrush="{x:Null}" Background="#FF06AB26" TabIndex="5"/>
<Button x:Name="pairDevice" Content="配对(F8)" ToolTip="输入配对的IP和端口进行配对" Margin="0,90,10,0" Foreground="White" Background="#FFE87D00" VerticalAlignment="Top" Height="30" HorizontalAlignment="Right" Width="100" Click="pairDevice_Click" Cursor="Hand" TabIndex="3"/>
</Grid>
<Grid Grid.Row="1" Grid.ColumnSpan="3">
<Label Content="已连接列表" Margin="10,5,10,0" VerticalAlignment="Top" HorizontalContentAlignment="Center"/>
<ListBox x:Name="deviceList" Margin="10,40,10,50" ToolTip="右键连接的设备进行操作">
<Grid Grid.Row="2" Grid.ColumnSpan="3">
<Label Content="连接列表" Margin="10,0,10,0" VerticalAlignment="Top" HorizontalContentAlignment="Center"/>
<ListBox x:Name="deviceList" Margin="10,35,10,10" ToolTip="右键连接的设备进行操作" ItemsSource="{Binding}" HorizontalContentAlignment="Center" TabIndex="4" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" ContextMenu="{StaticResource ListBoxItemContextMenu}" Cursor="Hand" Margin="0,0,0,0" Width="auto"/>
<Grid Cursor="Hand" Width="300" Margin="0,5" ContextMenu="{StaticResource ListBoxItemContextMenu}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<StackPanel>
<TextBlock Text="{Binding Path=DeviceInfo, Mode=Default}" TextWrapping="Wrap"/>
<TextBlock Text="{Binding Path=DeviceMark, Mode=Default}" TextWrapping="Wrap" Foreground="#FF2A9FFF" FontSize="13"/>
</StackPanel>
</Grid>
<Grid Grid.Column="1" Margin="0">
<Label Content="{Binding Path=ConnectWay}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Foreground="{Binding Path=ConnectWayColor}"/>
</Grid>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button x:Name="refreshList" Content="刷新列表" ToolTip="刷新已连接列表" Margin="0,0,0,10" Width="90" Cursor="Hand" Height="30" VerticalAlignment="Bottom" Click="refreshList_Click"/>
</Grid>
</Grid>
<Grid Grid.RowSpan="2" Visibility="Collapsed" x:Name="processBarGrid" Background="#7F000000" >
<Grid Grid.RowSpan="3" Visibility="Collapsed" x:Name="processBarGrid" Background="#7F000000" >
<customcontrol:RoundProcessBarLoading x:Name="waitProcessBar" Height="130" Width="130"/>
<Label Content="处理中" Height="120" Width="120" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"/>
</Grid>

View File

@ -1,4 +1,6 @@
using Microsoft.Win32;
using AdbTools.AccessInterface;
using AdbTools.bean;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -17,6 +19,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Update;
namespace AdbTools
{
@ -25,17 +28,57 @@ namespace AdbTools
/// </summary>
public partial class MainWindow : Window
{
private string adbPath = "";
public static RoutedCommand CommandF5 = new RoutedCommand();
public static RoutedCommand CommandF8 = new RoutedCommand();
public static string adbPath = "";
//private DispatcherTimer timer;
private ObservableCollection<string> deviceAddressHistory;
private ObservableCollection<string> deviceAddressList;
private ObservableCollection<Device> deviceAddressList;
public MainWindow()
{
InitializeComponent();
deviceAddressHistory = new ObservableCollection<string>();
deviceAddressList = new ObservableCollection<string>();
deviceAddressList = new ObservableCollection<Device>();
// 创建 CommandBinding 并绑定到处理程序
CommandBinding commandF5Binding = new CommandBinding(
CommandF5,
CommandF5_Executed,
CommandF5_CanExecute);
CommandBinding commandF8Binding = new CommandBinding(
CommandF8,
CommandF8_Executed,
CommandF8_CanExecute);
this.CommandBindings.Add(commandF5Binding);
this.CommandBindings.Add(commandF8Binding);
}
private void CommandF5_Executed(object sender, ExecutedRoutedEventArgs e)
{
Timer_Tick(null, null);
}
private void CommandF5_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true; // 始终可以执行
}
private void CommandF8_Executed(object sender, ExecutedRoutedEventArgs e)
{
pairDevice_Click(null, null);
}
private void CommandF8_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true; // 始终可以执行
}
private void refreshDeviceAddressHistory()
@ -50,6 +93,7 @@ namespace AdbTools
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.Title = $"{this.Title} V{App.Version}";
//adb相关资源文件
string path = AppDomain.CurrentDomain.BaseDirectory + "adb.exe";
string adbDll1 = AppDomain.CurrentDomain.BaseDirectory + "AdbWinApi.dll";
@ -60,6 +104,13 @@ namespace AdbTools
Environment.Exit(0);
return;
}
if (!Globals.AppSettings.IS_GITHUB_PROXY)
{
Globals.AppSettings.GITHUB_PROXY = Globals.AppSettings.GITHUB_PROXY;
}
RequestJson.UpdateCheck(this, updateVersion);
adbPath = $"\"{path}\"";
deviceAddress.Text = Globals.AppSettings.LAST_DEVICE_ADDRESS;
@ -69,29 +120,58 @@ namespace AdbTools
deviceList.ItemsSource = deviceAddressList;
//timer = new DispatcherTimer();
//timer.Interval = TimeSpan.FromSeconds(10);
//timer.Interval = TimeSpan.FromSeconds(3);
//timer.Tick += Timer_Tick;
//timer.Start();
Timer_Tick(null, null);
}
private void Timer_Tick(object sender, EventArgs e)
{
waitAnimation(true);
deviceAddressList.Clear();
CmdExecutor.ExecuteCommandAndReturnAsync($"{adbPath} devices", content =>
string command = $"{adbPath} devices";
CmdExecutor.ExecuteCommandAndReturnAsync(command, content =>
{
// 定义正则表达式模式
string pattern = @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+\b";
// 创建 Regex 对象
Regex regex = new Regex(pattern);
// 查找所有匹配项
MatchCollection matches = regex.Matches(content);
// 输出所有匹配项
foreach (Match match in matches)
int index = 0;
List<string> list = new List<string>();
string[] str = content.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < str.Length; ++i)
{
deviceAddressList.Add(match.Value.Trim());
if (str[i].EndsWith("device"))
{
string address = str[i].Replace("device", "").Trim();
list.Add(address);
Device d = null;
if (!deviceAddressList.Any(o =>
{
d = o;
return o.DeviceMark.Equals(address);
}))
{
Device device = new Device()
{
IsWifiConnect = IsValidIPEndPoint(address),
DeviceMark = address,
ShowDeviceName = address
};
deviceAddressList.Insert(index, device);
}
else
{
deviceAddressList.Remove(d);
deviceAddressList.Insert(index, d);
}
index++;
}
}
List<Device> removeList = deviceAddressList.Where(o => !list.Contains(o.DeviceMark)).ToList();
removeList.ForEach(o => deviceAddressList.Remove(o));
foreach (Device d in deviceAddressList)
{
d.Refresh();
}
waitAnimation(false);
@ -100,12 +180,13 @@ namespace AdbTools
private void Window_Unloaded(object sender, RoutedEventArgs e)
{
//timer.Stop();
}
private void connectDevice_Click(object sender, RoutedEventArgs e)
{
string address = deviceAddress.Text;
address = address.Replace("", ":");
deviceAddress.Text = address;
if (!IsValidIPEndPoint(address))
{
MessageBox.Show("设备连接地址输入错误!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
@ -115,30 +196,37 @@ namespace AdbTools
waitAnimation(true);
CmdExecutor.ExecuteCommandAndReturnAsync($"{adbPath} connect {address}", result =>
{
Application.Current.Dispatcher.Invoke(new Action(() =>
if (string.IsNullOrWhiteSpace(result) || ContainsAny(result, new string[] { "(10060)", "(10061)", "failed to connect" }))
{
if (string.IsNullOrWhiteSpace(result) || ContainsAny(result, new string[] { "(10060)", "(10061)" }))
{
waitAnimation(false);
MessageBox.Show("设备连接失败!\r\n请检查IP和端口输入是否正确。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
Globals.AppSettings.LAST_DEVICE_ADDRESS = $"{address}";
if (!Globals.AppSettings.DEVICE_ADDRESS_HISTORY.Contains(address))
{
Globals.AppSettings.DEVICE_ADDRESS_HISTORY.Insert(0, address);
Globals.AppSettings.DEVICE_ADDRESS_HISTORY = Globals.AppSettings.DEVICE_ADDRESS_HISTORY;
refreshDeviceAddressHistory();
}
Timer_Tick(null, null);
waitAnimation(false);
}));
MessageBox.Show("设备连接失败!\r\n1.请检查IP和端口输入是否正确\r\n2.设备与电脑是否完成配对。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
Globals.AppSettings.LAST_DEVICE_ADDRESS = $"{address}";
string ip = address.Split(':')[0];
List<string> list = Globals.AppSettings.DEVICE_ADDRESS_HISTORY.Where(item => !item.StartsWith(ip)).ToList();
list.Insert(0, address);
Globals.AppSettings.DEVICE_ADDRESS_HISTORY = list;
refreshDeviceAddressHistory();
deviceAddress.Text = Globals.AppSettings.LAST_DEVICE_ADDRESS;
Timer_Tick(null, null);
waitAnimation(false);
}, (err) =>
{
waitAnimation(false);
MessageBox.Show("设备连接失败!\r\n1.请检查IP和端口输入是否正确\r\n2.设备与电脑是否完成配对。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return true;
});
}
private void pairDevice_Click(object sender, RoutedEventArgs e)
{
string address = deviceAddress.Text;
address = address.Replace("", ":");
deviceAddress.Text = address;
string code = pairCode.Text;
if (!IsValidIPEndPoint(address))
{
@ -156,7 +244,7 @@ namespace AdbTools
waitAnimation(false);
if (string.IsNullOrWhiteSpace(result) || !ContainsAny(result, new string[] { "Successfully" }))
{
MessageBox.Show("设备配对失败!\r\n请确认IP地址和端口是否处于配对状态并且配对码输入正确", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
MessageBox.Show("设备配对失败!\r\n1.确认IP地址和端口是否处于配对状态\r\n2.配对码输入是否正确。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (ContainsAny(result, new string[] { "Successfully" }))
@ -183,10 +271,9 @@ namespace AdbTools
private void installApkItem_Click(object sender, RoutedEventArgs e)
{
var menuItem = (MenuItem)sender;
var contextMenu = (ContextMenu)menuItem.Parent;
var textBlock = (TextBlock)contextMenu.PlacementTarget;
if (MessageBoxResult.OK != MessageBox.Show($"确定要安装应用到【{textBlock.Text}】吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
int index = deviceList.SelectedIndex;
Device device = deviceAddressList[index];
if (MessageBoxResult.OK != MessageBox.Show($"确定要安装应用到设备【{device.ShowDeviceName}】吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
return;
}
@ -196,35 +283,37 @@ namespace AdbTools
return;
}
waitAnimation(true);
CmdExecutor.ExecuteCommandAndReturnAsync(new string[] { $"{adbPath} -s {textBlock.Text} install \"{path}\"" }, result =>
CmdExecutor.ExecuteCommandAndReturnAsync(new string[] { $"{adbPath} -s {device.DeviceMark} install \"{path}\"" }, result =>
{
waitAnimation(false);
if (!string.IsNullOrWhiteSpace(result) && ContainsAny(result, new string[] { "Success" }))
{
MessageBox.Show("安装应用成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk);
MessageBox.Show($"设备【{device.ShowDeviceName}】安装应用成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
},
err =>
{
waitAnimation(false);
if (!string.IsNullOrWhiteSpace(err) && ContainsAny(err, new string[] { "adb: failed to install" }))
if (!string.IsNullOrWhiteSpace(err) && ContainsAny(err, new string[] { "adb: failed to install", "device offline" }))
{
MessageBox.Show("安装应用失败!\r\n请确认安卓设备是否允许安装应用\r\n应用签名是否不符", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
MessageBox.Show($"设备【{device.ShowDeviceName}】安装应用失败!\r\n1.请确认安卓设备是否允许安装应用;\r\n2.应用签名是否不符;\r\n3.检查设备是否已离线。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return true;
}
});
return false;
}, 600);
}
private void disconnectDeviceItem_Click(object sender, RoutedEventArgs e)
{
var menuItem = (MenuItem)sender;
var contextMenu = (ContextMenu)menuItem.Parent;
var textBlock = (TextBlock)contextMenu.PlacementTarget;
if (MessageBoxResult.OK != MessageBox.Show($"确定要断开设备【{textBlock.Text}】的连接吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
int index = deviceList.SelectedIndex;
Device device = deviceAddressList[index];
if (MessageBoxResult.OK != MessageBox.Show($"确定要断开设备【{device.ShowDeviceName}】的连接吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
return;
}
waitAnimation(true);
CmdExecutor.ExecuteCommandAndReturnAsync($"{adbPath} disconnect {textBlock.Text}", result =>
CmdExecutor.ExecuteCommandAndReturnAsync($"{adbPath} disconnect {device.DeviceMark}", result =>
{
Timer_Tick(null, null);
waitAnimation(false);
@ -233,7 +322,7 @@ namespace AdbTools
private void disconnectAllDeviceItem_Click(object sender, RoutedEventArgs e)
{
if (MessageBoxResult.OK == MessageBox.Show("确定要断开所有设备吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
if (MessageBoxResult.OK == MessageBox.Show("确定要断开所有设备吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
waitAnimation(true);
CmdExecutor.ExecuteCommandAndReturnAsync($"{adbPath} disconnect", result =>
@ -246,6 +335,10 @@ namespace AdbTools
public static bool IsValidIPEndPoint(string ipPort)
{
if (ipPort.Contains("._adb-tls-connect._tcp"))
{
return true;
}
string[] parts = ipPort.Split(':');
if (parts.Length > 2)
{
@ -299,7 +392,7 @@ namespace AdbTools
private void deleteAllHistory_Click(object sender, RoutedEventArgs e)
{
if (MessageBoxResult.OK == MessageBox.Show("确定要清空所有历史纪录吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
if (MessageBoxResult.OK == MessageBox.Show("确定要清空所有历史纪录吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
Globals.AppSettings.DEVICE_ADDRESS_HISTORY.Clear();
Globals.AppSettings.DEVICE_ADDRESS_HISTORY = Globals.AppSettings.DEVICE_ADDRESS_HISTORY;
@ -331,5 +424,175 @@ namespace AdbTools
Timer_Tick(null, null);
}
private void resetPortItem_Click(object sender, RoutedEventArgs e)
{
int index = deviceList.SelectedIndex;
Device device = deviceAddressList[index];
if (MessageBoxResult.OK == MessageBox.Show($"确定要对设备【{device.ShowDeviceName}】执行【恢复默认TCP端口(5555)】吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
waitAnimation(true);
CmdExecutor.ExecuteCommandAndReturnAsync(new string[] { $"{adbPath} -s {device.DeviceMark} tcpip 5555 " }, result =>
{
waitAnimation(false);
MessageBox.Show($"设备【{device.ShowDeviceName}】恢复默认TCP端口(5555)成功", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk);
},
err =>
{
waitAnimation(false);
MessageBox.Show($"设备【{device.ShowDeviceName}】恢复默认TCP端口(5555)失败!\r\n检查设备是否已离线。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return true;
});
}
}
private void resetPXItem_Click(object sender, RoutedEventArgs e)
{
int index = deviceList.SelectedIndex;
Device device = deviceAddressList[index];
if (MessageBoxResult.OK == MessageBox.Show($"确定要对设备【{device.ShowDeviceName}】执行【恢复默认分辨率】吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
waitAnimation(true);
CmdExecutor.ExecuteCommandAndReturnAsync(new string[] { $"{adbPath} -s {device.DeviceMark} shell wm size reset " }, result =>
{
waitAnimation(false);
MessageBox.Show($"设备【{device.ShowDeviceName}】恢复默认分辨率成功", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk);
},
err =>
{
waitAnimation(false);
MessageBox.Show($"设备【{device.ShowDeviceName}】恢复默认分辨率失败!\r\n检查设备是否已离线。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return true;
});
}
}
private void resetDPIItem_Click(object sender, RoutedEventArgs e)
{
int index = deviceList.SelectedIndex;
Device device = deviceAddressList[index];
if (MessageBoxResult.OK == MessageBox.Show($"确定要对设备【{device.ShowDeviceName}】执行【恢复默认DPI】吗", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
waitAnimation(true);
CmdExecutor.ExecuteCommandAndReturnAsync(new string[] { $"{adbPath} -s {device.DeviceMark} shell wm density reset " }, result =>
{
waitAnimation(false);
MessageBox.Show($"设备【{device.ShowDeviceName}】恢复默认DPI成功", "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk);
},
err =>
{
waitAnimation(false);
MessageBox.Show($"设备【{device.ShowDeviceName}】恢复默认DPI失败\r\n检查设备是否已离线。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
return true;
});
}
}
private void logcatItem_Click(object sender, RoutedEventArgs e)
{
int index = deviceList.SelectedIndex;
Device device = deviceAddressList[index];
CmdExecutor.ExecuteCommandByShell($"{adbPath} -s {device.DeviceMark} logcat");
}
private void logcatDebugItem_Click(object sender, RoutedEventArgs e)
{
int index = deviceList.SelectedIndex;
Device device = deviceAddressList[index];
CmdExecutor.ExecuteCommandByShell($"{adbPath} -s {device.DeviceMark} logcat -s DEBUG");
}
#region
private void updateVersion_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
GithubReleases githubReleases = (GithubReleases)updateVersion.Tag;
UpdateVersion(githubReleases);
}
}
private void UpdateVersion(GithubReleases githubReleases)
{
if (null == githubReleases) return;
GithubReleasesAssets githubReleasesAssets = null;
foreach (GithubReleasesAssets assets in githubReleases.Assets)
{
if (RequestJson.UpdateFileName.Equals(assets.Name, StringComparison.CurrentCultureIgnoreCase))
{
githubReleasesAssets = assets;
}
}
if (null == githubReleasesAssets)
{
return;
}
updateVersion.Visibility = Visibility.Visible;
updateVersion.Tag = githubReleases;
if (MessageBoxResult.OK != MessageBox.Show($"发现新版本【V{githubReleases.Name}】是否更新?", "新版本", MessageBoxButton.OKCancel, MessageBoxImage.Question))
{
return;
}
List<string> cmdArges = new List<string>();
//cmdArges.Add($"{Globals.AppSettings.GITHUB_PROXY}{githubReleasesAssets.browser_download_url}");
cmdArges.Add($"{githubReleasesAssets.browser_download_url}");
cmdArges.Add($"{AppDomain.CurrentDomain.BaseDirectory}");
cmdArges.Add($"{AppDomain.CurrentDomain.BaseDirectory}{AppDomain.CurrentDomain.FriendlyName}");
if (CmdExecutor.StartExe($"{AppDomain.CurrentDomain.BaseDirectory}Update.exe", cmdArges))
{
Application.Current.Shutdown();
}
else
{
}
}
#endregion
#region
private void about_Click(object sender, RoutedEventArgs e)
{
about_popup.IsOpen = true;
}
private void projectAddress_Click(object sender, RoutedEventArgs e)
{
about_popup.IsOpen = false;
CmdExecutor.StartExe("https://github.com/zsjy/AdbTools");
}
private void cheackUpdate_Click(object sender, RoutedEventArgs e)
{
about_popup.IsOpen = false;
RequestJson.UpdateCheck(this, githubReleases =>
{
UpdateVersion(githubReleases);
});
}
#endregion
#region
private void setup_Click(object sender, RoutedEventArgs e)
{
setup_popup.IsOpen = true;
}
private void topmastCB_Click(object sender, RoutedEventArgs e)
{
this.Topmost = (bool)topmastCB.IsChecked;
setup_popup.IsOpen = false;
}
#endregion
}
}

View File

@ -8,11 +8,11 @@ using System.Windows;
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("AdbTools")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Adb无线连接工具")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("宏尘极客")]
[assembly: AssemblyProduct("AdbTools")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyCopyright("Copyright © 宏尘极客 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -51,5 +51,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyVersion("1.1.2")]
[assembly: AssemblyFileVersion("1.1.2")]

View File

@ -1,68 +1,61 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// 对此文件的更改可能导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AdbTools.Properties
{
namespace AdbTools.Properties {
using System;
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// 一个强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AdbTools.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}

View File

@ -1,27 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace AdbTools.Properties
{
namespace AdbTools.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.13.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}

140
AdbTools/bean/Device.cs Normal file
View File

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Media;
namespace AdbTools.bean
{
public class Device : INotifyPropertyChanged
{
public string DeviceMark
{
get;
set;
}
public string DeviceBrand
{
get;
set;
}
public string DeviceModel
{
get;
set;
}
public bool IsWifiConnect
{
get;
set;
}
public string ShowDeviceName
{
get;
set;
}
public string ConnectWay
{
get;
set;
}
public Brush ConnectWayColor
{
get;
set;
}
public string DeviceInfo
{
get;
set;
}
public void Refresh()
{
UpdateShow();
new Thread(() =>
{
if (string.IsNullOrWhiteSpace(DeviceBrand))
{
CmdExecutor.ExecuteCommandAndReturnAsync($"{MainWindow.adbPath} -s {DeviceMark} shell getprop ro.product.brand ", result =>
{
string[] str = result.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
string s = "";
for (int i = 0; i < str.Length; ++i)
{
if (str[i].Contains("shell getprop ro.product.brand") && i < str.Length)
{
s = str[i + 1];
}
}
Application.Current.Dispatcher.Invoke(new Action(() =>
{
DeviceBrand = s;
UpdateShow();
}));
});
}
if (string.IsNullOrWhiteSpace(DeviceModel))
{
CmdExecutor.ExecuteCommandAndReturnAsync($"{MainWindow.adbPath} -s {DeviceMark} shell getprop ro.product.model ", result =>
{
string[] str = result.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
string s = "";
for (int i = 0; i < str.Length; ++i)
{
if (str[i].Contains("shell getprop ro.product.model") && i < str.Length)
{
s = str[i + 1];
}
}
Application.Current.Dispatcher.Invoke(new Action(() =>
{
DeviceModel = s;
UpdateShow();
}));
});
}
}).Start();
}
private void UpdateShow()
{
string s = "";
s += DeviceBrand;
s += (string.IsNullOrWhiteSpace(s) ? "" : " ") + DeviceModel;
DeviceInfo = s;
ConnectWay = IsWifiConnect ? "WiFi" : "USB";
ConnectWayColor = IsWifiConnect ? Brushes.Green : Brushes.Orange;
s += $" {ConnectWay}";
s += string.IsNullOrWhiteSpace(s) ? $"{DeviceMark}" : $" ({DeviceMark})";
ShowDeviceName = s;
OnPropertyChanged(string.Empty);
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AdbTools.bean
{
public class GithubReleases
{
/// <summary>
/// 发布的名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 上传构件
/// </summary>
public List<GithubReleasesAssets> Assets { get; set; }
/// <summary>
/// 发布的说明Markdown
/// </summary>
public string Body { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AdbTools.bean
{
public class GithubReleasesAssets
{
/// <summary>
/// 上传构件名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 上传构件下载地址
/// </summary>
public string browser_download_url { get; set; }
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

BIN
AdbTools/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,164 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Style x:Key="UserButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" CornerRadius="5" BorderThickness="0" BorderBrush="Black"
Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.8" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Background" Value="#FFCFCFCF" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="UserMenuItemStyle" TargetType="{x:Type MenuItem}">
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style x:Key="UserLabelStyle" TargetType="{x:Type Label}">
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style x:Key="UserGridStyle" TargetType="{x:Type Grid}">
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style x:Key="UserComboBoxItem" TargetType="{x:Type ComboBoxItem}">
<Setter Property="Cursor" Value="Hand" />
</Style>
<!--<Style x:Key="UserComboBox" TargetType="{x:Type ComboBox}">
<Setter Property="Cursor" Value="Hand" />
</Style>-->
<Style x:Key="UserTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid FocusManager.FocusedElement="{Binding ElementName=border}">
<Border x:Name="border" CornerRadius="5" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--ComboBox-->
<!--ComBoBox toggleButton样式-->
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Grid Height="25" >
<Border Grid.Column="1" Background="Transparent" Opacity="0" Cursor="Hand"/>
<Border Padding="0 0 5 0">
<Path x:Name="Arrow" Grid.Column="1" Data="M 0 0 6 6 12 0 Z" VerticalAlignment="Center" HorizontalAlignment="Right" Stretch="None" Fill="#FFB1B1B1" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="Arrow" Property="RenderTransform">
<Setter.Value>
<RotateTransform CenterX="6" CenterY="3" Angle="180"></RotateTransform>
</Setter.Value>
</Setter>
<Setter TargetName="Arrow" Property="Margin" Value="0 0 0 2"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="UserComboBox" TargetType="{x:Type ComboBox}">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ComboBoxItem">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Height" Value="auto"/>
<Setter Property="MinHeight" Value="25"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Grid Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<Border x:Name="_borderbg" Background="Transparent"/>
<TextBlock Margin="3 0 3 0" VerticalAlignment="Center" x:Name="_txt" Foreground="#e6e6e6" Text="{Binding Content,RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Center"/>
<Border x:Name="_border" Background="White" Opacity="0"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="_borderbg" Property="Background" Value="#FF69B6FF" />
<Setter TargetName="_txt" Property="Foreground" Value="White"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="false"/>
<Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions>
<Setter TargetName="_borderbg" Property="Background" Value="#FFC1C1C1" />
<Setter TargetName="_txt" Property="Foreground" Value="White"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Border Padding="0">
<Grid Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="20" MaxWidth="30"/>
</Grid.ColumnDefinitions>
<Border x:Name="_borderbg" Grid.Column="0" Grid.ColumnSpan="2" Background="{TemplateBinding Background}" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="3"/>
<ContentPresenter Grid.Column="0" HorizontalAlignment="Center" Margin="3" x:Name="ContentSite" VerticalAlignment="Center" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" IsHitTestVisible="False"/>
<!--ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen-->
<ToggleButton Grid.Column="0" Grid.ColumnSpan="2" Template="{StaticResource ComboBoxToggleButton}" x:Name="ToggleButton" Focusable="false" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
<!--必须将 TextBox 命名为 PART_EditableTextBox否则 ComboBox 将无法识别它-->
<TextBox Visibility="Hidden" BorderThickness="0" Margin="2 0 0 0" x:Name="PART_EditableTextBox" VerticalAlignment="Center" Focusable="True" Background="Transparent" IsReadOnly="{TemplateBinding IsReadOnly}"/>
<!--Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen-->
<Popup IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" x:Name="Popup" Focusable="False" AllowsTransparency="True" PopupAnimation="Slide">
<Grid MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
<Border x:Name="DropDownBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"/>
<ScrollViewer Margin="1" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
<!--StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True-->
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="White"/>
</ScrollViewer>
</Grid>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEditable" Value="true">
<Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
</Trigger>
<!--<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="false"/>
<Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions>
<Setter TargetName="_borderbg" Property="Background" Value="#FF1492C0" />
<Setter Property="Foreground" Value="White"/>
</MultiTrigger>-->
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

4039
AdbToolsSetup.suf Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

201
LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2025 宏尘
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

1
LICENSE.rtf Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,18 +1,20 @@
### 开发环境
> 使用VS2019开发
> 使用VS2022开发
>
> 依赖`.NET4.0`
> 依赖 [.NET4.6下载](https://www.microsoft.com/zh-cn/download/details.aspx?id=48137)
### 运行环境
- 需要`.NET4.0`运行时环境;
- 需要`.NET4.6`运行时环境;
- `64位Windows`电脑运行。
### 连接准备
[观看视频](/docs/videos/1.mp4)
#### 开启开发者模式
- `设置 - 关于 - 版本号`,连续点击`7次`开启开发者模式;
#### 安卓11及以上
- `设置 - 系统 - 开发者选项`,找到`无线调试`功能,`连接WiFi`后点击`开启`,进入`无线调试`,查看`IP地址和端口`,使用此地址即可无线连接到设备。
- **注:部分设备位置不同,需要自行寻找**
#### 安卓11以下
- `连接WiFi`查看当前设备的`局域网IP地址`,使用此地址即可无线连接到设备,此时无需输入端口号。
- **注:过低版本的设备可能无法连接**

View File

@ -0,0 +1,61 @@
using System;
using System.Net;
using System.IO;
namespace Update.AccessInterface
{
/// <summary>
/// post请求
/// </summary>
public static class RequestJson
{
public static bool DownloadFile(string url, string savePath)
{
try
{
// 创建 HttpWebRequest 对象
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
// 发送请求并获取响应
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (FileStream fileStream = new FileStream(savePath, FileMode.Create, FileAccess.Write))
{
// 缓冲区大小(可以根据需要调整)
byte[] buffer = new byte[4096];
int bytesRead;
// 从响应流中读取数据并写入文件
while ((bytesRead = responseStream.Read(buffer, 0, buffer.Length)) > 0)
{
fileStream.Write(buffer, 0, bytesRead);
}
}
return true;
}
catch (WebException ex)
{
Console.WriteLine($"WebException: {ex.Message}");
if (ex.Response != null)
{
using (var errorResponse = (HttpWebResponse)ex.Response)
using (var reader = new StreamReader(errorResponse.GetResponseStream()))
{
string errorText = reader.ReadToEnd();
Console.WriteLine($"Error details: {errorText}");
}
}
return false;
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
return false;
}
}
}
}

6
Update/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>

9
Update/App.xaml Normal file
View File

@ -0,0 +1,9 @@
<Application x:Class="Update.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Update"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

114
Update/App.xaml.cs Normal file
View File

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
namespace Update
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(System.IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(System.IntPtr hWnd);
public static string downloadUrl;
public static string unZipPath;
public static string startExePath;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
try
{
if (e.Args.Count() < 2)
{
///退出当前新开进程不走OnExit方法
Environment.Exit(0);
//Application.Current.Shutdown();
return;
}
downloadUrl = e.Args[0];
unZipPath = e.Args[1];
if (e.Args.Count() > 2) {
startExePath = e.Args[2];
}
Process current = Process.GetCurrentProcess();
Process[] createMeetingProcess = Process.GetProcessesByName(current.ProcessName);
if (createMeetingProcess.Count() > 1)
{
HandleRunningInstance(createMeetingProcess[0]);
///退出当前新开进程不走OnExit方法
Environment.Exit(0);
//Application.Current.Shutdown();
return;
}
}
catch { }
//UI线程未捕获异常处理事件UI主线程
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
//非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
//Task线程内未捕获异常处理事件
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
}
private void HandleRunningInstance(Process instance)
{
ShowWindowAsync(instance.MainWindowHandle, 1); //调用api函数正常显示窗口
SetForegroundWindow(instance.MainWindowHandle); //将窗口放置最前端
}
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("未捕获Task线程异常" + e.ToString() + "\r\n异常消息" + e.Exception.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}));
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
Environment.Exit(0);
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("未捕获非UI线程异常" + e.ToString() + "\r\n对象" + e.ExceptionObject, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}));
}
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
var comException = e.Exception as System.Runtime.InteropServices.COMException;
if (comException != null && comException.ErrorCode == -2147221040)
{
e.Handled = true;
return;
}
e.Handled = true;
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("未捕获UI线程异常" + e.ToString() + "\r\n异常消息" + e.Exception.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}));
}
}
}

View File

@ -0,0 +1,211 @@
<UserControl x:Class="Update.CustomControl.RoundProcessBarLoading"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800">
<Viewbox>
<Grid Height="800" Width="800">
<Grid x:Name="animationGrid" Visibility="Collapsed">
<Rectangle Name="Rect1" Height="200" Width="120" Fill="#FFC4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:IsLocked="True"/>
<Rectangle Name="Rect2" Height="200" Width="120" Fill="#20C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="45"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Name="Rect3" Height="200" Width="120" Fill="#40C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Name="Rect4" Height="200" Width="120" Fill="#60C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="135"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Name="Rect5" Height="200" Width="120" Fill="#80C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="180"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Name="Rect6" Height="200" Width="120" Fill="#A0C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="225"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Name="Rect7" Height="200" Width="120" Fill="#C0C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="270"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Name="Rect8" Height="200" Width="120" Fill="#E0C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="315"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Grid.Triggers>
<EventTrigger RoutedEvent="Page.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<!--Rect1-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect1" Duration="0:0:1" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<!--Rect2-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect2" Duration="0:0:0.125" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<ColorAnimation BeginTime="0:0:0.125" Storyboard.TargetName="Rect2" Duration="0:0:0.875" Storyboard.TargetProperty="Fill.Color" From="#FFC4C4C4" To="#20C4C4C4"/>
<!--Rect3-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect3" Duration="0:0:0.250" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<ColorAnimation BeginTime="0:0:0.250" Storyboard.TargetName="Rect3" Duration="0:0:0.750" Storyboard.TargetProperty="Fill.Color" From="#FFC4C4C4" To="#40C4C4C4"/>
<!--Rect4-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect4" Duration="0:0:0.375" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<ColorAnimation BeginTime="0:0:0.375" Storyboard.TargetName="Rect4" Duration="0:0:0.625" Storyboard.TargetProperty="Fill.Color" From="#FFC4C4C4" To="#60C4C4C4"/>
<!--Rect5-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect5" Duration="0:0:0.500" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<ColorAnimation BeginTime="0:0:0.500" Storyboard.TargetName="Rect5" Duration="0:0:0.500" Storyboard.TargetProperty="Fill.Color" From="#FFC4C4C4" To="#80C4C4C4"/>
<!--Rect6-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect6" Duration="0:0:0.625" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<ColorAnimation BeginTime="0:0:0.625" Storyboard.TargetName="Rect6" Duration="0:0:0.375" Storyboard.TargetProperty="Fill.Color" From="#FFC4C4C4" To="#A0C4C4C4"/>
<!--Rect7-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect7" Duration="0:0:0.750" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<ColorAnimation BeginTime="0:0:0.750" Storyboard.TargetName="Rect7" Duration="0:0:0.250" Storyboard.TargetProperty="Fill.Color" From="#FFC4C4C4" To="#C0C4C4C4"/>
<!--Rect8-->
<ColorAnimation BeginTime="0:0:0.0" Storyboard.TargetName="Rect8" Duration="0:0:0.875" Storyboard.TargetProperty="Fill.Color" To="#00C4C4C4"/>
<ColorAnimation BeginTime="0:0:0.875" Storyboard.TargetName="Rect8" Duration="0:0:0.125" Storyboard.TargetProperty="Fill.Color" From="#FFC4C4C4" To="#E0C4C4C4"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
<Grid x:Name="defaultGrid" Visibility="Visible">
<Rectangle Height="200" Width="120" Fill="#FFC4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:IsLocked="True"/>
<Rectangle Height="200" Width="120" Fill="#20C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="45"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Height="200" Width="120" Fill="#40C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Height="200" Width="120" Fill="#60C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="135"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Height="200" Width="120" Fill="#80C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="180"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Height="200" Width="120" Fill="#A0C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="225"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Height="200" Width="120" Fill="#C0C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="270"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Height="200" Width="120" Fill="#E0C4C4C4" RadiusY="60" RadiusX="60" VerticalAlignment="Top" d:LayoutOverrides="Width" RenderTransformOrigin="0.5,2">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="315"/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</Grid>
</Viewbox>
</UserControl>

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Update.CustomControl
{
/// <summary>
/// RoundProcessBarLoading.xaml 的交互逻辑
/// </summary>
public partial class RoundProcessBarLoading : UserControl
{
public RoundProcessBarLoading()
{
InitializeComponent();
}
[Description("获取或设置是否显示动画")]
public bool IsShowAnimation
{
set
{
if (value)
{
this.defaultGrid.Visibility = Visibility.Collapsed;
this.animationGrid.Visibility = Visibility.Visible;
}
else
{
this.defaultGrid.Visibility = Visibility.Visible;
this.animationGrid.Visibility = Visibility.Collapsed;
}
}
get
{
return Visibility.Visible == this.animationGrid.Visibility;
}
}
}
}

14
Update/MainWindow.xaml Normal file
View File

@ -0,0 +1,14 @@
<Window x:Class="Update.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Update" xmlns:customcontrol="clr-namespace:Update.CustomControl"
mc:Ignorable="d"
Title="更新" Height="200" Width="200" FontSize="12" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded">
<Grid x:Name="processBarGrid" Background="#7F000000" >
<customcontrol:RoundProcessBarLoading x:Name="waitProcessBar" Width="80" Margin="0,20,0,0" Height="80" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<Label x:Name="tipLabel" Content="处理中" Foreground="White" Margin="10,105,9.6,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
</Grid>
</Window>

123
Update/MainWindow.xaml.cs Normal file
View File

@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Update.AccessInterface;
namespace Update
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
private Thread thread;
private string updateFilePath;
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
waitProcessBar.IsShowAnimation = true;
updateFilePath = $"{AppDomain.CurrentDomain.BaseDirectory}update.zip";
updateTip("正在下载...");
thread = new Thread(() =>
{
try
{
if (RequestJson.DownloadFile(App.downloadUrl, updateFilePath))
{
updateTip("正在解压");
Thread.Sleep(1000);
ZipFileUtils.UnzipFile(updateFilePath, App.unZipPath);
updateTip("更新完成");
if (!string.IsNullOrWhiteSpace(App.startExePath))
{
updateTip("启动程序");
Thread.Sleep(1000);
StartExe(App.startExePath, "");
}
else
{
Thread.Sleep(1000);
Quit();
}
}
else
{
updateTip("下载失败");
}
}
catch (Exception ex)
{
updateTip("更新失败,请使用全量更新");
this.Dispatcher.Invoke(new Action(() =>
{
waitProcessBar.IsShowAnimation = false;
}));
}
});
thread.Start();
}
private void updateTip(string tip)
{
this.Dispatcher.Invoke(new Action(() =>
{
tipLabel.Content = tip;
}));
}
private void StartExe(string exePath, string args)
{
this.Dispatcher.Invoke(new Action(() =>
{
// 创建ProcessStartInfo对象
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = exePath,
Arguments = args,
UseShellExecute = true // 使用操作系统shell启动
};
try
{
// 启动外部程序
Process.Start(startInfo);
///退出当前新开进程不走OnExit方法
Environment.Exit(0);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}));
}
private void Quit()
{
this.Dispatcher.Invoke(new Action(() =>
{
Application.Current.Shutdown();
}));
}
}
}

View File

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Update")]
[assembly: AssemblyDescription("更新程序")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("宏尘极客")]
[assembly: AssemblyProduct("Update")]
[assembly: AssemblyCopyright("Copyright © 宏尘极客 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
//例如,如果您在源文件中使用的是美国英语,
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]

63
Update/Properties/Resources.Designer.cs generated Normal file
View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Update.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Update.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
Update/Properties/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Update.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.13.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

120
Update/Update.csproj Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F22C4131-D4CC-426E-8FC4-5C2E60C6B0CE}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Update</RootNamespace>
<AssemblyName>Update</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>update.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="CustomControl\RoundProcessBarLoading.xaml.cs">
<DependentUpon>RoundProcessBarLoading.xaml</DependentUpon>
</Compile>
<Compile Include="ZipFileUtils.cs" />
<Page Include="CustomControl\RoundProcessBarLoading.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="AccessInterface\RequestJson.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="update.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

66
Update/ZipFileUtils.cs Normal file
View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Update
{
public class ZipFileUtils
{
public static bool UnzipFile(string zipFilePath, string extractPath)
{
try
{
// 检查 ZIP 文件是否存在
if (!File.Exists(zipFilePath))
{
throw new FileNotFoundException($"ZIP file not found: {zipFilePath}");
}
// 检查目标文件夹是否存在,如果不存在则创建
if (!Directory.Exists(extractPath))
{
Directory.CreateDirectory(extractPath);
}
// 打开 ZIP 文件
using (ZipArchive archive = ZipFile.OpenRead(zipFilePath))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
string fullPath = Path.Combine(extractPath, entry.FullName);
// 如果是目录,则创建目录
if (string.IsNullOrEmpty(entry.Name))
{
Directory.CreateDirectory(fullPath);
}
else
{
// 如果是文件,检查是否已存在
if (File.Exists(fullPath))
{
File.Delete(fullPath); // 删除已存在的文件
}
// 解压文件
entry.ExtractToFile(fullPath);
}
}
}
File.Delete(zipFilePath);
return true;
}
catch (Exception ex)
{
Console.WriteLine($"Error extracting ZIP file: {ex.Message}");
throw ex;
}
}
}
}

78
Update/app.manifest Normal file
View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI无需
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

BIN
Update/update.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

BIN
docs/videos/1.mp4 Normal file

Binary file not shown.

BIN
libs/AdbWinApi.dll Normal file

Binary file not shown.

BIN
libs/AdbWinUsbApi.dll Normal file

Binary file not shown.

BIN
libs/adb.exe Normal file

Binary file not shown.

BIN
libs/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB