Skip to content

Commit 9930cc2

Browse files
committed
clearup
1 parent d5cbcb7 commit 9930cc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+538
-538
lines changed

CADPythonShell/CADPythonShell.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<Commands>
1010
<!-- a list of preconfigured commands -->
1111
</Commands>
12-
<InitScript src="init.py"/>
13-
<StartupScript src="startup.py"/>
12+
<InitScript src="init.py" />
13+
<StartupScript src="startup.py" />
1414
</CADPythonShell>

CADPythonShell/CADPythonShellApplication.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using System.IO;
1+
using CADRuntime;
2+
using System.IO;
23
using System.Windows.Media;
34
using System.Windows.Media.Imaging;
45
using System.Xml.Linq;
5-
using CADRuntime;
66
using Forms = System.Windows.Forms;
77

88
namespace CADPythonShell
99
{
10-
static class CADPythonShellApplication
10+
internal static class CADPythonShellApplication
1111
{
1212
private static string settingsFolder;
1313
public static bool applicationLoaded;
@@ -70,7 +70,6 @@ public static ImageSource GetEmbeddedPng(System.Reflection.Assembly app, string
7070
return source.Frames[0];
7171
}
7272

73-
7473
public static IRpsConfig GetConfig()
7574
{
7675
return new NpsConfig(GetSettingsFile());
@@ -223,7 +222,6 @@ public static string GetInitScriptPath()
223222
return GetScriptPath("InitScript");
224223
}
225224

226-
227225
/// <summary>
228226
/// Returns the path to the StartupScript as configured in the settings file or "" if not
229227
/// configured. This is used in the ConfigureCommandsForm.
@@ -236,7 +234,7 @@ public static string GetStartupScriptPath()
236234
/// <summary>
237235
/// Returns the value of the "src" attribute for the tag "tagName" in the settings file
238236
/// or "" if not configured.
239-
/// </summary>
237+
/// </summary>
240238
private static string GetScriptPath(string tagName)
241239
{
242240
var tags = GetSettings().Root.Descendants(tagName) ?? new List<XElement>();
@@ -326,7 +324,6 @@ public static void WriteSettings(
326324
new XAttribute("name", command.Name),
327325
new XAttribute("src", command.Source),
328326
new XAttribute("group", command.Group)));
329-
330327
}
331328
doc.Root.Add(xmlCommands);
332329

@@ -337,7 +334,6 @@ public static void WriteSettings(
337334
xmlSearchPaths.Add(new XElement(
338335
"SearchPath",
339336
new XAttribute("name", path)));
340-
341337
}
342338
doc.Root.Add(xmlSearchPaths);
343339

@@ -349,7 +345,6 @@ public static void WriteSettings(
349345
"StringVariable",
350346
new XAttribute("name", variable.Key),
351347
new XAttribute("value", variable.Value)));
352-
353348
}
354349
doc.Root.Add(xmlVariables);
355350

@@ -384,4 +379,4 @@ public override string ToString()
384379
return Name;
385380
}
386381
}
387-
}
382+
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
using System.IO;
2-
using CADRuntime;
1+
using CADRuntime;
2+
using System.IO;
33

44
namespace CADPythonShell
55
{
66
/// <summary>
77
/// Starts up a ScriptOutput window for a given canned command.
8-
///
8+
///
99
/// It is expected that this will be inherited by dynamic types that have the field
1010
/// _scriptSource set to point to a python file that will be executed in the constructor.
1111
/// </summary>
12-
12+
1313
public abstract class CommandLoaderBase
1414
{
1515
protected string _scriptSource;
1616

17-
CommandLoaderBase(string scriptSource)
17+
private CommandLoaderBase(string scriptSource)
1818
{
1919
_scriptSource = scriptSource;
2020
}
@@ -24,12 +24,12 @@ public abstract class CommandLoaderBase
2424
/// </summary>
2525
/// <returns>
2626
/// The result indicates if the execution fails, succeeds, or was canceled by user. If it does not
27-
/// succeed, Revit will undo any changes made by the external command.
27+
/// succeed, Revit will undo any changes made by the external command.
2828
/// </returns>
29-
int Execute(ref string message, params string[] parameters)
29+
private int Execute(ref string message, params string[] parameters)
3030
{
31-
// FIXME: somehow fetch back message after script execution...
32-
var executor = new ScriptExecutor(CADPythonShellApplication.GetConfig() );
31+
// FIXME: somehow fetch back message after script execution...
32+
var executor = new ScriptExecutor(CADPythonShellApplication.GetConfig());
3333

3434
string source;
3535
using (var reader = File.OpenText(_scriptSource))
@@ -39,8 +39,8 @@ int Execute(ref string message, params string[] parameters)
3939

4040
var result = executor.ExecuteScript(source, _scriptSource);
4141
message = executor.Message;
42-
42+
4343
return result;
4444
}
4545
}
46-
}
46+
}

