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