优化PPT模块
This commit is contained in:
@@ -672,7 +672,11 @@ namespace Ink_Canvas {
|
||||
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
|
||||
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) {
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
SaveScreenShot(true, $"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
|
||||
{
|
||||
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||
var presentationName = _pptManager?.GetPresentationName() ?? "";
|
||||
SaveScreenShot(true, $"{presentationName}/{currentSlide}_{DateTime.Now:HH-mm-ss}");
|
||||
}
|
||||
else
|
||||
SaveScreenShot(true);
|
||||
}
|
||||
@@ -1287,7 +1291,11 @@ namespace Ink_Canvas {
|
||||
if (inkCanvas.Strokes.Count > 0 &&
|
||||
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) {
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
SaveScreenShot(true, $"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
|
||||
{
|
||||
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||
var presentationName = _pptManager?.GetPresentationName() ?? "";
|
||||
SaveScreenShot(true, $"{presentationName}/{currentSlide}_{DateTime.Now:HH-mm-ss}");
|
||||
}
|
||||
else SaveScreenShot(true);
|
||||
}
|
||||
|
||||
|
||||
+602
-1658
File diff suppressed because it is too large
Load Diff
@@ -57,18 +57,21 @@ namespace Ink_Canvas {
|
||||
List<StrokeCollection> allPageStrokes = new List<StrokeCollection>();
|
||||
|
||||
// 检查PPT放映模式下的多页面墨迹
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible && pptApplication != null)
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible && _pptManager?.IsConnected == true)
|
||||
{
|
||||
hasMultiplePages = true;
|
||||
// 收集PPT放映模式下的所有页面墨迹
|
||||
for (int i = 1; i <= pptApplication.SlideShowWindows[1].Presentation.Slides.Count; i++)
|
||||
var totalSlides = _pptManager.SlidesCount;
|
||||
var currentSlide = _pptManager.GetCurrentSlideNumber();
|
||||
|
||||
for (int i = 1; i <= totalSlides; i++)
|
||||
{
|
||||
if (memoryStreams[i] != null && memoryStreams[i].Length > 8)
|
||||
var slideStrokes = _pptInkManager?.LoadSlideStrokes(i);
|
||||
if (slideStrokes != null && slideStrokes.Count > 0)
|
||||
{
|
||||
memoryStreams[i].Position = 0;
|
||||
allPageStrokes.Add(new StrokeCollection(memoryStreams[i]));
|
||||
allPageStrokes.Add(slideStrokes);
|
||||
}
|
||||
else if (i == previousSlideID && inkCanvas.Strokes.Count > 0)
|
||||
else if (i == currentSlide && inkCanvas.Strokes.Count > 0)
|
||||
{
|
||||
// 当前页面的墨迹
|
||||
allPageStrokes.Add(inkCanvas.Strokes.Clone());
|
||||
@@ -485,10 +488,8 @@ namespace Ink_Canvas {
|
||||
timeMachine.ClearStrokeHistory();
|
||||
|
||||
// 重置PPT墨迹存储
|
||||
if (memoryStreams == null) {
|
||||
memoryStreams = new MemoryStream[50];
|
||||
}
|
||||
|
||||
_pptInkManager?.ClearAllStrokes();
|
||||
|
||||
// 读取所有页面的墨迹文件
|
||||
var files = Directory.GetFiles(tempDir, "page_*.icstk");
|
||||
foreach (var file in files) {
|
||||
@@ -497,23 +498,19 @@ namespace Ink_Canvas {
|
||||
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) {
|
||||
var strokes = new StrokeCollection(fs);
|
||||
if (strokes.Count > 0) {
|
||||
var ms = new MemoryStream();
|
||||
strokes.Save(ms);
|
||||
ms.Position = 0;
|
||||
memoryStreams[pageNumber] = ms;
|
||||
_pptInkManager?.SaveCurrentSlideStrokes(pageNumber, strokes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 恢复当前页面的墨迹
|
||||
if (pptApplication.SlideShowWindows.Count > 0) {
|
||||
int currentSlide = pptApplication.SlideShowWindows[1].View.CurrentShowPosition;
|
||||
if (memoryStreams[currentSlide] != null && memoryStreams[currentSlide].Length > 0) {
|
||||
memoryStreams[currentSlide].Position = 0;
|
||||
inkCanvas.Strokes.Add(new StrokeCollection(memoryStreams[currentSlide]));
|
||||
if (_pptManager?.IsInSlideShow == true) {
|
||||
int currentSlide = _pptManager.GetCurrentSlideNumber();
|
||||
var currentStrokes = _pptInkManager?.LoadSlideStrokes(currentSlide);
|
||||
if (currentStrokes != null && currentStrokes.Count > 0) {
|
||||
inkCanvas.Strokes.Add(currentStrokes);
|
||||
}
|
||||
previousSlideID = currentSlide;
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"成功恢复PPT墨迹,共{files.Length}页");
|
||||
|
||||
@@ -95,10 +95,19 @@ namespace Ink_Canvas {
|
||||
Settings.PowerPointSettings.PowerPointSupport = ToggleSwitchSupportPowerPoint.IsOn;
|
||||
SaveSettingsToFile();
|
||||
|
||||
// 使用新的PPT管理器
|
||||
if (Settings.PowerPointSettings.PowerPointSupport)
|
||||
timerCheckPPT.Start();
|
||||
{
|
||||
if (_pptManager == null)
|
||||
{
|
||||
InitializePPTManagers();
|
||||
}
|
||||
StartPPTMonitoring();
|
||||
}
|
||||
else
|
||||
timerCheckPPT.Stop();
|
||||
{
|
||||
StopPPTMonitoring();
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSwitchShowCanvasAtNewSlideShow_Toggled(object sender, RoutedEventArgs e) {
|
||||
@@ -419,7 +428,12 @@ namespace Ink_Canvas {
|
||||
if (!isLoaded) return;
|
||||
Settings.PowerPointSettings.ShowPPTButton = ToggleSwitchShowPPTButton.IsOn;
|
||||
SaveSettingsToFile();
|
||||
UpdatePPTBtnDisplaySettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null)
|
||||
{
|
||||
_pptUIManager.ShowPPTButton = Settings.PowerPointSettings.ShowPPTButton;
|
||||
_pptUIManager.UpdateNavigationPanelsVisibility();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -436,7 +450,12 @@ namespace Ink_Canvas {
|
||||
c[0] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTButtonsDisplayOption = Settings.PowerPointSettings.PPTButtonsDisplayOption;
|
||||
_pptUIManager.UpdateNavigationPanelsVisibility();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -448,7 +467,12 @@ namespace Ink_Canvas {
|
||||
c[1] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTButtonsDisplayOption = Settings.PowerPointSettings.PPTButtonsDisplayOption;
|
||||
_pptUIManager.UpdateNavigationPanelsVisibility();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -460,7 +484,12 @@ namespace Ink_Canvas {
|
||||
c[2] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTButtonsDisplayOption = Settings.PowerPointSettings.PPTButtonsDisplayOption;
|
||||
_pptUIManager.UpdateNavigationPanelsVisibility();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -472,7 +501,12 @@ namespace Ink_Canvas {
|
||||
c[3] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTButtonsDisplayOption = Settings.PowerPointSettings.PPTButtonsDisplayOption;
|
||||
_pptUIManager.UpdateNavigationPanelsVisibility();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -484,7 +518,12 @@ namespace Ink_Canvas {
|
||||
c[0] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTSButtonsOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTSButtonsOption = Settings.PowerPointSettings.PPTSButtonsOption;
|
||||
_pptUIManager.UpdateNavigationButtonStyles();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -496,7 +535,12 @@ namespace Ink_Canvas {
|
||||
c[1] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTSButtonsOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTSButtonsOption = Settings.PowerPointSettings.PPTSButtonsOption;
|
||||
_pptUIManager.UpdateNavigationButtonStyles();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -508,7 +552,12 @@ namespace Ink_Canvas {
|
||||
c[2] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTSButtonsOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTSButtonsOption = Settings.PowerPointSettings.PPTSButtonsOption;
|
||||
_pptUIManager.UpdateNavigationButtonStyles();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -520,7 +569,12 @@ namespace Ink_Canvas {
|
||||
c[0] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTBButtonsOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
|
||||
// 更新PPT UI管理器设置
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTBButtonsOption = Settings.PowerPointSettings.PPTBButtonsOption;
|
||||
_pptUIManager.UpdateNavigationButtonStyles();
|
||||
}
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -532,7 +586,7 @@ namespace Ink_Canvas {
|
||||
c[1] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTBButtonsOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
|
||||
UpdatePPTUIManagerSettings();
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -544,7 +598,7 @@ namespace Ink_Canvas {
|
||||
c[2] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
|
||||
Settings.PowerPointSettings.PPTBButtonsOption = int.Parse(new string(c));
|
||||
SaveSettingsToFile();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
|
||||
UpdatePPTUIManagerSettings();
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
@@ -552,7 +606,7 @@ namespace Ink_Canvas {
|
||||
if (!isLoaded) return;
|
||||
Settings.PowerPointSettings.PPTLSButtonPosition = (int)PPTButtonLeftPositionValueSlider.Value;
|
||||
UpdatePPTBtnSlidersStatus();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
|
||||
UpdatePPTUIManagerSettings();
|
||||
SliderDelayAction.DebounceAction(2000, null, SaveSettingsToFile);
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
@@ -686,11 +740,28 @@ namespace Ink_Canvas {
|
||||
if (!isLoaded) return;
|
||||
Settings.PowerPointSettings.PPTRSButtonPosition = (int)PPTButtonRightPositionValueSlider.Value;
|
||||
UpdatePPTBtnSlidersStatus();
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
|
||||
UpdatePPTUIManagerSettings();
|
||||
SliderDelayAction.DebounceAction(2000,null, SaveSettingsToFile);
|
||||
UpdatePPTBtnPreview();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新PPT UI管理器设置的通用方法
|
||||
/// </summary>
|
||||
private void UpdatePPTUIManagerSettings()
|
||||
{
|
||||
if (_pptUIManager != null && BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
{
|
||||
_pptUIManager.PPTButtonsDisplayOption = Settings.PowerPointSettings.PPTButtonsDisplayOption;
|
||||
_pptUIManager.PPTSButtonsOption = Settings.PowerPointSettings.PPTSButtonsOption;
|
||||
_pptUIManager.PPTBButtonsOption = Settings.PowerPointSettings.PPTBButtonsOption;
|
||||
_pptUIManager.PPTLSButtonPosition = Settings.PowerPointSettings.PPTLSButtonPosition;
|
||||
_pptUIManager.PPTRSButtonPosition = Settings.PowerPointSettings.PPTRSButtonPosition;
|
||||
_pptUIManager.UpdateNavigationPanelsVisibility();
|
||||
_pptUIManager.UpdateNavigationButtonStyles();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePPTBtnPreview() {
|
||||
//new BitmapImage(new Uri("pack://application:,,,/Resources/new-icons/unfold-chevron.png"));
|
||||
var bopt = Settings.PowerPointSettings.PPTBButtonsOption.ToString();
|
||||
|
||||
@@ -278,10 +278,10 @@ namespace Ink_Canvas {
|
||||
|
||||
if (Settings.PowerPointSettings.PowerPointSupport) {
|
||||
ToggleSwitchSupportPowerPoint.IsOn = true;
|
||||
timerCheckPPT.Start();
|
||||
// PPT监控将在Window_Loaded中启动
|
||||
} else {
|
||||
ToggleSwitchSupportPowerPoint.IsOn = false;
|
||||
timerCheckPPT.Stop();
|
||||
// PPT监控将保持停止状态
|
||||
}
|
||||
|
||||
ToggleSwitchShowCanvasAtNewSlideShow.IsOn = Settings.PowerPointSettings.IsShowCanvasAtNewSlideShow;
|
||||
|
||||
@@ -88,8 +88,9 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void InitTimers() {
|
||||
timerCheckPPT.Elapsed += TimerCheckPPT_Elapsed;
|
||||
timerCheckPPT.Interval = 500;
|
||||
// PPT检查现在由PPTManager处理,不再需要定时器
|
||||
// timerCheckPPT.Elapsed += TimerCheckPPT_Elapsed;
|
||||
// timerCheckPPT.Interval = 500;
|
||||
timerKillProcess.Elapsed += TimerKillProcess_Elapsed;
|
||||
timerKillProcess.Interval = 2000;
|
||||
timerCheckAutoFold.Elapsed += timerCheckAutoFold_Elapsed;
|
||||
|
||||
Reference in New Issue
Block a user