Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
4.4.1.4 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed Apr 6, 2022
1 parent ec9f576 commit 63fdf8b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 179 deletions.
8 changes: 4 additions & 4 deletions Vizpower Plugin Installer/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Window x:Class="Vizpower_Plugin_Installer.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:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
Expand All @@ -24,10 +24,10 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label x:Name="SloganLabel" Content="为了阻挡无限宝的打击,本程序诞生了!" Foreground="Red" Grid.ColumnSpan="4" VerticalAlignment="Center" />
<Label x:Name="CloseSecurityTipLabel" Content="本程序释放的文件可能会引起部分杀毒软件的误报,如果出现误报,&#xD;&#xA;请关闭杀毒软件" Foreground="Red" Grid.ColumnSpan="4" Grid.Row="1" VerticalAlignment="Center" />
<Label x:Name="LocationTipLabel" Content="LoginTool.exe 位置 (位于无限宝安装目录):" Grid.ColumnSpan="3" Grid.Row="2" VerticalAlignment="Center" />
<Label x:Name="CloseDefenderTipLabel" Content="本程序释放的文件可能会引起部分杀毒软件的误报,如果出现误报,&#xD;&#xA;请关闭杀毒软件" Foreground="Red" Grid.ColumnSpan="4" Grid.Row="1" VerticalAlignment="Center" />
<Label x:Name="PathTipLabel" Content="LoginTool.exe 位置 (位于无限宝安装目录):" Grid.ColumnSpan="3" Grid.Row="2" VerticalAlignment="Center" />
<Button x:Name="AboutButton" Content="关于" Click="AboutButton_Click" VerticalAlignment="Bottom" Grid.Column="3" Margin="0,0,0,10" Grid.Row="1" Grid.RowSpan="2" />
<TextBox x:Name="LocationTextBox" TextWrapping="Wrap" Margin="0,0,10,0" VerticalContentAlignment="Center" IsReadOnly="True" Grid.ColumnSpan="3" Grid.Row="3" />
<TextBox x:Name="PathTextBox" Margin="0,0,10,0" VerticalContentAlignment="Center" Grid.ColumnSpan="3" Grid.Row="3" TextChanged="PathTextBox_TextChanged" />
<Button x:Name="NavigateButton" Content="浏览" Click="NavigateButton_Click" Grid.Column="3" Grid.Row="3" VerticalAlignment="Bottom" />

<Label x:Name="TipLabel" Grid.Row="4" MouseDown="TipLabel_MouseDown" Content="使用说明 (旧版)" HorizontalAlignment="Left" Foreground="Blue" Grid.Column="0" VerticalAlignment="Center" />
Expand Down
233 changes: 58 additions & 175 deletions Vizpower Plugin Installer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using MessageBox = System.Windows.Forms.MessageBox;
using OpenFileDialog = System.Windows.Forms.OpenFileDialog;

Expand All @@ -26,19 +23,16 @@ public partial class MainWindow : Window
//CaptureDesktop.dll和WxbPluginGUI.exe在Resources文件夹,替换掉原来的再编译即可
//OriginalCaptureDesktop.dll是原版无限宝CaptureDesktop.dll,用于在拆卸时还原,如文件有更新,可将文件名改为OriginalCaptureDesktop.dll并替换

private const string SpecialVersion = ""; //特殊版本后缀
private const string SpecialVersionSuffix = ""; //特殊版本后缀
private const bool SkipUpdate = false; //是否跳过开启时的检查更新
private const bool KillWxbBeforeInstall = true; //安装前是否自动杀死无限宝相关进程
private const bool KillWxbBeforeUninstall = true; //拆卸前是否自动杀死无限宝相关进程
private const string AgreementUrl = @"https://yuhuison-1259460701.cos.ap-chengdu.myqcloud.com/mzsm.html"; //用户协议Url
private const string InstallTipUrl = @"https://gitee.com/klxn/wxbplugin/raw/master/install.png"; //安装提示Url
private const string InstallVideoUrl = @"https://www.bilibili.com/video/BV1Ca4y1E7mx"; //使用教程Url
private const string InstallVideoUrl = @"https://www.bilibili.com/video/BV1Ca4y1E7mx"; //视频教程Url

//注意:打包请勿修改下方内容
private static readonly Version CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version; //当前版本
private static readonly int CurrentVersionCode = int.Parse(CurrentVersion.Major.ToString() + CurrentVersion.Minor.ToString() + CurrentVersion.Build.ToString()); //当前版本号

private static string FileName = ""; //LoginTool.exe的名字
private static readonly Version CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version; //当前版本信息
private static string CaptureDesktopPath = "";
private static string WxbPluginGUIExePath = "";
private static string WxbPluginGUIDllPath = "";
Expand All @@ -48,216 +42,105 @@ public MainWindow(string[] args)
InitializeComponent();

//联网检查更新
if (!SkipUpdate && Strings.Left(Environment.OSVersion.ToString(), 22) != "Microsoft Windows NT 5")
if (!SkipUpdate)
Task.Run(CheckUpdateOnline);

