Add options to save screenshots in date folders

This commit is contained in:
XY Wang 2023-05-19 20:15:38 +08:00
parent fdc565158a
commit 46e3d1a9ac
3 changed files with 58 additions and 15 deletions

View File

@ -545,6 +545,7 @@
<ui:SimpleStackPanel Spacing="12">
<ui:ToggleSwitch Name="ToggleSwitchAutoKillPptService" Header="自动查杀“PPT 小工具”" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchAutoKillPptService_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchAutoKillEasiNote" Header="自动查杀“希沃白板 5”" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchAutoKillEasiNote_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchSaveScreenshotsInDateFolders" Header="截图分日期文件夹保存" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchSaveScreenshotsInDateFolders_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchAutoSaveStrokesAtScreenshot" Header="截图时自动保存墨迹" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchAutoSaveStrokesAtScreenshot_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchAutoSaveStrokesAtClear" Header="清屏时自动截图" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchAutoSaveStrokesAtClear_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchClearExitingWritingMode" Header="切换到鼠标模式后自动清屏" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchExitingWritingMode_Toggled"/>

View File

@ -799,6 +799,15 @@ namespace Ink_Canvas
ToggleSwitchAutoKillPptService.IsOn = false;
}
if (Settings.Automation.IsSaveScreenshotsInDateFolders)
{
ToggleSwitchSaveScreenshotsInDateFolders.IsOn = true;
}
else
{
ToggleSwitchSaveScreenshotsInDateFolders.IsOn = false;
}
if (Settings.Automation.IsAutoSaveStrokesAtScreenshot)
{
ToggleSwitchAutoSaveStrokesAtScreenshot.IsOn = true;
@ -2845,6 +2854,13 @@ namespace Ink_Canvas
}
}
private void ToggleSwitchSaveScreenshotsInDateFolders_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Automation.IsSaveScreenshotsInDateFolders = ToggleSwitchSaveScreenshotsInDateFolders.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchAutoSaveStrokesAtScreenshot_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
@ -6416,22 +6432,42 @@ namespace Ink_Canvas
memoryGrahics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, System.Drawing.CopyPixelOperation.SourceCopy);
}
if (string.IsNullOrWhiteSpace(fileName))
fileName = DateTime.Now.ToString("HH-mm-ss");
var savePath =
$@"{Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)}\Ink Canvas Screenshots\{DateTime.Now.Date:yyyyMMdd}\{fileName}.png";
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
if (Settings.Automation.IsSaveScreenshotsInDateFolders)
{
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
if (string.IsNullOrWhiteSpace(fileName))
fileName = DateTime.Now.ToString("HH-mm-ss");
var savePath =
$@"{Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)}\Ink Canvas Screenshots\{DateTime.Now.Date:yyyyMMdd}\{fileName}.png";
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(savePath));
}
bitmap.Save(savePath, ImageFormat.Png);
if (!isHideNotification)
{
ShowNotification("截图成功保存至 " + savePath);
}
}
bitmap.Save(savePath, ImageFormat.Png);
if (!isHideNotification)
else
{
ShowNotification("截图成功保存至 " + savePath);
if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\Ink Canvas Screenshots"))
{
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) +
@"\Ink Canvas Screenshots");
}
bitmap.Save(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) +
@"\Ink Canvas Screenshots\" + DateTime.Now.ToString("u").Replace(':', '-') + ".png", ImageFormat.Png);
if (!isHideNotification)
{
ShowNotification("截图成功保存至 " + Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) +
@"\Ink Canvas Screenshots\" + DateTime.Now.ToString("u").Replace(':', '-') + ".png");
}
}
}
@ -6998,12 +7034,12 @@ namespace Ink_Canvas
if (newNotice)
{
ShowNotification("墨迹成功保存至 " + Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) +
ShowNotification("墨迹成功保存至 " + Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
@"\Ink Canvas Strokes\User Saved\" + DateTime.Now.ToString("u").Replace(':', '-') + ".icstk");
}
else
{
AppendNotification("墨迹成功保存至 " + Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) +
AppendNotification("墨迹成功保存至 " + Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
@"\Ink Canvas Strokes\User Saved\" + DateTime.Now.ToString("u").Replace(':', '-') + ".icstk");
}
}

View File

@ -116,10 +116,16 @@ namespace Ink_Canvas
{
[JsonProperty("isAutoKillPptService")]
public bool IsAutoKillPptService { get; set; } = false;
[JsonProperty("isAutoKillEasiNote")]
public bool IsAutoKillEasiNote { get; set; } = false;
[JsonProperty("isSaveScreenshotsInDateFolders")]
public bool IsSaveScreenshotsInDateFolders { get; set; } = false;
[JsonProperty("isAutoSaveStrokesAtScreenshot")]
public bool IsAutoSaveStrokesAtScreenshot { get; set; } = false;
[JsonProperty("isAutoSaveStrokesAtClear")]
public bool IsAutoSaveStrokesAtClear { get; set; } = false;