Files
ShrlAlgoToolkit/ShrlAlgoToolkit.RevitAddins/General/AutoSaveCmd.cs
2026-02-24 11:34:18 +08:00

45 lines
1.2 KiB
C#

using Autodesk.Revit.Attributes;
using Nice3point.Revit.Toolkit.External;
using ShrlAlgoToolkit.RevitAddins.RvCommon;
namespace ShrlAlgoToolkit.RevitAddins.General;
[Transaction(TransactionMode.Manual)]
public class AutoSaveCmd : ExternalCommand
{
private readonly System.Timers.Timer timer = Variables.AutoSaveTimer;
public override void Execute()
{
if (string.IsNullOrEmpty(Document.PathName))
{
ErrorMessage = "当前文件尚未保存,请先保存文件";
Result = Result.Failed;
return;
}
AutoSaveViewModel viewModel = new();
AutoSaveView view = new()
{
DataContext = viewModel
};
view.ShowDialog();
if (Properties.Settings.Default.IsActiveAutoSave)
{
if (Properties.Settings.Default.AutoSaveIntervalTime >= 1)
{
timer.Interval = Properties.Settings.Default.AutoSaveIntervalTime * 60 * 1000;
Properties.Settings.Default.Save();
}
//timer.Enabled = Properties.Settings.Default.AutoSave;
timer.Start();
}
else
{
timer.Stop();
}
Result = Result.Succeeded;
}
}