//修改全局标题
Title = "无限宝第三方插件 " + CurrentVersion.Major + "." + CurrentVersion.Minor + "." + CurrentVersion.Build + " " + SpecialVersion + (string.IsNullOrEmpty(SpecialVersion) ? "安装器" : " 安装器");
Title = "无限宝第三方插件 " + CurrentVersion.ToString().Substring(0, 5) + " " + SpecialVersionSuffix + (string.IsNullOrEmpty(SpecialVersionSuffix) ? "安装器" : " 安装器");

//填充安装路径
if (args.Length >= 1 && File.Exists(args[0]) && Path.GetFileName(args[0]).StartsWith("LoginTool") && Path.GetFileName(args[0]).EndsWith(".exe"))
DealWithPath(args[0]);
else if (File.Exists(Properties.Settings.Default.FilePath))
DealWithPath(Properties.Settings.Default.FilePath);
if (args.Length >= 1)
PathTextBox.Text = args[0];
else
PathTextBox.Text = Properties.Settings.Default.FilePath;
}
private void CheckUpdateOnline()
private async void CheckUpdateOnline()
{
try
{
string WebText = GetWebCode("https://gitee.com/klxn/wxbplugin/raw/master/service.txt"); //API返回结果

if (Strings.Split(WebText, "<版本>").ToList().Count < 3)
string currentVersionCode = CurrentVersion.Major.ToString() + CurrentVersion.Minor.ToString() + CurrentVersion.Build.ToString(); //当前版本号
string httpResponseStr = await new HttpClient().GetStringAsync("https://gitee.com/klxn/wxbplugin/raw/master/service.txt");
string latestVersion = Strings.Split(httpResponseStr, "<版本>")[1];
string latestVersionCode = "";
for (int i = 1; i <= latestVersion.Length; ++i)
latestVersionCode += (Strings.AscW(Strings.Mid(latestVersion, i, 1)) >= 48 && Strings.AscW(Strings.Mid(latestVersion, i, 1)) <= 57) ? Strings.Mid(latestVersion, i, 1) : "";

if (int.Parse(latestVersionCode) > int.Parse(currentVersionCode))
{
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("检查更新失败,请检查网络连接", Title);
}));
return;
}
string forceUpdate = Strings.Split(httpResponseStr, "<强制更新>")[1];
string downLoadURL = Strings.Split(httpResponseStr, "<链接>")[1];

string LatestVersion = Strings.Split(WebText, "<版本>")[1];

