Skip to content

Commit 7bc690e

Browse files
committed
[fix] IsSaveScreenshotsInDateFolders
1 parent a82c397 commit 7bc690e

File tree

5 files changed

+67
-65
lines changed

5 files changed

+67
-65
lines changed

Ink Canvas/MainWindow_cs/MW_BoardControls.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private void BtnWhiteBoardSwitchNext_Click(object sender, EventArgs e)
8585
{
8686
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
8787
{
88-
SaveScreenShot(true);
88+
SaveScreenshot(true);
8989
}
9090
if (CurrentWhiteboardIndex >= WhiteboardTotalCount)
9191
{
@@ -108,7 +108,7 @@ private void BtnWhiteBoardAdd_Click(object sender, EventArgs e)
108108
if (WhiteboardTotalCount >= 99) return;
109109
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
110110
{
111-
SaveScreenShot(true);
111+
SaveScreenshot(true);
112112
}
113113
SaveStrokes();
114114
ClearStrokes(true);

Ink Canvas/MainWindow_cs/MW_FloatBarIcons.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ private void SymbolIconDelete_MouseUp(object sender, RoutedEventArgs e)
281281
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
282282
{
283283
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
284-
SaveScreenShot(true, $"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
284+
SavePPTScreenshot($"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
285285
else
286-
SaveScreenShot(true);
286+
SaveScreenshot(true);
287287
}
288288
BtnClear_Click(null, null);
289289
}
@@ -376,7 +376,7 @@ private void ImageBlackboard_Click(object sender, RoutedEventArgs e)
376376

377377
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
378378
{
379-
SaveScreenShot(true);
379+
SaveScreenshot(true);
380380
}
381381

382382
if (BtnPPTSlideShowEnd.Visibility == Visibility.Collapsed)
@@ -658,8 +658,8 @@ private async void CursorIcon_Click(object sender, RoutedEventArgs e)
658658
// 切换前自动截图保存墨迹
659659
if (inkCanvas.Strokes.Count > 0 && inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
660660
{
661-
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) SaveScreenShot(true, $"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
662-
else SaveScreenShot(true);
661+
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) SavePPTScreenshot($"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
662+
else SaveScreenshot(true);
663663
}
664664

665665
if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible)
@@ -1234,7 +1234,7 @@ private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e)
12341234
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count >
12351235
Settings.Automation.MinimumAutomationStrokeNumber)
12361236
{
1237-
SaveScreenShot(true);
1237+
SaveScreenshot(true);
12381238
}
12391239

12401240
BtnClear_Click(null, null);
@@ -1252,7 +1252,7 @@ private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e)
12521252
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count >
12531253
Settings.Automation.MinimumAutomationStrokeNumber)
12541254
{
1255-
SaveScreenShot(true);
1255+
SaveScreenshot(true);
12561256
}
12571257

12581258
BtnClear_Click(null, null);

Ink Canvas/MainWindow_cs/MW_Notification.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Linq;
44
using System.Threading;
5+
using System.Threading.Tasks;
56
using System.Windows;
67

78
namespace Ink_Canvas
@@ -25,17 +26,11 @@ public void ShowNotification(string notice, bool isShowImmediately = true)
2526
TextBlockNotice.Text = notice;
2627
AnimationsHelper.ShowWithSlideFromBottomAndFade(GridNotifications);
2728

28-
new Thread(new ThreadStart(() =>
29+
Task.Run(async () =>
2930
{
30-
Thread.Sleep(notificationShowTime + 300);
31-
if (Environment.TickCount - lastNotificationShowTime >= notificationShowTime)
32-
{
33-
Application.Current.Dispatcher.Invoke(() =>
34-
{
35-
AnimationsHelper.HideWithSlideAndFade(GridNotifications);
36-
});
37-
}
38-
})).Start();
31+
await Task.Delay(300);
32+
AnimationsHelper.HideWithSlideAndFade(GridNotifications);
33+
});
3934
}
4035
catch { }
4136
}

Ink Canvas/MainWindow_cs/MW_PPT.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ private void PptApplication_SlideShowNextSlide(SlideShowWindow Wn)
584584
memoryStreams[previousSlideID] = ms;
585585

586586
if (inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber && Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint && !_isPptClickingBtnTurned)
587-
SaveScreenShot(true, Wn.Presentation.Name + "/" + Wn.View.CurrentShowPosition);
587+
SavePPTScreenshot(Wn.Presentation.Name + "/" + Wn.View.CurrentShowPosition);
588588
_isPptClickingBtnTurned = false;
589589

590590
ClearStrokes(true);
@@ -623,7 +623,7 @@ private void BtnPPTSlidesUp_Click(object sender, RoutedEventArgs e)
623623

624624
if (inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber &&
625625
Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint)
626-
SaveScreenShot(true, pptApplication.SlideShowWindows[1].Presentation.Name + "/" + pptApplication.SlideShowWindows[1].View.CurrentShowPosition);
626+
SavePPTScreenshot(pptApplication.SlideShowWindows[1].Presentation.Name + "/" + pptApplication.SlideShowWindows[1].View.CurrentShowPosition);
627627

