improve:墨迹保存
This commit is contained in:
@@ -1802,7 +1802,8 @@
|
||||
<TextBlock Foreground="#fafafa" Text="墨迹与截图的保存路径" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="10">
|
||||
<TextBox Width="320" x:Name="AutoSavedStrokesLocation" Text="D:\Ink Canvas"
|
||||
<TextBox Width="320" x:Name="AutoSavedStrokesLocation"
|
||||
Text="{Binding AppDomain.CurrentDomain.BaseDirectory, StringFormat={}Saves}"
|
||||
TextWrapping="Wrap"
|
||||
TextChanged="AutoSavedStrokesLocationTextBox_TextChanged" />
|
||||
<Button Name="AutoSavedStrokesLocationButton" Content="浏览"
|
||||
|
||||
@@ -22,9 +22,17 @@ namespace Ink_Canvas {
|
||||
|
||||
private void SaveInkCanvasStrokes(Boolean newNotice, Boolean saveByUser) {
|
||||
try {
|
||||
var savePath = Settings.Automation.AutoSavedStrokesLocation
|
||||
+ (saveByUser ? @"\User Saved - " : @"\Auto Saved - ")
|
||||
+ (currentMode == 0 ? "Annotation Strokes" : "BlackBoard Strokes");
|
||||
// 修改保存路径为软件根目录下的Saves文件夹
|
||||
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
if (string.IsNullOrEmpty(appDirectory))
|
||||
{
|
||||
appDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
}
|
||||
|
||||
string savePath = Path.Combine(appDirectory, "Saves",
|
||||
(saveByUser ? @"User Saved - " : @"Auto Saved - ") +
|
||||
(currentMode == 0 ? "Annotation Strokes" : "BlackBoard Strokes"));
|
||||
|
||||
if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath);
|
||||
string savePathWithName;
|
||||
if (currentMode != 0) // 黑板模式下
|
||||
@@ -48,11 +56,10 @@ namespace Ink_Canvas {
|
||||
|
||||
try {
|
||||
// 修改保存路径为软件所在目录下的 Saves 文件夹
|
||||
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string saveDirectory = Path.Combine(appDirectory, "Saves");
|
||||
Directory.CreateDirectory(saveDirectory); // 自动创建 Saves 目录
|
||||
|
||||
string fileName = Path.GetFileName(docPath); // 保留原始文件名
|
||||
string fileName = Path.GetFileNameWithoutExtension(savePathWithName) + "_retry.icstk"; // 使用正确的原始文件名
|
||||
string newPath = Path.Combine(saveDirectory, fileName); // 新路径组合
|
||||
|
||||
using (FileStream fs = new FileStream(newPath, FileMode.Create)) {
|
||||
|
||||
@@ -102,22 +102,14 @@ namespace Ink_Canvas {
|
||||
}
|
||||
catch (Exception ex) when
|
||||
(ex is IOException ||
|
||||
ex is UnauthorizedAccessException) // 明确捕获与目录创建相关的异常
|
||||
ex is UnauthorizedAccessException)
|
||||
{
|
||||
// 如果创建失败则尝试使用文档目录
|
||||
basePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
fullPath = Path.Combine(basePath, "Auto Saved - Screenshots", dateFolder);
|
||||
|
||||
try {
|
||||
Directory.CreateDirectory(fullPath);
|
||||
}
|
||||
catch (Exception) {
|
||||
// 如果文档目录也不可用,则使用软件根目录
|
||||
// 如果创建失败则使用软件根目录作为最终备选
|
||||
basePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
fullPath = Path.Combine(basePath, "Auto Saved - Screenshots", dateFolder);
|
||||
|
||||
Directory.CreateDirectory(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
return Path.Combine(fullPath, $"{fileName}.png");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
@@ -1218,7 +1218,10 @@ namespace Ink_Canvas {
|
||||
}
|
||||
|
||||
private void SetAutoSavedStrokesLocationToDiskDButton_Click(object sender, RoutedEventArgs e) {
|
||||
AutoSavedStrokesLocation.Text = @"D:\Ink Canvas";
|
||||
// 修改默认路径为软件根目录下的 Saves 文件夹
|
||||
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string savesPath = System.IO.Path.Combine(appDirectory, "Saves");
|
||||
AutoSavedStrokesLocation.Text = savesPath;
|
||||
}
|
||||
|
||||
private void SetAutoSavedStrokesLocationToDocumentFolderButton_Click(object sender, RoutedEventArgs e) {
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user