forked from chuongmep/CadPythonShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.cs
More file actions
142 lines (122 loc) · 5.74 KB
/
App.cs
File metadata and controls
142 lines (122 loc) · 5.74 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//
// (C) Copyright 2004 by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//
using Autodesk.AutoCAD.Runtime;
using MgdDbg.App;
using MgdDbg.ObjTests;
using MgdDbg.ObjTests.TestFramework;
using System.Collections;
[assembly: ExtensionApplication(typeof(App))]
[assembly: CommandClass(typeof(TestCmds))]
namespace MgdDbg.App
{
public class App : IExtensionApplication
{
private ArrayList m_tests = new ArrayList();
private AppDocReactor m_appDocReactor = null;
public void
Initialize()
{
Utils.AcadUi.PrintToCmdLine("\nLoading MgdDbg...");
// register any Snoop Collector Extension objectsthat we have
Snoop.CollectorExts.Object extObj = new Snoop.CollectorExts.Object();
Snoop.CollectorExts.RxObject extRxObj = new Snoop.CollectorExts.RxObject();
Snoop.CollectorExts.DbObject extObjects = new Snoop.CollectorExts.DbObject();
Snoop.CollectorExts.SymbolTable extSymTbl = new Snoop.CollectorExts.SymbolTable();
Snoop.CollectorExts.Entity extEnts = new Snoop.CollectorExts.Entity();
Snoop.CollectorExts.Color extColor = new Snoop.CollectorExts.Color();
Snoop.CollectorExts.Geometry extGeom = new Snoop.CollectorExts.Geometry();
Snoop.CollectorExts.GraphNodes extGraphNodes = new Snoop.CollectorExts.GraphNodes();
Snoop.CollectorExts.DbMisc extDbMisc = new Snoop.CollectorExts.DbMisc();
Snoop.CollectorExts.GraphicsInterface extGraphicsInterface = new Snoop.CollectorExts.GraphicsInterface();
Snoop.CollectorExts.LayerManager extLayerMgr = new Snoop.CollectorExts.LayerManager();
Snoop.CollectorExts.GraphicsSystem extGraphicsSystem = new Snoop.CollectorExts.GraphicsSystem();
Snoop.CollectorExts.Publish extPublish = new Snoop.CollectorExts.Publish();
Snoop.CollectorExts.Plotting extPlotting = new Snoop.CollectorExts.Plotting();
Snoop.CollectorExts.EditorInput extEdInput = new Snoop.CollectorExts.EditorInput();
AppContextMenu.AddContextMenu(); // add our commands to the App right-click menu
CreateAndAddTestFuncs(); // populate the TestFramework with our functions
m_appDocReactor = new AppDocReactor();
m_appDocReactor.EnableEvents();
AddFilterForSnoopClasses();
}
public void
Terminate()
{
AppContextMenu.RemoveContextMenu();
RemoveAndFreeTestFuncs();
m_appDocReactor.DisableEvents();
}
/// <summary>
/// The TestFramework allows us to plug tests and sample functions into an existing
/// UI Framework. For each TestFuncs object we've created to house our individual
/// tests, we need to add them during App start up, and remove them during App shut down.
/// </summary>
private void
CreateAndAddTestFuncs()
{
m_tests.Add(new DbTests());
m_tests.Add(new MakeEntTests());
m_tests.Add(new MakeSymTblRecTests());
m_tests.Add(new ModifyEntTests());
m_tests.Add(new QueryCurveTests());
m_tests.Add(new QueryEntTests());
m_tests.Add(new CategoryTests());
foreach (MgdDbgTestFuncs testFunc in m_tests)
{
MgdDbgTestFuncs.AddTestFuncsToFramework(testFunc);
}
}
/// <summary>
/// Reverse of above. Nothing to do for each TestFunc object though
/// because we already know which ones were registered for this app.
/// </summary>
private void
RemoveAndFreeTestFuncs()
{
foreach (MgdDbgTestFuncs testFunc in m_tests)
{
MgdDbgTestFuncs.RemoveTestFuncsFromFramework(testFunc);
}
}
/// <summary>
/// This function adds the assemblies we are interested in having the Snoop.Editor
/// dialog get class information from. We don't want to display class info for every
/// assembly in .NET, just the ones we are responsible for. So, it acts as a filter.
/// </summary>
private void
AddFilterForSnoopClasses()
{
ArrayList assembliesToLoad = new ArrayList();
assembliesToLoad.Add("mscorlib"); // for the base System.Object
assembliesToLoad.Add("acmgd");
assembliesToLoad.Add("acdbmgd");
System.Reflection.AssemblyName[] assemblyNames = System.Reflection.Assembly.GetExecutingAssembly().GetReferencedAssemblies();
foreach (System.Reflection.AssemblyName assemblyName in assemblyNames)
{
if (assembliesToLoad.Contains(assemblyName.Name))
{
MgdDbg.Snoop.Forms.Editor.assemblyNamesToLoad.Add(assemblyName.FullName);
}
}
}
}
}