628628
try
629629
{
@@ -664,7 +664,7 @@ private void BtnPPTSlidesDown_Click(object sender, RoutedEventArgs e)
664664
_isPptClickingBtnTurned = true;
665665
if (inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber &&
666666
Settings.PowerPointSettings.IsAutoSaveScreenShotInPowerPoint)
667-
SaveScreenShot(true, pptApplication.SlideShowWindows[1].Presentation.Name + "/" + pptApplication.SlideShowWindows[1].View.CurrentShowPosition);
667+
SavePPTScreenshot(pptApplication.SlideShowWindows[1].Presentation.Name + "/" + pptApplication.SlideShowWindows[1].View.CurrentShowPosition);
668668
try
669669
{
670670
new Thread(new ThreadStart(() =>
Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Drawing;
23
using System.Drawing.Imaging;
34
using System.IO;
45
using System.Windows;
@@ -7,64 +8,70 @@ namespace Ink_Canvas
78
{
89
public partial class MainWindow : Window
910
{
10-
private void SaveScreenShot(bool isHideNotification, string fileName = null)
11+
private void SaveScreenshot(bool isHideNotification, string fileName = null)
1112
{
12-
/*
13-
var size = System.Windows.Forms.SystemInformation.PrimaryMonitorSize;
14-
var rc = new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), new System.Drawing.Size(size.Width, size.Height));
15-
*/
16-
System.Drawing.Rectangle rc = System.Windows.Forms.SystemInformation.VirtualScreen;
17-
18-
var bitmap = new System.Drawing.Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
19-
20-
using (System.Drawing.Graphics memoryGrahics = System.Drawing.Graphics.FromImage(bitmap))
13+
var bitmap = GetScreenshotBitmap();
14+
string savePath = Settings.Automation.AutoSavedStrokesLocation + @"\Auto Saved - Screenshots";
15+
if (fileName == null) fileName = DateTime.Now.ToString("u").Replace(":", "-");
16+
if (Settings.Automation.IsSaveScreenshotsInDateFolders)
2117
{
22-
memoryGrahics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, System.Drawing.CopyPixelOperation.SourceCopy);
18+
savePath += @"\" + DateTime.Now.ToString("yyyy-MM-dd");
2319
}
24-
25-
if (Settings.Automation.IsSaveScreenshotsInDateFolders)
20+
savePath += @"\" + fileName + ".png";
21+
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
2622
{
27-
if (string.IsNullOrWhiteSpace(fileName)) fileName = DateTime.Now.ToString("HH-mm-ss");
28-
string savePath = Settings.Automation.AutoSavedStrokesLocation + @"\Auto Saved - Screenshots\{DateTime.Now.Date:yyyyMMdd}\{fileName}.png";
29-
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
30-
{
31-
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
32-
}
33-
bitmap.Save(savePath, ImageFormat.Png);
34-
if (!isHideNotification)
35-
{
36-
ShowNotification("截图成功保存至 " + savePath);
37-
}
23+
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
3824
}
39-
else
25+
bitmap.Save(savePath, ImageFormat.Png);
26+
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
4027
{
41-
string savePath = Settings.Automation.AutoSavedStrokesLocation + @"\Auto Saved - Screenshots";
42-
if (!Directory.Exists(savePath))
43-
{
44-
Directory.CreateDirectory(savePath);
45-
}
46-
bitmap.Save(savePath + @"\" + DateTime.Now.ToString("u").Replace(':', '-') + ".png", ImageFormat.Png);
47-
if (!isHideNotification)
48-
{
49-
ShowNotification("截图成功保存至 " + savePath + @"\" + DateTime.Now.ToString("u").Replace(':', '-') + ".png");
50-
}
28+
SaveInkCanvasStrokes(false, false);
29+
}
30+
if (!isHideNotification)
31+
{
32+
ShowNotification("截图成功保存至 " + savePath);
5133
}
52-
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot) SaveInkCanvasStrokes(false, false);
5334
}
5435

5536
private void SaveScreenShotToDesktop()
5637
{
57-
System.Drawing.Rectangle rc = System.Windows.Forms.SystemInformation.VirtualScreen;
58-
var bitmap = new System.Drawing.Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
59-
60-
using (System.Drawing.Graphics memoryGrahics = System.Drawing.Graphics.FromImage(bitmap))
61-
{
62-
memoryGrahics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, System.Drawing.CopyPixelOperation.SourceCopy);
63-
}
38+
var bitmap = GetScreenshotBitmap();
6439
string savePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
6540
bitmap.Save(savePath + @"\" + DateTime.Now.ToString("u").Replace(':', '-') + ".png", ImageFormat.Png);
6641
ShowNotification("截图成功保存至【桌面" + @"\" + DateTime.Now.ToString("u").Replace(':', '-') + ".png】");
6742
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot) SaveInkCanvasStrokes(false, false);
6843
}
44+
45+
private void SavePPTScreenshot(string fileName)
46+
{
47+
var bitmap = GetScreenshotBitmap();
48+
string savePath = Settings.Automation.AutoSavedStrokesLocation + @"\Auto Saved - PPT Screenshots";
49+
if (Settings.Automation.IsSaveScreenshotsInDateFolders)
50+
{
51+
savePath += @"\" + DateTime.Now.ToString("yyyy-MM-dd");
52+
}
53+
if (fileName == null) fileName = DateTime.Now.ToString("u").Replace(":", "-");
54+
savePath += @"\" + fileName + ".png";
55+
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
56+
{
57+
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
58+
}
59+
bitmap.Save(savePath, ImageFormat.Png);
60+
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
61+
{
62+
SaveInkCanvasStrokes(false, false);
63+
}
64+
}
65+
66+
private Bitmap GetScreenshotBitmap()
67+
{
68+
Rectangle rc = System.Windows.Forms.SystemInformation.VirtualScreen;
69+
var bitmap = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
70+
using (Graphics memoryGrahics = Graphics.FromImage(bitmap))
71+
{
72+
memoryGrahics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
73+
}
74+
return bitmap;
75+
}
6976
}
7077
}

0 commit comments

Comments
 (0)