-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSafeLayoutCommand.cs
More file actions
68 lines (59 loc) · 2.08 KB
/
Copy pathSafeLayoutCommand.cs
File metadata and controls
68 lines (59 loc) · 2.08 KB
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
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
namespace SafeLayout
{
public class SafeLayoutCommand : Command
{
public SafeLayoutCommand()
{
// 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 SafeLayoutCommand Instance
{
get; private set;
}
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName
{
get { return "SafeLayout"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// Get persistent settings (from Registry)
PersistentSettings settings = this.PlugIn.Settings;
bool save_settings = false;
bool enabled = settings.GetBool("enabled", true);
bool new_layer_visible_in_layout = settings.GetBool("new_layer_visible_in_layout", false);
GetOption go = new GetOption();
OptionToggle option_toggle_enabled = new OptionToggle(enabled, "off", "on");
OptionToggle option_toggle_newLayerLayoutVisible = new OptionToggle(new_layer_visible_in_layout, "off", "on");
go.AddOptionToggle("enabled", ref option_toggle_enabled);
go.AddOptionToggle("new_layer_visible_in_layout", ref option_toggle_newLayerLayoutVisible);
go.SetCommandPrompt("Safe Layout Settings");
Rhino.Input.GetResult get_rc = go.Get();
Result rc = go.CommandResult();
if (enabled != option_toggle_enabled.CurrentValue)
{
enabled = option_toggle_enabled.CurrentValue;
settings.SetBool("enabled", enabled);
save_settings = true;
}
if (new_layer_visible_in_layout != option_toggle_newLayerLayoutVisible.CurrentValue)
{
new_layer_visible_in_layout = option_toggle_newLayerLayoutVisible.CurrentValue;
settings.SetBool("new_layer_visible_in_layout", new_layer_visible_in_layout);
save_settings = true;
}
if (save_settings) this.PlugIn.SaveSettings();
return rc;
}
}
}