CADPythonShell/CompletionToolTip.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ public class CompletionToolTip
99
private TextBox _lblDocumentation;
1010
private CompletionToolTipWindow _dialog;
1111
private bool _cancel = false;
12-
IEnumerable<string> _documentations;
12+
private IEnumerable<string> _documentations;
1313

14-
private class CompletionToolTipWindow: Form
14+
private class CompletionToolTipWindow : Form
1515
{
1616
private ListBox _completions;
1717
private TextBox _documentation;
1818

19-
public CompletionToolTipWindow(ListBox completions,TextBox documentation)
19+
public CompletionToolTipWindow(ListBox completions, TextBox documentation)
2020
{
2121
_completions = completions;
2222
_documentation = documentation;
@@ -27,16 +27,16 @@ public CompletionToolTipWindow(ListBox completions,TextBox documentation)
2727
ShowInTaskbar = false;
2828
BackColor = Color.White;
2929
Opacity = 0.9;
30-
30+
3131
Controls.Add(completions);
3232
Controls.Add(documentation);
3333

3434
Width = completions.PreferredSize.Width;
3535
Height = completions.Height + documentation.Height;
3636
completions.Width = Width;
3737
documentation.Width = Width;
38-
documentation.Location = new Point(completions.Location.X,completions.Location.Y + completions.Height);
39-
38+
documentation.Location = new Point(completions.Location.X, completions.Location.Y + completions.Height);
39+
4040
completions.Show();
4141
documentation.Show();
4242
}
@@ -54,17 +54,16 @@ protected override void OnShown(EventArgs e)
5454
_completions.Focus();
5555
}
5656
}
57-
5857

5958
/// <summary>
6059
/// Show a listbox with possible completions for the uncompleted string.
6160
/// When the user chooses one and presses enter (or clicks it with the mouse),
62-
/// return the chosen completion. Or, when the user presses escape, then
61+
/// return the chosen completion. Or, when the user presses escape, then
6362
/// close the window and return null.
64-
/// </summary>
65-
public string ShowTooltip(string uncompleted, IEnumerable<string> completions, IEnumerable<string> documentations,Point location)
63+
/// </summary>
64+
public string ShowTooltip(string uncompleted, IEnumerable<string> completions, IEnumerable<string> documentations, Point location)
6665
{
67-
_lstCompletions = new ListBox();
66+
_lstCompletions = new ListBox();
6867
_lstCompletions.ScrollAlwaysVisible = true;
6968
_lstCompletions.Items.AddRange(completions.ToArray());
7069
_lstCompletions.SelectionMode = SelectionMode.One;
@@ -87,27 +86,27 @@ public string ShowTooltip(string uncompleted, IEnumerable<string> completions, I
8786
_lblDocumentation.WordWrap = true;
8887
_lblDocumentation.Width = _lstCompletions.Width;
8988
_lblDocumentation.BackColor = SystemColors.ControlLight;
90-
if (_documentations!=null && _documentations.Count() > 0)
89+
if (_documentations != null && _documentations.Count() > 0)
9190
_lblDocumentation.Text = _documentations.ElementAt(0);
9291
_lblDocumentation.ScrollBars = ScrollBars.Vertical;
9392
_lblDocumentation.Multiline = true;
9493
_lblDocumentation.AutoSize = true;
9594
_lblDocumentation.Height = 100;
9695
_lblDocumentation.ReadOnly = true;
9796

98-
_dialog = new CompletionToolTipWindow(_lstCompletions,_lblDocumentation);
97+
_dialog = new CompletionToolTipWindow(_lstCompletions, _lblDocumentation);
9998
_dialog.KeyDown += new KeyEventHandler(dialog_KeyDown);
10099
_dialog.Location = location;
101100
_dialog.KeyPreview = true;
102101
_dialog.ShowDialog();
103-
104102

105103
if (_cancel || _lstCompletions.SelectedIndex < 0)
106104
return null;
107105

108106
return (string)_lstCompletions.SelectedItem;
109107
}
110-
void selectedIndexChanged(object sender, EventArgs e)
108+
109+
private void selectedIndexChanged(object sender, EventArgs e)
111110
{
112111
try
113112
{
@@ -120,7 +119,7 @@ void selectedIndexChanged(object sender, EventArgs e)
120119
_dialog.resize();
121120
}
122121

123-
void dialog_KeyDown(object sender, KeyEventArgs e)
122+
private void dialog_KeyDown(object sender, KeyEventArgs e)
124123
{
125124
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab || e.KeyCode == Keys.Return)
126125
{
@@ -132,9 +131,10 @@ void dialog_KeyDown(object sender, KeyEventArgs e)
132131
_dialog.Hide();
133132
}
134133
}
135-
void lstCompletionsClicked(object sender, EventArgs e)
134+
135+
private void lstCompletionsClicked(object sender, EventArgs e)
136136
{
137137
_dialog.Hide();
138138
}
139139
}
140-
}
140+
}

