1
//Copyright (C) 2011, FIE LLC.
b'//See LICENSE.TXT for details.'
b'using System.Collections.Generic;'
b'using System.ComponentModel;'
b'using System.Windows.Forms;'
2
1
public partial class SCGuiWindow : Form
4
3
libscclient.ISCUIAppContextClient scguiContext;
5
4
bool branchingAllowed = true;
6
5
public libscclient.ISCUIAppContextClient SCGuiContext
8
7
get { return scguiContext; }
9
8
set { scguiContext = value; }
11
10
private libscclient.LaunchableContextSettingsPlatform launchers;
b'\t\tprivate libscclient.IPedestalClient pedestal;'
b'\t\tprivate libscclient.Client client;'
12
11
private TreeNode CreateNode(TreeNode root, string path)
14
13
TreeNode current = root.Nodes[path];
15
14
if (current == null)
17
16
current = new TreeNode(path);
18
17
current.Name = path;
19
18
root.Nodes.Add(current);
23
22
private void AddNodeAtPath(TreeNode parentNode, string newNodeName, string[] path)
25
24
TreeNode currentNode = parentNode;
29
28
foreach (string s in path)
31
30
currentNode = CreateNode(currentNode, s);
34
33
TreeNode nodeToAdd = new ContextTreeNode(newNodeName);
35
34
nodeToAdd.Name = newNodeName;
36
35
currentNode.Nodes.Add(nodeToAdd);
38
37
private void BuildTree()
40
39
string currentNamespace = null;
41
40
string reason = string.Empty;
b'\t\t\tlibscclient.IContextClient[] stack = client.GetStack();'
42
41
if (stack.Length > 1)
b'\t\t\t\tcurrentNamespace = stack[stack.Length - 2].GetSettings().NameSpace;'
45
44
TreeNode nsRootNode = null;
46
45
foreach (string ns in launchers.Data.Keys)
48
47
// Create namespace root node.
49
48
nsRootNode = new NamespaceTreeNode(ns);
50
49
nsRootNode.Name = ns;
51
50
this.treeView1.Nodes.Add(nsRootNode);
52
51
// Iterate through launchers for this ns
b'\t\t\t\tforeach (string name in launchers.Data[ns].Keys){'
b'\t\t\t\t\tlibscclient.LaunchableContextSettings launchableSettings = launchers.Data[ns][name];'
b'\t\t\t\t\tif (launchableSettings.CanRun){'
54
53
AddNodeAtPath(nsRootNode, name, launchableSettings.Path);
58
57
System.Console.WriteLine("context cannot run: " + launchableSettings.Reason);
61
60
if (ns == currentNamespace || currentNamespace == null)
63
62
nsRootNode.Expand();
67
66
nsRootNode.Collapse();
71
70
public SCGuiWindow(libscclient.ISCUIAppContextClient currentContext, bool allowBranching, libscclient.Client client, libscclient.IPedestalClient pedestal)
73
72
this.scguiContext = currentContext;
74
73
this.branchingAllowed = allowBranching;
b'\t\t\tthis.pedestal = pedestal;'
b'\t\t\tthis.client = client;'
75
74
this.launchers = client.GetLaunchPlatformSettings();
76
75
InitializeComponent();
79
78
private void nodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
81
80
TreeNode selectedNode = e.Node;
82
81
if (selectedNode is ContextTreeNode)
84
83
string name = selectedNode.Name;
85
84
TreeNode currentNode = selectedNode.Parent;
86
85
while (currentNode.Parent != null)
88
87
currentNode = currentNode.Parent;
90
89
string ns = currentNode.Name;
b'\t\t\t\tlibscclient.LaunchableContextSettings launchableSettings;'
b'\t\t\t\tlaunchableSettings = this.launchers.Data[ns][name];'
91
90
//branch based on modifier keys
92
91
if (Control.ModifierKeys == Keys.Shift)
b'// //shift key pressed.'
b'// //this means leave this SCGui up and make a new on with the selected context.'
b'// //does nothing if branching is not allowed.'
b'// libscclient.ContextSettings settings = launchableSettings.Settings;'
b'// if (launchableSettings.IsIntermediate)'
b'// //the new context is not interactive. So we should set scgui'
b'// //as the next context before running it.'
b'//\t\t\t\t\t\t//no longer needed becasue we recycle the current one. To change it, you run it explicitly.'
b'//\t\t\t\t\t\t//libsc.SCGUIAppContextSettings uisettings = new libsc.SCGUIAppContextSettings();'
b'// settings.AppendToEnd(this.scguiContext.GetSettings()); '
b'// if (scguiContext.HasParent()){'
b'// buffer = libsc.Context.GetAs<libsc.IntermediateContext>(scguiContext.GetParent()).GetSerializedContextStack(settings.SerializedVersion());'
b'// buffer = settings.SerializedVersion();'
b'// System.Diagnostics.Process p = libsc.CurrentContext.SplayContext(buffer);'
96
95
else if (Control.ModifierKeys == Keys.Alt)
99
98
//this opens the settings for the given context and allows them to
b'\t System.Windows.Forms.Form f = new Form();'
101
100
libpropsguiwf.PropertyPageControl ppc = new libpropsguiwf.PropertyPageControl(launchableSettings.Settings);
b'\t f.Controls.Add(ppc);'
b'\t\t\t\t\tppc.Dock = DockStyle.Fill;'
102
101
System.Windows.Forms.Button cancel = new Button();
103
102
cancel.Text = "&Close";
104
103
f.Controls.Add(cancel);
105
104
cancel.Dock = DockStyle.Bottom;
106
105
f.MaximizeBox = false;
107
106
f.ShowInTaskbar = false;
108
107
f.Text = launchableSettings.Settings.NameSpace + ":" + launchableSettings.Settings.Name + " Settings";
109
108
f.CancelButton = cancel;
b'\t f.ShowDialog(this);'
110
109
ppc.DisconnectAllEvents();
114
113
//no relevant modifier keys pressed. run the selected context in this one's place.
115
114
libscclient.ContextSettings settings = launchableSettings.Settings;
116
115
if (launchableSettings.IsIntermediate)
118
117
//the new context is not interactive. So we should set scgui
119
118
//as the next context before running it.
b'\t\t\t\t\t\t//not used because we recycle the current one.'
120
119
//libsc.SCGUIAppContextSettings uisettings = new libsc.SCGUIAppContextSettings();
121
120
settings.AppendToEnd(this.SCGuiContext.GetSettings());
123
122
scguiContext.SetSuccessor(settings);
b'\t\t\t\t\t//System.Windows.Forms.Application.ExitThread();'
125
124
//System.Windows.Forms.Application.Exit();
130
129
private void SCGuiWindow_Load(object sender, EventArgs e)
b'\\ No newline at end of file'
133
//Copyright (C) 2011, FIE LLC.
b'//See LICENSE.TXT for details.'
b'using System.Collections.Generic;'
b'using System.ComponentModel;'
b'using System.Windows.Forms;'
134
134
public partial class SCGuiWindow : Form
136
136
libscclient.ISCUIAppContextClient scguiContext;
137
137
bool branchingAllowed = true;
138
138
public libscclient.ISCUIAppContextClient SCGuiContext
140
140
get { return scguiContext; }
141
141
set { scguiContext = value; }
143
143
private libscclient.LaunchableContextSettingsPlatform launchers;
b'\t\tprivate libscclient.IPedestalClient pedestal;'
b'\t\tprivate libscclient.Client client;'
144
144
private TreeNode CreateNode(TreeNode root, string path)
146
146
TreeNode current = root.Nodes[path];
147
147
if (current == null)
149
149
current = new TreeNode(path);
150
150
current.Name = path;
151
151
root.Nodes.Add(current);
155
155
private void AddNodeAtPath(TreeNode parentNode, string newNodeName, string[] path)
157
157
TreeNode currentNode = parentNode;
159
159
if (path != null)
161
161
foreach (string s in path)
163
163
currentNode = CreateNode(currentNode, s);
166
166
TreeNode nodeToAdd = new ContextTreeNode(newNodeName);
167
167
nodeToAdd.Name = newNodeName;
168
168
currentNode.Nodes.Add(nodeToAdd);
170
170
private void BuildTree()
172
172
string currentNamespace = null;
173
173
string reason = string.Empty;
b'\t\t\tlibscclient.IContextClient[] stack = client.GetStack();'
174
174
if (stack.Length > 1)
b'\t\t\t\tcurrentNamespace = stack[stack.Length - 2].GetSettings().NameSpace;'
177
177
TreeNode nsRootNode = null;
178
178
foreach (string ns in launchers.Data.Keys)
180
180
// Create namespace root node.
181
181
nsRootNode = new NamespaceTreeNode(ns);
182
182
nsRootNode.Name = ns;
183
183
this.treeView1.Nodes.Add(nsRootNode);
184
184
// Iterate through launchers for this ns
b'\t\t\t\tforeach (string name in launchers.Data[ns].Keys){'
b'\t\t\t\t\tlibscclient.LaunchableContextSettings launchableSettings = launchers.Data[ns][name];'
b'\t\t\t\t\tif (launchableSettings.CanRun){'
186
186
AddNodeAtPath(nsRootNode, name, launchableSettings.Path);
190
190
System.Console.WriteLine("context cannot run: " + launchableSettings.Reason);
193
193
if (ns == currentNamespace || currentNamespace == null)
195
195
nsRootNode.Expand();
199
199
nsRootNode.Collapse();
203
203
public SCGuiWindow(libscclient.ISCUIAppContextClient currentContext, bool allowBranching, libscclient.Client client, libscclient.IPedestalClient pedestal)
205
205
this.scguiContext = currentContext;
206
206
this.branchingAllowed = allowBranching;
b'\t\t\tthis.pedestal = pedestal;'
b'\t\t\tthis.client = client;'
207
207
this.launchers = client.GetLaunchPlatformSettings();
208
208
InitializeComponent();
211
211
private void nodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
213
213
TreeNode selectedNode = e.Node;
214
214
if (selectedNode is ContextTreeNode)
216
216
string name = selectedNode.Name;
217
217
TreeNode currentNode = selectedNode.Parent;
218
218
while (currentNode.Parent != null)
220
220
currentNode = currentNode.Parent;
222
222
string ns = currentNode.Name;
b'\t\t\t\tlibscclient.LaunchableContextSettings launchableSettings;'
b'\t\t\t\tlaunchableSettings = this.launchers.Data[ns][name];'
223
223
//branch based on modifier keys
224
224
if (Control.ModifierKeys == Keys.Shift)
226
226
//shift key pressed.
227
227
//this means leave this SCGui up and make a new on with the selected context.
228
228
//does nothing if branching is not allowed.
229
229
libscclient.ContextSettings settings = launchableSettings.Settings;
230
230
if (launchableSettings.IsIntermediate)
232
232
//the new context is not interactive. So we should set scgui
233
233
//as the next context before running it.
234
234
//no longer needed becasue we recycle the current one. To change it, you run it explicitly.
235
235
//libsc.SCGUIAppContextSettings uisettings = new libsc.SCGUIAppContextSettings();
236
236
settings.NextSettings = this.scguiContext.GetSettings().SerializedVersionNothingNext();
238
238
libscclient.ContextSettings splaySettingsStack;
239
239
if (scguiContext.HasParent())
241
241
splaySettingsStack = client.GetSettingsStack(client.GetParent(scguiContext),settings);
245
245
splaySettingsStack = settings;
247
247
pedestal.SplayContextStack(splaySettingsStack);
250
250
else if (Control.ModifierKeys == Keys.Alt)
252
252
//alt key pressed.
253
253
//this opens the settings for the given context and allows them to
b'\t System.Windows.Forms.Form f = new Form();'
255
255
libpropsguiwf.PropertyPageControl ppc = new libpropsguiwf.PropertyPageControl(launchableSettings.Settings);
b'\t f.Controls.Add(ppc);'
b'\t\t\t\t\tppc.Dock = DockStyle.Fill;'
256
256
System.Windows.Forms.Button cancel = new Button();
257
257
cancel.Text = "&Close";
258
258
f.Controls.Add(cancel);
259
259
cancel.Dock = DockStyle.Bottom;
260
260
f.MaximizeBox = false;
261
261
f.ShowInTaskbar = false;
262
262
f.Text = launchableSettings.Settings.NameSpace + ":" + launchableSettings.Settings.Name + " Settings";
263
263
f.CancelButton = cancel;
b'\t f.ShowDialog(this);'
264
264
ppc.DisconnectAllEvents();
268
268
//no relevant modifier keys pressed. run the selected context in this one's place.
269
269
libscclient.ContextSettings settings = launchableSettings.Settings;
270
270
if (launchableSettings.IsIntermediate)
272
272
//the new context is not interactive. So we should set scgui
273
273
//as the next context before running it.
b'\t\t\t\t\t\t//not used because we recycle the current one.'
274
274
//libsc.SCGUIAppContextSettings uisettings = new libsc.SCGUIAppContextSettings();
275
275
settings.AppendToEnd(this.SCGuiContext.GetSettings());
277
277
scguiContext.SetSuccessor(settings);
b'\t\t\t\t\t//System.Windows.Forms.Application.ExitThread();'
279
279
//System.Windows.Forms.Application.Exit();
284
284
private void SCGuiWindow_Load(object sender, EventArgs e)
b'\\ No newline at end of file'