2024-09-22 11:05:41 +08:00
|
|
|
|
using Autodesk.Revit.Attributes;
|
|
|
|
|
|
using Autodesk.Revit.UI;
|
|
|
|
|
|
|
|
|
|
|
|
using Nice3point.Revit.Toolkit.External;
|
|
|
|
|
|
using Nice3point.Revit.Toolkit.External.Handlers;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Sai.RvKits.RvCommon;
|
|
|
|
|
|
|
|
|
|
|
|
[Transaction(TransactionMode.Manual)]
|
|
|
|
|
|
[Regeneration(RegenerationOption.Manual)]
|
|
|
|
|
|
public class AutoSaveCmd : ExternalCommand
|
|
|
|
|
|
{
|
2024-10-27 00:19:48 +08:00
|
|
|
|
private readonly System.Timers.Timer timer = Variables.AutoSaveTimer;
|
2024-09-22 11:05:41 +08:00
|
|
|
|
public override void Execute()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(Document.PathName))
|
|
|
|
|
|
{
|
|
|
|
|
|
ErrorMessage = "当前文件尚未保存,请先保存文件";
|
|
|
|
|
|
Result = Result.Failed;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
AutoSaveViewModel viewModel = new();
|
|
|
|
|
|
AutoSaveView view = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
DataContext = viewModel
|
|
|
|
|
|
};
|
|
|
|
|
|
view.ShowDialog();
|
2024-10-27 00:19:48 +08:00
|
|
|
|
|
|
|
|
|
|
if (Properties.Settings.Default.IsActiveAutoSave)
|
2024-09-22 11:05:41 +08:00
|
|
|
|
{
|
2024-10-27 00:19:48 +08:00
|
|
|
|
if (Properties.Settings.Default.AutoSaveIntervalTime >= 1)
|
2024-09-22 11:05:41 +08:00
|
|
|
|
{
|
2024-10-27 00:19:48 +08:00
|
|
|
|
timer.Interval = Properties.Settings.Default.AutoSaveIntervalTime * 60 * 1000;
|
2024-09-22 11:05:41 +08:00
|
|
|
|
Properties.Settings.Default.Save();
|
|
|
|
|
|
}
|
2024-10-27 00:19:48 +08:00
|
|
|
|
//timer.Enabled = Properties.Settings.Default.AutoSave;
|
|
|
|
|
|
timer.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
timer.Stop();
|
2024-09-22 11:05:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
Result = Result.Succeeded;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|