-
Notifications
You must be signed in to change notification settings - Fork 0
/
DisableAutosave.cs
58 lines (46 loc) · 1.58 KB
/
DisableAutosave.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.IO;
using System.Collections.Generic;
using Rhino;
using Rhino.Commands;
using Rhino.ApplicationSettings;
using Rhino.Input;
using System.Threading.Tasks;
namespace Scripted_Utilities
{
public class DisableAutosave : Command
{
public DisableAutosave()
{
// Rhino only creates one instance of each command class defined in a
// plug-in, so it is safe to store a refence in a static property.
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static DisableAutosave Instance
{
get; private set;
}
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName
{
get { return "DisableAutosave"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
RhinoApp.WriteLine("The {0} command will run now", EnglishName);
int after = 10;
RhinoGet.GetInteger("Disable Autosave for: (minutes):", true, ref after);
FileSettings.AutoSaveEnabled = false;
RhinoApp.WriteLine("Disabling Autosave for {0} minutes", after);
enableAutosave(after);
return Result.Success;
}
private async void enableAutosave(int after)
{
await Task.Delay(after * 60000);
RhinoApp.WriteLine("Re-Enabling Autosave Now", after);
FileSettings.AutoSaveEnabled = true;
}
}
}