Skip to content

Commit

Permalink
可能修好了罢
Browse files Browse the repository at this point in the history
  • Loading branch information
NetheriteBowl committed Aug 1, 2024
1 parent 587ea12 commit f91deb5
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions Ink Canvas/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ private void PptApplication_PresentationClose(Presentation Pres)
timerCheckPPT.Start();
Application.Current.Dispatcher.Invoke(() =>
{
BtnPPTSlideShow.Visibility = Visibility.Collapsed;
//BtnPPTSlideShow.Visibility = Visibility.Collapsed;
BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
});
}
Expand All @@ -2504,6 +2504,7 @@ private void PptApplication_PresentationClose(Presentation Pres)


private string pptName = null;
int currentShowPosition = -1;
//bool isButtonBackgroundTransparent = true; //此变量仅用于保存用于幻灯片放映时的优化
private void PptApplication_SlideShowBegin(SlideShowWindow Wn)
{
Expand Down Expand Up @@ -2564,21 +2565,24 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn)
int count = 0;
foreach (FileInfo file in files)
{
int i = -1;
try
if (file.Name != "Position")
{
i = int.Parse(System.IO.Path.GetFileNameWithoutExtension(file.Name));
//var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);
//MemoryStream ms = new MemoryStream(File.ReadAllBytes(file.FullName));
//new StrokeCollection(fs).Save(ms);
//ms.Position = 0;
memoryStreams[i] = new MemoryStream(File.ReadAllBytes(file.FullName));
memoryStreams[i].Position = 0;
count++;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile(string.Format("Failed to load strokes on Slide {0}\n{1}", i, ex.ToString()), LogHelper.LogType.Error);
int i = -1;
try
{
i = int.Parse(System.IO.Path.GetFileNameWithoutExtension(file.Name));
//var fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read);
//MemoryStream ms = new MemoryStream(File.ReadAllBytes(file.FullName));
//new StrokeCollection(fs).Save(ms);
//ms.Position = 0;
memoryStreams[i] = new MemoryStream(File.ReadAllBytes(file.FullName));
memoryStreams[i].Position = 0;
count++;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile(string.Format("Failed to load strokes on Slide {0}\n{1}", i, ex.ToString()), LogHelper.LogType.Error);
}
}
}
LogHelper.WriteLogToFile(string.Format("Loaded {0} saved strokes", count.ToString()));
Expand Down Expand Up @@ -2669,6 +2673,7 @@ private void PptApplication_SlideShowBegin(SlideShowWindow Wn)
bool isEnteredSlideShowEndEvent = false; //防止重复调用本函数导致墨迹保存失效
private void PptApplication_SlideShowEnd(Presentation Pres)
{
IsNotifyPreviousPageWindowShown = false;
LogHelper.WriteLogToFile(string.Format("PowerPoint Slide Show End"), LogHelper.LogType.Event);
if (isEnteredSlideShowEndEvent)
{
Expand All @@ -2684,7 +2689,22 @@ private void PptApplication_SlideShowEnd(Presentation Pres)
{
Directory.CreateDirectory(folderPath);
}
File.WriteAllText(folderPath + "/Position", previousSlideID.ToString());
try
{
File.WriteAllText(folderPath + "/Position", previousSlideID.ToString());
}
catch { }
Application.Current.Dispatcher.Invoke(() =>
{
try
{
MemoryStream ms = new MemoryStream();
inkCanvas.Strokes.Save(ms);
ms.Position = 0;
memoryStreams[currentShowPosition] = ms;
}
catch { }
});
for (int i = 1; i <= Pres.Slides.Count; i++)
{
if (memoryStreams[i] != null)
Expand Down Expand Up @@ -2801,6 +2821,7 @@ private void PptApplication_SlideShowNextSlide(SlideShowWindow Wn)
{
inkCanvas.Strokes.Add(new StrokeCollection(memoryStreams[Wn.View.CurrentShowPosition]));
}
currentShowPosition = Wn.View.CurrentShowPosition;
}
catch
{ }
Expand Down

0 comments on commit f91deb5

Please sign in to comment.