Skip to content

Commit 754fbd6

Browse files
committed
refactor
1 parent 6e16307 commit 754fbd6

39 files changed

+3380
-3052
lines changed

CADPythonShell/App/CADPythonShellApplication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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.App

CADPythonShell/App/IronPythonConsoleApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private static RibbonPanel AddPanelTwo()
175175
Size = RibbonItemSize.Large,
176176
Name = nameof(MgdDbgAction.SnoopEnts),
177177
ShowText = true,
178-
Text ="Snoop\nEntities",
178+
Text = "Snoop\nEntities",
179179
Description = $"Start snoop Snoop Entities inside Autocad \n Command: {nameof(MgdDbgAction.SnoopEnts)}",
180180
Image = CADPythonShellApplication.GetEmbeddedPng(addinAssembly,
181181
"CADPythonShell.Resources.snoopentities-16.png"),

CADPythonShell/Command/CommandLoaderBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System.IO;
2-
using CADPythonShell.App;
1+
using CADPythonShell.App;
32
using CADRuntime;
3+
using System.IO;
44

55
namespace CADPythonShell.Command
66
{

CADPythonShell/Command/IronPythonConsoleCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using System.Windows;
2-
using System.Windows.Interop;
3-
using System.Windows.Threading;
4-
using Autodesk.AutoCAD.ApplicationServices;
1+
using Autodesk.AutoCAD.ApplicationServices;
52
using Autodesk.AutoCAD.Runtime;
63
using CADPythonShell.App;
74
using CADRuntime;
85
using Microsoft.Scripting;
6+
using System.Windows;
7+
using System.Windows.Interop;
8+
using System.Windows.Threading;
99
using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application;
1010
using Exception = System.Exception;
1111
using Forms = System.Windows.Forms;

CADPythonShell/Command/SnoopCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class SnoopCommand : ICadCommand
77
[CommandMethod("Snoop")]
88
public override void Execute()
99
{
10-
new CADSnoop.SnoopCommand().Snoop();
10+
new CADSnoop.SnoopCommand().Snoop();
1111
}
1212
}
13-
}
13+
}

CADPythonShell/ConfigureCommandsForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System.IO;
2-
using CADPythonShell.App;
1+
using CADPythonShell.App;
2+
using System.IO;
33

