LunarPresentation/Commands/SaveFile.cs
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.IO;
using System.Text;
using System.Windows;
using System.Xml;
using Microsoft.Win32;
namespace SHomeWorkshop.LunarPresentation.Commands
{
public partial class Command
{
public static bool SaveFile()
{
if (Globals.selectedEditor == null)
{
System.Windows.MessageBox.Show("当前没有文档可以保存!",
Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
Editor editor = Globals.selectedEditor;
return SaveFile(editor);
}
/// <summary>
/// 在调用“另存为”时,如果发现给文档的文件名与当前打开的另一个文档重复,
/// 可以控制是否在保存后立即关闭。
/// </summary>
/// <param name="editor"></param>
/// <param name="closeIfHasSameFilename">这个参数只在调用“另存为”时才有用处。
/// </param>
/// <returns></returns>
public static bool SaveFile(Editor editor, bool closeIfHasSameFilename = true)
{
if (editor.IsReadOnly)
{
System.Windows.MessageBox.Show("当前文档是只读文档,不能保存!您可以使用“另存为”功能保存一个副本。",
Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
if (editor.FileName != null)
{
if (editor.IsModified == false) return true;// 未修改文档。直接返回真,没必要保存。
if (File.Exists(editor.FileName))
{
FileAttributes fileAttributes = File.GetAttributes(editor.FileName);
if (fileAttributes == FileAttributes.ReadOnly)
{
System.Windows.MessageBox.Show("目标磁盘文档具有“只读”属性,无法写入!",
Globals.appName, MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
//已确定存在文件名。
}
else//不存在对应磁盘文档。
{
//SaveFileDialog sfd = new SaveFileDialog();
后面还有 149 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。