improve:PPT及自动更新
This commit is contained in:
@@ -1610,12 +1610,24 @@ namespace Ink_Canvas.Helpers
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
}
|
||||
|
||||
// 定义需要覆盖的文件列表(仅覆盖主程序和配置文件)
|
||||
string[] filesToOverwrite = { "InkCanvasForClass.exe", "InkCanvasForClass.exe.config" };
|
||||
|
||||
// 复制文件
|
||||
foreach (FileInfo file in dir.GetFiles())
|
||||
{
|
||||
// 只覆盖指定的文件,跳过其他文件
|
||||
if (!filesToOverwrite.Contains(file.Name))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 跳过文件(不在覆盖列表中): {file.Name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
string targetFilePath = Path.Combine(destinationDir, file.Name);
|
||||
bool fileCopied = false;
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 开始覆盖文件: {file.Name}");
|
||||
|
||||
// 重试机制,最多重试3次
|
||||
for (int retry = 0; retry < 3; retry++)
|
||||
{
|
||||
@@ -1641,6 +1653,7 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
await Task.Run(() => file.CopyTo(targetFilePath));
|
||||
fileCopied = true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 文件覆盖成功: {file.Name}");
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1687,12 +1700,24 @@ namespace Ink_Canvas.Helpers
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
}
|
||||
|
||||
// 定义需要覆盖的文件列表(仅覆盖主程序和配置文件)
|
||||
string[] filesToOverwrite = { "InkCanvasForClass.exe", "InkCanvasForClass.exe.config" };
|
||||
|
||||
// 复制文件
|
||||
foreach (FileInfo file in dir.GetFiles())
|
||||
{
|
||||
// 只覆盖指定的文件,跳过其他文件
|
||||
if (!filesToOverwrite.Contains(file.Name))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 跳过文件(不在覆盖列表中): {file.Name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
string targetFilePath = Path.Combine(destinationDir, file.Name);
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 开始覆盖文件: {file.Name}");
|
||||
|
||||
// 如果目标文件存在且正在使用,先删除
|
||||
if (File.Exists(targetFilePath))
|
||||
{
|
||||
@@ -1700,6 +1725,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
|
||||
await Task.Run(() => file.CopyTo(targetFilePath));
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 文件覆盖成功: {file.Name}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -531,6 +531,27 @@
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
</Border>
|
||||
<GroupBox Name="GroupBoxModeSettings">
|
||||
<GroupBox.Header>
|
||||
<TextBlock Margin="0,12,0,0" Text="模式设置" FontWeight="Bold" Foreground="#fafafa"
|
||||
FontSize="26" />
|
||||
</GroupBox.Header>
|
||||
<ui:SimpleStackPanel Spacing="6" Margin="0,10,0,0">
|
||||
<TextBlock TextWrapping="Wrap" Margin="0,0,0,10" Foreground="#fafafa">
|
||||
选择软件运行模式。仅PPT模式下,软件将完全隐藏,仅在PPT放映时出现。
|
||||
</TextBlock>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,10,0,0">
|
||||
<TextBlock Text="正常模式" VerticalAlignment="Center" Foreground="#fafafa"
|
||||
FontSize="14" Margin="0,0,8,0"/>
|
||||
<ui:ToggleSwitch x:Name="ToggleSwitchMode"
|
||||
OnContent="仅PPT模式" OffContent="仅PPT模式"
|
||||
IsOn="False"
|
||||
FontFamily="Microsoft YaHei UI" FontWeight="Bold"
|
||||
Toggled="ToggleSwitchMode_Toggled"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Name="GroupBoxNewSettings">
|
||||
<GroupBox.Header>
|
||||
<TextBlock Margin="0,12,0,0" Text="新设置窗口" FontWeight="Bold" Foreground="#fafafa"
|
||||
|
||||
@@ -542,6 +542,9 @@ namespace Ink_Canvas
|
||||
|
||||
// 初始化文件关联状态显示
|
||||
InitializeFileAssociationStatus();
|
||||
|
||||
// 检查模式设置并应用
|
||||
CheckMainWindowVisibility();
|
||||
}
|
||||
|
||||
private void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs e)
|
||||
@@ -2606,5 +2609,78 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 模式切换相关
|
||||
|
||||
/// <summary>
|
||||
/// 模式切换开关事件处理
|
||||
/// </summary>
|
||||
private void ToggleSwitchMode_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var toggle = sender as iNKORE.UI.WPF.Modern.Controls.ToggleSwitch;
|
||||
if (toggle != null)
|
||||
{
|
||||
Settings.ModeSettings.IsPPTOnlyMode = toggle.IsOn;
|
||||
|
||||
// 如果切换到仅PPT模式,立即隐藏主窗口
|
||||
if (Settings.ModeSettings.IsPPTOnlyMode)
|
||||
{
|
||||
Hide();
|
||||
LogHelper.WriteLogToFile("已切换到仅PPT模式,主窗口已隐藏", LogHelper.LogType.Event);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果切换到正常模式,显示主窗口
|
||||
Show();
|
||||
LogHelper.WriteLogToFile("已切换到正常模式,主窗口已显示", LogHelper.LogType.Event);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"切换模式时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否应该显示主窗口(基于PPT模式和PPT放映状态)
|
||||
/// </summary>
|
||||
private void CheckMainWindowVisibility()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Settings.ModeSettings.IsPPTOnlyMode)
|
||||
{
|
||||
// 仅PPT模式下,只有在PPT放映时才显示
|
||||
bool isInSlideShow = BtnPPTSlideShowEnd.Visibility == Visibility.Visible;
|
||||
if (isInSlideShow && !IsVisible)
|
||||
{
|
||||
Show();
|
||||
LogHelper.WriteLogToFile("PPT放映开始,显示主窗口(仅PPT模式)", LogHelper.LogType.Trace);
|
||||
}
|
||||
else if (!isInSlideShow && IsVisible)
|
||||
{
|
||||
Hide();
|
||||
LogHelper.WriteLogToFile("PPT放映结束,隐藏主窗口(仅PPT模式)", LogHelper.LogType.Trace);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 正常模式下,确保主窗口可见
|
||||
if (!IsVisible)
|
||||
{
|
||||
Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"检查主窗口可见性时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,6 +585,9 @@ namespace Ink_Canvas
|
||||
{
|
||||
LogHelper.WriteLogToFile("PPT放映状态变化:退出放映模式", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
// 检查主窗口可见性(用于仅PPT模式)
|
||||
CheckMainWindowVisibility();
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -786,6 +786,17 @@ namespace Ink_Canvas
|
||||
ToggleSwitchDirectCallCiRand.IsOn = Settings.RandSettings.DirectCallCiRand;
|
||||
}
|
||||
|
||||
// ModeSettings
|
||||
if (Settings.ModeSettings != null)
|
||||
{
|
||||
ToggleSwitchMode.IsOn = Settings.ModeSettings.IsPPTOnlyMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.ModeSettings = new ModeSettings();
|
||||
ToggleSwitchMode.IsOn = false;
|
||||
}
|
||||
|
||||
// Automation
|
||||
if (Settings.Automation != null)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Ink_Canvas
|
||||
public Startup Startup { get; set; } = new Startup();
|
||||
[JsonProperty("randSettings")]
|
||||
public RandSettings RandSettings { get; set; } = new RandSettings();
|
||||
[JsonProperty("modeSettings")]
|
||||
public ModeSettings ModeSettings { get; set; } = new ModeSettings();
|
||||
}
|
||||
|
||||
public class Canvas
|
||||
@@ -584,4 +586,10 @@ namespace Ink_Canvas
|
||||
// 用于JSON序列化
|
||||
public CustomFloatingBarIcon() { }
|
||||
}
|
||||
|
||||
public class ModeSettings
|
||||
{
|
||||
[JsonProperty("isPPTOnlyMode")]
|
||||
public bool IsPPTOnlyMode { get; set; } = false; // 是否为仅PPT模式,默认为false(正常模式)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user