Commit cc5b088e authored by 黄树航's avatar 黄树航

源码+

parents
Pipeline #490 failed with stages
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="wix.bootstrapper" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore">
<section name="host" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" />
</sectionGroup>
</configSections>
<wix.bootstrapper>
<host assemblyName="Dqkj.Setup.Wpf">
<supportedFramework version="v4\Full" />
</host>
</wix.bootstrapper>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<Application x:Class="Dqkj.Setup.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Dqkj.Setup"
xmlns:prism="http://prismlibrary.com/"
StartupUri="MainWindow.xaml" >
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>-->
<ResourceDictionary Source="pack://application:,,,/Dqkj.Setup.Wpf;component/Style/ControlStyle.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
namespace Dqkj.Setup
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
public App()
{
InitializeComponent();
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dqkj.Setup.Common
{
public class DirectoryHelper
{
public static void CopyDirectory(string srcPath, string destPath)
{
try
{
DirectoryInfo dir = new DirectoryInfo(srcPath);
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //获取目录下(不包含子目录)的文件和子目录
foreach (FileSystemInfo i in fileinfo)
{
if (i is DirectoryInfo) //判断是否文件夹
{
if (!Directory.Exists(destPath + "\\" + i.Name))
{
Directory.CreateDirectory(destPath + "\\" + i.Name); //目标目录下不存在此文件夹即创建子文件夹
}
CopyDirectory(i.FullName, destPath + "\\" + i.Name); //递归调用复制子文件夹
}
else
{
File.Copy(i.FullName, destPath + "\\" + i.Name, true); //不是文件夹即复制文件,true表示可以覆盖同名文件
}
}
}
catch (Exception)
{
throw;
}
}
public static void DeleteTemp(List<string> lisDelete)
{
foreach (var ss in lisDelete)
{
try
{
if (Directory.Exists(ss))
{
Directory.Delete(ss, true);
}
else if (File.Exists(ss))
{
File.Delete(ss);
}
}
catch { }
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoDownload.Common
{
public class DownloadWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
this.DownloadFileCompleted += MyWebClient2_DownloadFileCompleted;
var result = base.GetWebRequest(address) as HttpWebRequest;
result.Timeout = (int)TimeSpan.FromMinutes(60).TotalMilliseconds;
result.ReadWriteTimeout = (int)TimeSpan.FromMinutes(60).TotalMilliseconds;
result.Proxy = null;
//result.Proxy = new WebProxy("127.0.0.2:8888");
//MessageBox.Show("MyWebClient2" + address);
return result;
}
private void MyWebClient2_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs asyncCompletedEventArgs)
{
if (asyncCompletedEventArgs.Error != null)
{
MessageBox.Show(asyncCompletedEventArgs.Error.ToString(), "系统繁忙,请稍后重试", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace Dqkj.Setup
{
public static class Encrypt
{
static DES des = new DES();
//static string key = "GZCZKJABCDEFG";
static string key = "GZCZKJABCDEFG001";
public static string DesEncrypt(string normalTxt)
{
return des.DesEncrypt(normalTxt, key);
}
public static string DesDecrypt(string securityTxt)
{
return des.DesDecrypt(securityTxt, key);
}
}
public class DES
{
public DES()
{
this.keyvi = new byte[] { 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7, 0x08, 0xa9 };
}
public DES(byte[] keyvi)
{
this.keyvi = keyvi;
}
private byte[] keyvi;
public string DesEncrypt(string normalTxt, string EncryptKey)
{
var bytes = Encoding.UTF8.GetBytes(normalTxt);
var key = Encoding.UTF8.GetBytes(EncryptKey.PadLeft(8, '0').Substring(0, 8));
using (MemoryStream ms = new MemoryStream())
{
var encry = new DESCryptoServiceProvider();
CryptoStream cs = new CryptoStream(ms, encry.CreateEncryptor(key, keyvi), CryptoStreamMode.Write);
cs.Write(bytes, 0, bytes.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
}
public string DesDecrypt(string securityTxt, string EncryptKey)//解密
{
try
{
var bytes = Convert.FromBase64String(securityTxt);
var key = Encoding.UTF8.GetBytes(EncryptKey.PadLeft(8, '0').Substring(0, 8));
using (MemoryStream ms = new MemoryStream())
{
var descrypt = new DESCryptoServiceProvider();
CryptoStream cs = new CryptoStream(ms, descrypt.CreateDecryptor(key, keyvi), CryptoStreamMode.Write);
cs.Write(bytes, 0, bytes.Length);
cs.FlushFinalBlock();
return Encoding.UTF8.GetString(ms.ToArray());
}
}
catch (Exception)
{
return string.Empty;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dqkj.Setup.Common
{
public class ProcessHelper
{
public static void KillProcess(string name)
{
foreach (Process process in Process.GetProcesses())
{
try
{
if (process.ProcessName.ToLower() == name.ToLower())
{
process.Kill();
}
}
catch { }
}
}
public static bool CheckProcess(string name)
{
foreach (Process process in Process.GetProcesses())
{
try
{
if (process.ProcessName.ToLower() == name.ToLower())
{
return true;
}
}
catch { }
}
return false;
}
}
}
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace Dqkj.Setup.Common
{
public class RegeditHelper
{
public static void UninstallDelete(string uninstallName)
{
try
{
Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true); //定义注册表操作类并指向注册表的软件信息目录
foreach (string site in rk.GetSubKeyNames()) //在Uninstall目录下搜索子键
{
RegistryKey subkey = rk.OpenSubKey(site, true); //定义注册表搜索子类
foreach (string m in subkey.GetValueNames()) //遍历搜索
{
if (m == "DisplayName") //搜索键名为DisplayName的键
{
string name = subkey.GetValue(m).ToString(); //把键名为DisplayName的键值赋值给字符串
if (name == uninstallName)
{
rk.DeleteSubKeyTree(site);
}
}
}
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Dqkj.Setup
{
public class Utils
{
public static string GetMD5(byte[] data)
{
try
{
var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(data);
var sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch { }
return "";
}
public static string GetMD5HashFromFile(string fileName)
{
try
{
FileStream file = new FileStream(fileName, FileMode.Open);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch (Exception ex)
{
//throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
}
return "";
}
public static string CurrentPath
{
get
{
var dir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
return dir;
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace Dqkj.Setup
{
public class XmlHelper
{
#region 反序列化
public static T Deserialize<T>(string xml)
{
using (StringReader sr = new StringReader(xml))
{
XmlSerializer xmldes = new XmlSerializer(typeof(T));
return (T)xmldes.Deserialize(sr);
}
}
#endregion
#region 序列化
/// <summary>
/// 序列化
/// </summary>
/// <param name="type">类型</param>
/// <param name="obj">对象</param>
/// <returns></returns>
public static string Serializer<T>(object obj)
{
MemoryStream Stream = new MemoryStream();
XmlSerializer xml = new XmlSerializer(typeof(T));
//序列化对象
xml.Serialize(Stream, obj);
Stream.Position = 0;
StreamReader sr = new StreamReader(Stream);
string str = sr.ReadToEnd();
sr.Dispose();
Stream.Dispose();
return str;
}
#endregion
}
}
Img/Vector.png

943 Bytes

Img/关闭.jpg

634 Bytes

Logo.ico

8.72 KB

<Window x:Class="Dqkj.Setup.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:Dqkj.Setup"
mc:Ignorable="d"
Title="安装包"
Height="300"
Width="560"
WindowStyle="None" Background="Transparent" AllowsTransparency="True" WindowStartupLocation="CenterScreen"
Loaded="Window_Loaded" >
<Border CornerRadius="5" Background="White" BorderThickness="2"
BorderBrush="#EB6618" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="45*" ></RowDefinition>
<RowDefinition Height="55*"></RowDefinition>
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="{StaticResource gd_color}" CornerRadius="3,3,0,0" MouseDown="Border_MouseDown" ></Border>
<Button x:Name="buttClose" Content="×" Style="{StaticResource ButtonDashedBaseStyle}" Click="buttClose_Click" />
<StackPanel Grid.Row="0" Orientation="Horizontal" Style="{StaticResource stackPanel_setup}">
<Image x:Name="imageLogo" Source="/Img/Subtract.png" Width="40" Height="40" />
<TextBlock x:Name="txtBlockTitle" Text="电趣采集助手" FontSize="25" Foreground="White" VerticalAlignment="Center" Margin="10 0" ></TextBlock>
</StackPanel>
<Image Source="/Img/Rectangle 310-1.png" HorizontalAlignment="Left" IsHitTestVisible="False" />
<Image Source="/Img/Rectangle 310.png" HorizontalAlignment="Right" IsHitTestVisible="False" />
<Border Grid.Row="1" x:Name="operate">
<ContentControl x:Name="mian_content"/>
</Border>
</Grid>
</Border>
</Window>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
namespace Dqkj.Setup
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Border_MouseDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
private void buttClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.mian_content.Content=new InstallView(this);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dqkj.Setup
{
public class UpdateInfo : VersionInfo
{
public DateTime Time { get; set; }
public string Content { get; set; }
public string Md5 { get; set; }
public string UpdateUrl { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Dqkj.Setup
{
public class VersionInfo
{
public string Version { get; set; }
public string Url { get; set; }
public Version Ver
{
get
{
return System.Version.Parse(this.Version);
}
}
}
}
using Dqkj.Setup;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Dqkj.Setup")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Organization")]
[assembly: AssemblyProduct("Dqkj.Setup")]
[assembly: AssemblyCopyright("Copyright © Organization 2022")]
[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.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="_Net472" type="System.Resources.ResXFileRef, System.Windows.Forms">
</data>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Setup.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.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;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
\ No newline at end of file
<?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>{743C17E3-641B-429C-A271-2ED6BEAA6B63}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Setup</RootNamespace>
<AssemblyName>Setup</AssemblyName>
<TargetFrameworkVersion>v4.5</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>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Logo.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Dqkj.Setup.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Numerics" />
<Reference Include="System.Windows.Forms" />
<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.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>
<Page Include="Style\ControlStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\InstallCompleteView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\InstallView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Common\DirectoryHelper.cs" />
<Compile Include="Common\DownloadWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Common\Encrypt.cs" />
<Compile Include="Common\ProcessHelper.cs" />
<Compile Include="Common\RegeditHelper.cs" />
<Compile Include="Common\Utils.cs" />
<Compile Include="Common\XmlHelper.cs" />
<Compile Include="Model\UpdateInfo.cs" />
<Compile Include="Model\VersionInfo.cs" />
<Compile Include="View\InstallCompleteView.xaml.cs">
<DependentUpon>InstallCompleteView.xaml</DependentUpon>
</Compile>
<Compile Include="View\InstallView.xaml.cs">
<DependentUpon>InstallView.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="View\ProgressView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="View\ProgressView.xaml.cs">
<DependentUpon>ProgressView.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</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>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="Img\Subtract.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Img\Rectangle 310-1.png" />
<Resource Include="Img\Rectangle 310.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Img\关闭.jpg" />
</ItemGroup>
<ItemGroup>
<Resource Include="Img\Vector.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Img\Logo.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Img\Logo.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Logo.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Setup", "Setup.csproj", "{743C17E3-641B-429C-A271-2ED6BEAA6B63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Debug|x86.ActiveCfg = Debug|Any CPU
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Debug|x86.Build.0 = Debug|Any CPU
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Release|Any CPU.Build.0 = Release|Any CPU
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Release|x86.ActiveCfg = Release|Any CPU
{743C17E3-641B-429C-A271-2ED6BEAA6B63}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EABA2786-899A-4275-ABAF-32644696A76E}
EndGlobalSection
EndGlobal
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<LinearGradientBrush x:Key="gd_color" StartPoint="0,0" EndPoint="0,1" >
<GradientStop Offset="0" Color="#F49651" />
<GradientStop Offset="1" Color="#EB6618" />
</LinearGradientBrush>
<Style x:Key="stackPanel_setup" TargetType="StackPanel">
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
<Setter Property="VerticalAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="textBlock_setup" TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
<Setter Property="VerticalAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="border_setup" TargetType="Border">
<Setter Property="CornerRadius" Value="2"></Setter>
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="BorderBrush" Value="#AEAAAA"></Setter>
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
<Setter Property="VerticalAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="ButtonDashedBaseStyle" TargetType="{x:Type Button}">
<Setter Property="HorizontalAlignment" Value="Right"></Setter>
<Setter Property="VerticalAlignment" Value="Top"></Setter>
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="Width" Value="30"></Setter>
<Setter Property="Height" Value="30"></Setter>
<Setter Property="FontSize" Value="20"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border TextBlock.Foreground="{TemplateBinding Foreground}"
x:Name="Border"
CornerRadius="2"
BorderThickness="1">
<ContentPresenter Name="ContentPresenterMain" RecognizesAccessKey="True" VerticalAlignment="Center" Margin="6,0,0,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Value="True" Property="IsMouseOver">
<Setter TargetName="Border" Property="Background" Value="Transparent" />
<Setter TargetName="Border" Property="TextBlock.Foreground" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
<UserControl x:Class="Dqkj.Setup.View.InstallCompleteView"
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"
xmlns:local="clr-namespace:Dqkj.Setup.View"
mc:Ignorable="d"
Height="120" Width="545" >
<Grid>
<Border Width="200" Height="51" Style="{StaticResource border_setup}">
<Button x:Name="bttOpen" Click="bttOpen_Click" Content="立即体验" Width="200" Height="50" BorderThickness="0" Background="#EB6618"></Button>
</Border>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
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;
namespace Dqkj.Setup.View
{
/// <summary>
/// InstallCompleteView.xaml 的交互逻辑
/// </summary>
public partial class InstallCompleteView : UserControl
{
MainWindow _mainWindow { get; set; }
string _executionPath { get; set; }
public InstallCompleteView(string executionPath, MainWindow mainWindow)
{
InitializeComponent();
_executionPath = executionPath;
_mainWindow = mainWindow;
}
private void bttOpen_Click(object sender, RoutedEventArgs e)
{
if (File.Exists(_executionPath))
{
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(_executionPath);
process.StartInfo = startInfo;
process.Start();
_mainWindow.Close();
}
else
{
MessageBox.Show("启动异常,请尝试手动打开!", "温馨提示");
}
}
}
}
<UserControl x:Class="Dqkj.Setup.InstallView"
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:Dqkj.Setup"
mc:Ignorable="d"
Height="120" Width="545" x:Name="Install" Loaded="Install_Loaded">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="5*"></RowDefinition>
<RowDefinition Height="25*"></RowDefinition>
<RowDefinition Height="70*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" Orientation="Horizontal" Style="{StaticResource stackPanel_setup}" >
<TextBlock Text="安装路径:" Style="{StaticResource textBlock_setup}" Margin="10,0" ></TextBlock>
<Border Style="{StaticResource border_setup}">
<TextBox x:Name="txtPath" Text="C:\Dqkj\" Width="300" Height="25" BorderThickness="0" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"></TextBox>
</Border>
<Border Margin="5,0" Style="{StaticResource border_setup}" >
<Button x:Name="bttBrowse" Content="浏览" Background="White" BorderThickness="0" Height="25" Width="62" Click="bttBrowse_Click" ></Button>
</Border>
</StackPanel>
<Border Grid.Row="2" Width="200" Height="51" BorderThickness="1" Style="{StaticResource border_setup}">
<Button x:Name="bttSetup" Content="立即安装" Width="200" Height="50" BorderThickness="0" Background="White" Click="bttSetup_Click" />
</Border>
</Grid>
</UserControl>
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
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.Shapes;
namespace Dqkj.Setup
{
/// <summary>
/// InstallView.xaml 的交互逻辑
/// </summary>
public partial class InstallView : UserControl
{
private MainWindow _mainWindow { get; set; }
public InstallView(MainWindow mainWindow)
{
InitializeComponent();
_mainWindow = mainWindow;
}
private void bttBrowse_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.FolderBrowserDialog saveFileDialog = new System.Windows.Forms.FolderBrowserDialog();
if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
txtPath.Text = saveFileDialog.SelectedPath;
}
}
private void bttSetup_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(txtPath.Text))
{
MessageBox.Show("请选择安装路径!", "温馨提示");
return;
}
if (!System.IO.Path.GetInvalidFileNameChars().Any(c => txtPath.Text.Contains(c)))
{
MessageBox.Show("非法路径,请重新填写或者选择路径!", "温馨提示");
return;
}
try
{
Directory.CreateDirectory(txtPath.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
if (!Directory.Exists(txtPath.Text))
{
MessageBox.Show("选择的路径不存在!","温馨提示");
return;
}
_mainWindow.mian_content.Content = new ProgressView(txtPath.Text, _mainWindow);
}
private void Install_Loaded(object sender, RoutedEventArgs e)
{
}
}
}
<UserControl x:Class="Dqkj.Setup.ProgressView"
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:Dqkj.Setup"
mc:Ignorable="d"
Height="120" Width="545" x:Name="installProgress" Loaded="installProgress_Loaded" >
<Grid>
<StackPanel Orientation="Vertical" Width="520" Style="{StaticResource stackPanel_setup}">
<TextBlock x:Name="txtBlockHint" Text="正在安装,请稍后(0%)" Margin="0,5" FontSize="12" FontFamily="PingFang SC"></TextBlock>
<ProgressBar x:Name="progress" Height="8" Foreground="#EB6618" Maximum="100" ></ProgressBar>
</StackPanel>
</Grid>
</UserControl>
#define 天猫助手
using AutoDownload.Common;
using Dqkj.Setup.Common;
using Dqkj.Setup.View;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Path = System.IO.Path;
namespace Dqkj.Setup
{
/// <summary>
/// ProgressView.xaml 的交互逻辑
/// </summary>
public partial class ProgressView : System.Windows.Controls.UserControl
{
private MainWindow _mainWindow { get; set; }
string defaultUpdateXmlUrl { get; set; }
static string executeName { get; set; }
string formTitle { get; set; }
static string zip_temp { get; set; }
static string _installPath { get; set; }
public ProgressView(string installPath, MainWindow mainWindow)
{
InitializeComponent();
Initialize(installPath);
_mainWindow = mainWindow;
}
public void Initialize(string installPath)
{
_installPath = installPath;
zip_temp = Path.Combine(installPath, "data_temp.zip");
#if 天猫助手
defaultUpdateXmlUrl = "http://112.74.55.104/AutomaticUpdates/全平台采集/Update.xml";
executeName = "电趣采集助手.exe";
formTitle = $"电趣采集助手-自动更新";
#endif
}
private void installProgress_Loaded(object sender, RoutedEventArgs e)
{
try
{
Download();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
public async void Download()
{
var serverVersion = await GetUpdateInfo();
if (serverVersion == null) { throw new Exception("获取安装配置异常!"); }
if (ProcessHelper.CheckProcess(executeName.Replace(".exe", "")))
{
var reply = System.Windows.MessageBox.Show("程序正在运行,是否自动关闭程序并开始更新升级", formTitle,MessageBoxButton.YesNo,MessageBoxImage.Information);
if (reply != MessageBoxResult.Yes)
{
return;
}
ProcessHelper.KillProcess(executeName.Replace(".exe", ""));
DirectoryHelper.DeleteTemp(new List<string> { zip_temp, _installPath + "_" });
}
//开始下载文件
DownloadWebClient client = new DownloadWebClient();
client.DownloadFileCompleted += Client_DownloadFileCompleted;
client.DownloadProgressChanged += Client_DownloadProgressChanged;
client.DownloadFileAsync(new Uri(serverVersion.Url), zip_temp, serverVersion);
//Application.Run(frm);
}
private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progress.Value = e.ProgressPercentage;
txtBlockHint.Text = $"正在安装,请稍后({progress.Value}%)";
}
/// <summary>
/// 当文件下载完成时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
try
{
if (File.Exists(zip_temp))
{
var serverVersion = (e.UserState as UpdateInfo);
//通过文件MD5检测文件是否下载完整
var md5 = Utils.GetMD5HashFromFile(zip_temp);
if (md5 == serverVersion.Md5)
{
DecompressZip(zip_temp, _installPath); //解压升级包
//DirectoryHelper.CopyDirectory(unzip_temp, app); //替换进app目录中
VersionInfo localVersion = new VersionInfo();
//替换新版本号
localVersion.Version = serverVersion.Version;
//刷新、保存本地版本信息
localVersion.Version = serverVersion.Version;
File.WriteAllText(Path.Combine(_installPath, "version.xml"), Encrypt.DesEncrypt(XmlHelper.Serializer<VersionInfo>(localVersion)));
Completed();
}
else
{
throw new Exception("下载的安装文件不一致,请稍后再尝试安装");
}
}
}
catch (Exception ex)
{
System.Windows.MessageBox.Show("安装失败:\r\n\t" + ex.Message, formTitle);
}
finally
{
DirectoryHelper.DeleteTemp(new List<string>{ zip_temp, _installPath + "_" });
}
}
private void Completed()
{
_mainWindow.txtBlockTitle.Text = "安装完成";
_mainWindow.imageLogo.Source = new BitmapImage(new Uri("/Img/Vector.png", UriKind.Relative));
RegeditHelper.UninstallDelete(Path.GetFileNameWithoutExtension(executeName));
_mainWindow.mian_content.Content = new InstallCompleteView(Path.Combine(_installPath, executeName), _mainWindow);
}
public async Task<UpdateInfo> GetUpdateInfo()
{
UpdateInfo info = null;
try
{
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
var serverXml =await client.DownloadStringTaskAsync(new Uri(defaultUpdateXmlUrl));
if (!string.IsNullOrEmpty(serverXml))
{
info = XmlHelper.Deserialize<UpdateInfo>(serverXml);
}
}
catch { }
return info;
}
public static void DecompressZip(string zipPath, string folderPath)
{
ZipArchive zipArchive = null;
try
{
if (zipPath == string.Empty)
{
throw new Exception("压缩文件不能为空!");
}
if (!File.Exists(zipPath))
{
throw new FileNotFoundException("压缩文件不存在!");
}
DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);
if (!directoryInfo.Exists)
{
directoryInfo.Create();
}
zipArchive = ZipFile.OpenRead(zipPath);
foreach (var item in zipArchive.Entries)
{
string entryFullname = Path.Combine(folderPath, item.FullName);
string entryPath = Path.GetDirectoryName(entryFullname);
if (!Directory.Exists(entryPath))
{
Directory.CreateDirectory(entryPath);
}
else
{
string entryFn = Path.GetFileName(entryFullname);
if (!string.IsNullOrEmpty(entryFn))
{
item.ExtractToFile(entryFullname, true);
}
}
}
}
catch (Exception ex)
{
System.Windows.MessageBox.Show($"解压异常:{ex.Message}");
}
finally
{
zipArchive?.Dispose();
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HandyControl" version="3.3.0" targetFramework="net472" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment