Commit c5ae9e85 authored by 潘栩锋's avatar 潘栩锋 :bicyclist:

Merge remote-tracking branch 'origin/master' into feature-feng-flyad2021-20210804

parents 588b37fa 64064eb4

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Install", "Install\Install.csproj", "{91C66C22-AE4C-4B3C-8FDC-AE38C4848CF6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstallCommon", "InstallCommon\InstallCommon.csproj", "{B89EA330-7A10-4974-91BA-72B00FE5B873}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{C7A1914A-AC99-4166-9CD3-24953E3934DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{91C66C22-AE4C-4B3C-8FDC-AE38C4848CF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91C66C22-AE4C-4B3C-8FDC-AE38C4848CF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91C66C22-AE4C-4B3C-8FDC-AE38C4848CF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91C66C22-AE4C-4B3C-8FDC-AE38C4848CF6}.Release|Any CPU.Build.0 = Release|Any CPU
{B89EA330-7A10-4974-91BA-72B00FE5B873}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B89EA330-7A10-4974-91BA-72B00FE5B873}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B89EA330-7A10-4974-91BA-72B00FE5B873}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B89EA330-7A10-4974-91BA-72B00FE5B873}.Release|Any CPU.Build.0 = Release|Any CPU
{C7A1914A-AC99-4166-9CD3-24953E3934DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7A1914A-AC99-4166-9CD3-24953E3934DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7A1914A-AC99-4166-9CD3-24953E3934DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7A1914A-AC99-4166-9CD3-24953E3934DE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F53BDE6A-3A7B-444F-B88A-A6CB1A045026}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
<Application x:Class="Install.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Install"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/MyStyle.xaml"/>
<ResourceDictionary Source="Converters/MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Install
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace Install.Converters
{
public class Abort2VisConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double progress = (double)value;
if (progress < 1)
return Visibility.Visible;
else
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class Finish2VisConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double progress = (double)value;
if (progress >= 1)
return Visibility.Visible;
else
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Install.Converters
{
public class Equals2BoolConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return false;
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return true;
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((bool)value == true)
{
return parameter;
}
else
{
return null;
}
}
#endregion
}
/// <summary>
/// 逻辑反向
/// </summary>
public class BoolReverseConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool b = (bool)value;
return !b;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool b = (bool)value;
return !b;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Install.Converters
{
public class Equals2VisibleConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Visible;
}
return System.Windows.Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2VisibleConverter_Collapsed : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Visible;
}
return System.Windows.Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2CollapsedConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Collapsed;
}
return System.Windows.Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2HiddenConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Hidden;
}
return System.Windows.Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media.Imaging;
namespace Install.Converters
{
public class IconConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
string processName = values[0] as string;
Dictionary<string, BitmapSource> icons = values[1] as Dictionary<string, BitmapSource>;
if (string.IsNullOrEmpty(processName))
{
return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
}
if (icons == null)
{
return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
}
if (!icons.ContainsKey(processName))
{
return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
}
return icons[processName];
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Install.Converters
{
public class ListBoxItemWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double w = (double)value;
return w - 50;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Install.Converters"
xmlns:conv="clr-namespace:Install.Converters"
>
<local:IconConverter x:Key="iconConv"/>
<local:Abort2VisConverter x:Key="abortConv"/>
<local:Finish2VisConverter x:Key="finishConv"/>
<local:ListBoxItemWidthConverter x:Key="lbiwConv"/>
<conv:VisibilityConverter x:Key="visbilityconv" />
<conv:Equals2VisibleConverter_Collapsed x:Key="e2visconv_collapsed" />
<conv:Equals2VisibleConverter x:Key="e2visconv" />
<conv:Equals2HiddenConverter x:Key="e2hiddenconv" />
<conv:Equals2CollapsedConverter x:Key="e2collapsedconv" />
<conv:Equals2BoolConverter x:Key="e2bconv"/>
<conv:BoolReverseConverter x:Key="brconv"/>
</ResourceDictionary>
\ 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.Data;
namespace Install.Converters
{
public class VisibilityConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool enable = (bool)value;
string p = null;
if (parameter != null)
p = parameter as string;
if (p == "Collapsed")
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else if (p == "HiddenWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
else if (p == "CollapsedWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
<Costura>
<ExcludeAssemblies>
SevenZipSharp
</ExcludeAssemblies>
</Costura>
</Weavers>
\ No newline at end of file
This diff is collapsed.
Install2/Install/Images/a9dce02bce69ea10b.jpg

61.5 KB

Install2/Install/Images/cross.png

1.47 KB

<?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>{91C66C22-AE4C-4B3C-8FDC-AE38C4848CF6}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Install</RootNamespace>
<AssemblyName>Install</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</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>
<ApplicationIcon>system_software_install_128px_541174_easyicon.net.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<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.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="Converters\Abort2VisConverter.cs" />
<Compile Include="Converters\Equals2BoolConverter.cs" />
<Compile Include="Converters\Equals2VisibleConverter.cs" />
<Compile Include="Converters\IconConverter.cs" />
<Compile Include="Converters\ListBoxItemWidthConverter.cs" />
<Compile Include="Converters\VisibilityConverter.cs" />
<Compile Include="Core\InstallWizard.cs" />
<Compile Include="View\ListItem.cs" />
<Compile Include="View\WdDownload.xaml.cs">
<DependentUpon>WdDownload.xaml</DependentUpon>
</Compile>
<Compile Include="View\PgInstall\PgInstallVm.cs" />
<Compile Include="View\PgProgress.xaml.cs">
<DependentUpon>PgProgress.xaml</DependentUpon>
</Compile>
<Compile Include="View\Pg1st.xaml.cs">
<DependentUpon>Pg1st.xaml</DependentUpon>
</Compile>
<Compile Include="View\PgInstall\PgInstall.xaml.cs">
<DependentUpon>PgInstall.xaml</DependentUpon>
</Compile>
<Compile Include="View\PgUpdate\PgUpdate.xaml.cs">
<DependentUpon>PgUpdate.xaml</DependentUpon>
</Compile>
<Compile Include="View\PgUpdate\PgUpdateVm.cs" />
<Page Include="Converters\MyConv.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="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Styles\MyStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\WdDownload.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\PgProgress.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\Pg1st.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\PgInstall\PgInstall.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\PgUpdate\PgUpdate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</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="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody">
<Version>5.5.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MvvmLight">
<Version>5.4.1.1</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.4.0</Version>
</PackageReference>
<PackageReference Include="SevenZipSharp.Interop">
<Version>19.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\a9dce02bce69ea10b.jpg" />
</ItemGroup>
<ItemGroup>
<Resource Include="system_software_install_128px_541174_easyicon.net.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\cross.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\InstallCommon\InstallCommon.csproj">
<Project>{b89ea330-7a10-4974-91ba-72b00fe5b873}</Project>
<Name>InstallCommon</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<NavigationWindow x:Class="Install.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:Install"
mc:Ignorable="d"
Title="[FLY 系列软件] 安装 " Height="600" Width="600" WindowStartupLocation="CenterScreen"
ShowsNavigationUI="False" Icon="/Install;component/system_software_install_128px_541174_easyicon.net.ico">
</NavigationWindow>
using Install.Core;
using Install.Core.Common;
using Install.View;
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 Install
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : NavigationWindow
{
InstallWizard installWizard;
public MainWindow()
{
InitializeComponent();
Ver ver = new Ver() { SrcType = this.GetType() };
this.Title = ver.ToString();
installWizard = new InstallWizard();
if (!installWizard.Init())
{
//异常,不能找到安装包
MessageBox.Show(installWizard.Msg, "异常", MessageBoxButton.OK, MessageBoxImage.Error);
App.Current.Shutdown();
return;
}
Application.Current.Properties[nameof(InstallWizard)] = installWizard;
Application.Current.Properties["NavigationService"] = NavigationService;
Pg1st p = new Pg1st();
p.Init();
NavigationService.Navigate(p);
}
}
}
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("FLY系列软件安装向导")]
[assembly: AssemblyDescription("写安装信息到注册表,复制到指定安装目录")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化有限公司")]
[assembly: AssemblyProduct("FLY系列软件安装向导")]
[assembly: AssemblyCopyright("Copyright © 2021 flyautomation")]
[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("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: Guid("AB127AC6-16C6-411F-8892-D90413A863C8")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Install.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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 ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Install.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;
}
}
}
}
<?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>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Install.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
{
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"?>
<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="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
</applicationRequestMinimum>
</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"。-->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</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>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Install.Styles">
<Style x:Key="NormalBtn" TargetType="Button" >
<Setter Property="Height" Value="23"/>
<Setter Property="Width" Value="75"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Margin" Value="10"/>
</Style>
<Style x:Key="BtnSp" TargetType="StackPanel" >
<Setter Property="Orientation" Value="Horizontal"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
</Style>
<Style x:Key="BottomPanel" TargetType="Grid" >
<Setter Property="Background" Value="#FFF0F0F0"/>
</Style>
<Style x:Key="h1" TargetType="TextBlock">
<Setter Property="FontSize" Value="24"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
</Style>
<SolidColorBrush x:Key="AccentBaseColorBrush" Color="LightBlue"/>
<SolidColorBrush x:Key="GrayBrush4" Color="#555555"/>
</ResourceDictionary>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.View
{
public class ListItem : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public bool IsSelected { get; set; }
public object Item { get; set; }
}
}
<Page x:Class="Install.View.Pg1st"
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:Install.View"
mc:Ignorable="d"
d:DesignHeight="411" d:DesignWidth="605"
Title="Pg1st">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="248*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="142*" />
<ColumnDefinition Width="281*" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/Images/a9dce02bce69ea10b.jpg" Stretch="UniformToFill" TileMode="None" />
</Grid.Background>
</Grid>
<Grid Grid.Column="1" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="238*" />
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Left" Margin="5" Text="欢迎使用 [FLY系列软件] 安装向导" FontWeight="Bold" FontSize="20" />
<StackPanel Grid.Row="1" HorizontalAlignment="Left" Margin="5,20,5,5" VerticalAlignment="Top" Grid.Column="1" >
<TextBlock >
当前安装包版本号为: v<Run Foreground="Red" FontSize="20" Text="{Binding CurrentInstallZipVersion,Mode=OneWay}"/>
</TextBlock>
<TextBlock TextWrapping = "Wrap" >
<LineBreak/>
这个向导会指引你 完成[FLY 系列软件]的安装进程。<LineBreak/>
在开始安装之前,建议先关闭其他所有应用程序。这将允许“安装程序”更新指定的系统文件,而不需要重新启动你的计算机。<LineBreak/>
<LineBreak/>
单击【下一步】继续。<LineBreak/>
</TextBlock>
</StackPanel>
</Grid>
</Grid>
<Grid Style="{StaticResource BottomPanel}" Grid.Row="1" >
<StackPanel Style="{StaticResource BtnSp}">
<Button Content="下一步" Click="btNextClick" Style="{StaticResource NormalBtn}"/>
</StackPanel>
</Grid>
</Grid>
</Page>
using Install.Core;
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 Install.View
{
/// <summary>
/// Pg1st.xaml 的交互逻辑
/// </summary>
public partial class Pg1st : Page
{
InstallWizard installWizard;
public Pg1st()
{
InitializeComponent();
}
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
this.DataContext = installWizard;
}
private void btNextClick(object sender, RoutedEventArgs e)
{
if (installWizard.HasInstalled.Count() == 0)
{
//没有任何软件被安装
PgInstall p = new PgInstall();
p.Init();
this.NavigationService.Navigate(p);
}
else
{
PgUpdate p = new PgUpdate();
p.Init();
this.NavigationService.Navigate(p);
}
}
}
}
<Page x:Class="Install.View.PgInstall"
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"
xmlns:local="clr-namespace:Install.View"
d:DesignHeight="392" d:DesignWidth="596"
Title="PgInstall" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="174*" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="390*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="安装项目" Style="{StaticResource h1}" />
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Margin="5" Command="{Binding DownloadCmd}" Visibility="{Binding InstallWizard.HasNewestInstallZip,Converter={StaticResource visbilityconv}}">
<TextBlock Margin="10,2">
点击下载 最新版本 v<Run Foreground="Red" FontSize="20" Text="{Binding InstallWizard.NewestInstallZipVersion,Mode=OneWay}"/>
</TextBlock>
</Button>
</StackPanel>
</Grid>
<ListBox Margin="5" Name="listBox1" Grid.Row="1" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" Margin="5"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" DataContext="{Binding Item}">
<Image Height="30" Width="30" >
<Image.Source>
<MultiBinding Converter="{StaticResource iconConv}">
<Binding Path="ProcessName"/>
<Binding Path="DataContext.Icons" ElementName="listBox1"/>
</MultiBinding>
</Image.Source>
</Image>
<StackPanel Margin="2">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontSize="15" Margin="2"/>
<TextBlock Text="{Binding Version}" Foreground="{StaticResource AccentBaseColorBrush}"/>
</StackPanel>
<TextBlock Text="{Binding ProcessName}" Foreground="{StaticResource GrayBrush4}"/>
</StackPanel>
<CheckBox IsChecked="{Binding IsAutoRun}" Margin="2" Content="开机启动" VerticalAlignment="Center" />
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="346*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock FontWeight="Bold" Margin="5" Text="安装路径" />
<TextBlock Grid.Column="1" Margin="2" Text="{Binding InstallPath}" />
<!--<Button Grid.Column="2" Content="+" Height="23" Margin="5" Width="40" Command="{Binding SelectPathCmd}" />-->
</Grid>
<Grid Style="{StaticResource BottomPanel}" Grid.Row="3" >
<StackPanel Style="{StaticResource BtnSp}">
<Button Content="下一步" Style="{StaticResource NormalBtn}" Command="{Binding NextCmd}" />
</StackPanel>
</Grid>
</Grid>
</Page>
using Install.Core;
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 Install.View
{
/// <summary>
/// PgInstall.xaml 的交互逻辑
/// </summary>
public partial class PgInstall : Page
{
InstallWizard installWizard;
PgInstallVm viewModel;
public PgInstall()
{
InitializeComponent();
viewModel = new PgInstallVm();
this.DataContext = viewModel;
}
public void Init()
{
viewModel.Init();
}
}
}
using GalaSoft.MvvmLight.Command;
using Install.Core;
using Install.Core.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
namespace Install.View
{
public class PgInstallVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ObservableCollection<ListItem> Items { get; } = new ObservableCollection<ListItem>();
public string InstallPath { get; set; }
public Dictionary<string, BitmapSource> Icons { get; private set; }
public RelayCommand NextCmd { get; private set; }
public RelayCommand SelectPathCmd { get; private set; }
public RelayCommand DownloadCmd { get; private set; }
InstallWizard installWizard;
public InstallWizard InstallWizard => installWizard;
public PgInstallVm()
{
NextCmd = new RelayCommand(Next);
SelectPathCmd = new RelayCommand(SelectPath);
DownloadCmd = new RelayCommand(Download);
}
private void Download()
{
//打开 下载进度界面
WdDownload w = new WdDownload();
w.Init();
w.ShowDialog();
}
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
Icons = installWizard.Icons;
foreach (var installpack in installWizard.ToInstall)
{
Items.Add(new ListItem() { Item = installpack, IsSelected = installpack.IsDefaultSelected });
}
InstallPath = installWizard.InstallPacks.DefaultInstallPath;
}
private void SelectPath()
{
var dbd = new System.Windows.Forms.FolderBrowserDialog();
dbd.SelectedPath = InstallPath;
if (dbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
InstallPath = dbd.SelectedPath;
}
}
private async void Next()
{
//筛选出选择的软件
var installPacks = from item in Items where item.IsSelected select item.Item as InstallPack;
//检测有没安装被选
if (installPacks.Count() == 0)
{
//没有任何一个被选择
System.Windows.MessageBox.Show("没有任何一个被选择", "异常", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
//检测路径
if (!System.IO.Directory.Exists(InstallPath))
{
try
{
System.IO.Directory.CreateDirectory(InstallPath);
}
catch
{
System.Windows.MessageBox.Show(InstallPath + " 路径不能创建,重新选择", "异常", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
PgProgress p = new PgProgress();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
await installWizard.Install(InstallPath, installPacks);
}
}
}
<Page x:Class="Install.View.PgProgress"
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"
xmlns:local="clr-namespace:Install.View"
d:DesignHeight="360" d:DesignWidth="495"
Title="PgProgress" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="284*" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ListBox Margin="5" Name="listBox1" />
<ProgressBar Grid.Row="1" Height="10" Margin="3" Maximum="1" Value="{Binding Progress,Mode=OneWay}" />
<Grid Style="{StaticResource BottomPanel}" Grid.Row="2" >
<StackPanel Style="{StaticResource BtnSp}" >
<Button Style="{StaticResource NormalBtn}" Content="完成" Click="btnFinishClick" Visibility="{Binding Progress, Converter={StaticResource finishConv}}" />
<Button Style="{StaticResource NormalBtn}" Content="取消" Click="btnCancelClick" Visibility="{Binding Progress, Converter={StaticResource abortConv}}" />
</StackPanel>
</Grid>
</Grid>
</Page>
\ No newline at end of file
using Install.Core;
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 Install.View
{
/// <summary>
/// PaProgress.xaml 的交互逻辑
/// </summary>
public partial class PgProgress : Page
{
InstallWizard installWizard;
public PgProgress()
{
InitializeComponent();
}
public void Init()
{
installWizard = App.Current.Properties[nameof(InstallWizard)] as InstallWizard;
this.DataContext = installWizard;
installWizard.PropertyChanged += InstallWizard_PropertyChanged;
listBox1.Items.Clear();
}
private void InstallWizard_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "Msg")
{
this.Dispatcher.Invoke(new Action<string>((s) => listBox1.Items.Add(s)), installWizard.Msg);
}
}
private void btnCancelClick(object sender, RoutedEventArgs e)
{
installWizard.Abort();
App.Current.Shutdown();
}
private void btnFinishClick(object sender, RoutedEventArgs e)
{
App.Current.Shutdown();
}
}
}
<Page x:Class="Install.View.PgUpdate"
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:Install.View"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="PgUpdate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="174*" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="390*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="已安装项目" Style="{StaticResource h1}"/>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Margin="5" Command="{Binding DownloadCmd}" Visibility="{Binding InstallWizard.HasNewestInstallZip,Converter={StaticResource visbilityconv}}">
<TextBlock Margin="10,2">
点击下载 最新版本 v<Run Foreground="Red" FontSize="20" Text="{Binding InstallWizard.NewestInstallZipVersion,Mode=OneWay}"/>
</TextBlock>
</Button>
</StackPanel>
</Grid>
<ListBox Margin="5" Name="listBox1" Grid.Row="1" ItemsSource="{Binding Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" Margin="5"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" DataContext="{Binding Item}">
<Image Height="30" Width="30" >
<Image.Source>
<MultiBinding Converter="{StaticResource iconConv}">
<Binding Path="ProcessName"/>
<Binding Path="DataContext.Icons" ElementName="listBox1"/>
</MultiBinding>
</Image.Source>
</Image>
<StackPanel Margin="2">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontSize="15" Margin="2"/>
<TextBlock Text="{Binding Version}" Foreground="{StaticResource AccentBaseColorBrush}"/>
<Grid Width="30"/>
<TextBlock Foreground="Red" Visibility="{Binding NeedToUpdate,Converter={StaticResource visbilityconv}}">
-> <Run Text="{Binding NewestVersion,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
<TextBlock Text="{Binding ProcessName}" Foreground="{StaticResource GrayBrush4}"/>
</StackPanel>
<CheckBox IsChecked="{Binding IsAutoRun}" Margin="2" Content="开机启动" VerticalAlignment="Center" />
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<GroupBox Grid.Row="2" x:Name="groupbox_opt">
<StackPanel Orientation="Vertical" Margin="5">
<StackPanel.Resources>
<ResourceDictionary>
<Style TargetType="RadioButton" >
<Setter Property="Height" Value="20"/>
<Setter Property="Margin" Value="2.5"/>
<Setter Property="FontWeight" Value="Bold" />
</Style>
</ResourceDictionary>
</StackPanel.Resources>
<RadioButton GroupName="option" Content="只设置开机启动 &amp; 创建快捷方式" IsChecked="{Binding Option,Converter={StaticResource e2bconv}, ConverterParameter={x:Static local:OPTION.AUTORUN}}"/>
<RadioButton GroupName="option" Content="升级(复制*.dll 与 *.exe)" IsChecked="{Binding Option,Converter={StaticResource e2bconv},ConverterParameter={x:Static local:OPTION.UPDATE}}"/>
<RadioButton GroupName="option" Content="删除" IsChecked="{Binding Option,Converter={StaticResource e2bconv},ConverterParameter={x:Static local:OPTION.REMOVE}}"/>
</StackPanel>
</GroupBox>
<Grid Style="{StaticResource BottomPanel}" Grid.Row="3" >
<StackPanel Style="{StaticResource BtnSp}">
<Button Content="新增" Style="{StaticResource NormalBtn}" Command="{Binding NewCmd}" Visibility="{Binding HasNew,Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}"/>
<Button Content="下一步" Style="{StaticResource NormalBtn}" Command="{Binding NextCmd}" />
</StackPanel>
</Grid>
</Grid>
</Page>
\ 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 Install.View
{
/// <summary>
/// PgUpdate.xaml 的交互逻辑
/// </summary>
public partial class PgUpdate : Page
{
PgUpdateVm viewModel;
public PgUpdate()
{
InitializeComponent();
viewModel = new PgUpdateVm();
this.DataContext = viewModel;
}
public void Init()
{
viewModel.Init();
}
}
}
using GalaSoft.MvvmLight.Command;
using Install.Core;
using Install.Core.Common;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
namespace Install.View
{
public class PgUpdateVm : INotifyPropertyChanged
{
public OPTION Option { get; set; } = OPTION.AUTORUN;
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 有能新安装的程序
/// </summary>
public bool HasNew { get; private set; }
public Dictionary<string, BitmapSource> Icons { get; private set; }
public ObservableCollection<ListItem> Items { get; } = new ObservableCollection<ListItem>();
public RelayCommand NextCmd { get; private set; }
public RelayCommand NewCmd { get; private set; }
public RelayCommand DownloadCmd { get; private set; }
InstallWizard installWizard;
public InstallWizard InstallWizard => installWizard;
public PgUpdateVm()
{
NextCmd = new RelayCommand(Next);
NewCmd = new RelayCommand(New);
DownloadCmd = new RelayCommand(Download);
}
private void Download()
{
//打开 下载进度界面
WdDownload w = new WdDownload();
w.Init();
w.ShowDialog();
}
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
Icons = installWizard.Icons;
foreach (var installInfo in installWizard.HasInstalled)
{
Items.Add(new ListItem() { Item = installInfo, IsSelected = installInfo.NeedToUpdate });
}
HasNew = installWizard.ToInstall.Count > 0;
}
private void New()
{
PgInstall p = new PgInstall();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
}
private async void Next()
{
//检测有没选
var items = from item in Items where item.IsSelected select item.Item as InstallInfo;
if (items.Count()==0)
{
System.Windows.MessageBox.Show("没有任何一个被选择", "异常", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
PgProgress p = new PgProgress();
p.Init();
(Application.Current.Properties["NavigationService"] as NavigationService).Navigate(p);
switch (Option)
{
case OPTION.AUTORUN:
{
await installWizard.SetAutoRun(items);
}
break;
case OPTION.UPDATE:
{
await installWizard.Update(items);
}
break;
case OPTION.REMOVE:
{
await installWizard.Remove(items);
}
break;
}
}
}
public enum OPTION
{
AUTORUN,
UPDATE,
REMOVE
}
}
<Window x:Class="Install.View.WdDownload"
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:Install.View"
mc:Ignorable="d"
Title="WdDownload" Height="172" Width="754">
<Grid x:Name="grid_root">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<StackPanel Margin="5" DataContext="{Binding InstallWizard}">
<ProgressBar Height="20" Margin="5" Maximum="1" Value="{Binding DownloadInfo_Progress,Mode=OneWay}" />
<Grid Margin="5" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock>
<Run Text="{Binding DownloadInfo_CurrSizeStr,Mode=OneWay}"/>/<Run Text="{Binding DownloadInfo_TotalSizeStr,Mode=OneWay}"/>
</TextBlock>
<TextBlock Grid.Column="1">
<Run Text="{Binding DownloadInfo_SpeedStr,Mode=OneWay}"/> | 已经耗时:<Run Text="{Binding DownloadInfo_ElapsedTimeStr,Mode=OneWay}"/> | 估计剩余时间:<Run Text="{Binding DownloadInfo_RemainingTimeStr,Mode=OneWay}"/>
</TextBlock>
</Grid>
<TextBlock Margin="5" Text="{Binding DataContext.Msg,ElementName=grid_root}"/>
</StackPanel>
<Grid Grid.Row="1" Style="{StaticResource BottomPanel}" >
<StackPanel Style="{StaticResource BtnSp}" >
<Button Style="{StaticResource NormalBtn}" Content="打开" Command="{Binding ExecCmd}" Visibility="{Binding IsReady, Converter={StaticResource visbilityconv}}" />
<Button Style="{StaticResource NormalBtn}" Content="取消" Command="{Binding CancelCmd}" Visibility="{Binding IsReady, Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}" />
</StackPanel>
</Grid>
</Grid>
</Window>
using GalaSoft.MvvmLight.Command;
using Install.Core;
using Install.Core.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
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.Shapes;
namespace Install.View
{
/// <summary>
/// PgDownload.xaml 的交互逻辑
/// </summary>
public partial class WdDownload : Window
{
WdDownloadVm viewModel;
public WdDownload()
{
InitializeComponent();
viewModel = new WdDownloadVm();
}
public void Init()
{
viewModel.Init();
this.DataContext = viewModel;
viewModel.DownloadNewestInstallZip();
}
}
public class WdDownloadVm : INotifyPropertyChanged
{
InstallWizard installWizard;
public event PropertyChangedEventHandler PropertyChanged;
public bool IsReady { get; private set; } = false;
public string Msg { get; private set; }
public InstallWizard InstallWizard => installWizard;
public RelayCommand ExecCmd { get; set; }
public RelayCommand CancelCmd { get; set; }
public WdDownloadVm()
{
ExecCmd = new RelayCommand(Exec);
CancelCmd = new RelayCommand(Cancel);
}
public void Init()
{
installWizard = Application.Current.Properties[nameof(InstallWizard)] as InstallWizard;
Msg = $"下载 {installWizard.NewestInstallZipVersionInfo.InstallZipUrl}";
}
public async void DownloadNewestInstallZip()
{
var ret = await installWizard.DownloadNewestInstallZip();
Msg = installWizard.DownloadInfo_ErrMsg;
if (ret == true)
{
//解压
//获取当前 exe 目录
Msg = "开始解压......";
await Task.Factory.StartNew(() =>
{
SeverZipExt.Uncompress(installWizard.NewestInstallZipPath + ".7z", installWizard.NewestInstallZipPath);
});
Msg = "解压完成!!!";
IsReady = true;
}
}
private void Cancel()
{
//关闭当前
Application.Current.Shutdown();
}
private void Exec()
{
//关闭当前,进入新的安装包,运行
string exePath = System.IO.Path.Combine(installWizard.NewestInstallZipPath, "install.exe");
CMD.RunExe(exePath);
Application.Current.Shutdown();
}
}
}
Install2/Install/system_software_install_128px_541174_easyicon.net.ico

66.1 KB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
namespace Install.Core.Common
{
public static class BitmapExt
{
#region 基本支持
[DllImport("gdi32")]
public static extern int DeleteObject(IntPtr o);
public static BitmapSource CreateBitmapSourceFromBitmap(System.Drawing.Bitmap m_Bitmap)
{
IntPtr ip = m_Bitmap.GetHbitmap();
BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
ip, IntPtr.Zero, Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
DeleteObject(ip);
return bitmapSource;
}
public static BitmapSource CreateBitmapSource(this System.Drawing.Bitmap bmp)
{
return CreateBitmapSourceFromBitmap(bmp);
}
public static void ToBitmapImage(this System.Drawing.Bitmap bmp, System.Windows.Media.Imaging.BitmapImage bitmapImage)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);// 格式自处理,这里用 bitmap
// 初始一个 ImageSource 作为 myImage 的Source
bitmapImage.BeginInit();
bitmapImage.StreamSource = new MemoryStream(ms.ToArray()); // 不要直接使用 ms
bitmapImage.EndInit();
ms.Close();
}
public static System.Windows.Media.Imaging.BitmapImage CreateBitmapImage(this System.Drawing.Bitmap bmp)
{
System.Windows.Media.Imaging.BitmapImage bitmapImage = new BitmapImage();
bmp.ToBitmapImage(bitmapImage);
return bitmapImage;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public static class CMD
{
public static void RunExe(string exePath, string arguments, out string output, out string error)
{
using (Process process = new Process())
{
process.StartInfo.FileName = exePath;
process.StartInfo.Arguments = arguments;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
output = process.StandardOutput.ReadToEnd();
error = process.StandardError.ReadToEnd();
process.WaitForExit();
process.Close();
}
}
public static void RunExe(string exePath)
{
Process startProc = new Process();
startProc.StartInfo.FileName = exePath; //就是你要打开的文件的详细路径
startProc.StartInfo.UseShellExecute = true;
startProc.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(exePath); //就是如APGIS.Tools.exe 执行文件是在那个文件夹下。
startProc.Start();
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public static class CopyExt
{
public static Exception Error;
public static bool Copy(string sourceDirName, string destDirName)
{
if (!Directory.Exists(sourceDirName))
{
return false;
}
if (!Directory.Exists(destDirName))
Directory.CreateDirectory(destDirName);
string[] files = Directory.GetFiles(sourceDirName);
foreach (string formFileName in files)
{
string fileName = Path.GetFileName(formFileName);
string toFileName = Path.Combine(destDirName, fileName);
try
{
File.Copy(formFileName, toFileName, true);
}
catch (Exception e)
{
Error = e;
return false;
}
}
string[] fromDirs = Directory.GetDirectories(sourceDirName);
foreach (string fromDirName in fromDirs)
{
string dirName = Path.GetFileName(fromDirName);
string toDirName = Path.Combine(destDirName, dirName);
if (!Copy(fromDirName, toDirName))
return false;
}
return true;
}
public static bool CopyFileOrDirectory(string src, string dest)
{
if (File.Exists(src))
{
//文件复制
try
{
File.Copy(src, dest, true);
}
catch (Exception e)
{
Error = e;
return false;
}
return true;
}
else
{
return Copy(src, dest);
}
}
/// <summary>
/// 从 文件夹 sourceDirName 内 把扩展名为 extname 的文件 复制到 destDirName文件夹内
/// </summary>
/// <param name="sourceDirName"></param>
/// <param name="destDirName"></param>
/// <returns></returns>
public static bool Copy(string sourceDirName, string destDirName, string[] extnames)
{
if (!Directory.Exists(sourceDirName))
return false;
if (!Directory.Exists(destDirName))
Directory.CreateDirectory(destDirName);
string[] files = Directory.GetFiles(sourceDirName);
foreach (string fromFileName in files)
{
if (extnames.Any(ext => fromFileName.EndsWith(ext)))
{
string fileName = Path.GetFileName(fromFileName);
string toFileName = Path.Combine(destDirName, fileName);
try
{
File.Copy(fromFileName, toFileName, true);
}
catch (Exception e)
{
Error = e;
return false;
}
}
}
return true;
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public class HttpExt
{
/// <summary>
/// http下载文件
/// </summary>
/// <param name="url">下载文件地址</param>
/// <returns></returns>
public static byte[] HttpDownload(string url)
{
try
{
MemoryStream fs = new MemoryStream();
// 设置参数
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
//发送请求并获取相应回应数据
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
//直到request.GetResponse()程序才开始向目标网页发送Post请求
Stream responseStream = response.GetResponseStream();
//创建本地文件写入流
long totalSize = response.ContentLength;
int postion = 0;
byte[] bArr = new byte[1024];
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
while (size > 0)
{
postion += size;
fs.Write(bArr, 0, size);
size = responseStream.Read(bArr, 0, (int)bArr.Length);
}
Console.WriteLine();
//stream.Close();
fs.Close();
responseStream.Close();
return fs.ToArray();
}
catch (Exception ex)
{
Console.WriteLine(ex);
return null;
}
}
/// <summary>
///
/// </summary>
/// <param name="url">下载的路径</param>
/// <param name="path">下载到的本地位置</param>
/// <param name="md5">md5</param>
/// <param name="totalSizeChanged">文件总大小 byte</param>
/// <param name="currSizeChanged">已经下载大小 byte</param>
/// <param name="speedChanged">下载速度 byte/s</param>
/// <param name="elapsedTimeSecChanged">已经消耗的秒数</param>
/// <param name="remainingTimeSecChanged">预计剩余秒数</param>
/// <returns></returns>
public static bool BreakpointDownload(
string url, string path, string md5,
Action<long> totalSizeChanged = null,
Action<long> currSizeChanged = null,
Action<long> speedChanged = null,
Action<int> elapsedTimeSecChanged = null,
Action<int> remainingTimeSecChanged = null)
{
//1.下载 md5 文件
string path_md5 = $"{path}.md5";
if (File.Exists(path_md5))
{
//获取本地 md5
StreamReader sr = new StreamReader(path_md5, System.Text.Encoding.UTF8);
string localMd5 = sr.ReadLine();
localMd5 = localMd5.Trim();
sr.Close();
//2. 检测 下载回来的md5 与 本地的md5 是否一致, 一致则断点下载
if (md5 == localMd5)
{
//相同, 继续下载
bool ret = BreakpointDownload(url, path, false, totalSizeChanged, currSizeChanged, speedChanged, elapsedTimeSecChanged, remainingTimeSecChanged);
if (ret == true)
{
//下载完了
//把本地的 md5 文件删除
File.Delete(path_md5);
}
return ret;
}
}
{
//没有本地 md5 信息,创建
//保存到 filePath.md5
StreamWriter sw = new StreamWriter(path_md5, false, System.Text.Encoding.UTF8);
sw.WriteLine(md5);
sw.Flush();
sw.Close();
//重新下载
return BreakpointDownload(url, path, true, totalSizeChanged, currSizeChanged, speedChanged, elapsedTimeSecChanged, remainingTimeSecChanged);
}
}
/// <summary>
///
/// </summary>
/// <param name="url">下载的路径</param>
/// <param name="path">下载到的本地位置</param>
/// <param name="isRedownload">重新下载?</param>
/// <param name="totalSizeChanged">文件总大小 byte</param>
/// <param name="currSizeChanged">已经下载大小 byte</param>
/// <param name="speedChanged">下载速度 byte/s</param>
/// <param name="elapsedTimeSecChanged">已经消耗的秒数</param>
/// <param name="remainingTimeSecChanged">预计剩余秒数</param>
/// <returns></returns>
public static bool BreakpointDownload(
string url, string path, bool isRedownload=false,
Action<long> totalSizeChanged = null,
Action<long> currSizeChanged =null,
Action<long> speedChanged = null,
Action<int> elapsedTimeSecChanged = null,
Action<int> remainingTimeSecChanged = null)
{
string tempPath = System.IO.Path.GetDirectoryName(path);// + @"\temp";
if (!string.IsNullOrEmpty(tempPath))
{
//先新建文件夹
if(!System.IO.Directory.Exists(tempPath))
System.IO.Directory.CreateDirectory(tempPath);
tempPath += @"\";
}
//System.IO.Directory.CreateDirectory(tempPath); //创建临时文件目录
string tempFile = $@"{tempPath}{System.IO.Path.GetFileName(path)}.temp"; //临时文件
if (isRedownload)
{
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path); //存在则删除
}
//重新下载
if (System.IO.File.Exists(tempFile))
{
System.IO.File.Delete(tempFile); //存在则删除
}
}
else {
if (System.IO.File.Exists(path))
return true;//已经下载过了
}
try
{
//FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
// 设置参数
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
request.AddRange(Convert.ToInt32(fs.Length));//接上次下载的字节开始下载文件
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
int elapsedTimeSec = 0;
//发送请求并获取相应回应数据
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
//直到request.GetResponse()程序才开始向目标网页发送Post请求
Stream responseStream = response.GetResponseStream();
long downloadSize = 0;
long currSize = fs.Length;
long totalSize = response.ContentLength + currSize;
currSizeChanged?.Invoke(currSize);
totalSizeChanged?.Invoke(totalSize);
do {
byte[] bArr = new byte[1024];
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
if (size <= 0)
break;//没有数据。。。。
currSize += size;
currSizeChanged?.Invoke(currSize);
downloadSize += size;
if (elapsedTimeSec != (int)stopwatch.Elapsed.TotalSeconds) {
elapsedTimeSec = (int)stopwatch.Elapsed.TotalSeconds;
elapsedTimeSecChanged?.Invoke(elapsedTimeSec);
//过了1秒
long speed = (long)(downloadSize / stopwatch.Elapsed.TotalSeconds);
speedChanged?.Invoke(speed);
//更新剩余时间
int remainingTimeSec = (int)((totalSize - currSize) / speed);
remainingTimeSecChanged?.Invoke(remainingTimeSec);
}
fs.Write(bArr, 0, size);
} while (true);
fs.Close();
responseStream.Close();
//把临时文件,重命名
System.IO.File.Move(tempFile, path);
return true;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace Install.Core.Common
{
public static class IconExt
{
//details: https://msdn.microsoft.com/en-us/library/windows/desktop/ms648075(v=vs.85).aspx
//Creates an array of handles to icons that are extracted from a specified file.
//This function extracts from executable (.exe), DLL (.dll), icon (.ico), cursor (.cur), animated cursor (.ani), and bitmap (.bmp) files.
//Extractions from Windows 3.x 16-bit executables (.exe or .dll) are also supported.
[DllImport("User32.dll")]
public static extern int PrivateExtractIcons(
string lpszFile, //file name
int nIconIndex, //The zero-based index of the first icon to extract.
int cxIcon, //The horizontal icon size wanted.
int cyIcon, //The vertical icon size wanted.
IntPtr[] phicon, //(out) A pointer to the returned array of icon handles.
int[] piconid, //(out) A pointer to a returned resource identifier.
int nIcons, //The number of icons to extract from the file. Only valid when *.exe and *.dll
int flags //Specifies flags that control this function.
);
//details:https://msdn.microsoft.com/en-us/library/windows/desktop/ms648063(v=vs.85).aspx
//Destroys an icon and frees any memory the icon occupied.
[DllImport("User32.dll")]
public static extern bool DestroyIcon(
IntPtr hIcon //A handle to the icon to be destroyed. The icon must not be in use.
);
//public static int SaveIcon(string exePath, string outFolder)
//{
// //指定存放图标的文件夹
// if (!Directory.Exists(outFolder)) Directory.CreateDirectory(outFolder);
// //选中文件中的图标总数
// var iconTotalCount = PrivateExtractIcons(exePath, 0, 0, 0, null, null, 0, 0);
// //用于接收获取到的图标指针
// IntPtr[] hIcons = new IntPtr[iconTotalCount];
// //对应的图标id
// int[] ids = new int[iconTotalCount];
// //成功获取到的图标个数
// var successCount = PrivateExtractIcons(exePath, 0, 256, 256, hIcons, ids, iconTotalCount, 0);
// string filename = Path.GetFileNameWithoutExtension(exePath);
// //遍历并保存图标
// for (var i = 0; i < successCount; i++)
// {
// //指针为空,跳过
// if (hIcons[i] == IntPtr.Zero) continue;
// using (var ico = Icon.FromHandle(hIcons[i]))
// {
// using (var myIcon = ico.ToBitmap())
// {
// string iconpath = $@"{outFolder}\{filename}.png";
// if (i == 0)
// iconpath = $@"{outFolder}\{filename}.png";
// else
// iconpath = $@"{outFolder}\{filename}{ids[i]:000} .png";
// if (File.Exists(iconpath))
// File.Delete(iconpath);
// myIcon.Save(iconpath, ImageFormat.Png);
// }
// }
// //内存回收
// DestroyIcon(hIcons[i]);
// }
// return successCount;
//}
public static bool SaveIcon(string exePath, string outFolder)
{
//指定存放图标的文件夹
if (!Directory.Exists(outFolder)) Directory.CreateDirectory(outFolder);
string filename = Path.GetFileNameWithoutExtension(exePath);
string iconpath = $@"{outFolder}\{filename}.png";
if (File.Exists(iconpath))
return true;
//选中文件中的图标总数
var iconTotalCount = PrivateExtractIcons(exePath, 0, 0, 0, null, null, 0, 0);
if (iconTotalCount <= 0)
return false;
iconTotalCount = 1;
//用于接收获取到的图标指针
IntPtr[] hIcons = new IntPtr[iconTotalCount];
//对应的图标id
int[] ids = new int[iconTotalCount];
//成功获取到的图标个数
var successCount = PrivateExtractIcons(exePath, 0, 256, 256, hIcons, ids, iconTotalCount, 0);
if (successCount != iconTotalCount)
return false;
//遍历并保存图标
//指针为空,跳过
if (hIcons[0] == IntPtr.Zero) return false;
using (var ico = Icon.FromHandle(hIcons[0]))
{
using (Bitmap myIcon = ico.ToBitmap())
{
myIcon.Save(iconpath, ImageFormat.Png);
}
}
//内存回收
DestroyIcon(hIcons[0]);
return true;
}
public static BitmapSource GetIcon(string exePath)
{
//选中文件中的图标总数
var iconTotalCount = PrivateExtractIcons(exePath, 0, 0, 0, null, null, 0, 0);
if (iconTotalCount <= 0)
return null;
iconTotalCount = 1;
//用于接收获取到的图标指针
IntPtr[] hIcons = new IntPtr[iconTotalCount];
//对应的图标id
int[] ids = new int[iconTotalCount];
//成功获取到的图标个数
var successCount = PrivateExtractIcons(exePath, 0, 256, 256, hIcons, ids, iconTotalCount, 0);
if (successCount != iconTotalCount)
return null;
//遍历并保存图标
//指针为空,跳过
if (hIcons[0] == IntPtr.Zero) return null;
using (var ico = Icon.FromHandle(hIcons[0]))
{
using (Bitmap myIcon = ico.ToBitmap())
{
var bitmapSource =myIcon.CreateBitmapSource();
//内存回收
DestroyIcon(hIcons[0]);
return bitmapSource;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
/// <summary>
/// 安装信息
/// </summary>
public class InstallInfo
{
/// <summary>
/// 安装目录
/// </summary>
public string InstallPath { get; set; }
/// <summary>
/// 执行文件相对安装目录路径
/// </summary>
public string Exe { get; set; }
/// <summary>
/// 快捷方式名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 开机自启动
/// </summary >
public bool IsAutoRun { get; set; }
/// <summary>
/// 版本
/// </summary>
public string Version { get; set; }
/// <summary>
/// 安装包 中 最新版本
/// </summary>
public string NewestVersion { get; set; }
/// <summary>
/// 需要更新
/// </summary>
public bool NeedToUpdate { get; set; }
[Newtonsoft.Json.JsonIgnore]
/// <summary>
/// 在注册表中的keyname
/// </summary>
public string KeyName
{
get
{
//对Exe 转换。
//1.去掉.exe
//2.把所有 . 转为 _
return ProcessName.Replace('.', '_');
}
}
[Newtonsoft.Json.JsonIgnore]
/// <summary>
/// 任务管理器中的名称
/// </summary>
public string ProcessName
{
get
{
//对Exe 转换。
//1.去掉.exe
return System.IO.Path.GetFileNameWithoutExtension(Exe);
}
}
[Newtonsoft.Json.JsonIgnore]
/// <summary>
/// 快捷方式路径
/// </summary>
public string ShortcutPath
{
get {
return $@"{InstallPath}\{Name}.lnk";
}
}
[Newtonsoft.Json.JsonIgnore]
/// <summary>
/// 执行文件 的绝对路径
/// </summary>
public string ExePath
{
get {
return $@"{InstallPath}\{Exe}";
}
}
}
}
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public static class InstallInfoHelper
{
/// <summary>
/// 从注册表获取已经安装程序信息
/// </summary>
/// <returns></returns>
public static List<InstallInfo> GetInstallInfos()
{
List<InstallInfo> installInfos = new List<InstallInfo>();
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\FLYAutomation"); //该项必须已存在
if (key == null)
{
//没有安装任何软件
return installInfos;
}
string[] subKeyNames = key.GetSubKeyNames();
for (int i = 0; i < subKeyNames.Count(); i++)
{
string subKeyName = subKeyNames[i];
var subKey = key.OpenSubKey(subKeyName);
string exePath = subKey.GetValue("ExePath") as string;
string installPath = subKey.GetValue("InstallPath") as string;
string name = subKey.GetValue("Name") as string;
//版本信息从实际的执行文件获取
//string version = subKey.GetValue("Version") as string;
if ((exePath == null) || (installPath == null) || (name == null))
continue;
string path = System.IO.Path.Combine(installPath, exePath);
if (!File.Exists(path))
{
//执行文件不存在,这个没有用的安装信息
continue;
}
FileVersionInfo fileVerInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(path);
//版本号显示为“主版本号.次版本号.内部版本号.专用部件号”。
string version = String.Format("{0}.{1}.{2}.{3}", fileVerInfo.FileMajorPart, fileVerInfo.FileMinorPart, fileVerInfo.FileBuildPart, fileVerInfo.FilePrivatePart);
InstallInfo installInfo = new InstallInfo()
{
InstallPath = installPath,
Exe = System.IO.Path.GetFileName(exePath),
Name = name,
Version = version
};
installInfo.IsAutoRun = CheckAutoRun(installInfo);
installInfos.Add(installInfo);
}
return installInfos;
}
/// <summary>
/// 从路径获取已经安装程序信息
/// </summary>
/// <returns></returns>
public static List<InstallInfo> GetInstallInfosFromPath(InstallPackCollection installPackCollection)
{
List<InstallInfo> installInfos = new List<InstallInfo>();
string installBasePath = installPackCollection.DefaultInstallPath;
if (!Directory.Exists(installBasePath))
return installInfos;
foreach (var installPack in installPackCollection.Items) {
string installPath = $@"{installBasePath}\{installPack.ProcessName}";
string filePath = $@"{installPath}\{installPack.Exe}";
if (!File.Exists(filePath))
continue;//这个软件不存在
FileVersionInfo fileVerInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(filePath);
//版本号显示为“主版本号.次版本号.内部版本号.专用部件号”。
string version = String.Format("{0}.{1}.{2}.{3}", fileVerInfo.FileMajorPart, fileVerInfo.FileMinorPart, fileVerInfo.FileBuildPart, fileVerInfo.FilePrivatePart);
InstallInfo installInfo = new InstallInfo()
{
InstallPath = installPath,
Exe = System.IO.Path.GetFileName(installPack.Exe),
Name = installPack.Name,
Version = version
};
installInfo.IsAutoRun = CheckAutoRun(installInfo);
//补充安装信息
SetInstallInfo(installInfo);
installInfos.Add(installInfo);
}
return installInfos;
}
public static bool SetInstallInfo(InstallInfo item)
{
RegistryKey key3 = Registry.CurrentUser.OpenSubKey($@"Software\FLYAutomation\{item.KeyName}", true);
if (key3 == null)
key3 = Registry.CurrentUser.CreateSubKey($@"Software\FLYAutomation\{item.KeyName}", RegistryKeyPermissionCheck.ReadWriteSubTree);
key3.SetValue("Name", item.Name);
key3.SetValue("ExePath", item.ExePath);
key3.SetValue("InstallPath", item.InstallPath);
key3.SetValue("Version", item.Version);
key3.Close();
return true;
}
public static void RemoveInstallInfo(InstallInfo item)
{
Registry.CurrentUser.DeleteSubKey(@"Software\FLYAutomation\" + item.KeyName, false);
}
public static void SetAutoRun(InstallInfo item)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
key.SetValue(item.KeyName, item.ShortcutPath);
key.Close();
}
public static bool CheckAutoRun(InstallInfo item)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
object o = key.GetValue(item.KeyName);
key.Close();
if (string.IsNullOrEmpty(o as string))
return false;
else
return true;
}
public static void RemoveAutoRun(InstallInfo item)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
key.DeleteValue(item.KeyName, false);
key.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public class InstallPack
{
/// <summary>
/// 本地安装包路径
/// </summary>
public string PackPath { get; set; }
/// <summary>
/// 执行文件相对安装目录路径
/// </summary>
public string Exe { get; set; }
/// <summary>
/// 快捷方式名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 开机自启动
/// </summary >
public bool IsAutoRun { get; set; }
/// <summary>
/// 默认被选择
/// </summary>
public bool IsDefaultSelected { get; set; }
/// <summary>
/// 当升级时,必须复制的文件
/// </summary>
public List<string> Others { get; set; }
/// <summary>
/// 更新程序的脚本dll
/// </summary>
public string UpdateScript { get; set; }
/// <summary>
/// 在 脚本dll 的 脚本类全名
/// </summary>
public string ScriptTypeFullName { get; set; }
/// <summary>
/// 版本
/// </summary>
public string Version { get; set; }
[Newtonsoft.Json.JsonIgnore]
/// <summary>
/// 任务管理器中的名称
/// </summary>
public string ProcessName
{
get
{
//对Exe 转换。
//1.去掉.exe
return System.IO.Path.GetFileNameWithoutExtension(Exe);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public class InstallPackCollection
{
/// <summary>
/// 当前安装包版本号
/// </summary>
public string InstallZipVersion { get; set; }
/// <summary>
/// 最新安装包信息,下载路径
/// </summary>
public string NewestInstallZipVersionInfoPath { get; set; }
/// <summary>
/// 默认最新安装包下载后,放置的路径
/// </summary>
public string DefaultNewestInstallZipPath { get; set; }
/// <summary>
/// 默认安装路径
/// </summary>
public string DefaultInstallPath { get; set; }
/// <summary>
/// 安装包资料
/// </summary>
public List<InstallPack> Items { get; set; } = new List<InstallPack>();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
/// <summary>
/// 在互联网中,最新版本安装包信息
/// </summary>
public class NewestInstallZipVersionInfo
{
/// <summary>
/// 安装包版本号
/// </summary>
public string InstallZipVersion { get; set; }
/// <summary>
/// 安装包路径 7z 最后肯定名字
/// </summary>
public string InstallZipUrl { get; set; }
/// <summary>
/// 安装包文件名,格式为 和美安装包_v7.0.0_20210906 这个是文件夹的名称, 应该从 InstallZipUrl 最后部分提取
/// </summary>
public string InstallZipName {
get {
if (string.IsNullOrEmpty(InstallZipUrl))
return null;
return System.IO.Path.GetFileNameWithoutExtension(InstallZipUrl);
}
}
}
}
using SevenZip;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public static class SeverZipExt
{
public static void Uncompress(string path_7z, string dstPath)
{
string path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;// Assembly.GetExecutingAssembly().Location;
path = Path.GetDirectoryName(path);
//exe的根目录
//设置7z.dll 路径
path = Path.Combine(path, Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
SevenZip.SevenZipBase.SetLibraryPath(path);
//先删除
if (Directory.Exists(dstPath))
{
Directory.Delete(dstPath, true);
}
using (var tmp = new SevenZipExtractor(path_7z))
{
tmp.ExtractArchive(dstPath);
//for (var i = 0; i < tmp.ArchiveFileData.Count; i++)
//{
// tmp.ExtractFiles($@"{dstPath}\", tmp.ArchiveFileData[i].Index);
//}
}
//删除xxx.7z
//File.Delete(filePath);
// return true;
}
}
}

using IWshRuntimeLibrary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
/// <summary>
/// 创建快捷方式的类
/// </summary>
/// <remarks></remarks>
public class ShortcutCreator
{
//需要引入IWshRuntimeLibrary,搜索Windows Script Host Object Model
/// <summary>
/// 创建快捷方式
/// </summary>
/// <param name="directory">快捷方式所处的文件夹</param>
/// <param name="shortcutName">快捷方式名称</param>
/// <param name="targetPath">目标路径</param>
/// <param name="description">描述</param>
/// <param name="iconLocation">图标路径,格式为"可执行文件或DLL路径, 图标编号",
/// 例如System.Environment.SystemDirectory + "\\" + "shell32.dll, 165"</param>
/// <remarks></remarks>
public static void CreateShortcut(string directory, string shortcutName, string targetPath,
string description = null, string iconLocation = null)
{
if (!System.IO.Directory.Exists(directory))
{
System.IO.Directory.CreateDirectory(directory);
}
string shortcutPath = Path.Combine(directory, string.Format("{0}.lnk", shortcutName));
WshShell shell = new WshShell();
//Console.WriteLine("CreateShortcut shortcutPath = " + shortcutPath);
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath);//创建快捷方式对象
//Console.WriteLine("CreateShortcut targetPath = " + targetPath);
shortcut.TargetPath = targetPath;//指定目标路径
shortcut.WorkingDirectory = Path.GetDirectoryName(targetPath);//设置起始位置
shortcut.WindowStyle = 1;//设置运行方式,默认为常规窗口
shortcut.Description = description;//设置备注
shortcut.IconLocation = string.IsNullOrWhiteSpace(iconLocation) ? targetPath : iconLocation;//设置图标路径
shortcut.Save();//保存快捷方式
}
public static void DelShortcut(string directory, string targetPath)
{
if (!System.IO.Directory.Exists(directory))
{
return;
}
WshShell shell = new WshShell();
string[] files = Directory.GetFiles(directory, "*.lnk");
foreach (string fromFileName in files)
{
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(fromFileName);//创建快捷方式对象
if (string.Compare(shortcut.TargetPath, targetPath, true) == 0)
{
System.IO.File.Delete(fromFileName);
}
}
}
public static string GetShortcut(string directory, string targetPath)
{
if (!System.IO.Directory.Exists(directory))
{
return null;
}
WshShell shell = new WshShell();
string[] files = Directory.GetFiles(directory, "*.lnk");
foreach (string fromFileName in files)
{
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(fromFileName);//创建快捷方式对象
if (string.Compare(shortcut.TargetPath, targetPath, true) == 0)
{
return fromFileName;
}
}
return null;
}
/// <summary>
/// 创建桌面快捷方式
/// </summary>
/// <param name="shortcutName">快捷方式名称</param>
/// <param name="targetPath">目标路径</param>
/// <param name="description">描述</param>
/// <param name="iconLocation">图标路径,格式为"可执行文件或DLL路径, 图标编号"</param>
/// <remarks></remarks>
public static void CreateShortcutOnDesktop(string shortcutName, string targetPath,
string description = null, string iconLocation = null)
{
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);//获取桌面文件夹路径
CreateShortcut(desktop, shortcutName, targetPath, description, iconLocation);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Install.Core.Common
{
/// <summary>
/// 给定 程序集其中一个类,需要获取程序集版本号
/// </summary>
public class Ver
{
/// <summary>
/// 产品名
/// </summary>
public string Product { get; private set; }
/// <summary>
/// 版本号
/// </summary>
public string V { get; private set; }
/// <summary>
/// 编译时间
/// </summary>
public string BuildTime { get; private set; }
public Ver()
{
}
private Type srcType;
/// <summary>
/// 需要获取程序集版本号, 程序集其中一个类
/// </summary>
public Type SrcType
{
get { return srcType; }
set
{
srcType = value;
update();
}
}
void update()
{
Assembly asm = Assembly.GetAssembly(SrcType);
AssemblyProductAttribute asmproduct = (AssemblyProductAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyProductAttribute));
Version version = asm.GetName().Version;
string version_str = string.Format("v{0}.{1}.{2}", version.Major, version.Minor, version.Build);
string location = asm.Location;
string buliddt;
if (!string.IsNullOrEmpty(location))
{
buliddt = System.IO.File.GetLastWriteTime(location).ToString("yyyyMMdd");
}
else
{
buliddt = "";
}
Product = asmproduct.Product;
V = version_str;
BuildTime = buliddt;
}
public override string ToString()
{
if (!string.IsNullOrEmpty(BuildTime))
{
return Product + " " + V + " at " + BuildTime;
}
else
{
return Product + " " + V;
}
}
}
public static class VerExt
{
public static int[] String2Version(string version)
{
int[] version_parts = new int[3];
Regex regex = new Regex(@"(\d*).(\d*).(\d*)");
var match = regex.Match(version);
if (match.Success)
{
version_parts[0] = int.Parse(match.Groups[1].Value);
version_parts[1] = int.Parse(match.Groups[2].Value);
version_parts[2] = int.Parse(match.Groups[3].Value);
return version_parts;
}
else {
return null;
}
}
public static int VersionCompare(string version1, string version2)
{
var ver_parts1 = String2Version(version1);
var ver_parts2 = String2Version(version2);
if (ver_parts1 == null && ver_parts2 == null)
return 0;
if (ver_parts1 == null && ver_parts2 != null)
return -1;
if (ver_parts1 != null && ver_parts2 == null)
return 1;
for (int i = 0; i < 3; i++) {
if (ver_parts1[i] < ver_parts2[i])
return -1;
else if (ver_parts1[i] > ver_parts2[i])
return 1;
}
return 0;
}
}
}
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
using Install.Core.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core
{
public interface IUpdateScript
{
/// <summary>
///
/// </summary>
/// <param name="installPack">安装包资料</param>
/// <param name="currVersion">还没升级前的版本号</param>
/// <param name="installPath">安装包中,软件的路径</param>
/// <param name="showMessage">升级过程,显示的信息</param>
/// <returns></returns>
bool Update(InstallPack installPack, string currVersion, string installPath, Action<string> showMessage);
}
}
<?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>{B89EA330-7A10-4974-91BA-72B00FE5B873}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Install.Core</RootNamespace>
<AssemblyName>InstallCommon</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Interop.IWshRuntimeLibrary">
<HintPath>..\dll\Interop.IWshRuntimeLibrary.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Common\BitmapExt.cs" />
<Compile Include="Common\CMD.cs" />
<Compile Include="Common\CopyExt.cs" />
<Compile Include="Common\HttpExt.cs" />
<Compile Include="Common\IconExt.cs" />
<Compile Include="Common\InstallInfo.cs" />
<Compile Include="Common\InstallInfoHelper.cs" />
<Compile Include="Common\InstallPack.cs" />
<Compile Include="Common\InstallPackCollection.cs" />
<Compile Include="Common\NewestInstallZipVersionInfo.cs" />
<Compile Include="Common\SeverZipExt.cs" />
<Compile Include="Common\ShortcutCreator.cs" />
<Compile Include="Common\Ver.cs" />
<Compile Include="IUpdateScript.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.4.0</Version>
</PackageReference>
<PackageReference Include="SevenZipSharp.Interop">
<Version>19.0.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("InstallCommon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InstallCommon")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("b89ea330-7a10-4974-91ba-72b00fe5b873")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
<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>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/MyStyle.xaml"/>
<ResourceDictionary Source="Converters/MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Update
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace Update.Converters
{
public class Abort2VisConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double progress = (double)value;
if (progress < 1)
return Visibility.Visible;
else
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class Finish2VisConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double progress = (double)value;
if (progress >= 1)
return Visibility.Visible;
else
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Update.Converters
{
public class Equals2BoolConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return false;
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return true;
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((bool)value == true)
{
return parameter;
}
else
{
return null;
}
}
#endregion
}
/// <summary>
/// 逻辑反向
/// </summary>
public class BoolReverseConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool b = (bool)value;
return !b;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool b = (bool)value;
return !b;
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Update.Converters
{
public class Equals2VisibleConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Visible;
}
return System.Windows.Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2VisibleConverter_Collapsed : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Visible;
}
return System.Windows.Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2CollapsedConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Collapsed;
}
return System.Windows.Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
public class Equals2HiddenConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Type tv = value.GetType();
Type tp = parameter.GetType();
if (tp.Equals(tv))
{
if (value.Equals(parameter))
return System.Windows.Visibility.Hidden;
}
return System.Windows.Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media.Imaging;
namespace Update.Converters
{
public class IconConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
string processName = values[0] as string;
Dictionary<string, BitmapSource> icons = values[1] as Dictionary<string, BitmapSource>;
if (string.IsNullOrEmpty(processName))
{
return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
}
if (icons == null)
{
return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
}
if (!icons.ContainsKey(processName))
{
return new BitmapImage(new Uri("Images/cross.png", UriKind.Relative));
}
return icons[processName];
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Update.Converters
{
public class ListBoxItemWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double w = (double)value;
return w - 50;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Update.Converters"
xmlns:conv="clr-namespace:Update.Converters"
>
<local:IconConverter x:Key="iconConv"/>
<local:Abort2VisConverter x:Key="abortConv"/>
<local:Finish2VisConverter x:Key="finishConv"/>
<local:ListBoxItemWidthConverter x:Key="lbiwConv"/>
<conv:VisibilityConverter x:Key="visbilityconv" />
<conv:Equals2VisibleConverter_Collapsed x:Key="e2visconv_collapsed" />
<conv:Equals2VisibleConverter x:Key="e2visconv" />
<conv:Equals2HiddenConverter x:Key="e2hiddenconv" />
<conv:Equals2CollapsedConverter x:Key="e2collapsedconv" />
<conv:Equals2BoolConverter x:Key="e2bconv"/>
<conv:BoolReverseConverter x:Key="brconv"/>
</ResourceDictionary>
\ 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.Data;
namespace Update.Converters
{
public class VisibilityConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool enable = (bool)value;
string p = null;
if (parameter != null)
p = parameter as string;
if (p == "Collapsed")
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else if (p == "HiddenWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
else if (p == "CollapsedWhenTrue")
{
if (!enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Collapsed;
}
else
{
if (enable)
return System.Windows.Visibility.Visible;
else
return System.Windows.Visibility.Hidden;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
<Costura>
<ExcludeAssemblies>
SevenZipSharp
</ExcludeAssemblies>
</Costura>
</Weavers>
\ No newline at end of file
This diff is collapsed.
Install2/Update/Images/cross.png

1.47 KB

<NavigationWindow 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"
mc:Ignorable="d"
Title="[FLY 系列软件] 安装 " Height="600" Width="600" WindowStartupLocation="CenterScreen"
ShowsNavigationUI="False" Icon="info.ico" >
</NavigationWindow>
using Install.Core.Common;
using System.Windows;
using System.Windows.Navigation;
using Update.Core;
using Update.View;
namespace Update
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : NavigationWindow
{
InstallWizard installWizard;
public MainWindow()
{
InitializeComponent();
Ver ver = new Ver() { SrcType = this.GetType() };
this.Title = ver.ToString();
installWizard = new InstallWizard();
if (!installWizard.Init())
{
//异常,不能找到安装包
MessageBox.Show(installWizard.Msg, "异常", MessageBoxButton.OK, MessageBoxImage.Error);
App.Current.Shutdown();
return;
}
Application.Current.Properties[nameof(InstallWizard)] = installWizard;
Application.Current.Properties["NavigationService"] = NavigationService;
PgUpdate p = new PgUpdate();
p.Init();
NavigationService.Navigate(p);
}
}
}
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("FLY系列软件升级检测")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化技术有限公司")]
[assembly: AssemblyProduct("FLY系列软件升级检测")]
[assembly: AssemblyCopyright("Copyright © 2021 flyautomation")]
[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")]
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Install2/Update/info.ico

66.1 KB

File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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