44
namespace CADPythonShell
55
{

CADRuntime/SettingsDictionary.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class SettingsDictionary : IDictionary<string, string>
1313
private readonly string _settingsPath;
1414
private XDocument _settings;
1515
private string nameVariable = "StringVariable";
16+
1617
public SettingsDictionary(string settingsPath)
1718
{
1819
_settingsPath = settingsPath;

Installer/Installer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
54
using System.Text;
65
using System.Text.RegularExpressions;
76
using WixSharp;

MgdDbgLibrary/App/App.cs

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,47 @@
1-
21
//
3-
// (C) Copyright 2004 by Autodesk, Inc.
2+
// (C) Copyright 2004 by Autodesk, Inc.
43
//
54
// Permission to use, copy, modify, and distribute this software in
6-
// object code form for any purpose and without fee is hereby granted,
7-
// provided that the above copyright notice appears in all copies and
5+
// object code form for any purpose and without fee is hereby granted,
6+
// provided that the above copyright notice appears in all copies and
87
// that both that copyright notice and the limited warranty and
9-
// restricted rights notice below appear in all supporting
8+
// restricted rights notice below appear in all supporting
109
// documentation.
1110
//
12-
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
11+
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
1312
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
14-
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
13+
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
1514
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1615
// UNINTERRUPTED OR ERROR FREE.
1716
//
18-
// Use, duplication, or disclosure by the U.S. Government is subject to
17+
// Use, duplication, or disclosure by the U.S. Government is subject to
1918
// restrictions set forth in FAR 52.227-19 (Commercial Computer
2019
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
2120
// (Rights in Technical Data and Computer Software), as applicable.
2221
//
2322

24-
25-
using System.Collections;
2623
using Autodesk.AutoCAD.Runtime;
2724
using MgdDbg.App;
2825
using MgdDbg.ObjTests;
2926
using MgdDbg.ObjTests.TestFramework;
27+
using System.Collections;
3028

31-
[assembly:ExtensionApplication(typeof(App))]
32-
[assembly:CommandClass(typeof(TestCmds))]
29+
[assembly: ExtensionApplication(typeof(App))]
30+
[assembly: CommandClass(typeof(TestCmds))]
3331

3432
namespace MgdDbg.App
3533
{
36-
37-
public class App : IExtensionApplication
38-
{
34+
public class App : IExtensionApplication
35+
{
3936
private ArrayList m_tests = new ArrayList();
4037
private AppDocReactor m_appDocReactor = null;
4138

42-
public void
43-
Initialize()
44-
{
39+
public void
40+
Initialize()
41+
{
4542
Utils.AcadUi.PrintToCmdLine("\nLoading MgdDbg...");
46-
47-
// register any Snoop Collector Extension objectsthat we have
43+
44+
// register any Snoop Collector Extension objectsthat we have
4845
Snoop.CollectorExts.Object extObj = new Snoop.CollectorExts.Object();
4946
Snoop.CollectorExts.RxObject extRxObj = new Snoop.CollectorExts.RxObject();
5047
Snoop.CollectorExts.DbObject extObjects = new Snoop.CollectorExts.DbObject();
@@ -60,7 +57,7 @@ public void
6057
Snoop.CollectorExts.Publish extPublish = new Snoop.CollectorExts.Publish();
6158
Snoop.CollectorExts.Plotting extPlotting = new Snoop.CollectorExts.Plotting();
6259
Snoop.CollectorExts.EditorInput extEdInput = new Snoop.CollectorExts.EditorInput();
63-
60+
6461
AppContextMenu.AddContextMenu(); // add our commands to the App right-click menu
6562

6663
CreateAndAddTestFuncs(); // populate the TestFramework with our functions
@@ -69,23 +66,23 @@ public void
6966
m_appDocReactor.EnableEvents();
7067

7168
AddFilterForSnoopClasses();
72-
}
73-
74-
public void
75-
Terminate()
76-
{
69+
}
70+
71+
public void
72+
Terminate()
73+
{
7774
AppContextMenu.RemoveContextMenu();
7875
RemoveAndFreeTestFuncs();
7976

8077
m_appDocReactor.DisableEvents();
81-
}
78+
}
8279

8380
/// <summary>
8481
/// The TestFramework allows us to plug tests and sample functions into an existing
8582
/// UI Framework. For each TestFuncs object we've created to house our individual
8683
/// tests, we need to add them during App start up, and remove them during App shut down.
8784
/// </summary>
88-
85+
8986
private void
9087
CreateAndAddTestFuncs()
9188
{
@@ -97,7 +94,8 @@ private void
9794
m_tests.Add(new QueryEntTests());
9895
m_tests.Add(new CategoryTests());
9996

100-
foreach (MgdDbgTestFuncs testFunc in m_tests) {
97+
foreach (MgdDbgTestFuncs testFunc in m_tests)
98+
{
10199
MgdDbgTestFuncs.AddTestFuncsToFramework(testFunc);
102100
}
103101
}
@@ -106,11 +104,12 @@ private void
106104
/// Reverse of above. Nothing to do for each TestFunc object though
107105
/// because we already know which ones were registered for this app.
108106
/// </summary>
109-
107+
110108
private void
111109
RemoveAndFreeTestFuncs()
112110
{
113-
foreach (MgdDbgTestFuncs testFunc in m_tests) {
111+
foreach (MgdDbgTestFuncs testFunc in m_tests)
112+
{
114113
MgdDbgTestFuncs.RemoveTestFuncsFromFramework(testFunc);
115114
}
116115
}
@@ -120,22 +119,24 @@ private void
120119
/// dialog get class information from. We don't want to display class info for every
121120
/// assembly in .NET, just the ones we are responsible for. So, it acts as a filter.
122121
/// </summary>
123-
122+
124123
private void
125124
AddFilterForSnoopClasses()
126125
{
127126
ArrayList assembliesToLoad = new ArrayList();
128-
127+
129128
assembliesToLoad.Add("mscorlib"); // for the base System.Object
130129
assembliesToLoad.Add("acmgd");
131130
assembliesToLoad.Add("acdbmgd");
132131

133132
System.Reflection.AssemblyName[] assemblyNames = System.Reflection.Assembly.GetExecutingAssembly().GetReferencedAssemblies();
134-
foreach (System.Reflection.AssemblyName assemblyName in assemblyNames) {
135-
if (assembliesToLoad.Contains(assemblyName.Name)) {
133+
foreach (System.Reflection.AssemblyName assemblyName in assemblyNames)
134+
{
135+
if (assembliesToLoad.Contains(assemblyName.Name))
136+
{
136137
MgdDbg.Snoop.Forms.Editor.assemblyNamesToLoad.Add(assemblyName.FullName);
137138
}
138139
}
139140
}
140-
}
141-
}
141+
}
142+
}
Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,101 @@
1-
21
//
3-
// (C) Copyright 2004 by Autodesk, Inc.
2+
// (C) Copyright 2004 by Autodesk, Inc.
43
//
54
// Permission to use, copy, modify, and distribute this software in
6-
// object code form for any purpose and without fee is hereby granted,
7-
// provided that the above copyright notice appears in all copies and
5+
// object code form for any purpose and without fee is hereby granted,
6+
// provided that the above copyright notice appears in all copies and
87
// that both that copyright notice and the limited warranty and
9-
// restricted rights notice below appear in all supporting
8+
// restricted rights notice below appear in all supporting
109
// documentation.
1110
//
12-
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
11+
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
1312
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
14-
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
13+
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
1514
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
1615
// UNINTERRUPTED OR ERROR FREE.
1716
//
18-
// Use, duplication, or disclosure by the U.S. Government is subject to
17+
// Use, duplication, or disclosure by the U.S. Government is subject to
1918
// restrictions set forth in FAR 52.227-19 (Commercial Computer
2019
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
2120
// (Rights in Technical Data and Computer Software), as applicable.
2221
//
2322

24-
using System;
2523
using Autodesk.AutoCAD.ApplicationServices;
2624
using Autodesk.AutoCAD.Windows;
25+
using System;
2726

2827
namespace MgdDbg.App
2928
{
3029
/// <summary>
3130
/// Simple derived MenuItem class to keep a command name so that we can have
3231
/// a single generic callback function for the event.
3332
/// </summary>
34-
33+
3534
public class AppContextMenuItem : Autodesk.AutoCAD.Windows.MenuItem
3635
{
3736
private string m_cmdName;
38-
37+
3938
public
4039
AppContextMenuItem(string title, string cmdName)
41-
: base(title)
40+
: base(title)
4241
{
4342
m_cmdName = cmdName;
4443
}
45-
44+
4645
public string
4746
CommandName
4847
{
4948
get { return m_cmdName; }
5049
set { m_cmdName = value; }
51-
}
50+
}
5251
}
53-
54-
/// <summary>
55-
/// The AppContextMenu for our app.
56-
/// </summary>
57-
58-
public class AppContextMenu
59-
{
60-
static ContextMenuExtension m_appMenu = null;
6152

62-
public static void
63-
AddContextMenu()
64-
{
65-
m_appMenu = new ContextMenuExtension();
66-
m_appMenu.Title = "MgdDbg";
67-
m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Entities...", "SnoopEnts"));
53+
/// <summary>
54+
/// The AppContextMenu for our app.
55+
/// </summary>
56+
57+
public class AppContextMenu
58+
{
59+
private static ContextMenuExtension m_appMenu = null;
60+
61+
public static void
62+
AddContextMenu()
63+
{
64+
m_appMenu = new ContextMenuExtension();
65+
m_appMenu.Title = "MgdDbg";
66+
m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Entities...", "SnoopEnts"));
6867
m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Entities (nested)...", "SnoopNEnts"));
6968
m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop (by Handle)...", "SnoopByHandle"));
7069
m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Database...", "SnoopDB"));
7170
m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Editor...", "SnoopEd"));
7271
m_appMenu.MenuItems.Add(new MenuItem("")); // separator
7372
m_appMenu.MenuItems.Add(new AppContextMenuItem("Events...", "SnoopEvents"));
7473
m_appMenu.MenuItems.Add(new MenuItem("")); // separator
75-
m_appMenu.MenuItems.Add(new AppContextMenuItem("Test Framework...", "SnoopTests"));
76-
77-
foreach (MenuItem mnuItem in m_appMenu.MenuItems) {
78-
AppContextMenuItem appContextMnuItem = mnuItem as AppContextMenuItem;
79-
if (appContextMnuItem != null)
80-
appContextMnuItem.Click += new EventHandler(ExecuteCommand);
81-
}
82-
83-
Application.AddDefaultContextMenuExtension(m_appMenu);
84-
}
85-
86-
private static void
87-
ExecuteCommand(Object o, EventArgs e)
88-
{
74+
m_appMenu.MenuItems.Add(new AppContextMenuItem("Test Framework...", "SnoopTests"));
75+
76+
foreach (MenuItem mnuItem in m_appMenu.MenuItems)
77+
{
78+
AppContextMenuItem appContextMnuItem = mnuItem as AppContextMenuItem;
79+
if (appContextMnuItem != null)
80+
appContextMnuItem.Click += new EventHandler(ExecuteCommand);
81+
}
82+
83+
Application.AddDefaultContextMenuExtension(m_appMenu);
84+
}
85+
86+
private static void
87+
ExecuteCommand(Object o, EventArgs e)
88+
{
8989
AppContextMenuItem mnuItem = (AppContextMenuItem)o;
9090

91-
string fullCmdLine = string.Format("_{0}\n", mnuItem.CommandName);
92-
Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true);
93-
}
91+
string fullCmdLine = string.Format("_{0}\n", mnuItem.CommandName);
92+
Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true);
93+
}
9494

9595
public static void
9696
RemoveContextMenu()
9797
{
9898
Application.RemoveDefaultContextMenuExtension(m_appMenu);
9999
}
100-
101100
}
102-
}
101+
}

0 commit comments

Comments
 (0)