fix:进程崩溃判定错误 improve:重新配置了自动更新
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
|
||||
namespace Ink_Canvas.Helpers
|
||||
{
|
||||
@@ -122,7 +123,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
private static string updatesFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ink Canvas Annotation", "AutoUpdate");
|
||||
private static string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
private static string statusFilePath = null;
|
||||
|
||||
public static async Task<bool> DownloadSetupFileAndSaveStatus(string version, string proxy = "")
|
||||
@@ -137,49 +138,172 @@ namespace Ink_Canvas.Helpers
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure update directory exists
|
||||
if (!Directory.Exists(updatesFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(updatesFolderPath);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Created updates directory: {updatesFolderPath}");
|
||||
}
|
||||
|
||||
// Use the correct URL format for GitHub releases
|
||||
string downloadUrl = $"{proxy}https://github.com/awesome-iwb/icc-ce/releases/download/{version}/InkCanvasForClass.CE.{version}.zip";
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Download URL: {downloadUrl}");
|
||||
|
||||
SaveDownloadStatus(false);
|
||||
string zipFilePath = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
await DownloadFile(downloadUrl, zipFilePath);
|
||||
SaveDownloadStatus(true);
|
||||
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Setup file successfully downloaded.");
|
||||
return true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Target file path: {zipFilePath}");
|
||||
|
||||
bool downloadSuccess = await DownloadFile(downloadUrl, zipFilePath);
|
||||
|
||||
if (downloadSuccess)
|
||||
{
|
||||
SaveDownloadStatus(true);
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Setup file successfully downloaded.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Failed to download the update file.", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error downloading update: {ex.Message}", LogHelper.LogType.Error);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Inner exception: {ex.InnerException.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
|
||||
SaveDownloadStatus(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task DownloadFile(string fileUrl, string destinationPath)
|
||||
private static async Task<bool> DownloadFile(string fileUrl, string destinationPath)
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpResponseMessage response = await client.GetAsync(fileUrl);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
using (FileStream fileStream = File.Create(destinationPath))
|
||||
// Configure client
|
||||
client.Timeout = TimeSpan.FromMinutes(5); // Longer timeout for downloading larger files
|
||||
client.DefaultRequestHeaders.Add("User-Agent", "ICC-CE Auto Updater");
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Downloading from: {fileUrl}");
|
||||
|
||||
// 创建临时文件路径
|
||||
string tempFilePath = destinationPath + ".tmp";
|
||||
|
||||
// 确保目标目录存在
|
||||
string directory = Path.GetDirectoryName(destinationPath);
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
await response.Content.CopyToAsync(fileStream);
|
||||
fileStream.Close();
|
||||
Directory.CreateDirectory(directory);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Created directory: {directory}");
|
||||
}
|
||||
|
||||
// 删除可能存在的临时文件
|
||||
if (File.Exists(tempFilePath))
|
||||
{
|
||||
File.Delete(tempFilePath);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Deleted existing temp file");
|
||||
}
|
||||
|
||||
// 使用流式下载而不是一次性加载到内存
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Starting download...");
|
||||
|
||||
// 获取响应但不读取内容
|
||||
HttpResponseMessage response = await client.GetAsync(fileUrl, HttpCompletionOption.ResponseHeadersRead);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
// 获取文件大小(如果服务器提供)
|
||||
long? totalBytes = response.Content.Headers.ContentLength;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Expected file size: {(totalBytes.HasValue ? totalBytes.Value.ToString() : "unknown")} bytes");
|
||||
|
||||
// 使用流式方式下载文件
|
||||
using (var contentStream = await response.Content.ReadAsStreamAsync())
|
||||
using (var fileStream = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true))
|
||||
{
|
||||
byte[] buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
long totalBytesRead = 0;
|
||||
int progressPercent = 0;
|
||||
|
||||
while ((bytesRead = await contentStream.ReadAsync(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
await fileStream.WriteAsync(buffer, 0, bytesRead);
|
||||
|
||||
totalBytesRead += bytesRead;
|
||||
|
||||
// 报告进度(每10%)
|
||||
if (totalBytes.HasValue)
|
||||
{
|
||||
int newProgressPercent = (int)((totalBytesRead * 100) / totalBytes.Value);
|
||||
if (newProgressPercent >= progressPercent + 10)
|
||||
{
|
||||
progressPercent = newProgressPercent;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Download progress: {progressPercent}%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 确保所有数据都写入到文件
|
||||
await fileStream.FlushAsync();
|
||||
}
|
||||
|
||||
// 检查临时文件大小
|
||||
if (new FileInfo(tempFilePath).Length == 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Downloaded file is empty", LogHelper.LogType.Error);
|
||||
if (File.Exists(tempFilePath)) File.Delete(tempFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 如果目标文件已存在,先删除
|
||||
if (File.Exists(destinationPath))
|
||||
{
|
||||
File.Delete(destinationPath);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Deleted existing destination file");
|
||||
}
|
||||
|
||||
// 将临时文件移动到最终位置
|
||||
File.Move(tempFilePath, destinationPath);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | File saved to: {destinationPath}");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Console.WriteLine($"AutoUpdate | HTTP request error: {ex.Message}");
|
||||
throw;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | HTTP request error: {ex.Message}", LogHelper.LogType.Error);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Inner exception: {ex.InnerException.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Download timed out: {ex.Message}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | IO error while downloading: {ex.Message}", LogHelper.LogType.Error);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Inner exception: {ex.InnerException.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"AutoUpdate | Error: {ex.Message}");
|
||||
throw;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error downloading file: {ex.Message}", LogHelper.LogType.Error);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Inner exception: {ex.InnerException.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,6 +333,7 @@ namespace Ink_Canvas.Helpers
|
||||
try
|
||||
{
|
||||
string zipFilePath = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Checking for ZIP file: {zipFilePath}");
|
||||
|
||||
if (!File.Exists(zipFilePath))
|
||||
{
|
||||
@@ -216,84 +341,265 @@ namespace Ink_Canvas.Helpers
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify ZIP file size and validity
|
||||
FileInfo fileInfo = new FileInfo(zipFilePath);
|
||||
if (fileInfo.Length == 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | ZIP file is empty, cannot continue", LogHelper.LogType.Error);
|
||||
return;
|
||||
}
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | ZIP file size: {fileInfo.Length} bytes");
|
||||
|
||||
// 获取当前应用程序路径和进程ID
|
||||
string currentAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
int currentProcessId = Process.GetCurrentProcess().Id;
|
||||
string appPath = Assembly.GetExecutingAssembly().Location;
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Current application directory: {currentAppDir}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Current process ID: {currentProcessId}");
|
||||
|
||||
// 创建批处理文件来执行更新操作
|
||||
string batchFilePath = Path.Combine(Path.GetTempPath(), "UpdateICC_" + Guid.NewGuid().ToString().Substring(0, 8) + ".bat");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Creating update batch file: {batchFilePath}");
|
||||
|
||||
// 构建批处理文件内容
|
||||
StringBuilder batchContent = new StringBuilder();
|
||||
batchContent.AppendLine("@echo off");
|
||||
|
||||
// 使窗口隐藏(使用VBS脚本运行隐藏窗口)
|
||||
batchContent.AppendLine("echo Set objShell = CreateObject(\"WScript.Shell\") > \"%temp%\\hideme.vbs\"");
|
||||
batchContent.AppendLine("echo objShell.Run \"cmd /c \"\"\" ^& WScript.Arguments(0) ^& \"\"\"\", 0, True >> \"%temp%\\hideme.vbs\"");
|
||||
batchContent.AppendLine($"echo Wscript.Sleep 100 >> \"%temp%\\hideme.vbs\"");
|
||||
|
||||
// 创建真正的更新批处理文件
|
||||
string updateBatPath = Path.Combine(Path.GetTempPath(), "ICCUpdate_" + Guid.NewGuid().ToString().Substring(0, 8) + ".bat");
|
||||
batchContent.AppendLine($"echo @echo off > \"{updateBatPath}\"");
|
||||
|
||||
// 写入等待进程退出的代码到更新批处理文件
|
||||
batchContent.AppendLine($"echo set PROC_ID={currentProcessId} >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo :CHECK_PROCESS >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo tasklist /fi \"PID eq %PROC_ID%\" ^| find \"%PROC_ID%\" ^> nul >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo if %%ERRORLEVEL%% == 0 ( >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo timeout /t 1 /nobreak ^> nul >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo goto CHECK_PROCESS >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo ) >> \"{updateBatPath}\"");
|
||||
|
||||
// 应用程序已关闭,开始更新操作
|
||||
batchContent.AppendLine($"echo echo Application closed, starting update process... >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo timeout /t 2 /nobreak ^> nul >> \"{updateBatPath}\"");
|
||||
|
||||
// 创建临时解压目录
|
||||
string extractPath = Path.Combine(updatesFolderPath, $"Extract_{version}");
|
||||
if (Directory.Exists(extractPath))
|
||||
{
|
||||
Directory.Delete(extractPath, true);
|
||||
}
|
||||
Directory.CreateDirectory(extractPath);
|
||||
|
||||
// 解压ZIP文件
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Extracting ZIP file to: {extractPath}");
|
||||
ZipFile.ExtractToDirectory(zipFilePath, extractPath);
|
||||
|
||||
// 获取当前应用程序路径
|
||||
string currentAppDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Current application directory: {currentAppDir}");
|
||||
|
||||
// 复制解压的文件到应用程序目录
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Copying files to application directory");
|
||||
CopyDirectory(extractPath, currentAppDir);
|
||||
|
||||
batchContent.AppendLine($"echo echo Extracting update files... >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo if exist \"{extractPath}\" rd /s /q \"{extractPath}\" >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo mkdir \"{extractPath}\" >> \"{updateBatPath}\"");
|
||||
|
||||
// PowerShell解压ZIP文件(因为批处理不直接支持ZIP解压)
|
||||
batchContent.AppendLine($"echo powershell -command \"Expand-Archive -Path '{zipFilePath.Replace("'", "''")}' -DestinationPath '{extractPath.Replace("'", "''")}' -Force\" >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo if %%ERRORLEVEL%% neq 0 ( >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo goto ERROR_EXIT >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo ) >> \"{updateBatPath}\"");
|
||||
|
||||
// 复制文件到应用程序目录
|
||||
batchContent.AppendLine($"echo echo Copying updated files to application directory... >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo xcopy /s /y /e \"{extractPath}\\*\" \"{currentAppDir}\\\" >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo if %%ERRORLEVEL%% neq 0 ( >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo goto ERROR_EXIT >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo ) >> \"{updateBatPath}\"");
|
||||
|
||||
// 清理临时文件
|
||||
if (Directory.Exists(extractPath))
|
||||
{
|
||||
Directory.Delete(extractPath, true);
|
||||
}
|
||||
batchContent.AppendLine($"echo echo Cleaning up temporary files... >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo if exist \"{extractPath}\" rd /s /q \"{extractPath}\" >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo if exist \"{zipFilePath}\" del /f /q \"{zipFilePath}\" >> \"{updateBatPath}\"");
|
||||
|
||||
// 启动更新后的应用程序
|
||||
batchContent.AppendLine($"echo echo Update completed successfully! >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo :: 检查应用程序是否已经在运行 >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo tasklist /FI \"IMAGENAME eq Ink Canvas.exe\" | find /i \"Ink Canvas.exe\" > nul >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo if %%ERRORLEVEL%% neq 0 ( >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo echo 启动应用程序... >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo start \"\" \"{appPath}\" >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo ) else ( >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo echo 应用程序已经在运行,不再重复启动 >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo ) >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo exit /b 0 >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo goto EXIT >> \"{updateBatPath}\"");
|
||||
|
||||
// 错误退出处理
|
||||
batchContent.AppendLine($"echo :ERROR_EXIT >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo start \"\" cmd /c \"echo Update failed! ^& pause\" >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo exit /b 1 >> \"{updateBatPath}\"");
|
||||
|
||||
// 删除批处理文件自身
|
||||
batchContent.AppendLine($"echo :EXIT >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo del \"{updateBatPath}\" >> \"{updateBatPath}\"");
|
||||
batchContent.AppendLine($"echo exit >> \"{updateBatPath}\"");
|
||||
|
||||
// 重启应用程序
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Update completed, restarting application");
|
||||
RestartApplication();
|
||||
// 使用VBS脚本执行更新批处理文件(隐藏窗口)
|
||||
batchContent.AppendLine($"wscript \"%temp%\\hideme.vbs\" \"{updateBatPath}\"");
|
||||
batchContent.AppendLine("del \"%temp%\\hideme.vbs\"");
|
||||
batchContent.AppendLine("exit");
|
||||
|
||||
// 写入批处理文件
|
||||
File.WriteAllText(batchFilePath, batchContent.ToString());
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Created update batch file");
|
||||
|
||||
// 启动批处理文件(隐藏窗口)
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = batchFilePath,
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
});
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Started update batch process with hidden window");
|
||||
|
||||
// 应用程序将由用户手动关闭或由MainWindow中的代码关闭
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error installing update: {ex.Message}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error preparing update installation: {ex.Message}", LogHelper.LogType.Error);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Inner exception: {ex.InnerException.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CopyDirectory(string sourceDir, string destinationDir)
|
||||
private static bool CopyDirectory(string sourceDir, string destinationDir)
|
||||
{
|
||||
// 创建目标目录(如果不存在)
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
|
||||
// 复制所有文件
|
||||
foreach (string filePath in Directory.GetFiles(sourceDir))
|
||||
bool allCopiesSuccessful = true;
|
||||
|
||||
try
|
||||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
string destPath = Path.Combine(destinationDir, fileName);
|
||||
try
|
||||
// 创建目标目录(如果不存在)
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Created/verified destination directory: {destinationDir}");
|
||||
|
||||
// 复制所有文件
|
||||
foreach (string filePath in Directory.GetFiles(sourceDir))
|
||||
{
|
||||
// 如果目标文件存在,先删除
|
||||
if (File.Exists(destPath))
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
string destPath = Path.Combine(destinationDir, fileName);
|
||||
try
|
||||
{
|
||||
File.Delete(destPath);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Copying file: {fileName}");
|
||||
|
||||
// 如果目标文件存在,先删除
|
||||
if (File.Exists(destPath))
|
||||
{
|
||||
File.Delete(destPath);
|
||||
}
|
||||
|
||||
File.Copy(filePath, destPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
allCopiesSuccessful = false;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error copying file {fileName}: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
File.Copy(filePath, destPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error copying file {fileName}: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// 递归复制所有子目录
|
||||
foreach (string subDirPath in Directory.GetDirectories(sourceDir))
|
||||
// 递归复制所有子目录
|
||||
foreach (string subDirPath in Directory.GetDirectories(sourceDir))
|
||||
{
|
||||
string subDirName = Path.GetFileName(subDirPath);
|
||||
string destSubDir = Path.Combine(destinationDir, subDirName);
|
||||
|
||||
bool subDirCopyResult = CopyDirectory(subDirPath, destSubDir);
|
||||
if (!subDirCopyResult)
|
||||
{
|
||||
allCopiesSuccessful = false;
|
||||
}
|
||||
}
|
||||
|
||||
return allCopiesSuccessful;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string subDirName = Path.GetFileName(subDirPath);
|
||||
string destSubDir = Path.Combine(destinationDir, subDirName);
|
||||
CopyDirectory(subDirPath, destSubDir);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error copying directory {sourceDir}: {ex.Message}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RestartApplication()
|
||||
{
|
||||
string appPath = Assembly.GetExecutingAssembly().Location;
|
||||
Process.Start(appPath);
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
try
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
string appPath = Assembly.GetExecutingAssembly().Location;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Restarting application: {appPath}");
|
||||
|
||||
// Create a batch file to wait briefly and then start the application
|
||||
// This allows the current process to fully exit before starting the new instance
|
||||
string batchFilePath = Path.Combine(Path.GetTempPath(), "RestartICC_" + Guid.NewGuid().ToString().Substring(0, 8) + ".bat");
|
||||
|
||||
string batchContent =
|
||||
"@echo off\r\n" +
|
||||
"timeout /t 2 /nobreak >nul\r\n" +
|
||||
":: 检查应用程序是否已经在运行\r\n" +
|
||||
"tasklist /FI \"IMAGENAME eq Ink Canvas.exe\" | find /i \"Ink Canvas.exe\" > nul\r\n" +
|
||||
"if %ERRORLEVEL% neq 0 (\r\n" +
|
||||
" echo 启动应用程序...\r\n" +
|
||||
$" start \"\" \"{appPath}\"\r\n" +
|
||||
") else (\r\n" +
|
||||
" echo 应用程序已经在运行,不再重复启动\r\n" +
|
||||
")\r\n" +
|
||||
"timeout /t 1 /nobreak >nul\r\n" +
|
||||
"del \"%~f0\"\r\n" +
|
||||
"exit\r\n"; // 确保批处理进程结束
|
||||
|
||||
File.WriteAllText(batchFilePath, batchContent);
|
||||
|
||||
// Start the batch file
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "cmd.exe",
|
||||
Arguments = $"/c start \"\" \"{batchFilePath}\"",
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false
|
||||
});
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Created restart script at {batchFilePath}");
|
||||
|
||||
// Shutdown the application
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Shutting down application for restart");
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error restarting application: {ex.Message}", LogHelper.LogType.Error);
|
||||
|
||||
// Fallback direct restart approach
|
||||
try
|
||||
{
|
||||
string appPath = Assembly.GetExecutingAssembly().Location;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Attempting direct restart: {appPath}");
|
||||
|
||||
// 检查是否已有实例运行
|
||||
Process[] processes = Process.GetProcessesByName("Ink Canvas");
|
||||
if (processes.Length <= 1) // 只有当前进程
|
||||
{
|
||||
Process.Start(appPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Application already running, not starting a new instance");
|
||||
}
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
});
|
||||
}
|
||||
catch (Exception fallbackEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Fallback restart also failed: {fallbackEx.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ExecuteCommandLine(string command)
|
||||
@@ -303,7 +609,7 @@ namespace Ink_Canvas.Helpers
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "cmd.exe",
|
||||
Arguments = $"/c {command}",
|
||||
Arguments = $"/c {command} & exit", // 添加exit确保cmd进程退出
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
@@ -313,12 +619,20 @@ namespace Ink_Canvas.Helpers
|
||||
using (Process process = new Process { StartInfo = processStartInfo })
|
||||
{
|
||||
process.Start();
|
||||
// 设置一个超时时间
|
||||
bool exited = process.WaitForExit(500); // 等待500毫秒
|
||||
if (!exited)
|
||||
{
|
||||
// 不等待进程完成,让它在后台运行
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Command is running in background");
|
||||
}
|
||||
Application.Current.Shutdown();
|
||||
/*process.WaitForExit();
|
||||
int exitCode = process.ExitCode;*/
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error executing command: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteUpdatesFolder()
|
||||
@@ -327,12 +641,53 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
if (Directory.Exists(updatesFolderPath))
|
||||
{
|
||||
Directory.Delete(updatesFolderPath, true);
|
||||
// Try to delete all files first in case of locking issues
|
||||
foreach (string file in Directory.GetFiles(updatesFolderPath, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Deleted file: {file}");
|
||||
}
|
||||
catch (Exception fileEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Could not delete file {file}: {fileEx.Message}", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
// Then try to delete subdirectories
|
||||
foreach (string dir in Directory.GetDirectories(updatesFolderPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(dir, true);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Deleted directory: {dir}");
|
||||
}
|
||||
catch (Exception dirEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Could not delete directory {dir}: {dirEx.Message}", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally try to delete the main directory
|
||||
try
|
||||
{
|
||||
Directory.Delete(updatesFolderPath, true);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Deleted updates folder: {updatesFolderPath}");
|
||||
}
|
||||
catch (Exception mainDirEx)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Could not completely delete updates folder: {mainDirEx.Message}", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Updates folder does not exist: {updatesFolderPath}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate clearing| Error deleting updates folder: {ex.Message}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error deleting updates folder: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,3 +729,4 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+134
-11
@@ -21,6 +21,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
public partial class MainWindow : Window {
|
||||
@@ -301,24 +302,146 @@ namespace Ink_Canvas {
|
||||
SystemEvents.DisplaySettingsChanged -= SystemEventsOnDisplaySettingsChanged;
|
||||
|
||||
LogHelper.WriteLogToFile("Ink Canvas closed", LogHelper.LogType.Event);
|
||||
|
||||
// 检查是否有待安装的更新
|
||||
CheckPendingUpdates();
|
||||
}
|
||||
|
||||
private void CheckPendingUpdates()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果有可用的更新版本且启用了自动更新
|
||||
if (AvailableLatestVersion != null && Settings.Startup.IsAutoUpdate)
|
||||
{
|
||||
// 检查更新文件是否已下载
|
||||
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
string statusFilePath = Path.Combine(updatesFolderPath, $"DownloadV{AvailableLatestVersion}Status.txt");
|
||||
|
||||
if (File.Exists(statusFilePath) && File.ReadAllText(statusFilePath).Trim().ToLower() == "true")
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Installing pending update v{AvailableLatestVersion} on application close");
|
||||
|
||||
// 设置为用户主动退出,避免被看门狗判定为崩溃
|
||||
App.IsAppExitByUser = true;
|
||||
|
||||
// 创建批处理脚本并启动,软件关闭后会执行更新操作
|
||||
AutoUpdateHelper.InstallNewVersionApp(AvailableLatestVersion, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error checking pending updates: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async void AutoUpdate() {
|
||||
AvailableLatestVersion = await AutoUpdateHelper.CheckForUpdates();
|
||||
|
||||
if (AvailableLatestVersion != null) {
|
||||
var IsDownloadSuccessful = false;
|
||||
IsDownloadSuccessful = await AutoUpdateHelper.DownloadSetupFileAndSaveStatus(AvailableLatestVersion);
|
||||
// 打开更新提示窗口
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | New version available: {AvailableLatestVersion}");
|
||||
|
||||
// 获取当前版本和发布日期
|
||||
string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
string releaseDate = DateTime.Now.ToString("yyyy年MM月dd日");
|
||||
|
||||
// 创建更新说明内容(可以从服务器获取或直接在此处设置)
|
||||
string releaseNotes = $@"# InkCanvasForClass v{AvailableLatestVersion}更新
|
||||
|
||||
你好,此次更新包含了一系列新功能和改进:
|
||||
|
||||
if (IsDownloadSuccessful) {
|
||||
if (!Settings.Startup.IsAutoUpdateWithSilence) {
|
||||
if (MessageBox.Show("InkCanvasForClass 新版本安装包已下载完成,是否立即更新?",
|
||||
"InkCanvasForClass New Version Available", MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question) ==
|
||||
MessageBoxResult.Yes) AutoUpdateHelper.InstallNewVersionApp(AvailableLatestVersion, false);
|
||||
} else {
|
||||
timerCheckAutoUpdateWithSilence.Start();
|
||||
}
|
||||
1. 修复了一些已知的bug
|
||||
2. 优化了程序性能
|
||||
3. 改进了用户界面
|
||||
4. 添加了新的功能
|
||||
|
||||
感谢您使用InkCanvasForClass CE!";
|
||||
|
||||
// 创建并显示更新窗口
|
||||
HasNewUpdateWindow updateWindow = new HasNewUpdateWindow(currentVersion, AvailableLatestVersion, releaseDate, releaseNotes);
|
||||
bool? dialogResult = updateWindow.ShowDialog();
|
||||
|
||||
// 如果窗口被关闭但没有点击按钮,视为"稍后更新"
|
||||
if (dialogResult != true) {
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update dialog closed without selection");
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新自动更新设置并保存
|
||||
Settings.Startup.IsAutoUpdate = updateWindow.IsAutoUpdateEnabled;
|
||||
Settings.Startup.IsAutoUpdateWithSilence = updateWindow.IsSilentUpdateEnabled;
|
||||
SaveSettingsToFile();
|
||||
|
||||
// 声明下载结果变量
|
||||
bool isDownloadSuccessful;
|
||||
|
||||
// 根据用户选择处理更新
|
||||
switch (updateWindow.Result) {
|
||||
case HasNewUpdateWindow.UpdateResult.UpdateNow:
|
||||
// 立即更新:显示下载进度,下载完成后立即安装
|
||||
LogHelper.WriteLogToFile("AutoUpdate | User chose to update now");
|
||||
|
||||
// 显示下载进度提示
|
||||
MessageBox.Show("开始下载更新,请稍候...", "正在更新", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
|
||||
// 下载更新文件
|
||||
isDownloadSuccessful = await AutoUpdateHelper.DownloadSetupFileAndSaveStatus(AvailableLatestVersion);
|
||||
|
||||
if (isDownloadSuccessful) {
|
||||
// 下载成功,提示用户准备安装
|
||||
MessageBoxResult result = MessageBox.Show("更新已下载完成,点击确定后将关闭软件并安装新版本!", "安装更新", MessageBoxButton.OKCancel, MessageBoxImage.Information);
|
||||
|
||||
// 只有当用户点击确定按钮后才关闭软件
|
||||
if (result == MessageBoxResult.OK) {
|
||||
// 设置为用户主动退出,避免被看门狗判定为崩溃
|
||||
App.IsAppExitByUser = true;
|
||||
|
||||
// 准备批处理脚本
|
||||
AutoUpdateHelper.InstallNewVersionApp(AvailableLatestVersion, false);
|
||||
|
||||
// 关闭软件,让安装程序接管
|
||||
Application.Current.Shutdown();
|
||||
} else {
|
||||
LogHelper.WriteLogToFile("AutoUpdate | User cancelled update installation");
|
||||
}
|
||||
} else {
|
||||
// 下载失败
|
||||
MessageBox.Show("更新下载失败,请检查网络连接后重试。", "下载失败", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
break;
|
||||
|
||||
case HasNewUpdateWindow.UpdateResult.UpdateLater:
|
||||
// 稍后更新:静默下载,在软件关闭时自动安装
|
||||
LogHelper.WriteLogToFile("AutoUpdate | User chose to update later");
|
||||
|
||||
// 不管设置如何,都进行下载
|
||||
isDownloadSuccessful = await AutoUpdateHelper.DownloadSetupFileAndSaveStatus(AvailableLatestVersion);
|
||||
|
||||
if (isDownloadSuccessful) {
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update downloaded successfully, will install when application closes");
|
||||
|
||||
// 设置标志,在应用程序关闭时安装
|
||||
Settings.Startup.IsAutoUpdate = true;
|
||||
Settings.Startup.IsAutoUpdateWithSilence = true;
|
||||
|
||||
// 启动检查定时器
|
||||
timerCheckAutoUpdateWithSilence.Start();
|
||||
|
||||
// 通知用户
|
||||
MessageBox.Show("更新已下载完成,将在软件关闭时自动安装。", "更新已准备就绪", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
} else {
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update download failed", LogHelper.LogType.Error);
|
||||
MessageBox.Show("更新下载失败,请检查网络连接后重试。", "下载失败", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
break;
|
||||
|
||||
case HasNewUpdateWindow.UpdateResult.SkipVersion:
|
||||
// 跳过该版本:记录到设置中
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | User chose to skip version {AvailableLatestVersion}");
|
||||
// 可以在设置中添加"已跳过的版本"列表
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
AutoUpdateHelper.DeleteUpdatesFolder();
|
||||
|
||||
@@ -65,8 +65,22 @@ namespace Ink_Canvas
|
||||
var mainWin = (MainWindow)Application.Current.MainWindow;
|
||||
if (mainWin.IsLoaded) {
|
||||
App.IsAppExitByUser = true;
|
||||
|
||||
try {
|
||||
// 启动新实例
|
||||
string exePath = Process.GetCurrentProcess().MainModule.FileName;
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
startInfo.FileName = exePath;
|
||||
startInfo.UseShellExecute = true;
|
||||
|
||||
// 启动进程但不等待
|
||||
Process.Start(startInfo);
|
||||
} catch (Exception ex) {
|
||||
LogHelper.NewLog($"重启程序时出错: {ex.Message}");
|
||||
}
|
||||
|
||||
// 退出当前实例
|
||||
Application.Current.Shutdown();
|
||||
// mainWin.BtnExit_Click(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.6.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.3.0")]
|
||||
[assembly: AssemblyVersion("1.6.4.0")]
|
||||
[assembly: AssemblyFileVersion("1.6.4.0")]
|
||||
@@ -10,20 +10,24 @@
|
||||
ui:WindowHelper.UseModernWindowStyle = "True"
|
||||
ui:WindowHelper.SystemBackdropType="Mica"
|
||||
ui:TitleBar.Height="36"
|
||||
Title="InkCanvasForClass有新版本可用" Height="475" Width="800" ResizeMode="NoResize">
|
||||
<Grid Background="#fafafa">
|
||||
<ui:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0">
|
||||
Title="InkCanvasForClass CE有新版本可用" Height="680" Width="850" ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<Grid Background="#fafafa" Margin="0,0,0,30">
|
||||
<ui:SimpleStackPanel VerticalAlignment="Stretch" Spacing="0">
|
||||
<!-- 标题栏 -->
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" Background="#2563eb" Margin="0,0,0,0">
|
||||
<ui:SimpleStackPanel Orientation="Vertical" Width="685" Margin="24,18,0,12" Spacing="2">
|
||||
<TextBlock Text="InkCanvasForClass 新版本来了!" FontSize="24" FontWeight="Bold" Foreground="White" TextAlignment="Left"/>
|
||||
<ui:SimpleStackPanel Orientation="Vertical" Width="735" Margin="24,18,0,12" Spacing="2">
|
||||
<TextBlock Text="InkCanvasForClass CE新版本来了!" FontSize="24" FontWeight="Bold" Foreground="White" TextAlignment="Left"/>
|
||||
<TextBlock Text="希望您能喜欢我们的新版本 :-)" FontSize="20" TextAlignment="Left" Foreground="White"/>
|
||||
</ui:SimpleStackPanel>
|
||||
<Image Source="/Resources/Icons-fluent/party.png" Width="72" Height="72"/>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<Border BorderBrush="#3f3f46" Background="White" BorderThickness="1" CornerRadius="4" Margin="24,12,24,0">
|
||||
<ui:ScrollViewerEx Margin="0" VerticalScrollBarVisibility="Auto" Height="256" PanningMode="VerticalOnly">
|
||||
<mdxam:MarkdownScrollViewer xml:space="preserve" Foreground="Black" MarkdownStyleName="GithubLike">
|
||||
<!-- 更新内容 -->
|
||||
<Border BorderBrush="#3f3f46" Background="White" BorderThickness="1" CornerRadius="4" Margin="24,16,24,0">
|
||||
<ui:ScrollViewerEx Margin="0" VerticalScrollBarVisibility="Auto" Height="180" PanningMode="VerticalOnly">
|
||||
<mdxam:MarkdownScrollViewer x:Name="markdownContent" xml:space="preserve" Foreground="Black" MarkdownStyleName="GithubLike">
|
||||
# InkCanvasForClass v5.0.2更新
|
||||
|
||||
你好,旅行者们,本次InkCanvasForClass更新带来了如下新功能供您探索:
|
||||
@@ -39,21 +43,63 @@
|
||||
</mdxam:MarkdownScrollViewer>
|
||||
</ui:ScrollViewerEx>
|
||||
</Border>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="12" Margin="0,8,0,0">
|
||||
<TextBlock Text="本次更新: 4.9.1 -> 5.9.1" FontWeight="Bold" FontSize="14" TextAlignment="Center"/>
|
||||
<TextBlock Text="2024年8月4日发布更新" FontSize="14" TextAlignment="Center"/>
|
||||
|
||||
<!-- 版本信息 -->
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="16" Margin="0,16,0,0">
|
||||
<TextBlock x:Name="updateVersionInfo" Text="本次更新: 4.9.1 -> 5.9.1" FontWeight="Bold" FontSize="15" TextAlignment="Center"/>
|
||||
<TextBlock x:Name="updateDateInfo" Text="2024年8月4日发布更新" FontSize="15" TextAlignment="Center"/>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="12">
|
||||
<Button Content="立刻更新" Foreground="White" HorizontalAlignment="Center" Margin="0,10,0,0">
|
||||
<Button.Resources>
|
||||
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundKey}" Color="#15803d"/>
|
||||
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPointerOverKey}" Color="#15803d"/>
|
||||
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPressedKey}" Color="#166534"/>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<Button Content="下次更新" Foreground="Black" HorizontalAlignment="Center" Margin="0,10,0,0"/>
|
||||
<Button Content="跳过该版本" HorizontalAlignment="Center" Foreground="#71717a" Margin="0,10,0,0"/>
|
||||
|
||||
<!-- 自动更新选项 -->
|
||||
<Border Background="White" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="4" Margin="24,16,24,0">
|
||||
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0,16,0,16" Spacing="10">
|
||||
<TextBlock Text="更新设置" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" Margin="0,0,0,6"/>
|
||||
|
||||
<!-- 水平排列两个ToggleSwitch -->
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="20">
|
||||
<ui:SimpleStackPanel Orientation="Vertical" Spacing="4">
|
||||
<ui:ToggleSwitch x:Name="EnableAutoUpdateToggle" Header="启用自动更新" OnContent="开启" OffContent="关闭" IsOn="True" Width="170" Foreground="Black"/>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<ui:SimpleStackPanel Orientation="Vertical" Spacing="4">
|
||||
<ui:ToggleSwitch x:Name="EnableSilentUpdateToggle" Header="启用静默更新" OnContent="开启" OffContent="关闭" Width="170" Foreground="Black"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<TextBlock Text="静默更新将在软件不使用时自动安装,无需手动操作" FontSize="13" Foreground="#71717a" HorizontalAlignment="Center"
|
||||
Margin="4,0,0,0" Width="360" TextWrapping="Wrap"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 更新按钮组 -->
|
||||
<Border Background="#f1f5f9" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="4" Margin="24,16,24,20">
|
||||
<ui:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="14" Margin="0,16,0,16">
|
||||
<TextBlock Text="请选择更新方式" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" Margin="0,0,0,6"/>
|
||||
|
||||
<!-- 立即更新按钮 -->
|
||||
<Button x:Name="UpdateNowButton" Content="立刻下载并安装" Foreground="White" FontSize="15" FontWeight="SemiBold"
|
||||
Padding="20,10" Width="360" Height="48" HorizontalAlignment="Center"
|
||||
Click="UpdateNowButton_Click" ToolTip="立即下载更新并在完成后安装" Visibility="Visible" IsEnabled="True">
|
||||
<Button.Resources>
|
||||
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundKey}" Color="#15803d"/>
|
||||
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPointerOverKey}" Color="#15803d"/>
|
||||
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPressedKey}" Color="#166534"/>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
|
||||
<!-- 稍后更新按钮 -->
|
||||
<Button x:Name="UpdateLaterButton" Content="下载并在软件关闭时安装" Foreground="Black" FontSize="15"
|
||||
Padding="20,10" Width="360" Height="48" HorizontalAlignment="Center"
|
||||
Click="UpdateLaterButton_Click" Background="#e2e8f0" BorderBrush="#cbd5e1"
|
||||
ToolTip="后台下载更新,在软件关闭时自动安装" Visibility="Visible" IsEnabled="True"/>
|
||||
|
||||
<!-- 跳过版本按钮 -->
|
||||
<Button x:Name="SkipVersionButton" Content="跳过该版本" HorizontalAlignment="Center" Foreground="#71717a"
|
||||
FontSize="15" Padding="20,10" Width="360" Height="48" Click="SkipVersionButton_Click"
|
||||
Background="#f8fafc" BorderBrush="#cbd5e1" ToolTip="跳过此版本更新" Visibility="Visible" IsEnabled="True"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Window>
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
int useImmersiveDarkMode = enabled ? 1 : 0;
|
||||
return DwmSetWindowAttribute(handle, (int)attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
|
||||
return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -55,12 +55,261 @@ namespace Ink_Canvas
|
||||
{
|
||||
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build;
|
||||
}
|
||||
public HasNewUpdateWindow()
|
||||
|
||||
// 存储更新版本信息
|
||||
public string CurrentVersion { get; set; }
|
||||
public string NewVersion { get; set; }
|
||||
public string ReleaseDate { get; set; }
|
||||
public string ReleaseNotes { get; set; }
|
||||
|
||||
// 更新按钮结果
|
||||
public enum UpdateResult
|
||||
{
|
||||
UpdateNow,
|
||||
UpdateLater,
|
||||
SkipVersion
|
||||
}
|
||||
|
||||
public UpdateResult Result { get; private set; } = UpdateResult.UpdateLater;
|
||||
|
||||
// 更新设置
|
||||
public bool IsAutoUpdateEnabled => EnableAutoUpdateToggle.IsOn;
|
||||
public bool IsSilentUpdateEnabled => EnableSilentUpdateToggle.IsOn;
|
||||
|
||||
public HasNewUpdateWindow(string currentVersion, string newVersion, string releaseDate, string releaseNotes = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 设置版本信息
|
||||
CurrentVersion = currentVersion;
|
||||
NewVersion = newVersion;
|
||||
ReleaseDate = releaseDate;
|
||||
ReleaseNotes = releaseNotes;
|
||||
|
||||
// 更新UI
|
||||
updateVersionInfo.Text = $"本次更新: {CurrentVersion} -> {NewVersion}";
|
||||
updateDateInfo.Text = $"{ReleaseDate}发布更新";
|
||||
|
||||
// 如果有发布说明,设置到Markdown内容中
|
||||
if (!string.IsNullOrEmpty(ReleaseNotes))
|
||||
{
|
||||
markdownContent.Markdown = ReleaseNotes;
|
||||
}
|
||||
|
||||
// 初始化自动更新设置
|
||||
EnableAutoUpdateToggle.IsOn = MainWindow.Settings.Startup.IsAutoUpdate;
|
||||
EnableSilentUpdateToggle.IsOn = MainWindow.Settings.Startup.IsAutoUpdateWithSilence;
|
||||
|
||||
// 确保按钮可见且可用
|
||||
EnsureButtonsVisibility();
|
||||
|
||||
// 显示窗口动画
|
||||
AnimationsHelper.ShowWithFadeIn(this, 0.25);
|
||||
Trace.WriteLine(new WindowInteropHelper(this).Handle);
|
||||
|
||||
// 设置深色模式
|
||||
UseImmersiveDarkMode(new WindowInteropHelper(this).Handle, true);
|
||||
|
||||
// 窗口加载完成后再次确保按钮可见
|
||||
this.Loaded += HasNewUpdateWindow_Loaded;
|
||||
}
|
||||
|
||||
private void HasNewUpdateWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 窗口加载完成后再次确保按钮可见
|
||||
EnsureButtonsVisibility();
|
||||
|
||||
// 调整窗口大小以适应屏幕分辨率
|
||||
AdjustWindowSizeForScreenResolution();
|
||||
}
|
||||
|
||||
// 确保按钮可见并启用
|
||||
private void EnsureButtonsVisibility()
|
||||
{
|
||||
// 确保立即更新按钮可见
|
||||
UpdateNowButton.Visibility = Visibility.Visible;
|
||||
UpdateNowButton.IsEnabled = true;
|
||||
|
||||
// 确保稍后更新按钮可见
|
||||
UpdateLaterButton.Visibility = Visibility.Visible;
|
||||
UpdateLaterButton.IsEnabled = true;
|
||||
|
||||
// 确保跳过版本按钮可见
|
||||
SkipVersionButton.Visibility = Visibility.Visible;
|
||||
SkipVersionButton.IsEnabled = true;
|
||||
|
||||
// 强制刷新UI
|
||||
UpdateLayout();
|
||||
|
||||
// 记录日志
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update dialog buttons visibility ensured");
|
||||
}
|
||||
|
||||
private void UpdateNowButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update Now button clicked");
|
||||
|
||||
// 保存自动更新设置
|
||||
SaveUpdateSettings();
|
||||
|
||||
// 设置结果为立即更新
|
||||
Result = UpdateResult.UpdateNow;
|
||||
|
||||
// 关闭窗口,返回到MainWindow处理后续下载和安装流程
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void UpdateLaterButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Update Later button clicked");
|
||||
|
||||
// 保存自动更新设置
|
||||
SaveUpdateSettings();
|
||||
|
||||
// 设置结果为稍后更新
|
||||
Result = UpdateResult.UpdateLater;
|
||||
|
||||
// 关闭窗口
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SkipVersionButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Skip Version button clicked");
|
||||
|
||||
// 保存自动更新设置
|
||||
SaveUpdateSettings();
|
||||
|
||||
// 设置结果为跳过该版本
|
||||
Result = UpdateResult.SkipVersion;
|
||||
|
||||
// 关闭窗口
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveUpdateSettings()
|
||||
{
|
||||
// 保存自动更新设置
|
||||
MainWindow.Settings.Startup.IsAutoUpdate = EnableAutoUpdateToggle.IsOn;
|
||||
MainWindow.Settings.Startup.IsAutoUpdateWithSilence = EnableSilentUpdateToggle.IsOn;
|
||||
|
||||
// 记录到日志
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | User settings changed: AutoUpdate={EnableAutoUpdateToggle.IsOn}, SilentUpdate={EnableSilentUpdateToggle.IsOn}");
|
||||
}
|
||||
|
||||
// 根据屏幕分辨率调整窗口大小
|
||||
private void AdjustWindowSizeForScreenResolution()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取主屏幕分辨率
|
||||
double screenWidth = SystemParameters.PrimaryScreenWidth;
|
||||
double screenHeight = SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Screen resolution: {screenWidth}x{screenHeight}");
|
||||
|
||||
// 始终确保窗口不超过屏幕大小的85%
|
||||
double maxHeight = screenHeight * 0.85;
|
||||
double maxWidth = screenWidth * 0.85;
|
||||
|
||||
bool needsAdjustment = false;
|
||||
|
||||
// 如果窗口高度超过最大允许高度,调整窗口高度
|
||||
if (this.Height > maxHeight)
|
||||
{
|
||||
this.Height = maxHeight;
|
||||
needsAdjustment = true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window height to: {this.Height}");
|
||||
}
|
||||
|
||||
// 如果窗口宽度超过最大允许宽度,调整窗口宽度
|
||||
if (this.Width > maxWidth)
|
||||
{
|
||||
this.Width = maxWidth;
|
||||
needsAdjustment = true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window width to: {this.Width}");
|
||||
}
|
||||
|
||||
// 如果屏幕分辨率较低,调整更多UI元素
|
||||
if (screenHeight < 768 || screenWidth < 1024 || needsAdjustment)
|
||||
{
|
||||
// 查找相关控件并调整大小
|
||||
var markdownViewer = this.FindName("markdownContent") as MdXaml.MarkdownScrollViewer;
|
||||
var updateNowButton = this.FindName("UpdateNowButton") as Button;
|
||||
var updateLaterButton = this.FindName("UpdateLaterButton") as Button;
|
||||
var skipVersionButton = this.FindName("SkipVersionButton") as Button;
|
||||
|
||||
// 查找包含ScrollViewer的边框控件,减小其高度
|
||||
var contentBorders = this.FindVisualChildren<Border>().ToList();
|
||||
foreach (var border in contentBorders)
|
||||
{
|
||||
if (border.Child is ScrollViewer || border.Child is iNKORE.UI.WPF.Modern.Controls.ScrollViewerEx)
|
||||
{
|
||||
// 减小内容显示区域的高度
|
||||
if (border.Height > 180)
|
||||
{
|
||||
border.Height = 160;
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Reduced content area height");
|
||||
}
|
||||
else if (border.Child is iNKORE.UI.WPF.Modern.Controls.ScrollViewerEx scrollViewer && scrollViewer.Height > 160)
|
||||
{
|
||||
scrollViewer.Height = 160;
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Reduced scroll viewer height");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 调整按钮大小
|
||||
if (updateNowButton != null && updateLaterButton != null && skipVersionButton != null)
|
||||
{
|
||||
updateNowButton.Height = 42;
|
||||
updateLaterButton.Height = 42;
|
||||
skipVersionButton.Height = 42;
|
||||
updateNowButton.Padding = new Thickness(15, 8, 15, 8);
|
||||
updateLaterButton.Padding = new Thickness(15, 8, 15, 8);
|
||||
skipVersionButton.Padding = new Thickness(15, 8, 15, 8);
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Reduced button sizes for small screen");
|
||||
}
|
||||
}
|
||||
|
||||
// 确保窗口在屏幕范围内
|
||||
if (this.Left < 0) this.Left = 0;
|
||||
if (this.Top < 0) this.Top = 0;
|
||||
if (this.Left + this.Width > screenWidth) this.Left = screenWidth - this.Width;
|
||||
if (this.Top + this.Height > screenHeight) this.Top = screenHeight - this.Height;
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Final window size: {this.Width}x{this.Height}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Error adjusting window size: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
// 递归查找指定类型的所有子控件
|
||||
private IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj = null) where T : DependencyObject
|
||||
{
|
||||
if (depObj == null)
|
||||
depObj = this;
|
||||
|
||||
if (depObj != null)
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
|
||||
{
|
||||
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
|
||||
if (child != null && child is T)
|
||||
{
|
||||
yield return (T)child;
|
||||
}
|
||||
|
||||
foreach (T childOfChild in FindVisualChildren<T>(child))
|
||||
{
|
||||
yield return childOfChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
#pragma checksum "..\..\..\..\Windows\HasNewUpdateWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "237DE391CCBF9084C9908BFD5D5B61E01AF3B610"
|
||||
#pragma checksum "..\..\..\..\Windows\HasNewUpdateWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "53772E3067D35407A4B75166FFCE460ECF45D1E7"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
@@ -59,6 +59,70 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
public partial class HasNewUpdateWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
|
||||
|
||||
|
||||
#line 30 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal MdXaml.MarkdownScrollViewer markdownContent;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 49 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.TextBlock updateVersionInfo;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 50 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.TextBlock updateDateInfo;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 61 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal iNKORE.UI.WPF.Modern.Controls.ToggleSwitch EnableAutoUpdateToggle;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 65 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal iNKORE.UI.WPF.Modern.Controls.ToggleSwitch EnableSilentUpdateToggle;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 80 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button UpdateNowButton;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 91 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button UpdateLaterButton;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 97 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button SkipVersionButton;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
private bool _contentLoaded;
|
||||
|
||||
/// <summary>
|
||||
@@ -87,6 +151,51 @@ namespace Ink_Canvas {
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
||||
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
|
||||
switch (connectionId)
|
||||
{
|
||||
case 1:
|
||||
this.markdownContent = ((MdXaml.MarkdownScrollViewer)(target));
|
||||
return;
|
||||
case 2:
|
||||
this.updateVersionInfo = ((System.Windows.Controls.TextBlock)(target));
|
||||
return;
|
||||
case 3:
|
||||
this.updateDateInfo = ((System.Windows.Controls.TextBlock)(target));
|
||||
return;
|
||||
case 4:
|
||||
this.EnableAutoUpdateToggle = ((iNKORE.UI.WPF.Modern.Controls.ToggleSwitch)(target));
|
||||
return;
|
||||
case 5:
|
||||
this.EnableSilentUpdateToggle = ((iNKORE.UI.WPF.Modern.Controls.ToggleSwitch)(target));
|
||||
return;
|
||||
case 6:
|
||||
this.UpdateNowButton = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 82 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
this.UpdateNowButton.Click += new System.Windows.RoutedEventHandler(this.UpdateNowButton_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 7:
|
||||
this.UpdateLaterButton = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 93 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
this.UpdateLaterButton.Click += new System.Windows.RoutedEventHandler(this.UpdateLaterButton_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 8:
|
||||
this.SkipVersionButton = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 98 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
this.SkipVersionButton.Click += new System.Windows.RoutedEventHandler(this.SkipVersionButton_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
}
|
||||
this._contentLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma checksum "..\..\..\..\Windows\HasNewUpdateWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "237DE391CCBF9084C9908BFD5D5B61E01AF3B610"
|
||||
#pragma checksum "..\..\..\..\Windows\HasNewUpdateWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "53772E3067D35407A4B75166FFCE460ECF45D1E7"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
@@ -59,6 +59,70 @@ namespace Ink_Canvas {
|
||||
/// </summary>
|
||||
public partial class HasNewUpdateWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
|
||||
|
||||
|
||||
#line 30 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal MdXaml.MarkdownScrollViewer markdownContent;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 49 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.TextBlock updateVersionInfo;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 50 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.TextBlock updateDateInfo;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 61 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal iNKORE.UI.WPF.Modern.Controls.ToggleSwitch EnableAutoUpdateToggle;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 65 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal iNKORE.UI.WPF.Modern.Controls.ToggleSwitch EnableSilentUpdateToggle;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 80 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button UpdateNowButton;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 91 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button UpdateLaterButton;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 97 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.Button SkipVersionButton;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
private bool _contentLoaded;
|
||||
|
||||
/// <summary>
|
||||
@@ -87,6 +151,51 @@ namespace Ink_Canvas {
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
||||
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
|
||||
switch (connectionId)
|
||||
{
|
||||
case 1:
|
||||
this.markdownContent = ((MdXaml.MarkdownScrollViewer)(target));
|
||||
return;
|
||||
case 2:
|
||||
this.updateVersionInfo = ((System.Windows.Controls.TextBlock)(target));
|
||||
return;
|
||||
case 3:
|
||||
this.updateDateInfo = ((System.Windows.Controls.TextBlock)(target));
|
||||
return;
|
||||
case 4:
|
||||
this.EnableAutoUpdateToggle = ((iNKORE.UI.WPF.Modern.Controls.ToggleSwitch)(target));
|
||||
return;
|
||||
case 5:
|
||||
this.EnableSilentUpdateToggle = ((iNKORE.UI.WPF.Modern.Controls.ToggleSwitch)(target));
|
||||
return;
|
||||
case 6:
|
||||
this.UpdateNowButton = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 82 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
this.UpdateNowButton.Click += new System.Windows.RoutedEventHandler(this.UpdateNowButton_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 7:
|
||||
this.UpdateLaterButton = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 93 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
this.UpdateLaterButton.Click += new System.Windows.RoutedEventHandler(this.UpdateLaterButton_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
case 8:
|
||||
this.SkipVersionButton = ((System.Windows.Controls.Button)(target));
|
||||
|
||||
#line 98 "..\..\..\..\Windows\HasNewUpdateWindow.xaml"
|
||||
this.SkipVersionButton.Click += new System.Windows.RoutedEventHandler(this.SkipVersionButton_Click);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return;
|
||||
}
|
||||
this._contentLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user