int LatestVersionCode = 0;
try
{
string Num = "";
for (int i = 1; i <= LatestVersion.Length; ++i)
Num += (Strings.AscW(Strings.Mid(LatestVersion, i, 1)) >= 48 && Strings.AscW(Strings.Mid(LatestVersion, i, 1)) <= 57) ? Strings.Mid(LatestVersion, i, 1) : "";

LatestVersionCode = int.Parse(Num);
}
catch
{
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("处理联网信息时发生错误,请向开发者反馈", Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}));
return;
}
if (LatestVersionCode > CurrentVersionCode)
{
string ForceUpdate = Strings.Split(WebText, "<强制更新>")[1];
string DownLoadURL = Strings.Split(WebText, "<链接>")[1];

if (ForceUpdate == "0")
if (forceUpdate == "0")
{
//非强制更新
Dispatcher.Invoke(new Action(() =>
Dispatcher.Invoke(() =>
{
if (MessageBox.Show("插件已有更新,最新版本:" + LatestVersion + "\n是否跳转下载更新?", Title, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes)
Process.Start(DownLoadURL);
}));
if (MessageBox.Show("插件已有更新,最新版本:" + latestVersion + "\n是否跳转下载更新?", Title, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes)
Process.Start(downLoadURL);
});
}
else
{
//强制更新
Dispatcher.Invoke(new Action(() =>
Dispatcher.Invoke(() =>
{
MessageBox.Show("本版本已停用,最新版本:" + LatestVersion + "\n即将跳转下载更新", Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}));
MessageBox.Show("本版本已停用,最新版本:" + latestVersion + "\n即将跳转下载更新", Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
});

Process.Start(DownLoadURL);
Process.Start(downLoadURL);

Environment.Exit(0);
}
}
}
catch
{
Dispatcher.Invoke(new Action(() =>
{
MessageBox.Show("处理联网信息时发生错误,请向开发者反馈", Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}));
Dispatcher.Invoke(() => { MessageBox.Show("检查更新时发生错误,请检查网络连接", Title, MessageBoxButtons.OK, MessageBoxIcon.Error); });
return;
}
}
private string GetWebCode(string strURL)

//路径处理
private void PathTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
Uri arg_15_0 = new Uri(strURL);
byte[] i;
Queue<byte> dataQue = new Queue<byte>();
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(arg_15_0);
DateTime sTime = Conversions.ToDate("1990-09-21 00:00:00");
httpReq.IfModifiedSince = sTime;
httpReq.Method = "GET";
httpReq.Timeout = 6000;
HttpWebResponse httpResp;
try
if (File.Exists(PathTextBox.Text) && Path.GetFileName(PathTextBox.Text).StartsWith("LoginTool") && Path.GetFileName(PathTextBox.Text).EndsWith(".exe"))
{
httpResp = (HttpWebResponse)httpReq.GetResponse();
}
catch (Exception arg_58_0)
{
ProjectData.SetProjectError(arg_58_0);
string GetWebCode = "<title>no thing found</title>";
ProjectData.ClearProjectError();
return GetWebCode;
}
Stream ioS = httpResp.GetResponseStream();
checked
{
while (ioS.CanRead)
{
try
{
dataQue.Enqueue((byte)ioS.ReadByte());
}
catch (Exception arg_87_0)
{
ProjectData.SetProjectError(arg_87_0);
ProjectData.ClearProjectError();
break;
}
}
i = new byte[dataQue.Count - 1 + 1];
int num = dataQue.Count - 1;
for (int j = 0; j <= num; j++)
{
i[j] = dataQue.Dequeue();
}
string tCode = Encoding.GetEncoding("UTF-8").GetString(i);
string charSet = Strings.Replace(Conversions.ToString(GetByDiv2(tCode, "charset=", "\"")), "\"", "", 1, -1, CompareMethod.Binary);
if (Operators.CompareString(charSet, "", false) == 0)
{
if (Operators.CompareString(httpResp.CharacterSet, "", false) == 0)
{
tCode = Encoding.GetEncoding("UTF-8").GetString(i);
}
else
{
tCode = Encoding.GetEncoding(httpResp.CharacterSet).GetString(i);
}
}
else
{
tCode = Encoding.GetEncoding(charSet).GetString(i);
}
string GetWebCode = tCode;
if (Operators.CompareString(tCode, "", false) == 0)
{
GetWebCode = "<title>no thing found</title>";
}
return GetWebCode;
PathTextBox.Foreground = Brushes.Black;
DealWithPath(PathTextBox.Text);
}
else
PathTextBox.Foreground = Brushes.Red;
}
private object GetByDiv2(string code, string divBegin, string divEnd)
private void DealWithPath(string filePath)
{
int lens = Strings.Len(divBegin);
checked
{
object GetByDiv2;
if (Strings.InStr(1, code, divBegin, CompareMethod.Binary) == 0)
{
GetByDiv2 = "";
}
else
{
int lgStart = Strings.InStr(1, code, divBegin, CompareMethod.Binary) + lens;
int lgEnd = Strings.InStr(lgStart + 1, code, divEnd, CompareMethod.Binary);
if (lgEnd == 0)
{
GetByDiv2 = "";
}
else
{
GetByDiv2 = Strings.Mid(code, lgStart, lgEnd - lgStart);
}
}
return GetByDiv2;
}
string fileName = Path.GetFileName(filePath); //文件名(包括后缀名)

CaptureDesktopPath = filePath.Replace(fileName, "CaptureDesktop.dll");
WxbPluginGUIExePath = filePath.Replace(fileName, "WxbPluginGUI.exe");
WxbPluginGUIDllPath = filePath.Replace(fileName, "wxbPluginGUI.dll");

Properties.Settings.Default.FilePath = filePath;
Properties.Settings.Default.Save();

if (File.Exists(CaptureDesktopPath) && File.Exists(WxbPluginGUIExePath))
InstallButton.Content = "更新";
}

//安装路径
//浏览路径
private void NavigateButton_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "无限宝登陆工具|LoginTool*.exe" };

if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
DealWithPath(openFileDialog.FileName);
}
private void DealWithPath(string filePath)
{
LocationTextBox.Text = filePath; //路径
FileName = Path.GetFileName(filePath); //文件名(包括后缀名)

CaptureDesktopPath = LocationTextBox.Text.Replace(FileName, "CaptureDesktop.dll");
WxbPluginGUIExePath = LocationTextBox.Text.Replace(FileName, "WxbPluginGUI.exe");
WxbPluginGUIDllPath = LocationTextBox.Text.Replace(FileName, "wxbPluginGUI.dll");

Properties.Settings.Default.FilePath = LocationTextBox.Text;
Properties.Settings.Default.Save();

if (File.Exists(CaptureDesktopPath) &&
File.Exists(WxbPluginGUIExePath))
InstallButton.Content = "更新";
PathTextBox.Text = openFileDialog.FileName;
}

//安装拆卸
private void InstallButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(LocationTextBox.Text) || string.IsNullOrEmpty(FileName))
if (PathTextBox.Foreground != Brushes.Black)
{
MessageBox.Show("请点击浏览找到 LoginTool.exe 文件", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("请在输入框中填入正确的 LoginTool.exe 文件路径", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

Expand Down Expand Up @@ -296,9 +179,9 @@ private void InstallButton_Click(object sender, EventArgs e)
}
private void UninstallButton_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(LocationTextBox.Text) || string.IsNullOrEmpty(FileName))
if (PathTextBox.Foreground != Brushes.Black)
{
MessageBox.Show("请点击浏览找到 LoginTool.exe 文件", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("请在输入框中填入正确的 LoginTool.exe 文件路径", Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}

Expand Down
2 changes: 2 additions & 0 deletions Vizpower Plugin Installer/Vizpower Plugin Installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
Expand Down

0 comments on commit 63fdf8b

Please sign in to comment.