CADPythonShell/ConfigureCommand.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ public class ConfigureCommand
1313
public void Execute()
1414
{
1515
//load the application
16-
if (!CADPythonShellApplication.applicationLoaded)
17-
{
18-
CADPythonShellApplication.OnLoaded();
19-
}
20-
21-
var dialog = new ConfigureCommandsForm();
16+
if (!CADPythonShellApplication.applicationLoaded)
17+
{
18+
CADPythonShellApplication.OnLoaded();
19+
}
20+
21+
var dialog = new ConfigureCommandsForm();
2222
dialog.StartPosition = FormStartPosition.CenterScreen;
2323
NativeWindow nativeWindow = new NativeWindow();
2424
nativeWindow.AssignHandle(Application.MainWindow.Handle);
2525
dialog.ShowDialog(nativeWindow);
26-
2726
}
2827
}
29-
}
28+
}

CADPythonShell/ConfigureCommandsForm.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace CADPythonShell
44
{
55
public partial class ConfigureCommandsForm : Form
66
{
7-
private List<Command> _commands;
7+
private List<Command> _commands;
88
private List<string> _searchPaths;
99
private List<KeyValuePair<string, string>> _variables;
1010

@@ -22,14 +22,14 @@ private void btnCancel_Click(object sender, EventArgs e)
2222
}
2323

2424
/// <summary>
25-
/// Read in the commands from the XML file and display them in the
25+
/// Read in the commands from the XML file and display them in the
2626
/// list.
2727
/// </summary>
2828
private void ConfigureCommandsForm_Load(object sender, EventArgs e)
2929
{
3030
_commands = CADPythonShellApplication.GetCommands(
3131
CADPythonShellApplication.GetSettings()).ToList();
32-
lstCommands.DataSource = _commands;
32+
lstCommands.DataSource = _commands;
3333

3434
_searchPaths = CADPythonShellApplication.GetConfig().GetSearchPaths().ToList();
3535
lstSearchPaths.DataSource = _searchPaths;
@@ -153,7 +153,6 @@ private void btnSearchPathAdd_Click(object sender, EventArgs e)
153153
}
154154
}
155155

156-
157156
private void RefreshBindingContext(ListBox listBox, object dataSource)
158157
{
159158
((CurrencyManager)listBox.BindingContext[dataSource]).Refresh();
@@ -180,7 +179,7 @@ private void btnCommandMoveUp_Click(object sender, EventArgs e)
180179
int newPosition = Math.Max(0, oldPosition - 1);
181180

182181
SwapPositions(_commands, oldPosition, newPosition);
183-
182+
184183
RefreshBindingContext(lstCommands, _commands);
185184

186185
lstCommands.SelectedIndex = newPosition;
@@ -205,7 +204,6 @@ private void btnCommandMoveDown_Click(object sender, EventArgs e)
205204
lstCommands.SelectedIndex = newPosition;
206205
}
207206

208-
209207
/// <summary>
210208
/// Save changes to CADPythonShell.xml and close Dialog.
211209
/// </summary>
@@ -364,6 +362,6 @@ private void btnStartupScriptBrowse_Click(object sender, EventArgs e)
364362
{
365363
txtStartupScript.Text = dialog.FileName;
366364
}
367-
}
365+
}
368366
}
369-
}
367+
}

CADPythonShell/ConsoleOptions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright (c) 2010 Joe Moorhouse
22

3-
using System.ComponentModel;
43
using ICSharpCode.AvalonEdit;
54
using PythonConsoleControl;
5+
using System.ComponentModel;
66
using FontFamily = System.Windows.Media.FontFamily;
77

88
namespace CADPythonShell
99
{
1010
public class ConsoleOptions
1111
{
12-
TextEditor textEditor;
13-
PythonConsolePad pad;
14-
12+
private TextEditor textEditor;
13+
private PythonConsolePad pad;
14+
1515
public ConsoleOptions(PythonConsolePad pad)
1616
{
1717
this.textEditor = pad.Control;
@@ -67,4 +67,4 @@ public bool CtrlSpaceAutocompletion
6767
set { pad.Console.AllowCtrlSpaceAutocompletion = value; }
6868
}
6969
}
70-
}
70+
}

CADPythonShell/IronPythonConsole.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,5 @@
154154
</avalonEdit:TextEditor>
155155
</Grid>
156156
</DockPanel>
157-
158157
</Grid>
159-
</Window>
158+
</Window>

0 commit comments

Comments
 (0)