diff --git a/.github/workflows/Workflow.yml b/.github/workflows/Workflow.yml index 9f0147b..546981d 100644 --- a/.github/workflows/Workflow.yml +++ b/.github/workflows/Workflow.yml @@ -16,6 +16,6 @@ jobs: - name: Checkout uses: actions/checkout@v1 with: - submodules: true + submodules: false - name: Run Nuke Build run: ./.nuke/build.cmd --GitHubToken ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e903961..0000000 --- a/.gitmodules +++ /dev/null @@ -1,8 +0,0 @@ -[submodule "AutoCADLookup"] - path = AutoCADLookup - url = https://github.com/chuongmep/AutoCADLookup.git - ignore = dirty -[submodule "MgdDbg"] - path = MgdDbg - url = https://github.com/chuongmep/MgdDbg.git - ignore = dirty \ No newline at end of file diff --git a/AutoCADLookup b/AutoCADLookup deleted file mode 160000 index 4d52bb9..0000000 --- a/AutoCADLookup +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4d52bb9afb41e1489b80f62d0e3b1c901a8504b2 diff --git a/CADPythonShell.sln b/CADPythonShell.sln index 7857f83..078e858 100644 --- a/CADPythonShell.sln +++ b/CADPythonShell.sln @@ -13,7 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution CONTRIBUTING.md = CONTRIBUTING.md README.md = README.md RPS LICENSE.txt = RPS LICENSE.txt - .gitmodules = .gitmodules + .github\workflows\Workflow.yml = .github\workflows\Workflow.yml + CADPythonShell\PackageContents.xml = CADPythonShell\PackageContents.xml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CADPythonShell", "CADPythonShell\CADPythonShell.csproj", "{7E37F14E-D840-42F8-8CA6-90FFC5497972}" @@ -24,9 +25,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "build\Build.csproj EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Installer", "Installer\Installer.csproj", "{51C417E1-279A-46C2-B3AE-1FDE56FEE5AB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CADSnoop", "AutoCADLookup\CADSnoop.csproj", "{275C1B41-9089-4817-B48F-564A72A6D121}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MgdDbg", "MgdDbgLibrary\MgdDbg.csproj", "{A5639047-58FE-42F3-95D5-4ADC1F51F120}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MgdDbg", "MgdDbg\MgdDbg.csproj", "{C9B52572-4947-4AD7-86CE-EFB7A036FA9F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CADSnoop", "CadLookup\CADSnoop.csproj", "{19C935D2-8649-496F-ADD4-3D5E370B441A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -61,16 +62,18 @@ Global {51C417E1-279A-46C2-B3AE-1FDE56FEE5AB}.Installer|Any CPU.Build.0 = Release|Any CPU {51C417E1-279A-46C2-B3AE-1FDE56FEE5AB}.Release A23|Any CPU.ActiveCfg = Release|Any CPU {51C417E1-279A-46C2-B3AE-1FDE56FEE5AB}.Release A23|Any CPU.Build.0 = Release|Any CPU - {275C1B41-9089-4817-B48F-564A72A6D121}.Debug A23|Any CPU.ActiveCfg = Debug|Any CPU - {275C1B41-9089-4817-B48F-564A72A6D121}.Debug A23|Any CPU.Build.0 = Debug|Any CPU - {275C1B41-9089-4817-B48F-564A72A6D121}.Installer|Any CPU.ActiveCfg = Debug|Any CPU - {275C1B41-9089-4817-B48F-564A72A6D121}.Release A23|Any CPU.ActiveCfg = Release|Any CPU - {275C1B41-9089-4817-B48F-564A72A6D121}.Release A23|Any CPU.Build.0 = Release|Any CPU - {C9B52572-4947-4AD7-86CE-EFB7A036FA9F}.Debug A23|Any CPU.ActiveCfg = Debug|Any CPU - {C9B52572-4947-4AD7-86CE-EFB7A036FA9F}.Debug A23|Any CPU.Build.0 = Debug|Any CPU - {C9B52572-4947-4AD7-86CE-EFB7A036FA9F}.Installer|Any CPU.ActiveCfg = Debug|Any CPU - {C9B52572-4947-4AD7-86CE-EFB7A036FA9F}.Release A23|Any CPU.ActiveCfg = Debug|Any CPU - {C9B52572-4947-4AD7-86CE-EFB7A036FA9F}.Release A23|Any CPU.Build.0 = Debug|Any CPU + {A5639047-58FE-42F3-95D5-4ADC1F51F120}.Debug A23|Any CPU.ActiveCfg = Debug|Any CPU + {A5639047-58FE-42F3-95D5-4ADC1F51F120}.Debug A23|Any CPU.Build.0 = Debug|Any CPU + {A5639047-58FE-42F3-95D5-4ADC1F51F120}.Installer|Any CPU.ActiveCfg = Debug|Any CPU + {A5639047-58FE-42F3-95D5-4ADC1F51F120}.Installer|Any CPU.Build.0 = Debug|Any CPU + {A5639047-58FE-42F3-95D5-4ADC1F51F120}.Release A23|Any CPU.ActiveCfg = Debug|Any CPU + {A5639047-58FE-42F3-95D5-4ADC1F51F120}.Release A23|Any CPU.Build.0 = Debug|Any CPU + {19C935D2-8649-496F-ADD4-3D5E370B441A}.Debug A23|Any CPU.ActiveCfg = Debug|Any CPU + {19C935D2-8649-496F-ADD4-3D5E370B441A}.Debug A23|Any CPU.Build.0 = Debug|Any CPU + {19C935D2-8649-496F-ADD4-3D5E370B441A}.Installer|Any CPU.ActiveCfg = Debug|Any CPU + {19C935D2-8649-496F-ADD4-3D5E370B441A}.Installer|Any CPU.Build.0 = Debug|Any CPU + {19C935D2-8649-496F-ADD4-3D5E370B441A}.Release A23|Any CPU.ActiveCfg = Debug|Any CPU + {19C935D2-8649-496F-ADD4-3D5E370B441A}.Release A23|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CADPythonShell/App/CADPythonShellApplication.cs b/CADPythonShell/App/CADPythonShellApplication.cs index b4ba220..68fc05b 100644 --- a/CADPythonShell/App/CADPythonShellApplication.cs +++ b/CADPythonShell/App/CADPythonShellApplication.cs @@ -5,7 +5,7 @@ using System.Xml.Linq; using Forms = System.Windows.Forms; -namespace CADPythonShell +namespace CADPythonShell.App { internal static class CADPythonShellApplication { diff --git a/CADPythonShell/App/IronPythonConsoleApp.cs b/CADPythonShell/App/IronPythonConsoleApp.cs index 537c331..b43169e 100644 --- a/CADPythonShell/App/IronPythonConsoleApp.cs +++ b/CADPythonShell/App/IronPythonConsoleApp.cs @@ -1,9 +1,9 @@ using Autodesk.AutoCAD.Runtime; using Autodesk.Windows; -using MgdDbg; +using CADPythonShell.Command; using Orientation = System.Windows.Controls.Orientation; -namespace CADPythonShell +namespace CADPythonShell.App { public class IronPythonConsoleApp : ICadCommand { @@ -164,7 +164,7 @@ private static RibbonPanel AddPanelTwo() "CADPythonShell.Resources.handle-16.png"), LargeImage = CADPythonShellApplication.GetEmbeddedPng(addinAssembly, "CADPythonShell.Resources.handle-32.png"), - CommandHandler = new RelayCommand(new SnoopByHanderCommand().Execute), + CommandHandler = new RelayCommand(new SnoopByHandleCommand().Execute), AllowInToolBar = true, KeyTip = "Snoop By Handle", }; @@ -175,7 +175,7 @@ private static RibbonPanel AddPanelTwo() Size = RibbonItemSize.Large, Name = nameof(MgdDbgAction.SnoopEnts), ShowText = true, - Text ="Snoop\nEntities", + Text = "Snoop\nEntities", Description = $"Start snoop Snoop Entities inside Autocad \n Command: {nameof(MgdDbgAction.SnoopEnts)}", Image = CADPythonShellApplication.GetEmbeddedPng(addinAssembly, "CADPythonShell.Resources.snoopentities-16.png"), diff --git a/CADPythonShell/CADPythonShell.csproj b/CADPythonShell/CADPythonShell.csproj index 0caa312..417a3fb 100644 --- a/CADPythonShell/CADPythonShell.csproj +++ b/CADPythonShell/CADPythonShell.csproj @@ -7,15 +7,16 @@ false true true + x64 Debug A23 $(Configurations);Release A23 true - + true full @@ -26,7 +27,7 @@ none $(DefineConstants);RELEASE - + $(DefineConstants);A23 @@ -222,12 +223,12 @@ - - + + diff --git a/CADPythonShell/Command/CommandLoaderBase.cs b/CADPythonShell/Command/CommandLoaderBase.cs index 72bf848..e570ddf 100644 --- a/CADPythonShell/Command/CommandLoaderBase.cs +++ b/CADPythonShell/Command/CommandLoaderBase.cs @@ -1,7 +1,8 @@ -using CADRuntime; +using CADPythonShell.App; +using CADRuntime; using System.IO; -namespace CADPythonShell +namespace CADPythonShell.Command { /// /// Starts up a ScriptOutput window for a given canned command. diff --git a/CADPythonShell/Command/ConfigureCommand.cs b/CADPythonShell/Command/ConfigureCommand.cs index 318ad03..6427ac2 100644 --- a/CADPythonShell/Command/ConfigureCommand.cs +++ b/CADPythonShell/Command/ConfigureCommand.cs @@ -1,7 +1,8 @@ using Autodesk.AutoCAD.Runtime; +using CADPythonShell.App; using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; -namespace CADPythonShell +namespace CADPythonShell.Command { /// /// Open the configuration dialog. diff --git a/CADPythonShell/Command/ICadCommand.cs b/CADPythonShell/Command/ICadCommand.cs index 740e799..38630fe 100644 --- a/CADPythonShell/Command/ICadCommand.cs +++ b/CADPythonShell/Command/ICadCommand.cs @@ -1,4 +1,4 @@ -namespace CADPythonShell; +namespace CADPythonShell.Command; public abstract class ICadCommand { diff --git a/CADPythonShell/Command/IronPythonConsoleCommand.cs b/CADPythonShell/Command/IronPythonConsoleCommand.cs index 865a6bc..f23160c 100644 --- a/CADPythonShell/Command/IronPythonConsoleCommand.cs +++ b/CADPythonShell/Command/IronPythonConsoleCommand.cs @@ -1,5 +1,6 @@ using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.Runtime; +using CADPythonShell.App; using CADRuntime; using Microsoft.Scripting; using System.Windows; @@ -9,7 +10,7 @@ using Exception = System.Exception; using Forms = System.Windows.Forms; -namespace CADPythonShell +namespace CADPythonShell.Command { public class IronPythonConsoleCommand : ICadCommand { diff --git a/CADPythonShell/Command/SnoopByHandleCommand.cs b/CADPythonShell/Command/SnoopByHandleCommand.cs index ab62eaa..dfadf39 100644 --- a/CADPythonShell/Command/SnoopByHandleCommand.cs +++ b/CADPythonShell/Command/SnoopByHandleCommand.cs @@ -1,12 +1,12 @@ -using Application = Autodesk.AutoCAD.ApplicationServices.Application; +using MgdDbg.App; -namespace CADPythonShell; +namespace CADPythonShell.Command; -public class SnoopByHanderCommand : ICadCommand +public class SnoopByHandleCommand : ICadCommand { public override void Execute() { - string fullCmdLine = $"_{nameof(MgdDbgAction.SnoopByHandle)}\n"; - Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + TestCmds testCmds = new TestCmds(); + testCmds.SnoopEntityByHandle(); } } \ No newline at end of file diff --git a/CADPythonShell/Command/SnoopCommand.cs b/CADPythonShell/Command/SnoopCommand.cs index dc316f7..e0638be 100644 --- a/CADPythonShell/Command/SnoopCommand.cs +++ b/CADPythonShell/Command/SnoopCommand.cs @@ -1,13 +1,13 @@ using Autodesk.AutoCAD.Runtime; -namespace CADPythonShell +namespace CADPythonShell.Command { public class SnoopCommand : ICadCommand { [CommandMethod("Snoop")] public override void Execute() { - new CADSnoop.SnoopCommand().Snoop(); + new CADSnoop.SnoopCommand().Snoop(); } } -} +} \ No newline at end of file diff --git a/CADPythonShell/Command/SnoopDBCommand.cs b/CADPythonShell/Command/SnoopDBCommand.cs index fe9cc02..94ff01b 100644 --- a/CADPythonShell/Command/SnoopDBCommand.cs +++ b/CADPythonShell/Command/SnoopDBCommand.cs @@ -1,12 +1,12 @@ -using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; +using MgdDbg.App; -namespace CADPythonShell; +namespace CADPythonShell.Command; public class SnoopDBCommand : ICadCommand { public override void Execute() { - string fullCmdLine = $"_{nameof(MgdDbgAction.SnoopDB)}\n"; - Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + TestCmds cmd = new TestCmds(); + cmd.SnoopDatabase(); } } \ No newline at end of file diff --git a/CADPythonShell/Command/SnoopEditorCommand.cs b/CADPythonShell/Command/SnoopEditorCommand.cs index 0d74dca..34e34df 100644 --- a/CADPythonShell/Command/SnoopEditorCommand.cs +++ b/CADPythonShell/Command/SnoopEditorCommand.cs @@ -1,10 +1,12 @@ -namespace CADPythonShell; +using MgdDbg.App; + +namespace CADPythonShell.Command; public class SnoopEditorCommand : ICadCommand { public override void Execute() { - string fullCmdLine = $"_{nameof(MgdDbgAction.SnoopEd)}\n"; - Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + TestCmds cmd = new TestCmds(); + cmd.SnoopEd(); } } \ No newline at end of file diff --git a/CADPythonShell/Command/SnoopEntitiesCommand.cs b/CADPythonShell/Command/SnoopEntitiesCommand.cs index 7b455a4..77993b4 100644 --- a/CADPythonShell/Command/SnoopEntitiesCommand.cs +++ b/CADPythonShell/Command/SnoopEntitiesCommand.cs @@ -1,10 +1,12 @@ -namespace CADPythonShell; +using MgdDbg.App; + +namespace CADPythonShell.Command; public class SnoopEntitiesCommand : ICadCommand { public override void Execute() { - string fullCmdLine = $"_{nameof(MgdDbgAction.SnoopEnts)}\n"; - Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + TestCmds cmd = new TestCmds(); + cmd.SnoopEntity(); } } \ No newline at end of file diff --git a/CADPythonShell/Command/SnoopEntitiesNestedCommand.cs b/CADPythonShell/Command/SnoopEntitiesNestedCommand.cs index e3dcc2e..2223dfa 100644 --- a/CADPythonShell/Command/SnoopEntitiesNestedCommand.cs +++ b/CADPythonShell/Command/SnoopEntitiesNestedCommand.cs @@ -1,10 +1,12 @@ -namespace CADPythonShell; +using MgdDbg.App; + +namespace CADPythonShell.Command; public class SnoopEntitiesNestedCommand : ICadCommand { public override void Execute() { - string fullCmdLine = $"_{nameof(MgdDbgAction.SnoopNEnts)}\n"; - Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + TestCmds cmd = new TestCmds(); + cmd.SnoopNestedEntity(); } } \ No newline at end of file diff --git a/CADPythonShell/Command/SnoopEventsCommand.cs b/CADPythonShell/Command/SnoopEventsCommand.cs index 5bba961..ec4656f 100644 --- a/CADPythonShell/Command/SnoopEventsCommand.cs +++ b/CADPythonShell/Command/SnoopEventsCommand.cs @@ -1,10 +1,12 @@ -namespace CADPythonShell; +using MgdDbg.App; + +namespace CADPythonShell.Command; public class SnoopEventsCommand : ICadCommand { public override void Execute() { - string fullCmdLine = $"_{nameof(MgdDbgAction.SnoopEvents)}\n"; - Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + TestCmds cmd = new TestCmds(); + cmd.Events(); } } \ No newline at end of file diff --git a/CADPythonShell/Command/TestFrameworkCommand.cs b/CADPythonShell/Command/TestFrameworkCommand.cs index ab279a3..45562f7 100644 --- a/CADPythonShell/Command/TestFrameworkCommand.cs +++ b/CADPythonShell/Command/TestFrameworkCommand.cs @@ -1,10 +1,12 @@ -namespace CADPythonShell; +using MgdDbg.App; + +namespace CADPythonShell.Command; public class TestFrameworkCommand : ICadCommand { public override void Execute() { - string fullCmdLine = $"_{nameof(MgdDbgAction.SnoopTests)}\n"; - Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + TestCmds cmd = new TestCmds(); + cmd.TestDb(); } } \ No newline at end of file diff --git a/CADPythonShell/ConfigureCommandsForm.cs b/CADPythonShell/ConfigureCommandsForm.cs index c6b5669..1359f72 100644 --- a/CADPythonShell/ConfigureCommandsForm.cs +++ b/CADPythonShell/ConfigureCommandsForm.cs @@ -1,10 +1,11 @@ -using System.IO; +using CADPythonShell.App; +using System.IO; namespace CADPythonShell { public partial class ConfigureCommandsForm : Form { - private List _commands; + private List _commands; private List _searchPaths; private List> _variables; @@ -50,7 +51,7 @@ private void ConfigureCommandsForm_Load(object sender, EventArgs e) /// private void lstCommands_SelectedIndexChanged(object sender, EventArgs e) { - var command = (Command)lstCommands.SelectedItem; + var command = (App.Command)lstCommands.SelectedItem; txtCommandName.Text = command.Name; txtCommandPath.Text = command.Source; txtCommandGroup.Text = command.Group; @@ -61,7 +62,7 @@ private void lstCommands_SelectedIndexChanged(object sender, EventArgs e) /// private void txtCommandName_TextChanged(object sender, EventArgs e) { - var command = (Command)lstCommands.SelectedItem; + var command = (App.Command)lstCommands.SelectedItem; command.Name = txtCommandName.Text; RefreshBindingContext(lstCommands, _commands); @@ -69,7 +70,7 @@ private void txtCommandName_TextChanged(object sender, EventArgs e) private void txtCommandGroup_TextChanged(object sender, EventArgs e) { - var command = (Command)lstCommands.SelectedItem; + var command = (App.Command)lstCommands.SelectedItem; command.Group = txtCommandGroup.Text; RefreshBindingContext(lstCommands, _commands); @@ -80,7 +81,7 @@ private void txtCommandGroup_TextChanged(object sender, EventArgs e) /// private void txtCommandPath_TextChanged(object sender, EventArgs e) { - var command = (Command)lstCommands.SelectedItem; + var command = (App.Command)lstCommands.SelectedItem; command.Source = txtCommandPath.Text; RefreshBindingContext(lstCommands, _commands); @@ -120,7 +121,7 @@ private void btnCommandAdd_Click(object sender, EventArgs e) if (dialog.ShowDialog(this) == DialogResult.OK) { - var command = new Command(); + var command = new App.Command(); command.Name = ""; command.Group = ""; command.Source = dialog.FileName; diff --git a/CADPythonShell/PackageContents.xml b/CADPythonShell/PackageContents.xml index 479e08f..77d42fc 100644 --- a/CADPythonShell/PackageContents.xml +++ b/CADPythonShell/PackageContents.xml @@ -26,5 +26,25 @@ AppDescription="a module snoop entities of CAD PythonShell" LoadOnAutoCADStartup="True"> + + + + + + + + \ No newline at end of file diff --git a/CADPythonShell/Properties/launchSettings.json b/CADPythonShell/Properties/launchSettings.json index 640621d..0c8962e 100644 --- a/CADPythonShell/Properties/launchSettings.json +++ b/CADPythonShell/Properties/launchSettings.json @@ -1,6 +1,6 @@ { "profiles": { - "CADPythonShell": { + "CAD23": { "commandName": "Executable", "executablePath": "C:\\Program Files\\Autodesk\\AutoCAD 2023\\acad.exe" } diff --git a/CADRuntime/CADRuntime.csproj b/CADRuntime/CADRuntime.csproj index 1019bfd..227cb22 100644 --- a/CADRuntime/CADRuntime.csproj +++ b/CADRuntime/CADRuntime.csproj @@ -54,6 +54,8 @@ + + @@ -62,6 +64,8 @@ + + @@ -69,6 +73,6 @@ - + \ No newline at end of file diff --git a/CADRuntime/Resources/IronPython.3.4.0.zip b/CADRuntime/Resources/IronPython.3.4.0.zip new file mode 100644 index 0000000..75452e6 Binary files /dev/null and b/CADRuntime/Resources/IronPython.3.4.0.zip differ diff --git a/CADRuntime/ScriptExecutor.cs b/CADRuntime/ScriptExecutor.cs index 42f3130..3cf9d4d 100644 --- a/CADRuntime/ScriptExecutor.cs +++ b/CADRuntime/ScriptExecutor.cs @@ -104,7 +104,7 @@ private void AddEmbeddedLib(ScriptEngine engine) // use embedded python lib var asm = this.GetType().Assembly; var resQuery = from name in asm.GetManifestResourceNames() - where name.ToLowerInvariant().EndsWith("python_27_lib.zip") + where name.ToLowerInvariant().EndsWith("ironpython.3.4.0.zip") select name; var resName = resQuery.Single(); var importer = new IronPython.Modules.ResourceMetaPathImporter(asm, resName); diff --git a/CADRuntime/SettingsDictionary.cs b/CADRuntime/SettingsDictionary.cs index 82f2464..e6365de 100644 --- a/CADRuntime/SettingsDictionary.cs +++ b/CADRuntime/SettingsDictionary.cs @@ -13,6 +13,7 @@ public class SettingsDictionary : IDictionary private readonly string _settingsPath; private XDocument _settings; private string nameVariable = "StringVariable"; + public SettingsDictionary(string settingsPath) { _settingsPath = settingsPath; diff --git a/CHANGELOG.md b/CHANGELOG.md index d64a875..a594481 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ # Changelog +- 2023-06-05 **1.1.3** + - Fix bug snoop selected instance with lock document. +- 2023-04-12 **1.1.2** + - Fix snoop selected instance + - Merge submodule +- 2022-12-17 **1.1.1** + - Fix code Autocomple List ironpython 3.4 +- 2022-12-17 **1.1.0** + - Fix Assembly Security from IronPython 3.4 [#6](https://github.com/chuongmep/CadPythonShell/issues/6) +- 2022-12-16 **1.0.9** + - Support IronPython 3.4 - 2022-05-12 **1.0.8** - Fix bug duplicate snoop [#4](https://github.com/chuongmep/CadPythonShell/issues/4) - 2022-04-12 **1.0.7** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 309469f..d8d7e45 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,6 +8,15 @@ - In the dev branch, implement and test you changes specific to the feature. - Build the project and make sure everything works. - Create well-documented commits of your changes. +- Update Submodule: + - git submodule update --remote +- Commit submodules in case change in submodule + - cd path/to/submodule + - git add + - git commit -m "comment" + - git push + - Create a pull request to submodules +- Update and commit submodule: git submodule update --remote - Submit a pull request to the origin:dev branch. #### Please avoid: diff --git a/CadLookup/.gitattributes b/CadLookup/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/CadLookup/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/CadLookup/App.config b/CadLookup/App.config new file mode 100644 index 0000000..ecdcf8a --- /dev/null +++ b/CadLookup/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/CadLookup/CADSnoop.csproj b/CadLookup/CADSnoop.csproj new file mode 100644 index 0000000..f9e49b8 --- /dev/null +++ b/CadLookup/CADSnoop.csproj @@ -0,0 +1,35 @@ + + + net48 + Library + false + true + true + true + + + + + + + None + + + + + ..\RefrencedAssemblies\accoremgd.dll + + + ..\RefrencedAssemblies\acdbmgd.dll + + + + + + + + + + + + \ No newline at end of file diff --git a/CadLookup/LICENSE b/CadLookup/LICENSE new file mode 100644 index 0000000..fdcdd08 --- /dev/null +++ b/CadLookup/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Long + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/CadLookup/Model/ObjectDetails.cs b/CadLookup/Model/ObjectDetails.cs new file mode 100644 index 0000000..c76e413 --- /dev/null +++ b/CadLookup/Model/ObjectDetails.cs @@ -0,0 +1,16 @@ +using System; + +namespace CADSnoop.Model +{ + /// + /// Information Of Object + /// + public class ObjectDetails + { + public string GroupName { get; set; } + public string PropName { get; set; } + public string Type { get; set; } + public string Value { get; set; } + public Object LinkObject { get; set; } + } +} diff --git a/CadLookup/Model/RelayCommand.cs b/CadLookup/Model/RelayCommand.cs new file mode 100644 index 0000000..0aa8db6 --- /dev/null +++ b/CadLookup/Model/RelayCommand.cs @@ -0,0 +1,41 @@ +using System; +using System.Windows.Input; + +namespace CADSnoop.Model +{ + public class RelayCommand : ICommand + { + readonly Action _execute; + readonly Func _canExecute; + + public RelayCommand(Action execute, Func canExecute) + { + if (execute == null) + throw new NullReferenceException("execute"); + + _execute = execute; + _canExecute = canExecute; + } + + public RelayCommand(Action execute) : this(execute, null) + { + + } + + public event EventHandler CanExecuteChanged + { + add => CommandManager.RequerySuggested += value; + remove => CommandManager.RequerySuggested -= value; + } + + public bool CanExecute(object parameter) + { + return _canExecute == null ? true : _canExecute(); + } + + public void Execute(object parameter) + { + _execute.Invoke(); + } + } +} diff --git a/CadLookup/Model/ViewModelBase.cs b/CadLookup/Model/ViewModelBase.cs new file mode 100644 index 0000000..badeec1 --- /dev/null +++ b/CadLookup/Model/ViewModelBase.cs @@ -0,0 +1,90 @@ +using System.ComponentModel; +using System.Diagnostics; +using System.Globalization; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace CADSnoop.Model +{ + public class ViewModelBase : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + public virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + // + /// Called when the specified property has been changed. + /// + /// Name of the property. + /// The old value. + /// The new value. + protected virtual void OnPropertyChanged(string propertyName, object oldValue, object newValue) + { + this.OnPropertyChanged(propertyName); + } + + #region Can Optimize + /// + /// + /// + /// + /// + /// + /// + public void OnPropertyChanged(ref T property, T value, [CallerMemberName] string propertyName = "") + { + property = value; + var handler = PropertyChanged; + if (handler != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + + #endregion + + /// + /// Sets the property value. + /// + /// The type of the property. + /// The field. + /// The value. + /// Name of the property. + /// + /// True if the property was set. + /// + /// This method uses the CallerMemberNameAttribute to determine the property name. + protected bool SetValue(ref T field, T value, [System.Runtime.CompilerServices.CallerMemberName] string propertyName = "") + { + // ReSharper disable once RedundantNameQualifier + if (object.Equals(field, value)) + { + return false; + } + this.VerifyProperty(propertyName); + //// this.OnPropertyChanging(propertyName, field, value); + T oldValue = field; + field = value; + this.OnPropertyChanged(propertyName, oldValue, value); + return true; + } + + /// + /// Verifies the property name. + /// + /// Name of the property. + [Conditional("DEBUG")] + private void VerifyProperty(string propertyName) + { + var type = this.GetType(); + + // Look for a public property with the specified name. + var propertyInfo = type.GetTypeInfo().GetDeclaredProperty(propertyName); + + Debug.Assert(propertyInfo != null, string.Format(CultureInfo.InvariantCulture, "{0} is not a property of {1}", propertyName, type.FullName)); + } + } +} \ No newline at end of file diff --git a/CadLookup/Model/WindowHandle.cs b/CadLookup/Model/WindowHandle.cs new file mode 100644 index 0000000..ba52644 --- /dev/null +++ b/CadLookup/Model/WindowHandle.cs @@ -0,0 +1,68 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Interop; + +namespace CADSnoop.Model +{ + public static class WindowHandle + { + [DllImport("kernel32.dll")] + public static extern uint GetCurrentThreadId(); + + /// + /// Sets the given window's owner to Cad window. + /// + /// Target window. + public static void SetCadAsWindowOwner(this Window dialog) + { + if (null == dialog) { return; } + + WindowInteropHelper helper = new WindowInteropHelper(dialog); + helper.Owner = FindCadWindowHandle(); + } + + /// + /// Finds the Cad window handle. + /// + /// Revit window handle. + public static IntPtr FindCadWindowHandle() + { + try + { + IntPtr foundRevitHandle = IntPtr.Zero; + uint currentThreadID = GetCurrentThreadId(); + + // Search for the Revit process with current thread ID. + Process[] revitProcesses = Process.GetProcessesByName("acad"); + Process foundRevitProcess = null; + foreach (Process aRevitProcess in revitProcesses) + { + foreach (ProcessThread aThread in aRevitProcess.Threads) + { + if (aThread.Id == currentThreadID) + { + foundRevitProcess = aRevitProcess; + break; + } + } // For each thread in the process. + + // When we have found our Revit process, then stop searching. + if (null != foundRevitProcess) { break; } + } // For each revit process found + + if (null != foundRevitProcess) + { + foundRevitHandle = foundRevitProcess.MainWindowHandle; + } + + return foundRevitHandle; + } + catch (Exception) + { + return IntPtr.Zero; + } + } + } +} diff --git a/CadLookup/PackageContents.xml b/CadLookup/PackageContents.xml new file mode 100644 index 0000000..9096d79 --- /dev/null +++ b/CadLookup/PackageContents.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/CadLookup/Properties/AssemblyInfo.cs b/CadLookup/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0d0d053 --- /dev/null +++ b/CadLookup/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SnooAutoCADCSharp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HTL")] +[assembly: AssemblyProduct("SnooAutoCADCSharp")] +[assembly: AssemblyCopyright("Copyright © HTL 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CadLookup/Properties/Resources.Designer.cs b/CadLookup/Properties/Resources.Designer.cs new file mode 100644 index 0000000..95f5b85 --- /dev/null +++ b/CadLookup/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SnoopAutoCADCSharp.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SnoopAutoCADCSharp.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/CadLookup/Properties/Resources.resx b/CadLookup/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/CadLookup/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CadLookup/Properties/Settings.Designer.cs b/CadLookup/Properties/Settings.Designer.cs new file mode 100644 index 0000000..b8c5c75 --- /dev/null +++ b/CadLookup/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SnoopAutoCADCSharp.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/CadLookup/Properties/Settings.settings b/CadLookup/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/CadLookup/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/CadLookup/README.md b/CadLookup/README.md new file mode 100644 index 0000000..a3e57f6 --- /dev/null +++ b/CadLookup/README.md @@ -0,0 +1,49 @@ + +# AutoCADLookup + + + + +[](http://opensource.org/licenses/MIT) + +Interactive Autocad BIM database exploration tool to view and navigate element properties and relationships. + +### Setup + +Open the SnoopAutoCADCSharp.sln on Visual Studio 2022. All references should be ready for AutoCAD 2022 default install path, otherwise go to project properties >> References, then click on Reference Paths and adjust. Build the project in Release, the DLL should be placed at same folder. Copy the entire .bundle folder to C:\Program Files\Autodesk\Autodesk\ApplicationPlugins folder and launch Autocad. + +## Installation + +- Download last install stable(msi) from CadPythonShell [Release](https://github.com/chuongmep/CADPythonShell/releases/latest) +- Use command `Snoop` to open Window or use button Snoop from Ribbon +- See guide install detail at [How-to-Install-CadPythonShell](https://github.com/chuongmep/CadPythonShell/wiki/How-to-Install-CadPythonShell) + +Note : Support for 4 last version(2019-2022) Autocad or Civil 3D. Older versions can be used but will not guarantee the expected performance. + +# Usage + +- On AutoCAD , command the "Snoop" option, the main form should appear. At the left side is a list of the main collections on the active document. On the right side, the properties of the item selected on the left. + +- Can continue Snoop Database to check. + + + +### Author + +First Project write sypport Autocad and Civi3D with language VB.NET by Augusto Goncalves @augustomaia , member of the Autodesk Developer Technical Services team. + +Now project update in .NET C# by htlcnn and Hồ Văn Chương + +### Known Issues + +The tool may stop working on some properties that cannot be reflected (using .NET). + +### Demo + + + +### Release History + +1.0.0 : First Release + + diff --git a/CadLookup/SnoopAutoCADCSharp.sln b/CadLookup/SnoopAutoCADCSharp.sln new file mode 100644 index 0000000..b94ce74 --- /dev/null +++ b/CadLookup/SnoopAutoCADCSharp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32317.152 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CADSnoop", "CADSnoop.csproj", "{4AB3C6E6-D513-461D-BA9A-6F081E50323A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7C89A58D-A042-49B9-8849-1DEF4397E06F} + EndGlobalSection +EndGlobal diff --git a/CadLookup/SnoopCommand.cs b/CadLookup/SnoopCommand.cs new file mode 100644 index 0000000..82284d2 --- /dev/null +++ b/CadLookup/SnoopCommand.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Runtime; +using CADSnoop.Model; +using CADSnoop.View; +using CADSnoop.ViewModel; +using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; +using Exception = System.Exception; + +namespace CADSnoop +{ + public class SnoopCommand + { + [CommandMethod("Snoop")] + public void Snoop() + { + Snoop(new List()); + } + /// + /// Snoop Snoop a object by id + /// + /// + public void Snoop(ObjectId objectId) + { + Snoop(new List(){objectId}); + } + /// + /// snoop by dbobject + /// + /// + /// + public void Snoop(DBObject dbObject) + { + if (dbObject == null) throw new ArgumentException(nameof(dbObject)); + Document doc = Application.DocumentManager.MdiActiveDocument; + Editor ed = doc.Editor; + Database db = doc.Database; + using (DocumentLock lockDoc = doc.LockDocument()) + { + using (Transaction tran = db.TransactionManager.StartTransaction()) + { + { + SnoopViewModel vm = new SnoopViewModel(doc, db, dbObject); + MainWindow form = new MainWindow(vm); + form.SetCadAsWindowOwner(); + form.Show(); + } + tran.Commit(); + } + } + } + /// + /// Snoop snoop object by list object id + /// + /// + public void Snoop(List objectIds) + { + try + { + Document doc = Application.DocumentManager.MdiActiveDocument; + Editor ed = doc.Editor; + Database db = doc.Database; + using (DocumentLock lockDoc = doc.LockDocument()) + { + using (Transaction tran = db.TransactionManager.StartTransaction()) + { + if (objectIds == null || objectIds.Count==0) objectIds = PickObjectBySelect(doc); + if (objectIds != null) + { + SnoopViewModel vm = new SnoopViewModel(doc, db, objectIds); + MainWindow form = new MainWindow(vm); + form.SetCadAsWindowOwner(); + form.Show(); + } + tran.Commit(); + } + } + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + List PickObjectBySelect(Document doc) + { + try + { + //PromptSelectionOptions poOptions = new PromptSelectionOptions(); + //poOptions.SingleOnly = true; + PromptSelectionResult promptSelectionResult = doc.Editor.GetSelection(); + if (promptSelectionResult.Status != PromptStatus.OK) return null; + SelectionSet selectionSet = promptSelectionResult.Value; + return selectionSet.GetObjectIds().ToList(); + } + catch (ArgumentNullException) { } + catch (NullReferenceException) { } + catch (Exception e) + { + MessageBox.Show(e.ToString()); + } + + return null; + } + + } +} diff --git a/CadLookup/View/MainWindow.xaml b/CadLookup/View/MainWindow.xaml new file mode 100644 index 0000000..a167af0 --- /dev/null +++ b/CadLookup/View/MainWindow.xaml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CadLookup/View/MainWindow.xaml.cs b/CadLookup/View/MainWindow.xaml.cs new file mode 100644 index 0000000..931c1dc --- /dev/null +++ b/CadLookup/View/MainWindow.xaml.cs @@ -0,0 +1,135 @@ +using System.Collections.Generic; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using Autodesk.AutoCAD.DatabaseServices; +using CADSnoop.Model; +using CADSnoop.ViewModel; +using Exception = System.Exception; + +namespace CADSnoop.View +{ + + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private SnoopViewModel _viewModel; + + public MainWindow() + { + InitializeComponent(); + } + public MainWindow(SnoopViewModel vm) :this() + { + this._viewModel = vm; + this.DataContext = vm; + SnoopViewModel.FrmMain = this; + } + + private void Treeview_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) + { + try + { + + TreeViewCustomItem selected = e.NewValue as TreeViewCustomItem; + object obj = selected.Object; + DBObject dbObject = obj as DBObject; + if (dbObject != null) + { + foreach (KeyValuePair> pair in _viewModel.DataMethod) + { + if (pair.Key == dbObject.Id.ToString()) + { + _viewModel.LisViewItems = new List(); + _viewModel.LisViewItems = pair.Value; + } + } + + _viewModel.UpdateDataSource(_viewModel.LisViewItems); + } + + } + catch (Exception ex) + { + MessageBox.Show(ex.InnerException.StackTrace); + } + } + + private void ListViewItem_DoubleClick(object sender, MouseButtonEventArgs e) + { + if (this.listview.SelectedItems.Count != 1) + { + return; + } + ObjectDetails selectedItem = this.listview.SelectedItem as ObjectDetails; + object LinkObject = selectedItem.LinkObject; + if (LinkObject is null) + { + return; + } + if (_viewModel.IsEnumerable(LinkObject)) + { + using (_viewModel.doc.LockDocument()) + { + _viewModel.CollectionItemSelected(LinkObject); + } + + } + else if (LinkObject is ObjectId objectId) + { + if (!IsExcept(objectId)) + { + using (_viewModel.doc.LockDocument()) + { + _viewModel.ObjectIdItemSelected(objectId); + } + } + } + } + + + private void ContextMenu_MouseDown(object sender, RoutedEventArgs e) + { + MenuItem menuitem = sender as MenuItem; + if (menuitem != null) + { + ContextMenu parent_contextmenu = menuitem.CommandParameter as ContextMenu; + if (parent_contextmenu != null) + { + string clip = ""; + foreach (var item in this.listview.SelectedItems) + { + ObjectDetails objectDetails = item as ObjectDetails; + clip += objectDetails.PropName + "\t" + objectDetails.Type + "\t" + objectDetails.Value + "\n"; + } + Clipboard.SetText(clip); + } + } + } + + private void Window_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + Close(); + } + } + + + bool IsExcept(ObjectId objectId) + { + if (objectId.IsNull) return true; + if (objectId.ToString() == "0") return true; + if (objectId.ToString() == "(0)") return true; + return false; + } + + private void ButtonBase_OnClick(object sender, RoutedEventArgs e) + { + Close(); + } + } +} + diff --git a/CadLookup/ViewModel/SnoopViewModel.cs b/CadLookup/ViewModel/SnoopViewModel.cs new file mode 100644 index 0000000..9689745 --- /dev/null +++ b/CadLookup/ViewModel/SnoopViewModel.cs @@ -0,0 +1,403 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Windows; +using System.Windows.Data; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using CADSnoop.Model; +using CADSnoop.View; +using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application; +using Exception = System.Exception; + +namespace CADSnoop.ViewModel +{ + public class SnoopViewModel : ViewModelBase + + { + private Dictionary> dataMethod; + + public Dictionary> DataMethod + { + get => dataMethod; + set => dataMethod = value; + } + + private const string stringEmpty = "[Empty]"; + private const string stringEmptyCollection = "[Empty Collection]"; + private const string stringCollection = "[Collection]"; + public Editor Ed; + public Document doc; + public Database Database; + public static MainWindow FrmMain; + + public List ObjectIds; + + private List listviewitems; + + public List LisViewItems + { + get + { + if (listviewitems == null) + { + listviewitems = new List(); + } + return listviewitems; + } + set => OnPropertyChanged(ref listviewitems, value); + } + + private List treeViewItems; + + public List TreeViewItems + { + get + { + if (treeViewItems == null) + { + treeViewItems = new List(); + } + return treeViewItems; + } + set => OnPropertyChanged(ref treeViewItems, value); + } + + public SnoopViewModel(Document doc, Database db) + { + this.doc = doc; + this.Ed = doc.Editor; + this.Database = db; + this.dataMethod = new Dictionary>(); + + } + /// + /// Base Model + /// + /// + /// + public SnoopViewModel(Document doc, Database db, List objectIds) : this(doc,db) + { + this.ObjectIds = objectIds; + GetListViewItem(); + } + + public SnoopViewModel(Document doc, Database db, DBObject dbObject) :this(doc,db) + { + this.ObjectIds = new List(){ dbObject.Id}; + GetListViewItem(); + } + /// + /// Get list item of object + /// + void GetListViewItem() + { + try + { + listviewitems = new List(); + Transaction tran = Database.TransactionManager.StartTransaction(); + UpdateDataSource(listviewitems); + if (ObjectIds.Any()) + { + foreach (ObjectId objectId in ObjectIds) + { + DBObject obj = tran.GetObject(objectId, OpenMode.ForWrite, true); + AddToTreeView(obj); + ListObjectInformation(obj); + + } + } + + tran.Commit(); + } + catch (Exception e) + { + MessageBox.Show(e.ToString()); + } + } + + /// + /// Update Source Tree By Group Name + /// + /// + public void UpdateDataSource(List Items) + { + ICollectionView view = CollectionViewSource.GetDefaultView(Items); + view.GroupDescriptions.Clear(); + PropertyGroupDescription groupDescription = new PropertyGroupDescription("GroupName"); + view.GroupDescriptions.Add(groupDescription); + view.Refresh(); + } + + /// + /// Add Data object to tree view + /// + /// + public void AddToTreeView(DBObject obj) + { + try + { + string text = GetNameOrType(obj) + " " + obj.ObjectId; + TreeViewCustomItem item = new TreeViewCustomItem() { Title = text, Object = obj }; + TreeViewItems.Add(item); + } + catch (Exception e) + { + MessageBox.Show(e.ToString()); + } + } + + private string GetNameOrType(object obj) + { + PropertyInfo propName = obj.GetType().GetProperty("Name"); + if (propName != null && propName.CanRead) + return propName.GetValue(obj).ToString(); + else + return obj.GetType().Name; + } + + public void ListObjectInformation(DBObject obj) + { + try + { + LisViewItems.Clear(); + Type objType = obj.GetType(); + ListProperties(obj, objType); + ListMethods(obj, objType); + dataMethod.Add(obj.Id.ToString(), new List(listviewitems)); + ICollectionView view = CollectionViewSource.GetDefaultView(listviewitems); + view.Refresh(); + } + catch (Exception e) + { + MessageBox.Show(e.ToString()); + } + } + + /// + /// Get all properties objects + /// + /// + /// + public void ListProperties(object obj, Type objType) + { + PropertyInfo[] properties = objType.GetProperties(); + foreach (PropertyInfo prop in properties) + { + if ((IsBanned(objType, prop.Name))) + continue; + + string propName = prop.Name; + string propType = prop.PropertyType.Name; + string propValue = GetValueAsString(prop, obj); + object LinkObject = GetValue(prop, obj); + listviewitems.Add(new ObjectDetails() + { + GroupName = prop.DeclaringType.FullName, + PropName = propName, + Type = propType, + Value = propValue, + LinkObject = LinkObject + }); + + } + } + + /// + /// Get Value of method object + /// + /// + /// + /// + private object GetValue(MethodInfo method, object obj) + { + object methodValue = null; + try + { + methodValue = method.Invoke(obj, null); + } + catch + { + } + + if ((methodValue != null)) + return methodValue; + return stringEmpty; + } + + private object GetValue(PropertyInfo prop, object obj) + { + object propValue = null; + try + { + propValue = prop.GetValue(obj, null); + } + catch + { + } + + if ((propValue != null)) + return propValue; + return stringEmpty; + } + + private StringCollection _bannedList = new StringCollection(); + + /// + /// Check Tree View Is Expanded + /// + /// + /// + /// + private bool IsBanned(Type objectType, string propName) + { + return (_bannedList.Contains($"{objectType.Name}_{propName}")); + } + + + /// + /// Get All Method Object Name + /// + /// + /// + public void ListMethods(object obj, Type objType) + { + try + { + MethodInfo[] methods = objType.GetMethods(); + foreach (MethodInfo meth in methods) + { + if (meth.Name.Contains("Reactor")) + continue; // skip some unwanted methods... + if ((meth.GetParameters().Length == 0 & !meth.IsSpecialName & meth.ReturnType != typeof(void))) + { + object methodValue = GetValue(meth, obj); + if ((IsEnumerable(methodValue))) + { + string propName = meth.Name; + string propType = meth.ReturnType.Name; + string propValue = stringCollection; + object LinkObject = GetValue(meth, obj); + listviewitems.Add(new ObjectDetails() + { + GroupName = meth.DeclaringType.FullName, + PropName = propName, + Type = propType, + Value = propValue, + LinkObject = LinkObject + }); + } + } + } + } + catch (Exception) + { + // ignored + } + } + + public bool IsEnumerable(object obj) + { + string asString = obj as string; + if ((asString != null)) + return false; // strings are enumerable, but not collections + IEnumerable asEnum = obj as IEnumerable; + return (asEnum != null); + } + + /// + /// Get Value Object + /// + /// + /// + /// + private string GetValueAsString(PropertyInfo prop, object obj) + { + object propValue = null; + try + { + if (!(prop.CanRead)) + return "[Write-only]"; + + propValue = prop.GetValue(obj, null); + if (IsEnumerable(propValue)) + { + IEnumerable asEnum = propValue as IEnumerable; + foreach (object item in asEnum) + return stringCollection; // at least one, ok + return stringEmptyCollection; // empty collection then + } + } + catch + { + // ignored + } + + if ((propValue != null)) + return propValue.ToString(); + return stringEmpty; + } + + /// + /// Get Info Selected Object + /// + /// + public void ObjectIdItemSelected(object LinkObject) + { + List objectIds = new List(); + objectIds.Add((ObjectId)LinkObject); + try + { + SnoopViewModel viewModel = new SnoopViewModel(doc, Database, objectIds); + MainWindow form = new MainWindow(viewModel); + Application.ShowModalWindow(FrmMain.Owner, form); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + + } + + /// + /// Get Info Item Select Object + /// + /// + public void CollectionItemSelected(object LinkObject) + { + List objectIds = new List(); + + foreach (var item in (IEnumerable)LinkObject) + { + if (item is ObjectId) + { + objectIds.Add((ObjectId)item); + } + } + + if (objectIds.Count > 0) + { + try + { + SnoopViewModel vm = new SnoopViewModel(doc, Database, objectIds); + MainWindow form = new MainWindow(vm); + form.WindowStartupLocation = WindowStartupLocation.Manual; + Application.ShowModalWindow(form); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + else + { + MessageBox.Show("No ObjectId inside this Collection"); + } + } + } +} diff --git a/CadLookup/ViewModel/TreeViewCustom.cs b/CadLookup/ViewModel/TreeViewCustom.cs new file mode 100644 index 0000000..54176cc --- /dev/null +++ b/CadLookup/ViewModel/TreeViewCustom.cs @@ -0,0 +1,17 @@ +using System.Collections.ObjectModel; +using Autodesk.AutoCAD.DatabaseServices; + +namespace CADSnoop.ViewModel +{ + public class TreeViewCustomItem + { + public TreeViewCustomItem() + { + this.ChildItems = new ObservableCollection(); + } + + public string Title { get; set; } + public DBObject Object { get; set; } + public ObservableCollection ChildItems { get; set; } + } +} diff --git a/Images/AlertDialogDemo.png b/Images/AlertDialogDemo.png new file mode 100644 index 0000000..6d64460 Binary files /dev/null and b/Images/AlertDialogDemo.png differ diff --git a/Images/CadPythonShell.png b/Images/CadPythonShell.png new file mode 100644 index 0000000..e695c6e Binary files /dev/null and b/Images/CadPythonShell.png differ diff --git a/Images/ConfigPythonShell.png b/Images/ConfigPythonShell.png deleted file mode 100644 index 5fab0e7..0000000 Binary files a/Images/ConfigPythonShell.png and /dev/null differ diff --git a/Images/cadpythonshell3.png b/Images/cadpythonshell3.png new file mode 100644 index 0000000..ce641aa Binary files /dev/null and b/Images/cadpythonshell3.png differ diff --git a/Images/configure.png b/Images/configure.png new file mode 100644 index 0000000..15e1ca9 Binary files /dev/null and b/Images/configure.png differ diff --git a/Installer/Installer.cs b/Installer/Installer.cs index 5449423..ce36ffe 100644 --- a/Installer/Installer.cs +++ b/Installer/Installer.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Text.RegularExpressions; using WixSharp; @@ -13,7 +12,7 @@ const string projectName = "CADPythonShell"; const string outputName = "CADPythonShell"; const string outputDir = "output"; -const string version = "1.0.8"; +const string version = "1.1.3"; var fileName = new StringBuilder().Append(outputName).Append("-").Append(version); var project = new Project diff --git a/MgdDbg b/MgdDbg deleted file mode 160000 index 0f5f550..0000000 --- a/MgdDbg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0f5f550841b54be158f3201f6ccfe6207e52489e diff --git a/MgdDbgLibrary/App/App.cs b/MgdDbgLibrary/App/App.cs new file mode 100644 index 0000000..1ba1246 --- /dev/null +++ b/MgdDbgLibrary/App/App.cs @@ -0,0 +1,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(); + } + + /// + /// 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. + /// + + 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); + } + } + + /// + /// Reverse of above. Nothing to do for each TestFunc object though + /// because we already know which ones were registered for this app. + /// + + private void + RemoveAndFreeTestFuncs() + { + foreach (MgdDbgTestFuncs testFunc in m_tests) + { + MgdDbgTestFuncs.RemoveTestFuncsFromFramework(testFunc); + } + } + + /// + /// 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. + /// + + 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); + } + } + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/App/AppContextMenu.cs b/MgdDbgLibrary/App/AppContextMenu.cs new file mode 100644 index 0000000..7ba634d --- /dev/null +++ b/MgdDbgLibrary/App/AppContextMenu.cs @@ -0,0 +1,101 @@ +// +// (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.ApplicationServices; +using Autodesk.AutoCAD.Windows; +using System; + +namespace MgdDbg.App +{ + /// + /// Simple derived MenuItem class to keep a command name so that we can have + /// a single generic callback function for the event. + /// + + public class AppContextMenuItem : Autodesk.AutoCAD.Windows.MenuItem + { + private string m_cmdName; + + public + AppContextMenuItem(string title, string cmdName) + : base(title) + { + m_cmdName = cmdName; + } + + public string + CommandName + { + get { return m_cmdName; } + set { m_cmdName = value; } + } + } + + /// + /// The AppContextMenu for our app. + /// + + public class AppContextMenu + { + private static ContextMenuExtension m_appMenu = null; + + public static void + AddContextMenu() + { + m_appMenu = new ContextMenuExtension(); + m_appMenu.Title = "MgdDbg"; + m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Entities...", "SnoopEnts")); + m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Entities (nested)...", "SnoopNEnts")); + m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop (by Handle)...", "SnoopByHandle")); + m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Database...", "SnoopDB")); + m_appMenu.MenuItems.Add(new AppContextMenuItem("Snoop Editor...", "SnoopEd")); + m_appMenu.MenuItems.Add(new MenuItem("")); // separator + m_appMenu.MenuItems.Add(new AppContextMenuItem("Events...", "SnoopEvents")); + m_appMenu.MenuItems.Add(new MenuItem("")); // separator + m_appMenu.MenuItems.Add(new AppContextMenuItem("Test Framework...", "SnoopTests")); + + foreach (MenuItem mnuItem in m_appMenu.MenuItems) + { + AppContextMenuItem appContextMnuItem = mnuItem as AppContextMenuItem; + if (appContextMnuItem != null) + appContextMnuItem.Click += new EventHandler(ExecuteCommand); + } + + Application.AddDefaultContextMenuExtension(m_appMenu); + } + + private static void + ExecuteCommand(Object o, EventArgs e) + { + AppContextMenuItem mnuItem = (AppContextMenuItem)o; + + string fullCmdLine = string.Format("_{0}\n", mnuItem.CommandName); + Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true); + } + + public static void + RemoveContextMenu() + { + Application.RemoveDefaultContextMenuExtension(m_appMenu); + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/App/AppDocReactor.cs b/MgdDbgLibrary/App/AppDocReactor.cs new file mode 100644 index 0000000..ad0cc50 --- /dev/null +++ b/MgdDbgLibrary/App/AppDocReactor.cs @@ -0,0 +1,114 @@ +// +// (C) Copyright 2006 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 AcApp = Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.App +{ + internal class AppDocReactor + { + public + AppDocReactor() + { + } + + public void + EnableEvents() + { + AcApp.DocumentCollection docs = AcApp.Application.DocumentManager; + + docs.DocumentCreated += new AcApp.DocumentCollectionEventHandler(event_DocumentCreated); + docs.DocumentToBeDestroyed += new AcApp.DocumentCollectionEventHandler(event_DocumentToBeDestroyed); + } + + public void + DisableEvents() + { + AcApp.DocumentCollection docs = AcApp.Application.DocumentManager; + + // Throws an assert when the SnoopEd command is used. Need to investigate this further. + //docs.DocumentCreated -= new AcApp.DocumentCollectionEventHandler(event_DocumentCreated); + + docs.DocumentToBeDestroyed -= new AcApp.DocumentCollectionEventHandler(event_DocumentToBeDestroyed); + } + + private void + event_DocumentCreated(object sender, AcApp.DocumentCollectionEventArgs e) + { + // if the reactor instance exists and if the relevant checkbox is ticked in the Reactors UI + if (MgdDbg.Reactors.Forms.EventsForm.m_dbEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_dbEvents.EnableEvents(e.Document.Database); // will turn on just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_dbObjEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_dbObjEvents.EnableEvents(e.Document.Database); // will turn on just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_docEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_docEvents.EnableEvents(e.Document); // will turn on just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_edEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_edEvents.EnableEvents(e.Document.Editor); // will turn on just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_gsEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_gsEvents.EnableEvents(e.Document.GraphicsManager); // will turn on just for this new document + } + } + + private void + event_DocumentToBeDestroyed(object sender, AcApp.DocumentCollectionEventArgs e) + { + // if the reactor instance exists and if the relevant checkbox is ticked in the Reactors UI + if (MgdDbg.Reactors.Forms.EventsForm.m_dbEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_dbEvents.DisableEvents(e.Document.Database); // will turn off just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_dbObjEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_dbObjEvents.DisableEvents(e.Document.Database); // will turn off just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_docEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_docEvents.DisableEvents(e.Document); // will turn off just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_edEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_edEvents.DisableEvents(e.Document.Editor); // will turn off just for this new document + } + + if (MgdDbg.Reactors.Forms.EventsForm.m_gsEvents.AreEventsEnabled) + { + MgdDbg.Reactors.Forms.EventsForm.m_gsEvents.DisableEvents(e.Document.GraphicsManager); // will turn off just for this new document + } + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/App/AssemblyInfo.cs b/MgdDbgLibrary/App/AssemblyInfo.cs new file mode 100644 index 0000000..d1adadd --- /dev/null +++ b/MgdDbgLibrary/App/AssemblyInfo.cs @@ -0,0 +1,81 @@ +// $Header: //Desktop/Source/TestTools/MgdDbg/App/AssemblyInfo.cs#1 $ +// $Author: fergusja $ $DateTime: 2007/03/16 08:08:08 $ $Change: 68854 $ +// +// (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 System.Reflection; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] \ No newline at end of file diff --git a/MgdDbgLibrary/App/TestCmds.cs b/MgdDbgLibrary/App/TestCmds.cs new file mode 100644 index 0000000..738af38 --- /dev/null +++ b/MgdDbgLibrary/App/TestCmds.cs @@ -0,0 +1,354 @@ +// +// (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.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using Autodesk.AutoCAD.Runtime; +using MgdDbg.CompBuilder; +using MgdDbg.ObjTests.TestFramework; +using MgdDbg.Throwaway; +using MgdDbg.Utils; +using System; +using System.Windows.Forms; +using Autodesk.AutoCAD.ApplicationServices; +using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; +using TestForm = MgdDbg.ObjTests.TestFramework.TestForm; + +namespace MgdDbg.App +{ + /// + /// Summary description for TestCmds. + /// + public class TestCmds + { + [CommandMethod("MgdDbgTestTrans1", CommandFlags.Modal)] + public void TestTrans1() + { + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptSelectionResult res = ed.GetSelection(); + if (res.Status != PromptStatus.OK) + return; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = Utils.Db.GetCurDwg().TransactionManager; + + ObjectId[] objIds = res.Value.GetObjectIds(); + foreach (ObjectId objId in objIds) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + DBObject tmpObj = tr.GetObject(objId, OpenMode.ForRead); + tr.Commit(); + } + } + } + + [CommandMethod("MgdDbgTestTrans2", CommandFlags.Modal)] + public void TestTrans2() + { + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptSelectionResult res = ed.GetSelection(); + if (res.Status != PromptStatus.OK) + return; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = Utils.Db.GetCurDwg().TransactionManager; + + ObjectId[] objIds = res.Value.GetObjectIds(); + foreach (ObjectId objId in objIds) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + DBObject tmpObj = tr.GetObject(objId, OpenMode.ForRead); + tr.Abort(); + } + } + } + + //[CommandMethod("MgdDbg", "MgdDbgSnoopEnts", "SnoopEnts", CommandFlags.Modal)] + [CommandMethod("SnoopEnts", CommandFlags.Modal)] + public void SnoopEntity() + { + var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; + Editor ed = doc.Editor; + + PromptSelectionResult res = ed.GetSelection(); + if (res.Status != PromptStatus.OK) + return; + + ObjectIdCollection selSet = new ObjectIdCollection(res.Value.GetObjectIds()); + using (DocumentLock lockDoc = doc.LockDocument()) + { + using (TransactionHelper trHlp = new TransactionHelper()) + { + trHlp.Start(); + + Snoop.Forms.DBObjects dbox = new Snoop.Forms.DBObjects(selSet, trHlp); + dbox.Text = "Selected Entities"; + AcadApp.ShowModalDialog(dbox); + + trHlp.Commit(); + } + } + + } + + //[CommandMethod("MgdDbg", "MgdDbgSnoopNEnts", "SnoopNEnts", CommandFlags.Modal)] + [CommandMethod("SnoopNEnts", CommandFlags.Modal)] + public void SnoopNestedEntity() + { + var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; + Editor ed = doc.Editor; + ObjectIdCollection selSet = new ObjectIdCollection(); + + while (true) + { + PromptNestedEntityOptions prOptNent = new PromptNestedEntityOptions("\nSelect nested entities or: "); + prOptNent.AppendKeywordsToMessage = true; + prOptNent.Keywords.Add("Done"); + + PromptNestedEntityResult res = ed.GetNestedEntity(prOptNent); + if (res.Status == PromptStatus.OK) + selSet.Add(res.ObjectId); + else if (res.Status == PromptStatus.Keyword) + break; + else + return; + } + using (DocumentLock lockDoc = doc.LockDocument()) + { + using (TransactionHelper trHlp = new TransactionHelper()) + { + trHlp.Start(); + + Snoop.Forms.DBObjects dbox = new Snoop.Forms.DBObjects(selSet, trHlp); + dbox.Text = "Selected Entities"; + AcadApp.ShowModalDialog(dbox); + + trHlp.Commit(); + } + } + + } + + //[CommandMethod("MgdDbg", "MgdDbgSnoopByHandle", "SnoopEnts", CommandFlags.Modal)] + [CommandMethod("SnoopByHandle", CommandFlags.Modal)] + public void SnoopEntityByHandle() + { + ObjectId id = ObjectId.Null; + ObjectIdCollection selSet = new ObjectIdCollection(); + + Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + PromptStringOptions options = new PromptStringOptions("Handle of database object"); + + String str = ed.GetString(options).StringResult; + + if (str != String.Empty) + { + Handle h = Utils.Db.StringToHandle(str); + + try + { + id = Utils.Db.HandleToObjectId(db, h); + + selSet.Add(id); + + using (TransactionHelper trHlp = new TransactionHelper()) + { + trHlp.Start(); + + Snoop.Forms.DBObjects dbox = new Snoop.Forms.DBObjects(selSet, trHlp); + dbox.Text = "Selected Entities"; + AcadApp.ShowModalDialog(dbox); + + trHlp.Commit(); + } + } + catch (Autodesk.AutoCAD.Runtime.Exception x) + { + AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((ErrorStatus)x.ErrorStatus).ToString())); + } + } + } + + //[CommandMethod("MgdDbg", "MgdDbgSnoopDb", "SnoopDb", CommandFlags.Modal)] + [CommandMethod("SnoopDB", CommandFlags.Modal)] + public void SnoopDatabase() + { + var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; + Database db = doc.Database; + + using (DocumentLock lockDoc = doc.LockDocument()) + { + using (TransactionHelper trHlp = new TransactionHelper(db)) + { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(db, trHlp); + dbox.Text = db.Filename; + AcadApp.ShowModalDialog(dbox); + + trHlp.Commit(); + } + } + + } + + //[CommandMethod("MgdDbg", "MgdDbgSnoopEd", "SnoopEd", CommandFlags.Modal)] + [CommandMethod("SnoopEd", CommandFlags.Modal)] + public void SnoopEd() + { + Snoop.Forms.Editor dbox = new Snoop.Forms.Editor(); + AcadApp.ShowModalDialog(dbox); + } + + //[CommandMethod("MgdDbg", "MgdDbgEvents", "Reactors", CommandFlags.Modal)] + [CommandMethod("SnoopEvents", CommandFlags.Modal)] + public void Events() + { + MgdDbg.Reactors.Forms.EventsForm dbox = new MgdDbg.Reactors.Forms.EventsForm(); + AcadApp.ShowModalDialog(dbox); + } + + //[CommandMethod("MgdDbg", "MgdDbgTests", "Tests", CommandFlags.Modal)] + [CommandMethod("SnoopTests", CommandFlags.Modal)] + public void TestDb() + { + TestForm dbox = new TestForm(MgdDbgTestFuncs.RegisteredTestFuncs()); + if (AcadApp.ShowModalDialog(dbox) == DialogResult.OK) + dbox.DoTest(); + } + + //[CommandMethod("MgdDbg", "MgdDbgTestTabForm", "TestTabForm", CommandFlags.Modal)] + [CommandMethod("SnoopTestTabForm", CommandFlags.Modal)] + public void TestTabForm() + { + TestTabForm dbox = new TestTabForm(); + AcadApp.ShowModalDialog(dbox); + } + + //[CommandMethod("MgdDbg", "MgdDbgTestSpeed1", "TestSpeed1", CommandFlags.Modal)] + [CommandMethod("MgdDbgTestSpeed1", CommandFlags.Modal)] + public void TestSpeed1() + { + Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; + //db.Usrtimer = true; + System.DateTime time1 = System.DateTime.Now; + + using (Transaction tr = db.TransactionManager.StartTransaction()) + { + BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite); + + double x = 0.0; + double y = 0.0; + int colorIndex = 0; + + for (int i = 0; i < 10; i++) + { + Line tmpLine = new Line(new Point3d(x, y, 0.0), new Point3d(x, y + 10.0, 0.0)); + tmpLine.ColorIndex = colorIndex++; + btr.AppendEntity(tmpLine); + tr.AddNewlyCreatedDBObject(tmpLine, true); + + x += 5.0; + if (x > 500.0) + { + x = 0.0; + y += 15.0; + } + + // wrap colorIndex when it reaches the limit + if (colorIndex > 255) + colorIndex = 0; + } + + tr.Commit(); + } + + //System.DateTime time = db.Tdusrtimer; + //Utils.AcadUi.PrintToCmdLine(string.Format("\nTIME: {0}", time.ToString())); + //db.Usrtimer = false; + + System.DateTime time2 = System.DateTime.Now; + System.TimeSpan elapsedTime = time2 - time1; + Utils.AcadUi.PrintToCmdLine(string.Format("\nTIME: {0}", elapsedTime.ToString())); + } + + [CommandMethod("MgdDbgTestAngle", CommandFlags.Modal)] + public void TestAngle() + { + Point3d pt1 = new Point3d(0.0, 0.0, 0.0); + Point3d pt2 = new Point3d(2.0, 2.0, 0.0); + + // METHOD 1: Make a vector by subtracting pt1 from pt2 and then figure + // out the angle to the XAxis + double angle1 = Vector3d.XAxis.GetAngleTo(pt2 - pt1); + + // METHOD 2: Same thing, but specify the Plane you want to measure on. + Plane xyPlane = new Plane(Point3d.Origin, Vector3d.ZAxis); + double angle2 = (pt2 - pt1).AngleOnPlane(xyPlane); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + ed.WriteMessage(string.Format("\nAngle 1: {0}", + Autodesk.AutoCAD.Runtime.Converter.AngleToString(angle1, AngularUnitFormat.Current, -1))); + ed.WriteMessage(string.Format("\nAngle 2: {0}", + Autodesk.AutoCAD.Runtime.Converter.AngleToString(angle2, AngularUnitFormat.Current, -1))); + } + + [CommandMethod("MgdDbgGetImageAngle", CommandFlags.Modal)] + public void TestImageAngle() + { + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptEntityOptions prOpts = new PromptEntityOptions("\nSelect an Image"); + prOpts.SetRejectMessage("\nSelected entity must by of type RasterImage"); + prOpts.AddAllowedClass(typeof(RasterImage), false); + + PromptEntityResult prRes = ed.GetEntity(prOpts); + if (prRes.Status == PromptStatus.OK) + { + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = prRes.ObjectId.Database.TransactionManager; + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + RasterImage imgObj = (RasterImage)tr.GetObject(prRes.ObjectId, OpenMode.ForRead); + + CoordinateSystem3d entEcs = imgObj.Orientation; + + Vector3d arbXAxis = Utils.Db.GetEcsXAxis(entEcs.Zaxis); // get AutoCAD's arbitrary X-Axis + double rotAngle1 = arbXAxis.GetAngleTo(entEcs.Xaxis, entEcs.Zaxis); + ed.WriteMessage(string.Format("\nECS rotation angle: {0}", + Autodesk.AutoCAD.Runtime.Converter.AngleToString(rotAngle1, AngularUnitFormat.Current, -1))); + + Plane ucsPlane = Utils.Db.GetUcsPlane(prRes.ObjectId.Database); + double rotAngle2 = entEcs.Xaxis.AngleOnPlane(ucsPlane); + ed.WriteMessage(string.Format("\nRotation angle relative to UCS: {0}", + Autodesk.AutoCAD.Runtime.Converter.AngleToString(rotAngle2, AngularUnitFormat.Current, -1))); + + tr.Commit(); + } + } + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/CompBuilder/CompBldr.cs b/MgdDbgLibrary/CompBuilder/CompBldr.cs new file mode 100644 index 0000000..de0a5b6 --- /dev/null +++ b/MgdDbgLibrary/CompBuilder/CompBldr.cs @@ -0,0 +1,406 @@ +// +// (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.DatabaseServices; +using Autodesk.AutoCAD.Geometry; +using System.Collections; +using System.Diagnostics; + +namespace MgdDbg.CompBuilder +{ + /// + /// This class is intended to ease the creation of multiple entities that + /// are supposed to represent a "Component". Basically, anything you would + /// normally use a BlockDef for. It will manage a transaction and some transforms + /// to make it easier to batch produce several related entities. + /// + + public abstract class CompBldr : TransactionHelper + { + // member variables + protected BlockTableRecord m_blkRec = null; + + protected ObjectId m_blkDefId; + protected ObjectIdCollection m_objIds = new ObjectIdCollection(); + protected Stack m_xformStack = new Stack(); + protected bool m_ignoreXform = false; + + public + CompBldr(Database db) + : base(db) + { + // init stack with identity matrix + m_xformStack.Push(Matrix3d.Identity); + } + + protected abstract void SetCurrentBlkTblRec(); + + public ObjectId + BlockDefId + { + get + { + Debug.Assert(m_blkDefId.IsNull == false); // shouldn't be calling this if things haven't been started! + return m_blkDefId; + } + } + + public override void + Start() + { + // call base class to start a transaction + base.Start(); + + // call derived class to supply the block that we are drawing into. + SetCurrentBlkTblRec(); + if (m_blkRec == null) + throw (new System.Exception("No BlockTableRecord was set up!")); + + m_blkDefId = m_blkRec.ObjectId; + } + + public virtual void + Reset() + { + // reset the stack of xforms + m_xformStack.Clear(); + + // init stack with identity matrix + m_xformStack.Push(Matrix3d.Identity); + + m_objIds.Clear(); + } + + public virtual void + AddToDb(Entity ent) + { + Debug.Assert((m_db != null) && (m_trans != null) && (m_blkRec != null)); + + // transform if not the identity matrix + if ((m_ignoreXform == false) && (m_xformStack.Count > 1)) + ent.TransformBy(CurrentXform()); + + // add to the current block tbl record and add to the transaction + m_blkRec.AppendEntity(ent); + + m_objIds.Add(ent.ObjectId); // keep track of everything we added just in case + m_trans.AddNewlyCreatedDBObject(ent, true); + } + + public virtual void + AddToDbNoXform(Entity ent) + { + m_ignoreXform = true; + AddToDb(ent); + m_ignoreXform = false; + } + + public virtual void + SetToDefaultProps(Entity ent) + { + ent.SetDatabaseDefaults(m_db); + } + + public void + PushXform(Matrix3d mat) + { + Debug.Assert(m_xformStack.Count != 0); + + m_xformStack.Push(mat * CurrentXform()); + } + + public void + PopXform() + { + Debug.Assert(m_xformStack.Count > 1); // this means that someone has popped to many times - bad bad bad + m_xformStack.Pop(); + } + + public Matrix3d + CurrentXform() + { + Debug.Assert(m_xformStack.Count != 0); + return (Matrix3d)m_xformStack.Peek(); + } + } +} + +/* +Acad::ErrorStatus +AecRcpCompBldr::addPolyline(AcDbPolyline* newPline, const AcGePoint2dArray& pts, bool isClosed) +{ + // has to be a new polyine! + if ((newPline == NULL) || (newPline->objectId().isNull() == false)) { + AEC_ASSERT(0); + return Acad::eInvalidInput; + } + + Acad::ErrorStatus es; + + int len = pts.length(); + for (int i=0; iaddVertexAt(i, pts[i]); + AEC_ASSERT(es == Acad::eOk); + } + newPline->setClosed(isClosed); + + return addToDb(newPline); +} + +Acad::ErrorStatus +AecRcpCompBldr::addPolyline(AcDbPolyline* newPline, const AcGePoint2dArray& pts, const AcGeDoubleArray& bulges, bool isClosed) +{ + // has to be a new polyine! + if ((newPline == NULL) || (newPline->objectId().isNull() == false)) { + AEC_ASSERT(0); + return Acad::eInvalidInput; + } + + AEC_ASSERT(pts.length() == bulges.length()); + + Acad::ErrorStatus es; + + int len = pts.length(); + for (int i=0; iaddVertexAt(i, pts[i], bulges[i]); + AEC_ASSERT(es == Acad::eOk); + } + newPline->setClosed(isClosed); + + return addToDb(newPline); +} + +Acad::ErrorStatus +AecRcpCompBldr::addHatchToPrevBoundary(AcDbHatch* newHatch, bool makeAssoc) +{ + // got to have a boundary to set + if ((newHatch == NULL) || (m_objIds.isEmpty() == true) || (newHatch->objectId().isNull() == false)) { + AEC_ASSERT(0); + return Acad::eInvalidInput; + } + + // need to xform the hatch to the right plane before it tries to evaluate + // the pattern. + if (m_xformStack.length() > 1) + newHatch->transformBy(*curXform()); + + // pline is added and has an objectId, now let's add the hatch + AcDbObjectIdArray loopIds; + loopIds.append(m_objIds.last()); + + Acad::ErrorStatus es; + es = newHatch->setAssociative(makeAssoc); + AEC_ASSERT(es == Acad::eOk); + + es = newHatch->appendLoop(AcDbHatch::kExternal, loopIds); + AEC_ASSERT(es == Acad::eOk); + + if (es == Acad::eOk) { + es = newHatch->evaluateHatch(); + + if (es == Acad::eOk) { + es = addToDbNoXform(newHatch); + if (es == Acad::eOk) { + if (makeAssoc) + establishAssociativity(newHatch, loopIds); + + sendToBack(newHatch->objectId(), loopIds); + } + } + } + + if (es != Acad::eOk) { + AecRmCString str, tmpStr; + str.LoadString(GetAecRcpBaseAppName(), AECRB_STR_ERROR_CREATE_HATCH); + acutPrintf(str, newHatch->patternName(), Aec::doubleToStr(newHatch->patternScale(), tmpStr, Aec::kDecimal)); + delete newHatch; + } + + return es; +} + +Acad::ErrorStatus +AecRcpCompBldr::addHatchToBoundaries(AcDbHatch* newHatch, const AcDbObjectIdArray& boundaryIds, + bool makeAssoc, AcDbHatch::HatchStyle hstyle) { + // got to have a boundary to set + if ((newHatch == NULL) || (boundaryIds.isEmpty() == true) || (newHatch->objectId().isNull() == false)) { + AEC_ASSERT(0); + return Acad::eInvalidInput; + } + + // need to xform the hatch to the right plane before it tries to evaluate + // the pattern. + if (m_xformStack.length() > 1) + newHatch->transformBy(*curXform()); + + Acad::ErrorStatus es; + es = newHatch->setAssociative(makeAssoc); + AEC_ASSERT(es == Acad::eOk); + + es = newHatch->setHatchStyle(hstyle); + AEC_ASSERT(es == Acad::eOk); + + // add each boundary as its own loop + AcDbObjectIdArray loopIds; + int len = boundaryIds.length(); + for (int i=0; iappendLoop(AcDbHatch::kDefault, loopIds); + AEC_ASSERT(es == Acad::eOk); + + loopIds.setLogicalLength(0); //clear array + } + + if (es == Acad::eOk) { + es = newHatch->evaluateHatch(); + + if (es == Acad::eOk) { + es = addToDbNoXform(newHatch); + if (es == Acad::eOk) { + if (makeAssoc) + establishAssociativity(newHatch, boundaryIds); + + sendToBack(newHatch->objectId(), boundaryIds); + } + } + } + + if (es != Acad::eOk) { + AecRmCString str, tmpStr; + str.LoadString(GetAecRcpBaseAppName(), AECRB_STR_ERROR_CREATE_HATCH); + acutPrintf(str, newHatch->patternName(), Aec::doubleToStr(newHatch->patternScale(), tmpStr, Aec::kDecimal)); + delete newHatch; + } + + return es; +} + +Acad::ErrorStatus +AecRcpCompBldr::addHatchWithBoundary(AcDbHatch* newHatch, const AcGePoint2dArray& pts, const AcGeDoubleArray& bulges) +{ + // got to have a boundary to set + if ((newHatch == NULL) || (newHatch->objectId().isNull() == false)) { + AEC_ASSERT(0); + return Acad::eInvalidInput; + } + + Acad::ErrorStatus es; + + es = newHatch->setAssociative(false); + AEC_ASSERT(es == Acad::eOk); + + es = newHatch->appendLoop(AcDbHatch::kDefault, pts, bulges); + AEC_ASSERT(es == Acad::eOk); + + if (es == Acad::eOk) { + es = newHatch->evaluateHatch(); + + if (es == Acad::eOk) { + es = addToDb(newHatch); + + AcDbObjectIdArray bogusBoundaryIds; + sendToBack(newHatch->objectId(), bogusBoundaryIds); + } + } + + if (es != Acad::eOk) { + AecRmCString str, tmpStr; + str.LoadString(GetAecRcpBaseAppName(), AECRB_STR_ERROR_CREATE_HATCH); + acutPrintf(str, newHatch->patternName(), Aec::doubleToStr(newHatch->patternScale(), tmpStr, Aec::kDecimal)); + delete newHatch; + } + + return es; +} + +Acad::ErrorStatus +AecRcpCompBldr::establishAssociativity(AcDbHatch* hatch, const AcDbObjectIdArray& boundaryIds) +{ + AEC_ASSERT(hatch->objectId().isNull() == false); // have to add to database first! + + AcDbObject* obj; + Acad::ErrorStatus es; + + int len = boundaryIds.length(); + for (int i=0; iaddPersistentReactor(hatch->objectId()); + } + else { + AecRmCString strMsg; + strMsg.LoadString(GetAecRcpBaseAppName(),AECRB_STR_ERROR_CREATE_HATCH_ASSOC); + acutPrintf(strMsg); + return es; + } + } + + return Acad::eOk; +} + +Acad::ErrorStatus +AecRcpCompBldr::sendToBack(const AcDbObjectId& backEntId, const AcDbObjectIdArray& topEntIds) +{ + if (AecRcpPreferences::useDrawOrder() == false) + return Acad::eOk; + + Acad::ErrorStatus es; + + AcDbSortentsTable* sortTbl; + es = m_blkRec->getSortentsTable(sortTbl, AcDb::kForWrite, true); + AEC_ASSERT(es == Acad::eOk); + + if (es == Acad::eOk) { + if (topEntIds.isEmpty()) { + AcDbObjectIdArray tmpIds; + tmpIds.append(backEntId); + es = sortTbl->moveToBottom(tmpIds); + AEC_ASSERT(es == Acad::eOk); + } + else { + es = sortTbl->moveAbove(topEntIds, backEntId); + AEC_ASSERT(es == Acad::eOk); + } + + sortTbl->close(); + + // if we aren't already putting this sortents table on the block record + // that this hatch belongs to, then we need to "wake up" the layout this + // block will eventually go into. Until there is a SORTENTS dictionary on the + // ModelSpace or PaperSpace block def, no Draworder events happen. + // TBD: doesn't appear to help the problem! + /*if (m_blkRec->isLayout() == false) { + AcDbBlockTableRecord* curSpace = Aec::openCurrentSpaceBlock(AcDb::kForWrite, backEntId.database()); + if (curSpace) { + es = curSpace->getSortentsTable(sortTbl, AcDb::kForWrite, true); + if (es == Acad::eOk) + sortTbl->close(); + + curSpace->close(); + } + }*/ +/* } + + return es; +} + } +}*/ \ No newline at end of file diff --git a/MgdDbgLibrary/CompBuilder/CompBldrAnonBlkDef.cs b/MgdDbgLibrary/CompBuilder/CompBldrAnonBlkDef.cs new file mode 100644 index 0000000..aa40c62 --- /dev/null +++ b/MgdDbgLibrary/CompBuilder/CompBldrAnonBlkDef.cs @@ -0,0 +1,92 @@ +// +// (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.DatabaseServices; +using System.Diagnostics; + +namespace MgdDbg.CompBuilder +{ + /// + /// Derived component builder to direct the made entities into an + /// Anonymous block def. + /// + + public class CompBldrAnonBlkDef : CompBldr + { + public + CompBldrAnonBlkDef(Database db) + : base(db) + { + } + + /// + /// Make the new Anonymous block table record to add our entities to. + /// + + protected override void + SetCurrentBlkTblRec() + { + Debug.Assert(m_trans != null); + + // if we've already been started before, then we don't want to create another + // anonymous block, so just re-use the existing one. + if (m_blkDefId.IsNull) + { + m_blkRec = DefineNewAnonymousBlockRec(); + } + else + { + m_blkRec = (BlockTableRecord)m_trans.GetObject(m_blkDefId, OpenMode.ForWrite); + } + } + + /// + /// If they are calling Reset, we need to end this block and start another one + /// + public override void + Reset() + { + base.Reset(); + + m_blkDefId = ObjectId.Null; // will force new block def + } + + /// + /// Default properties for entities within a block def should be: + /// Layer = 0; + /// Color = ByBlock; + /// Linetype = ByBlock; + /// + /// This allows the entities nested in the block def to be controlled by + /// the properties of the individual BlockReference. + /// + /// The Entity to set the properties for + + public override void + SetToDefaultProps(Entity ent) + { + ent.LayerId = m_db.LayerZero; + ent.ColorIndex = 0; // ByBlock + ent.LinetypeId = m_db.ByBlockLinetype; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/CompBuilder/CompBldrCurSpace.cs b/MgdDbgLibrary/CompBuilder/CompBldrCurSpace.cs new file mode 100644 index 0000000..c0a7dd2 --- /dev/null +++ b/MgdDbgLibrary/CompBuilder/CompBldrCurSpace.cs @@ -0,0 +1,47 @@ +// +// (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.DatabaseServices; +using System.Diagnostics; + +namespace MgdDbg.CompBuilder +{ + /// + /// Derived component builder to direct the entities into the current + /// ModelSpace or PaperSpace block def. + /// + public class CompBldrCurSpace : CompBldr + { + public CompBldrCurSpace(Database db) + : base(db) + { + } + + protected override void + SetCurrentBlkTblRec() + { + Debug.Assert(m_trans != null); + + m_blkRec = (BlockTableRecord)m_trans.GetObject(m_db.CurrentSpaceId, OpenMode.ForWrite, false); + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/CompBuilder/CompBldrNamedBlkDef.cs b/MgdDbgLibrary/CompBuilder/CompBldrNamedBlkDef.cs new file mode 100644 index 0000000..1a6252d --- /dev/null +++ b/MgdDbgLibrary/CompBuilder/CompBldrNamedBlkDef.cs @@ -0,0 +1,95 @@ +// +// (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.DatabaseServices; +using System.Diagnostics; + +namespace MgdDbg.CompBuilder +{ + /// + /// Derived component builder to direct the made entities into a + /// Named block def. + /// + + public class CompBldrNamedBlkDef : CompBldr + { + protected string m_blkName; + + public + CompBldrNamedBlkDef(Database db, string blkName) + : base(db) + { + m_blkName = blkName; + } + + /// + /// Make the new Anonymous block table record to add our entities to. + /// + + protected override void + SetCurrentBlkTblRec() + { + Debug.Assert(m_trans != null); + + // if we've already been started before, then we don't want to create another + // anonymous block, so just re-use the existing one. + if (m_blkDefId.IsNull) + { + m_blkRec = DefineNewBlockRec(m_blkName); + } + else + { + m_blkRec = (BlockTableRecord)m_trans.GetObject(m_blkDefId, OpenMode.ForWrite); + } + } + + /// + /// If they are calling Reset, we need to end this block and start another one + /// + public override void + Reset() + { + base.Reset(); + + m_blkDefId = ObjectId.Null; // will force new block def + } + + /// + /// Default properties for entities within a block def should be: + /// Layer = 0; + /// Color = ByBlock; + /// Linetype = ByBlock; + /// + /// This allows the entities nested in the block def to be controlled by + /// the properties of the individual BlockReference. + /// + /// The Entity to set the properties for + + public override void + SetToDefaultProps(Entity ent) + { + ent.LayerId = m_db.LayerZero; + ent.ColorIndex = 0; // ByBlock + ent.LinetypeId = m_db.ByBlockLinetype; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/CompBuilder/TransactionHelper.cs b/MgdDbgLibrary/CompBuilder/TransactionHelper.cs new file mode 100644 index 0000000..fd4f6a5 --- /dev/null +++ b/MgdDbgLibrary/CompBuilder/TransactionHelper.cs @@ -0,0 +1,309 @@ +// +// (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.DatabaseServices; +using System; +using System.Diagnostics; + +namespace MgdDbg.CompBuilder +{ + /// + /// With the removal of ObjectId.Open/Close, it means that you need to + /// have a Transaction active to do just about anything. This is the + /// base class for a number of Helper objects that help manage a Transaction + /// and a set of operations around them. For instance, when creating a + /// BlockTableRecord, its nice to have someone manage the containing block, + /// Xforms to the WCS, etc. + /// + + public class TransactionHelper : IDisposable + { + // member variables + protected Database m_db = null; + + protected Transaction m_trans = null; + + public + TransactionHelper() + { + m_db = Utils.Db.GetCurDwg(); + } + + public + TransactionHelper(Database db) + { + Debug.Assert(db != null); + + m_db = db; + } + + ~TransactionHelper() + { + Dispose(false); + } + + public void + Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void + Dispose(bool disposing) + { + if (disposing) + { + if (m_trans != null) + { + m_trans.Dispose(); + } + } + } + + public virtual void + Start() + { + Debug.Assert(m_trans == null); + + m_trans = m_db.TransactionManager.StartTransaction(); + } + + public virtual void + Commit() + { + Debug.Assert(m_trans != null); + + m_trans.Commit(); + m_trans = null; + } + + public virtual void + Abort() + { + Debug.Assert(m_trans != null); + + m_trans.Abort(); + m_trans = null; + } + + /// + /// return the underlying Transaction + /// + + public Autodesk.AutoCAD.DatabaseServices.Transaction + Transaction + { + get { return m_trans; } + } + + /// + /// return the Database that this TransactionHelper goes with + /// + + public Autodesk.AutoCAD.DatabaseServices.Database + Database + { + get { return m_db; } + } + + /// + /// See if a SymbolTableRecord of the given name already exists + /// + /// Type of the SymbolTableRecord (e.g., LayerTableRecord) + /// Name of the symbol + /// True if the symbol already exists, False if it doesn't + + public bool + SymbolTableRecExists(System.Type classType, string name) + { + ObjectId tblId = Utils.SymTbl.GetSymbolTableId(classType, m_db); + + SymbolTable tbl = (SymbolTable)m_trans.GetObject(tblId, OpenMode.ForRead); + return tbl.Has(name); + } + + /// + /// Add a new SymbolTableRecord to the database (and the current transaction) + /// + /// A newly allocated SymbolTableRecord which hasn't yet been added to the database + + public virtual void + AddNewSymbolRec(SymbolTableRecord newRec) + { + Debug.Assert(m_trans != null); + + ObjectId tblId = Utils.SymTbl.GetSymbolTableId(newRec.GetType(), m_db); + + SymbolTable tbl = (SymbolTable)m_trans.GetObject(tblId, OpenMode.ForWrite); + Debug.Assert(tbl.Has(newRec.Name) == false); + + tbl.Add(newRec); + m_trans.AddNewlyCreatedDBObject(newRec, true); + } + + /// + /// Define a new named block and add it to the BlockTable. If the block + /// definition already exists, its contents will be emptied out so that + /// the block can be re-defined. + /// + /// Name of the BlockDef + /// New or existing BlockTableRecord + /// Specific database we are using + + public BlockTableRecord + DefineNewBlockRec(string blkName) + { + Debug.Assert(m_trans != null); + + BlockTableRecord blkRec = null; + + BlockTable tbl = (BlockTable)m_trans.GetObject(m_db.BlockTableId, OpenMode.ForWrite); + // if it already exists, we are re-defining it and we need to + // erase all the existing entities + if (tbl.Has(blkName)) + { + blkRec = (BlockTableRecord)m_trans.GetObject(tbl[blkName], OpenMode.ForWrite); + + // erase all + DBObject tmpObj = null; + foreach (ObjectId objId in blkRec) + { + tmpObj = m_trans.GetObject(objId, OpenMode.ForWrite); + if (tmpObj != null) + { + tmpObj.Erase(true); + } + } + } + else + { + blkRec = new BlockTableRecord(); + blkRec.Name = blkName; + + tbl.Add(blkRec); + m_trans.AddNewlyCreatedDBObject(blkRec, true); + } + + return blkRec; + } + + /// + /// Define a new Anonymous block and add it to the BlockTable + /// + /// + /// an open BlockTableRecord, ready to add Entities to + + public BlockTableRecord + DefineNewAnonymousBlockRec() + { + Debug.Assert(m_trans != null); + + BlockTableRecord blkRec = null; + + BlockTable tbl = (BlockTable)m_trans.GetObject(m_db.BlockTableId, OpenMode.ForWrite); + blkRec = new BlockTableRecord(); + blkRec.Name = "*U"; + + tbl.Add(blkRec); + m_trans.AddNewlyCreatedDBObject(blkRec, true); + + return blkRec; + } + + /// + /// Given the ObjectId of a SymbolTableRecord, get its name + /// + /// ObjectId of the SymbolTableRecord + /// name of the SymbolTableRecord + + public string + SymbolIdToName(ObjectId symId) + { + Debug.Assert(m_trans != null); + + string str = null; + + DBObject tmpObj = m_trans.GetObject(symId, OpenMode.ForRead); + SymbolTableRecord rec = tmpObj as SymbolTableRecord; + if (rec != null) + str = rec.Name; + + return str; + } + + public bool + IsOnLockedLayer(Entity ent, bool printMsg) + { + Debug.Assert(m_trans != null); + + LayerTableRecord layer = (LayerTableRecord)m_trans.GetObject(ent.LayerId, OpenMode.ForRead); + + if (printMsg && layer.IsLocked) + { + Utils.AcadUi.PrintToCmdLine("\nSelected entity is on a locked layer."); + } + + return layer.IsLocked; + } + + public ObjectIdCollection + CollectBlockIds(bool excludeMsPs, bool excludeXref, bool excludeXrefDep, bool excludeAnonymous) + { + Debug.Assert(m_trans != null); + + BlockTable blkTbl = (BlockTable)m_trans.GetObject(m_db.BlockTableId, OpenMode.ForRead); + + // iterate over each BlockTableRecord in the BlockTable + ObjectIdCollection blkRecIds = new ObjectIdCollection(); + foreach (ObjectId tblRecId in blkTbl) + { + BlockTableRecord blkRec = (BlockTableRecord)m_trans.GetObject(tblRecId, OpenMode.ForRead); + + if (excludeMsPs && blkRec.IsLayout) + { + ; // do nothing + } + else if ((excludeXrefDep) && blkRec.IsDependent) + { + ; // do nothing + } + else if ((excludeXref) && + ((blkRec.IsFromExternalReference) || + (blkRec.IsFromOverlayReference))) + { + ; // do nothing + } + else if (excludeAnonymous && blkRec.IsAnonymous) + { + ; // do nothing + } + else + { + blkRecIds.Add(tblRecId); + } + } + + return blkRecIds; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Documentation/MgdDbg.doc b/MgdDbgLibrary/Documentation/MgdDbg.doc new file mode 100644 index 0000000..a0a86e5 Binary files /dev/null and b/MgdDbgLibrary/Documentation/MgdDbg.doc differ diff --git a/MgdDbgLibrary/DwgStats/BlockCount.cs b/MgdDbgLibrary/DwgStats/BlockCount.cs new file mode 100644 index 0000000..63abfaa --- /dev/null +++ b/MgdDbgLibrary/DwgStats/BlockCount.cs @@ -0,0 +1,67 @@ +// +// (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.DatabaseServices; +using System.Collections; + +namespace MgdDbg.DwgStats +{ + /// + /// Summary description for BlockCount. + /// + public class BlockCount + { + // data members + public string m_blockName; + + public ObjectId m_blockDefId; + public ArrayList m_objCounts = new ArrayList(); + + public + BlockCount() + { + } + + public ObjCount + GetCount(string className, string displayName, bool addIfNotThere) + { + foreach (ObjCount tmpNode in m_objCounts) + { + if (tmpNode.m_className == className) + return tmpNode; + } + + if (addIfNotThere) + { + ObjCount tmpNode = new ObjCount(); + tmpNode.m_className = className; + tmpNode.m_displayName = displayName; + + m_objCounts.Add(tmpNode); + + return tmpNode; + } + + return null; // didn't find it + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/DwgStats/ObjCount.cs b/MgdDbgLibrary/DwgStats/ObjCount.cs new file mode 100644 index 0000000..82c9776 --- /dev/null +++ b/MgdDbgLibrary/DwgStats/ObjCount.cs @@ -0,0 +1,42 @@ +// +// (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. +// + +namespace MgdDbg.DwgStats +{ + /// + /// Summary description for ObjCount. + /// + public class ObjCount + { + // data members + public string m_className; // have to use class names to account for proxies + + public string m_displayName; + public long m_count; + + public + ObjCount() + { + m_count = 0L; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/DwgStats/Report.cs b/MgdDbgLibrary/DwgStats/Report.cs new file mode 100644 index 0000000..edb528e --- /dev/null +++ b/MgdDbgLibrary/DwgStats/Report.cs @@ -0,0 +1,571 @@ +// +// (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.DatabaseServices; +using MgdDbg.CompBuilder; +using System.Collections; +using System.Diagnostics; +using System.Xml; + +namespace MgdDbg.DwgStats +{ + /// + /// Summary description for Report. + /// + public class Report + { + // data members + private ArrayList m_entities = new ArrayList(); + + private ArrayList m_objects = new ArrayList(); + private Database m_db = null; + private TransactionHelper m_trHlp = null; + private ObjectIdCollection m_extDictIds = new ObjectIdCollection(); + + public + Report() + { + } + + /// + /// Return the Count object for this block (or make a new one if + /// we haven't already seen it). + /// + /// The BlockTableRecord we are looking for + /// Add a new one if not there? + /// The count object for this BlockTableRecord + + private BlockCount + GetEntityNode(ObjectId blkRecId, bool addIfNotThere) + { + foreach (BlockCount tmpNode in m_entities) + { + if (tmpNode.m_blockDefId == blkRecId) + return tmpNode; + } + + if (addIfNotThere) + { + BlockCount tmpNode = new BlockCount(); + tmpNode.m_blockDefId = blkRecId; + tmpNode.m_blockName = m_trHlp.SymbolIdToName(blkRecId); + m_entities.Add(tmpNode); + + return tmpNode; + } + + return null; // didn't find it + } + + /// + /// Return the Count object for this class of object (or make a new one if + /// we haven't already seen it). + /// + /// Name of the class we're looking for + /// Add a new one if not there? + /// The count object for this class + + private SymbolCount + GetObjectNode(string className, string displayName, bool addIfNotThere) + { + foreach (SymbolCount tmpNode in m_objects) + { + if (tmpNode.m_className == className) + return tmpNode; + } + + if (addIfNotThere) + { + SymbolCount tmpNode = new SymbolCount(); + tmpNode.m_className = className; + tmpNode.m_displayName = displayName; + m_objects.Add(tmpNode); + + return tmpNode; + } + + return null; // didn't find it + } + + /// + /// Given an object, get its class name, even if it is currently + /// a proxy. + /// + /// The object in question + /// The name of the class that this object is an instance of + private string + GetObjClassName(DBObject obj) + { + // if this is a proxy we can't use the proxy class + // name because we would get duplicates on the list + // for each object. + if (obj.IsAProxy) + { + ProxyObject proxyObj = obj as ProxyObject; + if (proxyObj != null) + return proxyObj.OriginalClassName; + else + { + ProxyEntity proxyEnt = obj as ProxyEntity; + if (proxyEnt != null) + return proxyEnt.OriginalClassName; + else + { + Debug.Assert(false); + return obj.GetRXClass().Name; + } + } + } + else + return obj.GetRXClass().Name; + } + + /// + /// Walk through all the blocks in the drawing and process all the entities + /// + + private void + ProcessEntities() + { + // get all blocks that aren't from Xrefs + ObjectIdCollection blkRecIds = m_trHlp.CollectBlockIds(false, false, false, true); + + DwgStats.BlockCount tmpBlkCount = null; + DwgStats.ObjCount tmpObjCount = null; + + // walk through all the block defs and count entities within them + foreach (ObjectId blkRecId in blkRecIds) + { + tmpBlkCount = GetEntityNode(blkRecId, true); + if (tmpBlkCount != null) + { + BlockTableRecord blkRec = (BlockTableRecord)m_trHlp.Transaction.GetObject(blkRecId, OpenMode.ForRead); + foreach (ObjectId tmpEntId in blkRec) + { + Entity ent = (Entity)m_trHlp.Transaction.GetObject(tmpEntId, OpenMode.ForRead); + tmpObjCount = tmpBlkCount.GetCount(GetObjClassName(ent), ent.GetType().Name, true); + + // if it has an extension dictionary, record its id so we can process it later + ObjectId extDictId = ent.ExtensionDictionary; + if ((extDictId.IsNull == false) && (extDictId.IsErased == false)) + m_extDictIds.Add(extDictId); + + if (tmpObjCount != null) + tmpObjCount.m_count++; + } + } + } + } + + /// + /// Walk through all the Dictionaries and process them + /// + + private void + ProcessObjects() + { + ObjectIdCollection objIds = new ObjectIdCollection(); + ArrayList names = new ArrayList(); + + // get all the symbol table objects + GetSymbolTableEntries(m_db.BlockTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.DimStyleTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.LayerTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.LinetypeTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.RegAppTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.TextStyleTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.ViewTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.ViewportTableId, ref objIds, ref names); + GetSymbolTableEntries(m_db.UcsTableId, ref objIds, ref names); + + // get all the NamedObjectDictionary objects + GetRecursiveDictionaryEntries(m_db.NamedObjectsDictionaryId, ref objIds, ref names); + + // get all the Extension dictionary objects + foreach (ObjectId extDictId in m_extDictIds) + GetRecursiveDictionaryEntries(extDictId, ref objIds, ref names); + + int len = objIds.Count; + + // get reference count to these objects + int[] countArray = new int[len]; + for (int i = 0; i < len; i++) + countArray[i] = 0; // init count values; + + m_db.CountHardReferences(objIds, countArray); + + SymbolCount tmpCount = null; + for (int i = 0; i < len; i++) + { + DBObject tmpObj = m_trHlp.Transaction.GetObject(objIds[i], OpenMode.ForRead); + tmpCount = GetObjectNode(GetObjClassName(tmpObj), tmpObj.GetType().Name, true); + if (tmpCount != null) + { + tmpCount.m_count++; + tmpCount.m_symbolNames.Add(names[i]); + tmpCount.m_references.Add(countArray[i]); + } + } + } + + /// + /// Get all the entries in a given SymbolTable + /// + /// The ObjectId of the SymbolTable + /// The ObjectIds of all the entries + /// The names of all the entries + + private void + GetSymbolTableEntries(ObjectId tblId, ref ObjectIdCollection objIds, ref ArrayList names) + { + DBObject tmpObj = m_trHlp.Transaction.GetObject(tblId, OpenMode.ForRead); + SymbolTable tbl = tmpObj as SymbolTable; + if (tbl != null) + { + // iterate over each TblRec in the SymbolTable + foreach (ObjectId tblRecId in tbl) + { + names.Add(m_trHlp.SymbolIdToName(tblRecId)); + objIds.Add(tblRecId); + } + } + } + + /// + /// Recursively walk through all Dictionaries under the one passed in + /// + /// + /// + /// + /// + + private void + GetRecursiveDictionaryEntries(ObjectId dictId, ref ObjectIdCollection objIds, ref ArrayList names) + { + // NOTE: when recursively processing items in a dictionary + // we may encounter things that are not derived from DBDictionary. + // In that case, the cast to type DBDictionary will fail and + // we'll just return without adding any nested items. + DBObject tmpObj = m_trHlp.Transaction.GetObject(dictId, OpenMode.ForRead); + DBDictionary dbDict = tmpObj as DBDictionary; + if (dbDict != null) + { + foreach (DictionaryEntry curEntry in dbDict) + { + objIds.Add((ObjectId)curEntry.Value); + names.Add((string)curEntry.Key); + + // if this is a dictionary, it will recursively add + // all of its children to the tree + GetRecursiveDictionaryEntries((ObjectId)curEntry.Value, ref objIds, ref names); + } + } + } + + /// + /// Create the XML Report for this database + /// + /// + /// + + public void + XmlReport(string reportPath, Database db) + { + // make sure everything is cleaned out in case they run this twice + m_entities.Clear(); + m_objects.Clear(); + m_extDictIds.Clear(); + m_db = db; + + using (m_trHlp = new TransactionHelper(db)) + { + m_trHlp.Start(); + + ProcessEntities(); + ProcessObjects(); + + XmlTextWriter stream = new XmlTextWriter(reportPath, System.Text.Encoding.UTF8); + stream.Formatting = Formatting.Indented; + stream.IndentChar = '\t'; + stream.Indentation = 1; + + stream.WriteStartDocument(); + stream.WriteStartElement("Drawings"); + stream.WriteStartElement("Drawing"); + + stream.WriteAttributeString("path", db.Filename); + + stream.WriteStartElement("Entities"); + XmlReportRawEntityCount(stream); + XmlReportBlockDefs(stream); + stream.WriteEndElement(); // "Entities" + + stream.WriteStartElement("Symbols"); + XmlReportRawSymbolCount(stream); + XmlReportSymbolReferences(stream); + stream.WriteEndElement(); // "Symbols" + + stream.WriteEndElement(); // "Drawing" + stream.WriteEndElement(); // "Drawings" + stream.WriteEndDocument(); + + stream.Close(); + + m_trHlp.Commit(); + } + } + + /// + /// Create the XML report for a batch of drawings. + /// + /// The XML filename to use + /// Array of paths to drawing files + public void + XmlReport(string reportPath, string[] fnames) + { + XmlTextWriter stream = new XmlTextWriter(reportPath, System.Text.Encoding.UTF8); + stream.Formatting = Formatting.Indented; + stream.IndentChar = '\t'; + stream.Indentation = 1; + + stream.WriteStartDocument(); + stream.WriteStartElement("Drawings"); + + foreach (string dwgPath in fnames) + { + // make sure everything is cleaned out in case they run this twice + m_entities.Clear(); + m_objects.Clear(); + m_extDictIds.Clear(); + + Utils.AcadUi.PrintToCmdLine(string.Format("\nProcessing drawing file: {0} ...", dwgPath)); + using (m_db = new Database(false, true)) + { + m_db.ReadDwgFile(dwgPath, System.IO.FileShare.Read, true, null); + + using (m_trHlp = new TransactionHelper(m_db)) + { + m_trHlp.Start(); + + ProcessEntities(); + ProcessObjects(); + + stream.WriteStartElement("Drawing"); + + stream.WriteAttributeString("path", dwgPath); + + stream.WriteStartElement("Entities"); + XmlReportRawEntityCount(stream); + XmlReportBlockDefs(stream); + stream.WriteEndElement(); // "Entities" + + stream.WriteStartElement("Symbols"); + XmlReportRawSymbolCount(stream); + XmlReportSymbolReferences(stream); + stream.WriteEndElement(); // "Symbols" + + stream.WriteEndElement(); // "Drawing" + + m_trHlp.Commit(); + } + + m_db.Dispose(); + } + + m_db = null; + } + + stream.WriteEndElement(); // "Drawings" + stream.WriteEndDocument(); + stream.Close(); + } + + private void + XmlReportBlockDefs(XmlTextWriter stream) + { + DwgStats.BlockCount tmpBlockCount; + DwgStats.ObjCount tmpObjCount; + + stream.WriteStartElement("BlockDefs"); + + // walk through all the entries and file out the stats + int len = m_entities.Count; + for (int i = 0; i < len; i++) + { + tmpBlockCount = (DwgStats.BlockCount)m_entities[i]; + + int len2 = tmpBlockCount.m_objCounts.Count; + + // only output this if there are entities within the block + if (len2 > 0) + { + stream.WriteStartElement("BlockDef"); + stream.WriteAttributeString("name", tmpBlockCount.m_blockName); + + BlockTableRecord blkRec = (BlockTableRecord)m_trHlp.Transaction.GetObject(tmpBlockCount.m_blockDefId, OpenMode.ForRead); + stream.WriteAttributeString("isAnonymous", blkRec.IsAnonymous ? "1" : "0"); + stream.WriteAttributeString("isFromXref", (blkRec.IsFromExternalReference || blkRec.IsFromOverlayReference) ? "1" : "0"); + stream.WriteAttributeString("isLayout", blkRec.IsLayout ? "1" : "0"); + + for (int j = 0; j < len2; j++) + { + tmpObjCount = (DwgStats.ObjCount)tmpBlockCount.m_objCounts[j]; + + stream.WriteStartElement("ObjectType"); + stream.WriteAttributeString("class", tmpObjCount.m_className); + stream.WriteAttributeString("displayName", tmpObjCount.m_displayName); + stream.WriteAttributeString("count", tmpObjCount.m_count.ToString()); + stream.WriteEndElement(); + } + + stream.WriteEndElement(); + } + } + + stream.WriteEndElement(); + } + + private void + XmlReportRawEntityCount(XmlTextWriter stream) + { + BlockCount tmpBlockCount = null; + ObjCount tmpObjCount = null; + + stream.WriteStartElement("RawCount"); + + ArrayList classNames = new ArrayList(); + ArrayList displayNames = new ArrayList(); + ArrayList objCounts = new ArrayList(); ; + + // walk through all the entries and file out the stats + int len = m_entities.Count; + for (int i = 0; i < len; i++) + { + tmpBlockCount = (BlockCount)m_entities[i]; + + int len2 = tmpBlockCount.m_objCounts.Count; + for (int j = 0; j < len2; j++) + { + tmpObjCount = (ObjCount)tmpBlockCount.m_objCounts[j]; + + int index; + if (FindClassName(classNames, tmpObjCount.m_className, out index)) + { + objCounts[index] = ((long)objCounts[index]) + tmpObjCount.m_count; + } + else + { + classNames.Add(tmpObjCount.m_className); + displayNames.Add(tmpObjCount.m_displayName); + objCounts.Add(tmpObjCount.m_count); + } + } + } + + // now push out to XML + len = classNames.Count; + for (int i = 0; i < len; i++) + { + stream.WriteStartElement("ObjectType"); + stream.WriteAttributeString("class", (string)classNames[i]); + stream.WriteAttributeString("displayName", (string)displayNames[i]); + stream.WriteAttributeString("count", objCounts[i].ToString()); + stream.WriteEndElement(); + } + + stream.WriteEndElement(); + } + + private void + XmlReportRawSymbolCount(XmlTextWriter stream) + { + SymbolCount tmpObjCount; + + stream.WriteStartElement("RawCount"); + + // walk through all the entries and file out the stats + int len = m_objects.Count; + for (int i = 0; i < len; i++) + { + tmpObjCount = (SymbolCount)m_objects[i]; + + stream.WriteStartElement("ObjectType"); + stream.WriteAttributeString("class", tmpObjCount.m_className); + stream.WriteAttributeString("displayName", tmpObjCount.m_displayName); + stream.WriteAttributeString("count", tmpObjCount.m_count.ToString()); + stream.WriteEndElement(); + } + + stream.WriteEndElement(); + } + + private void + XmlReportSymbolReferences(XmlTextWriter stream) + { + SymbolCount tmpSymCount; + + stream.WriteStartElement("References"); + + // walk through all the entries and file out the stats + int len = m_objects.Count; + for (int i = 0; i < len; i++) + { + tmpSymCount = (SymbolCount)m_objects[i]; + + stream.WriteStartElement("ObjectType"); + stream.WriteAttributeString("class", tmpSymCount.m_className); + stream.WriteAttributeString("displayName", tmpSymCount.m_displayName); + stream.WriteAttributeString("count", tmpSymCount.m_count.ToString()); + + int len2 = tmpSymCount.m_symbolNames.Count; + for (int j = 0; j < len2; j++) + { + stream.WriteStartElement("Symbol"); + stream.WriteAttributeString("name", (string)tmpSymCount.m_symbolNames[j]); + stream.WriteAttributeString("references", tmpSymCount.m_references[j].ToString()); + stream.WriteEndElement(); + } + stream.WriteEndElement(); // "ObjectType" + } + + stream.WriteEndElement(); // "References" + } + + private bool + FindClassName(ArrayList strs, string matchStr, out int index) + { + index = 0; + int len = strs.Count; + + for (int i = 0; i < len; i++) + { + if (matchStr == (string)strs[i]) + { + index = i; + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/DwgStats/SymbolCount.cs b/MgdDbgLibrary/DwgStats/SymbolCount.cs new file mode 100644 index 0000000..36a3bc2 --- /dev/null +++ b/MgdDbgLibrary/DwgStats/SymbolCount.cs @@ -0,0 +1,42 @@ +// +// (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 System.Collections; + +namespace MgdDbg.DwgStats +{ + /// + /// Summary description for SymbolCount. + /// + public class SymbolCount : ObjCount + { + // data members + public ArrayList m_symbolNames = new ArrayList(); // individual names of the instances of this class + + public ArrayList m_references = new ArrayList(); // parallel array of reference counts + + public + SymbolCount() + { + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/LICENSE b/MgdDbgLibrary/LICENSE new file mode 100644 index 0000000..b233efa --- /dev/null +++ b/MgdDbgLibrary/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Autodesk Developer Network + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MgdDbgLibrary/MgdDbg.csproj b/MgdDbgLibrary/MgdDbg.csproj new file mode 100644 index 0000000..c759fd1 --- /dev/null +++ b/MgdDbgLibrary/MgdDbg.csproj @@ -0,0 +1,107 @@ + + + net48 + Local + latest + net48 + JScript + Grid + IE50 + false + false + false + Library + OnBuildSuccess + + + false + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + false + true + true + true + + + 285212672 + 4096 + AllRules.ruleset + false + false + full + + + true + full + + + + None + + + + + System + + + 3.5 + + + System.Data + + + System.Drawing + + + System.XML + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 2.0 %28x86%29 + true + + + False + .NET Framework 3.0 %28x86%29 + false + + + False + .NET Framework 3.5 + false + + + False + .NET Framework 3.5 SP1 + false + + + + + + + + + + \ No newline at end of file diff --git a/MgdDbgLibrary/MgdDbg.sln b/MgdDbgLibrary/MgdDbg.sln new file mode 100644 index 0000000..4489b31 --- /dev/null +++ b/MgdDbgLibrary/MgdDbg.sln @@ -0,0 +1,18 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MgdDbg", "MgdDbg.csproj", "{C9B52572-4947-4AD7-86CE-EFB7A036FA9F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9B52572-4947-4AD7-86CE-EFB7A036FA9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9B52572-4947-4AD7-86CE-EFB7A036FA9F}.Debug|Any CPU.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/MgdDbgLibrary/ObjTests/CategoryTests.cs b/MgdDbgLibrary/ObjTests/CategoryTests.cs new file mode 100644 index 0000000..2c9740f --- /dev/null +++ b/MgdDbgLibrary/ObjTests/CategoryTests.cs @@ -0,0 +1,311 @@ +// +// (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.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using MgdDbg.CompBuilder; +using MgdDbg.ObjTests.Forms; +using MgdDbg.ObjTests.TestFramework; +using System.Windows.Forms; +using AcadApp = Autodesk.AutoCAD.ApplicationServices; +using SelectionSet = MgdDbg.Prompts.SelectionSet; + +namespace MgdDbg.ObjTests +{ + /// + /// + /// + public class CategoryTests : MgdDbgTestFuncs + { + private Autodesk.AutoCAD.DatabaseServices.Database db = null; + + public + CategoryTests() + { + db = Utils.Db.GetCurDwg(); + + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Selection Set Options", + "Various combinations of getting selection sets", "Selection Set", + new MgdDbgTestFuncInfo.TestFunc(SelectionSet), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Select Red Circles Only", + "Use a filter to only allow selection of Red Circles", "Selection Set", + new MgdDbgTestFuncInfo.TestFunc(SelectRedCircles), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Select Circles or Arcs", + "Use a filter to only allow selection of Circles and Arcs", "Selection Set", + new MgdDbgTestFuncInfo.TestFunc(SelectCirclesAndArcs), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Diff Entities", + "Diff between two entities", "Reflection", + new MgdDbgTestFuncInfo.TestFunc(EntityDiff), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Diff Objects", + "Diff between two objects", "Reflection", + new MgdDbgTestFuncInfo.TestFunc(ObjectDiff), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Snoop XML Dom Document", + "Exercise XML Dom API", "Import/Export", + new MgdDbgTestFuncInfo.TestFunc(SnoopXml), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Test Prompts", + "Exercise prompt classes", "Prompts", + new MgdDbgTestFuncInfo.TestFunc(TestPrompts), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Drawing Stats", + "Export database stats to XML file", "Import/Export", + new MgdDbgTestFuncInfo.TestFunc(DwgStats), MgdDbgTestFuncInfo.TestType.Other)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Drawing Stats Batch", + "Export batch stats to XML file", "Import/Export", + new MgdDbgTestFuncInfo.TestFunc(DwgStatsBatch), MgdDbgTestFuncInfo.TestType.Other)); + } + + #region Tests + + /// + /// A test for every basic combination of SelectionSet options + /// + + public void + SelectionSet() + { + SelectionSet dbox = new SelectionSet(); + AcadApp.Application.ShowModalDialog(dbox); + } + + /// + /// Simple test to show how to do a filtered selection + /// + + public void + SelectRedCircles() + { + TypedValue[] filterPairs = { + new TypedValue((int)DxfCode.Start, "CIRCLE"), + new TypedValue((int)DxfCode.Color, 1), + }; + + SelectionFilter filter = new SelectionFilter(filterPairs); + + Editor editor = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptSelectionOptions selOpts = new PromptSelectionOptions(); + selOpts.MessageForAdding = "Select red circles"; + + PromptSelectionResult prRes = editor.GetSelection(filter); + ShowPromptResult("Select Red Circles", prRes); + } + + /// + /// Simple test to show how to do a filtered selection with a boolean operator + /// + + public void + SelectCirclesAndArcs() + { + TypedValue[] filterPairs = { + new TypedValue((int)DxfCode.Operator, ""), + }; + + SelectionFilter filter = new SelectionFilter(filterPairs); + + Editor editor = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptSelectionOptions selOpts = new PromptSelectionOptions(); + selOpts.MessageForAdding = "Select circles and arcs"; + + PromptSelectionResult prRes = editor.GetSelection(filter); + ShowPromptResult("Select Circles and Arcs", prRes); + } + + /// + /// Display the result of the Selection Prompt to the user for inspection + /// + /// + /// + + private void + ShowPromptResult(string dboxTitle, PromptSelectionResult result) + { + if (result.Status == PromptStatus.OK) + { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(result.Value); + dbox.Text = dboxTitle; + AcadApp.Application.ShowModalDialog(dbox); + } + else + { + MessageBox.Show(string.Format("Prompt status: {0}", result.Status.ToString()), "PromptSelectionResult", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + /// + /// Compare two entities values using relection, and show the differences. + /// + + public void + EntityDiff() + { + Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptEntityResult res = ed.GetEntity("\nSelect first entity"); + if (res.Status != PromptStatus.OK) + return; + ObjectId objId1 = res.ObjectId; + + res = ed.GetEntity("\nSelect second entity"); + if (res.Status != PromptStatus.OK) + return; + ObjectId objId2 = res.ObjectId; + + using (TransactionHelper trHlp = new TransactionHelper()) + { + trHlp.Start(); + + EntityDiff dbox = new EntityDiff(objId1, objId2, trHlp); + dbox.Text = "Diff Objects"; + AcadApp.Application.ShowModalDialog(dbox); + + trHlp.Commit(); + } + } + + /// + /// Compare two object's values using relection, and show the differences. + /// + + public void + ObjectDiff() + { + using (TransactionHelper trHlpr = new TransactionHelper()) + { + trHlpr.Start(); + + ObjectDiff diff = new ObjectDiff(trHlpr); + AcadApp.Application.ShowModalDialog(diff); + + trHlpr.Commit(); + } + } + + /// + /// Allow the user to snoop through an XML file and test/learn all the various functions + /// available from the XML DOM. + /// + + public void + SnoopXml() + { + System.Windows.Forms.OpenFileDialog dbox = new System.Windows.Forms.OpenFileDialog(); + dbox.CheckFileExists = true; + dbox.AddExtension = true; + dbox.DefaultExt = "xml"; + dbox.Filter = "XML Files (*.xml)|*.xml"; + dbox.Multiselect = false; + dbox.Title = "Select an XML file"; + + if (dbox.ShowDialog() == DialogResult.OK) + { + try + { + System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); + xmlDoc.Load(dbox.FileName); + + Xml.Forms.Dom form = new Xml.Forms.Dom(xmlDoc); + AcadApp.Application.ShowModalDialog(form); + } + catch (System.Xml.XmlException e) + { + MessageBox.Show(e.Message, "XML Exception"); + } + } + } + + /// + /// Test/Demonstrate every option for Prompting + /// + + public void + TestPrompts() + { + Prompts.PromptTestForm form = new Prompts.PromptTestForm(); + + while (AcadApp.Application.ShowModalDialog(form) == DialogResult.OK) + { + form.RunPrompt(); + } + } + + /// + /// Publish out DWG stats to an XML file (number of blocks, how many times a layer is + /// referenced, etc.). The XML file can then be displayed as HTML Browser reports. + /// After producing the XML file, double-click on the file: ../MgdDbg/ReportBrowser/ObjCountReport.html + /// and then load the XML file. + /// + + public void + DwgStats() + { + // get output file to save XML report to + System.Windows.Forms.SaveFileDialog dbox = new System.Windows.Forms.SaveFileDialog(); + dbox.CreatePrompt = false; + dbox.OverwritePrompt = true; + dbox.AddExtension = true; + dbox.DefaultExt = "xml"; + dbox.Filter = "XML Files (*.xml)|*.xml"; + dbox.Title = "XML file to save report as"; + + if (dbox.ShowDialog() == DialogResult.OK) + { + DwgStats.Report statReport = new DwgStats.Report(); + statReport.XmlReport(dbox.FileName, Utils.Db.GetCurDwg()); + } + } + + /// + /// Same thing as above except you can batch process several files at once + /// + + public void + DwgStatsBatch() + { + // get multiple files to batch process + Autodesk.AutoCAD.Windows.OpenFileDialog dwgsForm = new Autodesk.AutoCAD.Windows.OpenFileDialog("Drawing Files To Process", + null, "dwg", "DwgStatsBatch", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple); + if (dwgsForm.ShowDialog() != DialogResult.OK) + return; + + // get output file to save XML report to + System.Windows.Forms.SaveFileDialog dbox = new System.Windows.Forms.SaveFileDialog(); + dbox.CreatePrompt = false; + dbox.OverwritePrompt = true; + dbox.AddExtension = true; + dbox.DefaultExt = "xml"; + dbox.Filter = "XML Files (*.xml)|*.xml"; + dbox.Title = "XML file to save report as"; + + if (dbox.ShowDialog() == DialogResult.OK) + { + DwgStats.Report statReport = new DwgStats.Report(); + statReport.XmlReport(dbox.FileName, dwgsForm.GetFilenames()); + } + } + + #endregion Tests + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/DbTests.cs b/MgdDbgLibrary/ObjTests/DbTests.cs new file mode 100644 index 0000000..a88411a --- /dev/null +++ b/MgdDbgLibrary/ObjTests/DbTests.cs @@ -0,0 +1,807 @@ +// +// (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.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using MgdDbg.CompBuilder; +using MgdDbg.ObjTests.Forms; +using MgdDbg.ObjTests.TestFramework; +using MgdDbg.Utils; +using System; +using System.Collections; +using System.Windows.Forms; +using AcadApp = Autodesk.AutoCAD.ApplicationServices; +using AcRx = Autodesk.AutoCAD.Runtime; + +namespace MgdDbg.ObjTests +{ + /// + /// Summary description for QueryDbTests. + /// + public class DbTests : MgdDbgTestFuncs + { + private Database m_db = null; + + public + DbTests() + { + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Xref graph (with ghosts)", "Display the graph of Xrefs for the current drawing", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(XrefGraphGhosts), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Xref graph (without ghosts)", "Display the graph of Xrefs for the current drawing", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(XrefGraphNoGhosts), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Count hard references", "See which objects have a hard reference to a selected object", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(CountHardReferences), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Attach xref", "Attaches an Xref file", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(AttachXref), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Overlay xref", "Overlays an Xref file", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(OverlayXref), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Detach xref", "Detaches an Xref file", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(DetachXref), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Deep clone", "Deep clones selected objects with Model Space as owner", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(DeepClone), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Insert (in block table)", "Creates a BlockTableRecord from external DWG's ModelSpace", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(InsertInBlockTable), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Insert (explode into model space)", "Inserts entities from ModelSpace of external DWG (INSERT*)", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(InsertInModelSpace), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Insert (copy block)", "Inserts contents of BlockTableRecord from one DWG to a new BlockTable Record in current DWG", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(InsertBlock), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Purge", "Queries if an object is purgable", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(Purge), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Wblock entire database", "Creates new db; clones in everything referenced from Model_Space", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(Wblock), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Wblock objects1", "Creates a new db; clones in a block or objects", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(WblockObjects1), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Wblock objects2", "Clones in objects to an existing db's Model Space", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(WblockObjects2), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Wblock clone objects", "Clones in objects from source to dest db", typeof(Database), new MgdDbgTestFuncInfo.TestFunc(WblockCloneObjects), MgdDbgTestFuncInfo.TestType.Create)); + } + + #region Tests + + public void + XrefGraphGhosts() + { + m_db = Utils.Db.GetCurDwg(); + + XrefGraph xrefGraph = m_db.GetHostDwgXrefGraph(true); + + Snoop.Forms.XrefGraph form = new Snoop.Forms.XrefGraph(xrefGraph); + form.ShowDialog(); + } + + public void + XrefGraphNoGhosts() + { + m_db = Utils.Db.GetCurDwg(); + + XrefGraph xrefGraph = m_db.GetHostDwgXrefGraph(false); + + Snoop.Forms.XrefGraph form = new Snoop.Forms.XrefGraph(xrefGraph); + form.ShowDialog(); + } + + public void + CountHardReferences() + { + Snoop.ObjIdSet objSet = Snoop.Utils.GetSnoopSet(); + if (objSet == null) + return; + + int[] countArray = new int[objSet.Set.Count]; + + if (countArray.Length > 0) + { + objSet.Db.CountHardReferences(objSet.Set, countArray); + } + + for (int i = 0; i < objSet.Set.Count; i++) + { + AcadUi.PrintToCmdLine(string.Format("\n{0,-30}: {1:d}", AcadUi.ObjToTypeAndHandleStr(objSet.Set[i]), countArray[i])); + } + } + + /// + /// Note that this is not the same as the Xref command + /// The Xref command does some further work to put a + /// block ref instance in the model space + /// + + public void + AttachXref() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + string fileName = Utils.Dialog.OpenFileDialog(".dwg", "Choose dwg to attach as Xref", "Dwg files (*.dwg)|*.dwg"); + if (fileName.Length == 0) + return; + string blockName = System.IO.Path.GetFileNameWithoutExtension(fileName); + if (blockName.Length == 0) + return; + if (blockName.ToLower() == System.IO.Path.GetFileNameWithoutExtension(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Name).ToLower()) + { + MessageBox.Show("External file name used could lead to a circular reference.", "MgdDbg", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + ObjectId objId = m_db.AttachXref(fileName, blockName); + + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + BlockTableRecord btr = (BlockTableRecord)trHlp.Transaction.GetObject(objId, OpenMode.ForRead); + Database xrefDb = btr.GetXrefDatabase(true); + + BlockTable blkTbl = (BlockTable)trHlp.Transaction.GetObject(m_db.BlockTableId, OpenMode.ForRead); + + ObjectIdCollection blkRecIds = new ObjectIdCollection(); + blkRecIds.Add(btr.ObjectId); + + foreach (ObjectId tblRecId in blkTbl) + { + BlockTableRecord blkRec = (BlockTableRecord)trHlp.Transaction.GetObject(tblRecId, OpenMode.ForRead); + if (blkRec.Database == xrefDb) + blkRecIds.Add(tblRecId); + } + + Snoop.Forms.DBObjects form = new Snoop.Forms.DBObjects(blkRecIds, trHlp); + form.Text = "Xref Block Table Records"; + form.ShowDialog(); + trHlp.Commit(); + } + } + + /// + /// Note that this is not the same as the Xref command + /// The Xref command does some further work to put a + /// block ref instance in the model space + /// + + public void + OverlayXref() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + string fileName = Utils.Dialog.OpenFileDialog(".dwg", "Choose dwg to overlay as Xref", "Dwg files (*.dwg)|*.dwg"); + if (fileName.Length == 0) + return; + + string blockName = System.IO.Path.GetFileNameWithoutExtension(fileName); + if (blockName.Length == 0) + return; + + ObjectId objId = m_db.OverlayXref(fileName, blockName); + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + ObjectIdCollection objIds = new ObjectIdCollection(); + objIds.Add(objId); + + Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(objIds, trHlp); + objs.Text = "Xrefd Block"; + objs.ShowDialog(); + + trHlp.Commit(); + } + } + + /// + /// + /// + public void + DetachXref() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + ObjectIdCollection selSet = null; + if (Utils.AcadUi.GetSelSetFromUser(out selSet) == false) + return; + + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + foreach (ObjectId bRefId in selSet) + { + BlockReference bRef = trHlp.Transaction.GetObject(bRefId, OpenMode.ForRead) as BlockReference; + if (bRef == null) + continue; + ObjectId xrefId = bRef.BlockTableRecord; + BlockTableRecord btr = trHlp.Transaction.GetObject(xrefId, OpenMode.ForRead) as BlockTableRecord; + if (btr.XrefStatus == XrefStatus.Resolved) + m_db.DetachXref(xrefId); + } + + trHlp.Commit(); + } + } + + /// + /// + /// + public void + DeepClone() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + ObjectIdCollection selSet = null; + if (Utils.AcadUi.GetSelSetFromUser(out selSet) == false) + return; + if (selSet.Count == 0) + return; + + ObjectId ownerId = new ObjectId(); + IdMapping idMap = new IdMapping(); + + /// check to make sure the objects all have same owner + /// if not set up as many objIdCollections + Hashtable ownerIdMap = new Hashtable(); + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + foreach (ObjectId tempId in selSet) + { + DBObject tempObj = trHlp.Transaction.GetObject(tempId, OpenMode.ForRead); + + if (ownerIdMap.ContainsKey(tempObj.OwnerId)) + { + ObjectIdCollection objIds = ownerIdMap[tempObj.OwnerId] as ObjectIdCollection; + objIds.Add(tempId); + } + else + { + /// if a new owner if found, stuff it in map + ObjectIdCollection objIds = new ObjectIdCollection(); + objIds.Add(tempId); + ownerIdMap.Add(tempObj.OwnerId, objIds); + } + } + /// make the model space the owner by default + BlockTable blkTbl = (BlockTable)trHlp.Transaction.GetObject(m_db.BlockTableId, OpenMode.ForRead); + ownerId = blkTbl["*MODEL_SPACE"]; + + trHlp.Commit(); + } + + ICollection keys = ownerIdMap.Keys; + int keyCount = ownerIdMap.Keys.Count; + int i = 0; + bool deferXlation = true; + + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + /// if objects to be cloned have different owners + /// DeepCloneObjects should be called with + /// deferXlation set to true for all except last time + foreach (object key in keys) + { + i++; + if (i == keyCount) + deferXlation = false; + ObjectIdCollection objectIds = ownerIdMap[key] as ObjectIdCollection; + m_db.DeepCloneObjects(objectIds, ownerId, idMap, deferXlation); + + Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(objectIds, trHlp); + objs.Text = "Deep cloned objects"; + objs.ShowDialog(); + } + trHlp.Commit(); + } + } + + /// + /// Select an external .dwg file. Then copy the contents of its MODEL_SPACE into a BlockTableRecord + /// in the current drawing. Equivalent to the INSERT command, but doesn't create the final BlockReference + /// + + public void + InsertInBlockTable() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + string dwgName = Utils.Dialog.OpenFileDialog(".dwg", "Choose dwg to insert from", "Dwg files (*.dwg)|*.dwg"); + if (dwgName.Length == 0) + return; + + try + { + Database extDb = new Database(false, true); + extDb.ReadDwgFile(dwgName, System.IO.FileShare.Read, true, null); + + ObjectId objId = m_db.Insert("MgdDbg_InsertedBlock", extDb, true); // TBD: should allow user to name the destination block + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + ObjectIdCollection objIds = new ObjectIdCollection(); + objIds.Add(objId); + + Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(objIds, trHlp); + objs.Text = "Inserted Block"; + objs.ShowDialog(); + + trHlp.Commit(); + } + } + catch (AcRx.Exception e) + { + AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString())); + } + } + + /// + /// Insert contents of external dwg's model space into our model space. + /// + + public void + InsertInModelSpace() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + string dwgName = Utils.Dialog.OpenFileDialog(".dwg", "Choose dwg to insert from", "Dwg files (*.dwg)|*.dwg"); + if (dwgName.Length == 0) + return; + + Database extDb = new Database(false, true); + extDb.ReadDwgFile(dwgName, System.IO.FileShare.Read, true, null); + + if (extDb == null) + return; + + try + { + m_db.Insert(Matrix3d.Identity, extDb, true); + } + catch (AcRx.Exception e) + { + AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString())); + } + } + + /// + /// Copy the contents of a selected block in external drawing and create/replace one + /// in the current drawing. + /// + + public void + InsertBlock() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + string dwgName = Utils.Dialog.OpenFileDialog(".dwg", "Choose dwg to insert from", "Dwg files (*.dwg)|*.dwg"); + if (dwgName.Length == 0) + return; + + Database extDb = new Database(false, true); + extDb.ReadDwgFile(dwgName, System.IO.FileShare.Read, true, null); + + if (extDb == null) + return; + + // TBD: should allow user to select source block and name the destination block + + ObjectId objId = m_db.Insert("*Model_Space", "MgdDbg_InsertedBlock2", extDb, true); + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + ObjectIdCollection objIds = new ObjectIdCollection(); + objIds.Add(objId); + + Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(objIds, trHlp); + objs.Text = "Inserted Block"; + objs.ShowDialog(); + + trHlp.Commit(); + } + } + + /// + /// Test the Purge function. Collect a set of selectable entities and non-graphic + /// Objects. Then call Purge and see which ones we are allowed to erase. + /// + + public void + Purge() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + Snoop.ObjIdSet objSet = Snoop.Utils.GetSnoopSet(); + if (objSet == null) + return; + + // set the purgeableIds to everything selected + ObjectIdCollection purgableIds = new ObjectIdCollection(); + foreach (ObjectId objId in objSet.Set) + purgableIds.Add(objId); + + ObjectIdCollection nonPurgableIds = new ObjectIdCollection(); + + try + { + m_db.Purge(purgableIds); + + // see which ones were non-purgeable by seeing which ones got taken out of the array + foreach (ObjectId objId in objSet.Set) + { + if (!purgableIds.Contains(objId)) + nonPurgableIds.Add(objId); + } + + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + if (purgableIds.Count == 0) + Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("No purgable objects"); + else + { + Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(purgableIds, trHlp); + objs.Text = "Purgable objects"; + objs.ShowDialog(); + } + + if (nonPurgableIds.Count == 0) + Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("No non-purgable objects"); + else + { + Snoop.Forms.DBObjects objs = new Snoop.Forms.DBObjects(nonPurgableIds, trHlp); + objs.Text = "Non-purgable objects"; + objs.ShowDialog(); + } + + trHlp.Commit(); + } + } + catch (AcRx.Exception e) + { + AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString())); + } + } + + /// + /// Wblock entire database + /// + + public void + Wblock() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + try + { + Database db = m_db.Wblock(); + using (TransactionHelper trHlp = new TransactionHelper(db)) + { + trHlp.Start(); + + Snoop.Forms.Database dbForm = new MgdDbg.Snoop.Forms.Database(db, trHlp); + dbForm.Text = "Destination Database (In memory only)"; + dbForm.ShowDialog(); + + trHlp.Commit(); + } + } + catch (AcRx.Exception e) + { + AcadUi.PrintToCmdLine(string.Format("\nERROR: {0}", ((AcRx.ErrorStatus)e.ErrorStatus).ToString())); + } + } + + /// + /// + /// + + public void + WblockObjects1() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + PromptKeywordOptions prOpts = new PromptKeywordOptions("\nWblock a block or objects"); + prOpts.Keywords.Add("Block", "Block", "Block", true, true); + prOpts.Keywords.Add("Objects", "Objects", "Objects", true, true); + + Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; + PromptResult prRes = ed.GetKeywords(prOpts); + if (prRes.Status != PromptStatus.OK) + return; + + Database db = null; + + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + ObjectIdCollection objIds; + if (!Utils.AcadUi.GetSelSetFromUser(out objIds)) + return; + + if (prRes.StringResult == "Block") + { + if (objIds.Count > 1) + { + ed.WriteMessage("\nSelect only one block"); + return; + } + DBObject obj = trHlp.Transaction.GetObject(objIds[0], OpenMode.ForRead); + BlockReference bRef = obj as BlockReference; + if (bRef != null) + { + db = m_db.Wblock(bRef.BlockTableRecord); + } + } + + if (prRes.StringResult == "Objects") + { + db = m_db.Wblock(objIds, new Point3d(0, 0, 0)); + } + + trHlp.Commit(); + } + + if (db == null) + return; + + using (TransactionHelper trHlp = new TransactionHelper(db)) + { + trHlp.Start(); + + Snoop.Forms.Database dbForm = new MgdDbg.Snoop.Forms.Database(db, trHlp); + dbForm.Text = "Destination Database (In memory only)"; + dbForm.ShowDialog(); + + trHlp.Commit(); + } + } + + /// + /// + /// + public void + WblockObjects2() + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + ObjectIdCollection objIds; + if (!Utils.AcadUi.GetSelSetFromUser(out objIds)) + return; + + String message = "\nDuplicate Record Cloning Options:"; + Array enums = Enum.GetValues(typeof(DuplicateRecordCloning)); + foreach (int option in enums) + { + message += string.Format("\n{0} = {1}", option, + Enum.GetName(typeof(DuplicateRecordCloning), option)); + } + + PromptIntegerOptions prOpts = new PromptIntegerOptions(message); + prOpts.LowerLimit = 0; + prOpts.UpperLimit = enums.Length; + + Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; + PromptIntegerResult prRes = ed.GetInteger(prOpts); + if (prRes.Status != PromptStatus.OK) + return; + + Database db = new Database(true, true); + + DuplicateRecordCloning drc = (DuplicateRecordCloning)prRes.Value; + if (drc == DuplicateRecordCloning.NotApplicable || + drc == DuplicateRecordCloning.RefMangleName) + { + ed.WriteMessage("Invalid Input"); + return; + } + + using (TransactionHelper trHlp = new TransactionHelper(m_db)) + { + trHlp.Start(); + + m_db.Wblock(db, objIds, new Point3d(0, 0, 0), drc); + + trHlp.Commit(); + } + + using (TransactionHelper trHlp = new TransactionHelper(db)) + { + trHlp.Start(); + + Snoop.Forms.Database dbForm = new MgdDbg.Snoop.Forms.Database(db, trHlp); + dbForm.Text = "Destination Database (In memory only)"; + dbForm.ShowDialog(); + + trHlp.Commit(); + } + } + + /// + /// + /// + public void + WblockCloneObjects() + { + try + { + m_db = Utils.Db.GetCurDwg(); + if (m_db == null) + return; + + using (TransactionHelper trHlpr = new TransactionHelper()) + { + trHlpr.Start(); + + /// get the object to clone + Objects objs = new Objects(trHlpr); + if (objs.ShowDialog() != DialogResult.OK) + { + trHlpr.Abort(); + return; + } + + DBObject objToClone = trHlpr.Transaction.GetObject(objs.ObjectId, OpenMode.ForRead); + + if (objToClone is DBDictionary) + throw new System.Exception("Please select a record in a dictionary"); + + AcadApp.Document activeDoc = AcadApp.Application.DocumentManager.MdiActiveDocument; + + /// get cloning options... + /// + + //String message = "\nDuplicate Record Cloning Options:"; + //Array enums = Enum.GetValues(typeof(DuplicateRecordCloning)); + //foreach (int option in enums) { + // message += string.Format("\n{0} = {1}", + // option, + // Enum.GetName(typeof(DuplicateRecordCloning), option)); + //} + + //PromptIntegerOptions prOpts = new PromptIntegerOptions(message); + //prOpts.LowerLimit = 0; + //prOpts.UpperLimit = enums.Length; + + //Editor ed = activeDoc.Editor; + //PromptIntegerResult prRes = ed.GetInteger(prOpts); + //if (prRes.Status != PromptStatus.OK) + // return; + + //DuplicateRecordCloning drc = (DuplicateRecordCloning)prRes.Value; + //if (drc == DuplicateRecordCloning.NotApplicable || + // drc == DuplicateRecordCloning.RefMangleName) { + // ed.WriteMessage("Invalid Input"); + // return; + //} + + /// .... or not + DuplicateRecordCloning drc = DuplicateRecordCloning.Ignore; + + if (objToClone.OwnerId == ObjectId.Null) /// object to clone is a root object, can't clone + return; + + /// get the destination db + Documents docs = new Documents(); + docs.Text = "Destination database"; + + if (docs.ShowDialog() != DialogResult.OK) + return; + + Database dbSrc = activeDoc.Database; + Database dbDest = docs.Document.Database; + + if (dbDest == dbSrc) + { + throw new System.Exception("Please pick a destination database other than the source"); + } + + /// find out parent dictionary + ObjectId owningDictId = objToClone.OwnerId; + DBDictionary owningDictSrc = trHlpr.Transaction.GetObject(owningDictId, OpenMode.ForRead) as DBDictionary; + + /// might be nested + Stack owningDictNames = new Stack(); + + while (owningDictSrc.OwnerId != ObjectId.Null) + { + owningDictSrc = trHlpr.Transaction.GetObject(owningDictSrc.OwnerId, OpenMode.ForRead) as DBDictionary; + String owningDictName = owningDictSrc.NameAt(owningDictId); + owningDictNames.Push(owningDictName); + + owningDictId = owningDictSrc.ObjectId; + } + + /// check if parent dictionary exists in dest. + DBDictionary owningDictDest = null; + + using (Transaction trDest = dbDest.TransactionManager.StartTransaction()) + { + AcadApp.Application.DocumentManager.GetDocument(dbDest).LockDocument(); + DBDictionary parentDictDest = trDest.GetObject(dbDest.NamedObjectsDictionaryId, OpenMode.ForRead) as DBDictionary; + + String owningDictName = owningDictNames.Peek().ToString(); + + if (parentDictDest.Contains(owningDictName)) + { + while (owningDictNames.Count != 0) + { + owningDictName = owningDictNames.Pop().ToString(); + owningDictDest = trDest.GetObject(parentDictDest.GetAt(owningDictName), OpenMode.ForRead) as DBDictionary; + parentDictDest = owningDictDest; + } + } + else + { + /// dest doesnt have same structure , create it + while (owningDictNames.Count != 0) + { + owningDictName = owningDictNames.Pop().ToString(); + parentDictDest.UpgradeOpen(); + owningDictDest = new DBDictionary(); + parentDictDest.SetAt(owningDictName, owningDictDest); + trDest.AddNewlyCreatedDBObject(owningDictDest, true); + parentDictDest = owningDictDest; + } + } + + trDest.Commit(); + } + + /// clone the objects over + ObjectIdCollection objIds = new ObjectIdCollection(); + objIds.Add(objToClone.ObjectId); + + IdMapping idMap = new IdMapping(); + idMap.DestinationDatabase = dbDest; + + m_db.WblockCloneObjects(objIds, owningDictDest.ObjectId, idMap, drc, false); + + trHlpr.Commit(); + } + } + catch (AcRx.Exception ex) + { + if (ex.ErrorStatus == AcRx.ErrorStatus.FileNotFound) + MessageBox.Show("No documents found in current session"); + else + MessageBox.Show(ex.Message); + } + catch (System.Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + #endregion Tests + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/Documents.Designer.cs b/MgdDbgLibrary/ObjTests/Forms/Documents.Designer.cs new file mode 100644 index 0000000..bb53959 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/Documents.Designer.cs @@ -0,0 +1,80 @@ +namespace MgdDbg.ObjTests.Forms +{ + partial class Documents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.m_cmbBox = new System.Windows.Forms.ComboBox(); + this.m_btnOk = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // m_cmbBox + // + this.m_cmbBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_cmbBox.FormattingEnabled = true; + this.m_cmbBox.Location = new System.Drawing.Point(12, 12); + this.m_cmbBox.Name = "m_cmbBox"; + this.m_cmbBox.Size = new System.Drawing.Size(157, 21); + this.m_cmbBox.TabIndex = 0; + this.m_cmbBox.SelectedIndexChanged += new System.EventHandler(this.m_cmbBox_SelectedIndexChanged); + // + // m_btnOk + // + this.m_btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.m_btnOk.Location = new System.Drawing.Point(50, 41); + this.m_btnOk.Name = "m_btnOk"; + this.m_btnOk.Size = new System.Drawing.Size(75, 23); + this.m_btnOk.TabIndex = 1; + this.m_btnOk.Text = "OK"; + this.m_btnOk.UseVisualStyleBackColor = true; + // + // Documents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(181, 76); + this.Controls.Add(this.m_btnOk); + this.Controls.Add(this.m_cmbBox); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Documents"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Documents in Session"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ComboBox m_cmbBox; + private System.Windows.Forms.Button m_btnOk; + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/Documents.cs b/MgdDbgLibrary/ObjTests/Forms/Documents.cs new file mode 100644 index 0000000..7bba2f9 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/Documents.cs @@ -0,0 +1,122 @@ +// (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.ApplicationServices; +using System; +using System.Collections; +using System.IO; +using System.Windows.Forms; +using AcRx = Autodesk.AutoCAD.Runtime; + +namespace MgdDbg.ObjTests.Forms +{ + /// + /// + /// + public partial class Documents : Form + { + private DocumentCollection m_docs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager; + private Document m_doc; + + /// + /// + /// + public Document + Document + { + get + { + return m_doc; + } + } + + /// + /// + /// + public Documents() + { + InitializeComponent(); + InitializeComboBox(); + } + + #region ComboBox Item + + /// + /// + /// + public class ComboBoxItem + { + private Document m_doc; + + public ComboBoxItem(Document doc) + { + m_doc = doc; + } + + public Document + Value + { + get + { + return m_doc; + } + } + + public override string ToString() + { + return Path.GetFileName(m_doc.Name); + } + } + + #endregion ComboBox Item + + /// + /// + /// + public void + InitializeComboBox() + { + IEnumerator iter = m_docs.GetEnumerator(); + + while (iter.MoveNext()) + { + Document doc = iter.Current as Document; + ComboBoxItem item = new ComboBoxItem(doc); + m_cmbBox.Items.Add(item); + } + + if (m_cmbBox.Items.Count == 0) + throw new AcRx.Exception(AcRx.ErrorStatus.FileNotFound); + m_cmbBox.SelectedIndex = 0; + } + + /// + /// + /// + /// + /// + private void m_cmbBox_SelectedIndexChanged(object sender, EventArgs e) + { + ComboBoxItem item = m_cmbBox.SelectedItem as ComboBoxItem; + m_doc = item.Value; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/Documents.resx b/MgdDbgLibrary/ObjTests/Forms/Documents.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/Documents.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/EntityDiff.cs b/MgdDbgLibrary/ObjTests/Forms/EntityDiff.cs new file mode 100644 index 0000000..1792f6a --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/EntityDiff.cs @@ -0,0 +1,346 @@ +// (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.DatabaseServices; +using MgdDbg.CompBuilder; +using MgdDbg.Utils; +using System; +using System.Collections; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; +using AcadApp = Autodesk.AutoCAD.ApplicationServices; + +using AcDb = Autodesk.AutoCAD.DatabaseServices; + +namespace MgdDbg.ObjTests.Forms +{ + /// + /// Summary description for ObjectCompare. + /// + public class EntityDiff : System.Windows.Forms.Form + { + // member vars + protected System.Windows.Forms.ListView m_lvData; + + protected System.Windows.Forms.Button m_bnOK; + protected System.Windows.Forms.ColumnHeader m_lvCol_label; + protected System.Windows.Forms.ColumnHeader m_lvCol_value1; + protected System.Windows.Forms.ColumnHeader m_lvCol_value2; + + private ObjectCompare m_compareObjs; + + /// + /// Required designer variable. + /// + protected System.ComponentModel.Container components = null; + + /// + /// + /// + /// + /// + /// + public + EntityDiff(AcDb.ObjectId objId1, AcDb.ObjectId objId2, TransactionHelper tr) + { + // Required for Windows Form Designer support + InitializeComponent(); + + Object obj1 = tr.Transaction.GetObject(objId1, OpenMode.ForRead); + Object obj2 = tr.Transaction.GetObject(objId2, OpenMode.ForRead); + + m_compareObjs = new ObjectCompare(obj1, obj2); + Initialise(); + } + + /// + /// + /// + /// + /// + public + EntityDiff(Object obj1, Object obj2) + { + // Required for Windows Form Designer support + InitializeComponent(); + + m_compareObjs = new ObjectCompare(obj1, obj2); + Initialise(); + } + + /// + /// Clean up any resources being used. + /// + protected override void + Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + protected void + InitializeComponent() + { + this.m_lvData = new System.Windows.Forms.ListView(); + this.m_lvCol_label = new System.Windows.Forms.ColumnHeader(); + this.m_lvCol_value1 = new System.Windows.Forms.ColumnHeader(); + this.m_lvCol_value2 = new System.Windows.Forms.ColumnHeader(); + this.m_bnOK = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // m_lvData + // + this.m_lvData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_lvData.AutoArrange = false; + this.m_lvData.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvCol_label, + this.m_lvCol_value1, + this.m_lvCol_value2}); + this.m_lvData.Cursor = System.Windows.Forms.Cursors.Default; + this.m_lvData.FullRowSelect = true; + this.m_lvData.GridLines = true; + this.m_lvData.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvData.HideSelection = false; + this.m_lvData.Location = new System.Drawing.Point(12, 16); + this.m_lvData.MultiSelect = false; + this.m_lvData.Name = "m_lvData"; + this.m_lvData.ShowItemToolTips = true; + this.m_lvData.Size = new System.Drawing.Size(553, 471); + this.m_lvData.TabIndex = 1; + this.m_lvData.UseCompatibleStateImageBehavior = false; + this.m_lvData.View = System.Windows.Forms.View.Details; + this.m_lvData.DoubleClick += new System.EventHandler(this.DataItemSelected); + this.m_lvData.Click += new System.EventHandler(this.DataItemSelected); + // + // m_lvCol_label + // + this.m_lvCol_label.Text = "Field"; + this.m_lvCol_label.Width = 150; + // + // m_lvCol_value1 + // + this.m_lvCol_value1.Text = "Value 1"; + this.m_lvCol_value1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.m_lvCol_value1.Width = 200; + // + // m_lvCol_value2 + // + this.m_lvCol_value2.Text = "Value 2"; + this.m_lvCol_value2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.m_lvCol_value2.Width = 200; + // + // m_bnOK + // + this.m_bnOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.m_bnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.m_bnOK.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_bnOK.Location = new System.Drawing.Point(247, 500); + this.m_bnOK.Name = "m_bnOK"; + this.m_bnOK.Size = new System.Drawing.Size(75, 23); + this.m_bnOK.TabIndex = 2; + this.m_bnOK.Text = "OK"; + // + // EntityDiff + // + this.AcceptButton = this.m_bnOK; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.CancelButton = this.m_bnOK; + this.ClientSize = new System.Drawing.Size(577, 535); + this.Controls.Add(this.m_bnOK); + this.Controls.Add(this.m_lvData); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(575, 225); + this.Name = "EntityDiff"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Diff Objects"; + this.ResumeLayout(false); + } + + #endregion Windows Form Designer generated code + + /// + /// Get the common hierarchy of the 2 objects + /// and then get the properties at each level + /// + private void + Initialise() + { + ArrayList hierarchy = m_compareObjs.CommonHierarchy; + + foreach (Object typeObj in hierarchy) + { + Type type = typeObj as Type; + Hashtable propsTable = m_compareObjs.GetPropsAtLevel(type); + /// display it + DisplayDiff(type.Name, propsTable); + } + } + + /// + /// Drill down + /// + /// + /// + protected void + DataItemSelected(object sender, System.EventArgs e) + { + Debug.Assert((m_lvData.SelectedItems.Count > 1) == false); + + if (m_lvData.SelectedItems.Count != 0) + { + ListViewItem item = m_lvData.SelectedItems[0]; + if (item.SubItems.Count != 3) + return; + + Object[] objs = new Object[2]; + objs[0] = item.SubItems[1].Tag; + objs[1] = item.SubItems[2].Tag; + if (objs[0] == null || objs[1] == null) + return; + + EntityDiff dbox = new EntityDiff(objs[0], objs[1]); + AcadApp.Application.ShowModalDialog(dbox); + } + } + + /// + /// Display the diff between the properties + /// of the two objects + /// + /// class separator string + /// + /// key --> property name + /// value --> an arraylist of 2 items, each item containing + /// the value of the current property for the respective object + /// + public void + DisplayDiff(string listViewItem, Hashtable propTable) + { + if (propTable == null) + return; + + m_lvData.BeginUpdate(); + + System.Drawing.Font boldFont = new System.Drawing.Font(m_lvData.Font, System.Drawing.FontStyle.Bold); + string text = string.Format("--- {0} ---", listViewItem); + ListViewItem lvItemSeparator = new ListViewItem(text); + /// show class separator + lvItemSeparator.BackColor = Color.LightBlue; + + m_lvData.Items.Add(lvItemSeparator); + + IDictionaryEnumerator iDictEnum = propTable.GetEnumerator(); + + while (iDictEnum.MoveNext()) + { + DictionaryEntry dictEntry = (DictionaryEntry)iDictEnum.Current; + string key = dictEntry.Key as string; + ArrayList arrList = dictEntry.Value as ArrayList; + object obj1 = arrList[0]; + object obj2 = arrList[1]; + + ListViewItem lvItem = new ListViewItem(key); + + ListViewItem.ListViewSubItem lvsItem1 = new ListViewItem.ListViewSubItem(); + lvsItem1.Text = obj1.ToString(); + + ListViewItem.ListViewSubItem lvsItem2 = new ListViewItem.ListViewSubItem(); + lvsItem2.Text = obj2.ToString(); + + lvItem.SubItems.Add(lvsItem1); + lvItem.SubItems.Add(lvsItem2); + + Type type = null; + if (obj1.GetType() == typeof(System.DBNull)) + { + type = obj2.GetType(); + } + else + type = obj1.GetType(); + + /// provide a drill down only on worthwhile data + if (IsDrillDown(type)) + { + lvsItem1.Tag = obj1; + lvsItem2.Tag = obj2; + + /// visual cue to drill down + lvItem.Font = boldFont; + } + + /// this may happen when there is a collection object comparison + if (obj1.GetType() != obj2.GetType()) + { + /// we know this is diff., so highlight it + lvItem.BackColor = Color.Red; + } + else + { + /// regular occurence of unequal objects + if (!obj1.Equals(obj2)) + { + /// we know this is diff., so highlight it + lvItem.BackColor = Color.Red; + } + } + + m_lvData.Items.Add(lvItem); + } + + m_lvData.EndUpdate(); + } + + /// + /// + /// + /// + /// + private Boolean + IsDrillDown(Type type) + { + if (type.IsPrimitive == false && + type.IsEnum == false && + type != typeof(String) && + type != typeof(DBNull)) + { + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/EntityDiff.resx b/MgdDbgLibrary/ObjTests/Forms/EntityDiff.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/EntityDiff.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.Designer.cs b/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.Designer.cs new file mode 100644 index 0000000..295ad9d --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.Designer.cs @@ -0,0 +1,280 @@ +namespace MgdDbg.ObjTests.Forms +{ + partial class ObjectDiff + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.components = new System.ComponentModel.Container(); + this.m_treeView = new System.Windows.Forms.TreeView(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addAsComparerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addAsCompareeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.m_gpBxDiff = new System.Windows.Forms.GroupBox(); + this.m_compareBx2 = new System.Windows.Forms.ListBox(); + this.m_labelVs = new System.Windows.Forms.Label(); + this.m_compareBx1 = new System.Windows.Forms.ListBox(); + this.m_btmCompare = new System.Windows.Forms.Button(); + this.m_listView = new System.Windows.Forms.ListView(); + this.m_lvCol_label = new System.Windows.Forms.ColumnHeader(); + this.m_lvCol_value1 = new System.Windows.Forms.ColumnHeader(); + this.m_lvCol_value2 = new System.Windows.Forms.ColumnHeader(); + this.m_btnEntChoose = new System.Windows.Forms.Button(); + this.m_labelObjs = new System.Windows.Forms.Label(); + this.m_gpBxSelect = new System.Windows.Forms.GroupBox(); + this.m_labelOr = new System.Windows.Forms.Label(); + this.contextMenuStrip1.SuspendLayout(); + this.m_gpBxDiff.SuspendLayout(); + this.m_gpBxSelect.SuspendLayout(); + this.SuspendLayout(); + // + // m_treeView + // + this.m_treeView.AllowDrop = true; + this.m_treeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.m_treeView.ContextMenuStrip = this.contextMenuStrip1; + this.m_treeView.Location = new System.Drawing.Point(41, 26); + this.m_treeView.Name = "m_treeView"; + this.m_treeView.Size = new System.Drawing.Size(275, 445); + this.m_treeView.TabIndex = 0; + this.m_treeView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.m_treeView_MouseClick); + this.m_treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.m_treeView_AfterSelect); + this.m_treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.m_treeView_ItemDrag); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addAsComparerToolStripMenuItem, + this.addAsCompareeToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(160, 48); + // + // addAsComparerToolStripMenuItem + // + this.addAsComparerToolStripMenuItem.Name = "addAsComparerToolStripMenuItem"; + this.addAsComparerToolStripMenuItem.Size = new System.Drawing.Size(159, 22); + this.addAsComparerToolStripMenuItem.Text = "Add as Comparer"; + this.addAsComparerToolStripMenuItem.Click += new System.EventHandler(this.addAsComparerToolStripMenuItem_Click); + // + // addAsCompareeToolStripMenuItem + // + this.addAsCompareeToolStripMenuItem.Name = "addAsCompareeToolStripMenuItem"; + this.addAsCompareeToolStripMenuItem.Size = new System.Drawing.Size(159, 22); + this.addAsCompareeToolStripMenuItem.Text = "Add as Comparee"; + this.addAsCompareeToolStripMenuItem.Click += new System.EventHandler(this.addAsCompareeToolStripMenuItem_Click); + // + // m_gpBxDiff + // + this.m_gpBxDiff.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.m_gpBxDiff.Controls.Add(this.m_compareBx2); + this.m_gpBxDiff.Controls.Add(this.m_labelVs); + this.m_gpBxDiff.Controls.Add(this.m_compareBx1); + this.m_gpBxDiff.Location = new System.Drawing.Point(12, 534); + this.m_gpBxDiff.Name = "m_gpBxDiff"; + this.m_gpBxDiff.Size = new System.Drawing.Size(338, 73); + this.m_gpBxDiff.TabIndex = 4; + this.m_gpBxDiff.TabStop = false; + this.m_gpBxDiff.Text = "Diff"; + // + // m_compareBx2 + // + this.m_compareBx2.AllowDrop = true; + this.m_compareBx2.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.m_compareBx2.FormattingEnabled = true; + this.m_compareBx2.ItemHeight = 12; + this.m_compareBx2.Location = new System.Drawing.Point(192, 15); + this.m_compareBx2.Name = "m_compareBx2"; + this.m_compareBx2.Size = new System.Drawing.Size(122, 52); + this.m_compareBx2.TabIndex = 9; + this.m_compareBx2.DragEnter += new System.Windows.Forms.DragEventHandler(this.m_compareBx2_DragEnter); + this.m_compareBx2.DragDrop += new System.Windows.Forms.DragEventHandler(this.m_compareBx2_DragDrop); + // + // m_labelVs + // + this.m_labelVs.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.m_labelVs.AutoSize = true; + this.m_labelVs.Location = new System.Drawing.Point(160, 42); + this.m_labelVs.Name = "m_labelVs"; + this.m_labelVs.Size = new System.Drawing.Size(22, 13); + this.m_labelVs.TabIndex = 5; + this.m_labelVs.Text = "Vs."; + // + // m_compareBx1 + // + this.m_compareBx1.AllowDrop = true; + this.m_compareBx1.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.m_compareBx1.FormattingEnabled = true; + this.m_compareBx1.ItemHeight = 12; + this.m_compareBx1.Location = new System.Drawing.Point(39, 15); + this.m_compareBx1.Name = "m_compareBx1"; + this.m_compareBx1.Size = new System.Drawing.Size(115, 52); + this.m_compareBx1.TabIndex = 8; + this.m_compareBx1.DragEnter += new System.Windows.Forms.DragEventHandler(this.m_compareBx1_DragEnter); + this.m_compareBx1.DragDrop += new System.Windows.Forms.DragEventHandler(this.m_compareBx1_DragDrop); + // + // m_btmCompare + // + this.m_btmCompare.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.m_btmCompare.Location = new System.Drawing.Point(668, 586); + this.m_btmCompare.Name = "m_btmCompare"; + this.m_btmCompare.Size = new System.Drawing.Size(75, 23); + this.m_btmCompare.TabIndex = 5; + this.m_btmCompare.Text = "Compare"; + this.m_btmCompare.UseVisualStyleBackColor = true; + this.m_btmCompare.Click += new System.EventHandler(this.m_btmCompare_Click); + // + // m_listView + // + this.m_listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_listView.AutoArrange = false; + this.m_listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvCol_label, + this.m_lvCol_value1, + this.m_lvCol_value2}); + this.m_listView.Cursor = System.Windows.Forms.Cursors.Default; + this.m_listView.FullRowSelect = true; + this.m_listView.GridLines = true; + this.m_listView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_listView.HideSelection = false; + this.m_listView.Location = new System.Drawing.Point(379, 12); + this.m_listView.MultiSelect = false; + this.m_listView.Name = "m_listView"; + this.m_listView.ShowItemToolTips = true; + this.m_listView.Size = new System.Drawing.Size(646, 568); + this.m_listView.TabIndex = 6; + this.m_listView.UseCompatibleStateImageBehavior = false; + this.m_listView.View = System.Windows.Forms.View.Details; + this.m_listView.Click += new System.EventHandler(this.DataItemSelected); + // + // m_lvCol_label + // + this.m_lvCol_label.Text = "Field"; + this.m_lvCol_label.Width = 148; + // + // m_lvCol_value1 + // + this.m_lvCol_value1.Text = "Value 1"; + this.m_lvCol_value1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.m_lvCol_value1.Width = 253; + // + // m_lvCol_value2 + // + this.m_lvCol_value2.Text = "Value 2"; + this.m_lvCol_value2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.m_lvCol_value2.Width = 273; + // + // m_btnEntChoose + // + this.m_btnEntChoose.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.m_btnEntChoose.Location = new System.Drawing.Point(63, 491); + this.m_btnEntChoose.Name = "m_btnEntChoose"; + this.m_btnEntChoose.Size = new System.Drawing.Size(229, 23); + this.m_btnEntChoose.TabIndex = 7; + this.m_btnEntChoose.Text = "Entities..."; + this.m_btnEntChoose.UseVisualStyleBackColor = true; + this.m_btnEntChoose.Click += new System.EventHandler(this.m_btnEntChoose_Click); + // + // m_labelObjs + // + this.m_labelObjs.AutoSize = true; + this.m_labelObjs.Location = new System.Drawing.Point(104, 10); + this.m_labelObjs.Name = "m_labelObjs"; + this.m_labelObjs.Size = new System.Drawing.Size(46, 13); + this.m_labelObjs.TabIndex = 8; + this.m_labelObjs.Text = "Objects:"; + // + // m_gpBxSelect + // + this.m_gpBxSelect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.m_gpBxSelect.Controls.Add(this.m_labelOr); + this.m_gpBxSelect.Controls.Add(this.m_treeView); + this.m_gpBxSelect.Controls.Add(this.m_btnEntChoose); + this.m_gpBxSelect.Controls.Add(this.m_labelObjs); + this.m_gpBxSelect.Location = new System.Drawing.Point(10, 3); + this.m_gpBxSelect.Name = "m_gpBxSelect"; + this.m_gpBxSelect.Size = new System.Drawing.Size(340, 525); + this.m_gpBxSelect.TabIndex = 10; + this.m_gpBxSelect.TabStop = false; + this.m_gpBxSelect.Text = "Select"; + // + // m_labelOr + // + this.m_labelOr.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.m_labelOr.AutoSize = true; + this.m_labelOr.Location = new System.Drawing.Point(162, 475); + this.m_labelOr.Name = "m_labelOr"; + this.m_labelOr.Size = new System.Drawing.Size(18, 13); + this.m_labelOr.TabIndex = 10; + this.m_labelOr.Text = "Or"; + // + // ObjectDiff + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1060, 619); + this.Controls.Add(this.m_gpBxSelect); + this.Controls.Add(this.m_listView); + this.Controls.Add(this.m_gpBxDiff); + this.Controls.Add(this.m_btmCompare); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(575, 225); + this.Name = "ObjectDiff"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ObjectDiff"; + this.contextMenuStrip1.ResumeLayout(false); + this.m_gpBxDiff.ResumeLayout(false); + this.m_gpBxDiff.PerformLayout(); + this.m_gpBxSelect.ResumeLayout(false); + this.m_gpBxSelect.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TreeView m_treeView; + private System.Windows.Forms.GroupBox m_gpBxDiff; + private System.Windows.Forms.Label m_labelVs; + private System.Windows.Forms.Button m_btmCompare; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem addAsComparerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addAsCompareeToolStripMenuItem; + protected System.Windows.Forms.ListView m_listView; + protected System.Windows.Forms.ColumnHeader m_lvCol_label; + protected System.Windows.Forms.ColumnHeader m_lvCol_value1; + protected System.Windows.Forms.ColumnHeader m_lvCol_value2; + private System.Windows.Forms.Button m_btnEntChoose; + private System.Windows.Forms.ListBox m_compareBx1; + private System.Windows.Forms.ListBox m_compareBx2; + private System.Windows.Forms.Label m_labelObjs; + private System.Windows.Forms.GroupBox m_gpBxSelect; + private System.Windows.Forms.Label m_labelOr; + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.cs b/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.cs new file mode 100644 index 0000000..b8aa963 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.cs @@ -0,0 +1,502 @@ +// (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.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using MgdDbg.CompBuilder; +using MgdDbg.Utils; +using System; +using System.Collections; +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; +using AcadApp = Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.ObjTests.Forms +{ + public partial class ObjectDiff : Form + { + private Database m_db = null; + private TransactionHelper m_trHlpr = null; + private Object m_tmpObj = null; + private Object m_obj1 = null; + private Object m_obj2 = null; + private ObjectCompare m_compareObjs; + + public ObjectDiff(TransactionHelper trHlpr) + { + InitializeComponent(); + + m_db = MgdDbg.Utils.Db.GetCurDwg(); + m_trHlpr = trHlpr; + + InitializeTreeView(); + } + + /// + /// Initialise tree with all symbol tables and NOD + /// + private void InitializeTreeView() + { + m_treeView.BeginUpdate(); + + AddSymbolTableToTree("Block Table", m_db.BlockTableId); + AddSymbolTableToTree("Dimension Style Table", m_db.DimStyleTableId); + AddSymbolTableToTree("Layer Table", m_db.LayerTableId); + AddSymbolTableToTree("Linetype Table", m_db.LinetypeTableId); + AddSymbolTableToTree("Reg App Table", m_db.RegAppTableId); + AddSymbolTableToTree("Text Style Table", m_db.TextStyleTableId); + AddSymbolTableToTree("View Table", m_db.ViewTableId); + AddSymbolTableToTree("Viewport Table", m_db.ViewportTableId); + AddSymbolTableToTree("UCS Table", m_db.UcsTableId); + + TreeNode rootNode = new TreeNode("Named Objects Dictionary"); + rootNode.Tag = m_db.NamedObjectsDictionaryId; + m_treeView.Nodes.Add(rootNode); + AddDictionaryToTree(m_db.NamedObjectsDictionaryId, rootNode, m_trHlpr.Transaction); + + m_treeView.Sorted = true; + + m_treeView.EndUpdate(); + } + + /// + /// Add a single Symbol Table to the tree and iterate over all its SymbolTableRecords, + /// adding each one of them as a sub-node + /// + /// Name of the table + /// ObjectId of the table + + private void + AddSymbolTableToTree(string tblName, ObjectId tblId) + { + DBObject tmpObj = m_trHlpr.Transaction.GetObject(tblId, OpenMode.ForRead); + SymbolTable tbl = tmpObj as SymbolTable; + if (tbl != null) + { + TreeNode mainTblNode = new TreeNode(tblName); + mainTblNode.Tag = tblId; + m_treeView.Nodes.Add(mainTblNode); + + // iterate over each TblRec in the SymbolTable + foreach (ObjectId tblRecId in tbl) + { + TreeNode recNode = new TreeNode(m_trHlpr.SymbolIdToName(tblRecId)); + recNode.Tag = tblRecId; + mainTblNode.Nodes.Add(recNode); + } + } + } + + private void + AddDictionaryToTree(ObjectId dictId, TreeNode parentNode, Transaction tr) + { + // NOTE: when recursively processing items in a dictionary + // we may encounter things that are not derived from DBDictionary. + // In that case, the cast to type DBDictionary will fail and + // we'll just return without adding any nested items. + DBObject tmpObj = tr.GetObject(dictId, OpenMode.ForRead); + DBDictionary dbDict = tmpObj as DBDictionary; + if (dbDict != null) + { + foreach (DictionaryEntry curEntry in dbDict) + { + TreeNode newNode = new TreeNode((string)curEntry.Key); + newNode.Tag = curEntry.Value; + parentNode.Nodes.Add(newNode); + + // if this is a dictionary, it will recursively add + // all of its children to the tree + AddDictionaryToTree((ObjectId)curEntry.Value, newNode, tr); + } + } + } + + /// + /// + /// + /// + /// + private void + m_treeView_AfterSelect(object sender, TreeViewEventArgs e) + { + if (e.Node.Tag != null) + { + m_tmpObj = m_trHlpr.Transaction.GetObject((ObjectId)e.Node.Tag, OpenMode.ForRead); + } + } + + /// + /// + /// + /// + /// + private void + addAsComparerToolStripMenuItem_Click(object sender, EventArgs e) + { + m_obj1 = m_tmpObj; + PopulateCompareBox(m_compareBx1, (ObjectId)m_treeView.SelectedNode.Tag, m_treeView.SelectedNode.Text); + } + + /// + /// + /// + /// + /// + private void + addAsCompareeToolStripMenuItem_Click(object sender, EventArgs e) + { + m_obj2 = m_tmpObj; + PopulateCompareBox(m_compareBx2, (ObjectId)m_treeView.SelectedNode.Tag, m_treeView.SelectedNode.Text); + } + + /// + /// + /// + /// + /// + private void + m_btmCompare_Click(object sender, EventArgs e) + { + if (m_obj1 == null || m_obj2 == null) + { + MessageBox.Show("Please choose two objects to compare"); + return; + } + Compare(); + } + + /// + /// + /// + private void + Compare() + { + m_compareObjs = new ObjectCompare(m_obj1, m_obj2); + PopulateListView(); + } + + /// + /// Get the common hierarchy of the 2 objects + /// and then get the properties at each level + /// + private void + PopulateListView() + { + m_listView.Items.Clear(); + + ArrayList hierarchy = m_compareObjs.CommonHierarchy; + + foreach (Object typeObj in hierarchy) + { + Type type = typeObj as Type; + Hashtable propsTable = m_compareObjs.GetPropsAtLevel(type); + /// display it + DisplayDiff(type.Name, propsTable); + } + } + + /// + /// Drill down + /// + /// + /// + protected void + DataItemSelected(object sender, System.EventArgs e) + { + Debug.Assert((m_listView.SelectedItems.Count > 1) == false); + + if (m_listView.SelectedItems.Count != 0) + { + ListViewItem item = m_listView.SelectedItems[0]; + if (item.SubItems.Count != 3) + return; + + Object[] objs = new Object[2]; + objs[0] = item.SubItems[1].Tag; + objs[1] = item.SubItems[2].Tag; + if (objs[0] == null || objs[1] == null) + return; + + EntityDiff dbox = new EntityDiff(objs[0], objs[1]); + AcadApp.Application.ShowModalDialog(dbox); + } + } + + /// + /// Display the diff between the properties + /// of the two objects + /// + /// class separator string + /// + /// key --> property name + /// value --> an arraylist of 2 items, each item containing + /// the value of the current property for the respective object + /// + public void + DisplayDiff(string listViewItem, Hashtable propTable) + { + if (propTable == null) + return; + + m_listView.BeginUpdate(); + + System.Drawing.Font boldFont = new System.Drawing.Font(m_listView.Font, System.Drawing.FontStyle.Bold); + string text = string.Format("--- {0} ---", listViewItem); + ListViewItem lvItemSeparator = new ListViewItem(text); + /// show class separator + lvItemSeparator.BackColor = Color.LightBlue; + + m_listView.Items.Add(lvItemSeparator); + + IDictionaryEnumerator iDictEnum = propTable.GetEnumerator(); + + while (iDictEnum.MoveNext()) + { + DictionaryEntry dictEntry = (DictionaryEntry)iDictEnum.Current; + string key = dictEntry.Key as string; + ArrayList arrList = dictEntry.Value as ArrayList; + object obj1 = arrList[0]; + object obj2 = arrList[1]; + + ListViewItem lvItem = new ListViewItem(key); + + ListViewItem.ListViewSubItem lvsItem1 = new ListViewItem.ListViewSubItem(); + lvsItem1.Text = obj1.ToString(); + + ListViewItem.ListViewSubItem lvsItem2 = new ListViewItem.ListViewSubItem(); + lvsItem2.Text = obj2.ToString(); + + lvItem.SubItems.Add(lvsItem1); + lvItem.SubItems.Add(lvsItem2); + + Type type = null; + if (obj1.GetType() == typeof(System.DBNull)) + { + type = obj2.GetType(); + } + else + type = obj1.GetType(); + + /// provide a drill down only on worthwhile data + if (IsDrillDown(type)) + { + lvsItem1.Tag = obj1; + lvsItem2.Tag = obj2; + + /// visual cue to drill down + lvItem.Font = boldFont; + } + + /// this may happen when there is a collection object comparison + if (obj1.GetType() != obj2.GetType()) + { + /// we know this is diff., so highlight it + lvItem.BackColor = Color.Red; + } + else + { + /// regular occurence of unequal objects + if (!obj1.Equals(obj2)) + { + /// we know this is diff., so highlight it + lvItem.BackColor = Color.Red; + } + } + + m_listView.Items.Add(lvItem); + } + + m_listView.EndUpdate(); + } + + /// + /// + /// + /// + /// + private Boolean + IsDrillDown(Type type) + { + if (type.IsPrimitive == false && + type.IsEnum == false && + type != typeof(String) && + type != typeof(DBNull)) + { + return true; + } + return false; + } + + /// + /// + /// + /// + /// + private void + m_btnEntChoose_Click(object sender, EventArgs e) + { + Editor ed = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; + + EditorUserInteraction userInteraction = ed.StartUserInteraction(this); + + try + { + PromptEntityResult res = ed.GetEntity("\nSelect first entity"); + if (res.Status != PromptStatus.OK) + return; + ObjectId objId1 = res.ObjectId; + + res = ed.GetEntity("\nSelect second entity"); + if (res.Status != PromptStatus.OK) + return; + ObjectId objId2 = res.ObjectId; + + m_obj1 = m_trHlpr.Transaction.GetObject(objId1, OpenMode.ForRead); + m_obj2 = m_trHlpr.Transaction.GetObject(objId2, OpenMode.ForRead); + + PopulateCompareBox(m_compareBx1, objId1, string.Empty); + PopulateCompareBox(m_compareBx2, objId2, string.Empty); + + Compare(); + } + /// dont leave editor paralysed if user cancels out + finally + { + userInteraction.End(); + } + } + + /// + /// + /// + /// + /// + private void + m_treeView_ItemDrag(object sender, ItemDragEventArgs e) + { + DoDragDrop(e.Item, DragDropEffects.Move); + } + + /// + /// + /// + /// + /// + private void + m_compareBx1_DragEnter(object sender, DragEventArgs e) + { + e.Effect = DragDropEffects.Move; + } + + /// + /// + /// + /// + /// + private void + m_compareBx1_DragDrop(object sender, DragEventArgs e) + { + TreeNode treeNode = e.Data.GetData(typeof(TreeNode)) as TreeNode; + if (treeNode != null) + { + m_obj1 = m_trHlpr.Transaction.GetObject((ObjectId)treeNode.Tag, OpenMode.ForRead); + PopulateCompareBox(m_compareBx1, (ObjectId)treeNode.Tag, treeNode.Text); + } + } + + /// + /// + /// + /// + /// + private void + m_compareBx2_DragEnter(object sender, DragEventArgs e) + { + e.Effect = DragDropEffects.Move; + } + + /// + /// + /// + /// + /// + private void + m_compareBx2_DragDrop(object sender, DragEventArgs e) + { + TreeNode treeNode = e.Data.GetData(typeof(TreeNode)) as TreeNode; + if (treeNode != null) + { + m_obj2 = m_trHlpr.Transaction.GetObject((ObjectId)treeNode.Tag, OpenMode.ForRead); + PopulateCompareBox(m_compareBx2, (ObjectId)treeNode.Tag, treeNode.Text); + } + } + + /// + /// + /// + /// + /// + private void + m_treeView_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + TreeNode treeNode = m_treeView.GetNodeAt(e.Location); + if (treeNode.Tag != null) + { + m_treeView.SelectedNode = treeNode; + } + } + } + + /// + /// + /// + /// + /// + /// + private void + PopulateCompareBox(object compareBox, ObjectId objId, string name) + { + DBObject tempObj = m_trHlpr.Transaction.GetObject(objId, OpenMode.ForRead); + + String type = String.Format("Type : {0}", tempObj.GetType().Name); + String id = String.Format("ObjectId : {0}", objId.ToString()); + + if (compareBox == m_compareBx1) + { + m_compareBx1.Items.Clear(); + m_compareBx1.Items.Add(name); + m_compareBx1.Items.Add(type); + m_compareBx1.Items.Add(id); + } + + if (compareBox == m_compareBx2) + { + m_compareBx2.Items.Clear(); + m_compareBx2.Items.Add(name); + m_compareBx2.Items.Add(type); + m_compareBx2.Items.Add(id); + } + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.resx b/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.resx new file mode 100644 index 0000000..6fab886 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/ObjectDiff.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/Objects.Designer.cs b/MgdDbgLibrary/ObjTests/Forms/Objects.Designer.cs new file mode 100644 index 0000000..1dcbaa7 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/Objects.Designer.cs @@ -0,0 +1,79 @@ +namespace MgdDbg.ObjTests.Forms +{ + partial class Objects + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.m_treeView = new System.Windows.Forms.TreeView(); + this.m_btnOk = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // m_treeView + // + this.m_treeView.AllowDrop = true; + this.m_treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_treeView.Location = new System.Drawing.Point(9, 12); + this.m_treeView.Name = "m_treeView"; + this.m_treeView.Size = new System.Drawing.Size(256, 323); + this.m_treeView.TabIndex = 1; + this.m_treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.m_treeView_AfterSelect); + // + // m_btnOk + // + this.m_btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.m_btnOk.Location = new System.Drawing.Point(101, 361); + this.m_btnOk.Name = "m_btnOk"; + this.m_btnOk.Size = new System.Drawing.Size(56, 23); + this.m_btnOk.TabIndex = 6; + this.m_btnOk.Text = "OK"; + this.m_btnOk.UseVisualStyleBackColor = true; + // + // Objects + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(273, 408); + this.Controls.Add(this.m_btnOk); + this.Controls.Add(this.m_treeView); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Objects"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Objects"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TreeView m_treeView; + private System.Windows.Forms.Button m_btnOk; + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/Objects.cs b/MgdDbgLibrary/ObjTests/Forms/Objects.cs new file mode 100644 index 0000000..b72b7a2 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/Objects.cs @@ -0,0 +1,162 @@ +// (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.DatabaseServices; +using MgdDbg.CompBuilder; +using System.Collections; +using System.Windows.Forms; + +namespace MgdDbg.ObjTests.Forms +{ + /// + /// + /// + public partial class Objects : Form + { + private Database m_db = null; + private TransactionHelper m_trHlpr = null; + private ObjectId m_objectId = ObjectId.Null; + + /// + /// + /// + public ObjectId + ObjectId + { + get + { + return m_objectId; + } + } + + /// + /// + /// + /// + public Objects(TransactionHelper trHlpr) + { + InitializeComponent(); + + m_db = MgdDbg.Utils.Db.GetCurDwg(); + m_trHlpr = trHlpr; + + InitializeTreeView(); + } + + /// + /// Initialise tree with all symbol tables and NOD + /// + private void InitializeTreeView() + { + m_treeView.BeginUpdate(); + + //AddSymbolTableToTree("Block Table", m_db.BlockTableId); + //AddSymbolTableToTree("Dimension Style Table", m_db.DimStyleTableId); + //AddSymbolTableToTree("Layer Table", m_db.LayerTableId); + //AddSymbolTableToTree("Linetype Table", m_db.LinetypeTableId); + //AddSymbolTableToTree("Reg App Table", m_db.RegAppTableId); + //AddSymbolTableToTree("Text Style Table", m_db.TextStyleTableId); + //AddSymbolTableToTree("View Table", m_db.ViewTableId); + //AddSymbolTableToTree("Viewport Table", m_db.ViewportTableId); + //AddSymbolTableToTree("UCS Table", m_db.UcsTableId); + + TreeNode rootNode = new TreeNode("Named Objects Dictionary"); + rootNode.Tag = m_db.NamedObjectsDictionaryId; + m_treeView.Nodes.Add(rootNode); + AddDictionaryToTree(m_db.NamedObjectsDictionaryId, rootNode, m_trHlpr.Transaction); + + m_treeView.Sorted = true; + + m_treeView.EndUpdate(); + } + + /// + /// Add a single Symbol Table to the tree and iterate over all its SymbolTableRecords, + /// adding each one of them as a sub-node + /// + /// Name of the table + /// ObjectId of the table + + private void + AddSymbolTableToTree(string tblName, ObjectId tblId) + { + DBObject tmpObj = m_trHlpr.Transaction.GetObject(tblId, OpenMode.ForRead); + SymbolTable tbl = tmpObj as SymbolTable; + if (tbl != null) + { + TreeNode mainTblNode = new TreeNode(tblName); + mainTblNode.Tag = tblId; + m_treeView.Nodes.Add(mainTblNode); + + // iterate over each TblRec in the SymbolTable + foreach (ObjectId tblRecId in tbl) + { + TreeNode recNode = new TreeNode(m_trHlpr.SymbolIdToName(tblRecId)); + recNode.Tag = tblRecId; + mainTblNode.Nodes.Add(recNode); + } + } + } + + /// + /// + /// + /// + /// + /// + private void + AddDictionaryToTree(ObjectId dictId, TreeNode parentNode, Transaction tr) + { + // NOTE: when recursively processing items in a dictionary + // we may encounter things that are not derived from DBDictionary. + // In that case, the cast to type DBDictionary will fail and + // we'll just return without adding any nested items. + DBObject tmpObj = tr.GetObject(dictId, OpenMode.ForRead); + DBDictionary dbDict = tmpObj as DBDictionary; + if (dbDict != null) + { + foreach (DictionaryEntry curEntry in dbDict) + { + TreeNode newNode = new TreeNode((string)curEntry.Key); + newNode.Tag = curEntry.Value; + parentNode.Nodes.Add(newNode); + + // if this is a dictionary, it will recursively add + // all of its children to the tree + AddDictionaryToTree((ObjectId)curEntry.Value, newNode, tr); + } + } + } + + /// + /// + /// + /// + /// + private void m_treeView_AfterSelect(object sender, TreeViewEventArgs e) + { + if (e.Node.Tag != null) + { + m_objectId = (ObjectId)e.Node.Tag; + } + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/Forms/Objects.resx b/MgdDbgLibrary/ObjTests/Forms/Objects.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/MgdDbgLibrary/ObjTests/Forms/Objects.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/MakeEntTests.cs b/MgdDbgLibrary/ObjTests/MakeEntTests.cs new file mode 100644 index 0000000..0cf6dcd --- /dev/null +++ b/MgdDbgLibrary/ObjTests/MakeEntTests.cs @@ -0,0 +1,934 @@ +// +// (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.Colors; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using MgdDbg.CompBuilder; +using MgdDbg.ObjTests.TestFramework; +using System; + +namespace MgdDbg.ObjTests +{ + /// + /// The entmake functions in this module are designed to show how to create + /// entities based on user input. Therefore, things like the current UCS are + /// of concern because points input by the user are in UCS, but points in the + /// database must be in WCS. The general strategy is: + /// + /// 1) acquire points from the user in UCS without translating them to WCS. + /// 2) do not set the Normal for any entity explicitly. Instead, let it + /// default to (0, 0, 1). + /// 3) transform the entity from the UCS to WCS to get the correct points, + /// normals, and angles that the database will expect. + /// + /// This method allows you to "pretend" that everything is in WCS and you don't + /// have to bother with trasforming individual points and reverse engineering + /// any angles input by the user. + /// + /// Also, I try to demonstrate several different "styles" of handling errors and + /// exceptions. I'm still experimenting with things myself, so bear with me a bit + /// until I can come to grips with the best practices. (jma - 04/28/04) + /// + + public class MakeEntTests : MgdDbgTestFuncs + { + private Database m_db = null; + + public + MakeEntTests() + { + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Line", "Hardwired line from (0,0) to (50, 50)", typeof(Line), new MgdDbgTestFuncInfo.TestFunc(LineHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Circle (WCS-only)", "Hardwired circle [Center=(10,10) Radius=(6)]. Will not be relative to currnt UCS.", typeof(Circle), new MgdDbgTestFuncInfo.TestFunc(CircleHardwiredWcsOnly), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Circle", "Hardwired circle [Center=(10,10) Radius=(6)]", typeof(Circle), new MgdDbgTestFuncInfo.TestFunc(CircleHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Solid", "Hardwired solid [Triangle with thickness]", typeof(Solid), new MgdDbgTestFuncInfo.TestFunc(SolidHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Arc", "Hardwired arc [Center=(12,12) Radius=(6)]", typeof(Arc), new MgdDbgTestFuncInfo.TestFunc(ArcHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Polyline (light weight)", "Hardwired Polyline [Rectangle=(15 x 8)]", typeof(Polyline), new MgdDbgTestFuncInfo.TestFunc(PolylineHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Polyline 2d", "Hardwired Polyline 2d [Rectangle=(15 x 8)]", typeof(Polyline2d), new MgdDbgTestFuncInfo.TestFunc(Polyline2dHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Polyline 3d", "Hardwired Polyline 3d [Rectangle=(15 x 8)]", typeof(Polyline3d), new MgdDbgTestFuncInfo.TestFunc(Polyline3dHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Polyline (width & bulge)", "Hardwired Polyline [Rectangle=(15 x 8), Width=1, Filleted]", typeof(Polyline), new MgdDbgTestFuncInfo.TestFunc(PolylineWidthFillet), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Hatch", "Hardwired triangle with fill", typeof(Hatch), new MgdDbgTestFuncInfo.TestFunc(HatchHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Assoc Hatch", "Hardwired triangle with void, and boundaries are associative", typeof(Hatch), new MgdDbgTestFuncInfo.TestFunc(HatchAssoc), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("3D Face", "Hardwired 3D Face", typeof(Face), new MgdDbgTestFuncInfo.TestFunc(FaceHardwired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Point", "User picked point", typeof(DBPoint), new MgdDbgTestFuncInfo.TestFunc(Point), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Aligned Dimension", "Aligned dim based on two points", typeof(Dimension), new MgdDbgTestFuncInfo.TestFunc(DimAligned), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Comp Builder (Current Space)", "Test of the CompBldr object", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(CompBldrCurSpace), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Lineweight test", "Test of each lineweight", typeof(Line), new MgdDbgTestFuncInfo.TestFunc(Lineweights), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Ray", "Hardwired Ray [From=(0,0) To=(50,50)]", typeof(Ray), new MgdDbgTestFuncInfo.TestFunc(RayHardWired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Leader", "Hardwired Leader [From=(0,0) Through=(50,50) To=(100,50)]", typeof(Leader), new MgdDbgTestFuncInfo.TestFunc(LeaderHardWired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Ellipse", "Hardwired Ellipse [Center=(50,50)]", typeof(Ellipse), new MgdDbgTestFuncInfo.TestFunc(EllipseHardWired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Spline", "Hardwired Spline", typeof(Spline), new MgdDbgTestFuncInfo.TestFunc(SplineHardWired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Helix", "Hardwired Helix", typeof(Helix), new MgdDbgTestFuncInfo.TestFunc(HelixHardWired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Xline", "Hardwired Xline", typeof(Xline), new MgdDbgTestFuncInfo.TestFunc(XlineHardWired), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Simple Table", "Hardwired Table", typeof(Table), new MgdDbgTestFuncInfo.TestFunc(TableHardWired), MgdDbgTestFuncInfo.TestType.Create)); + } + + #region Tests + + public void + LineHardwired() + { + // This shows the style that C++ programmers are used to. In this + // simple case, it is probably OK because it is very unlikely that + // any exceptions will be thrown between the time the Line object + // is instantiated and the time it gets (safely) added to the database + // by AddToCurrentSpaceAndClose(). Technically, an exception could be + // thrown in a function like TransformToWcs(). Would that be bad? + // When an exception is thrown we want to cleanly return to the command + // line and leave the database/system in the same state it was before + // we started. In this case, we wouldn't leave any messes behind because + // we only have a single entity that never got added. + // So, for this simple case, the only drawback is that we left the new + // Line entity around for garbage collection to deal with. This isn't + // so bad in a pure .NET environment, but we need to remember that the Line + // object is really a managed wrapper that points to an unmanaged resource + // in C++. So, having alot of these guys around will trick the garbage + // collector into thinking there isn't as much pressure to clean up + // as there really is. Therefore, for anything but super-trivial cases, + // it is advised to use one of the techniques demonstrated below + // (a using statement, transactions, Component builders, etc.) + m_db = Utils.Db.GetCurDwg(); + + Line line = new Line(); + line.StartPoint = new Point3d(0.0, 0.0, 0.0); + line.EndPoint = new Point3d(50.0, 50.0, 0.0); + line.ColorIndex = 1; + + Utils.Db.TransformToWcs(line, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(line, m_db); + } + + public void + CircleHardwired() + { + // To be exception safe, we need to keep things in a + // try/catch/finally block. Any error that happens + // within the try block will be caught and we will + // clean up our new Circle. However, it is painful + // to write all this housekeeping code each time we + // want to use an object. The other methods of creating + // objects makes the process a bit less tedious. + + m_db = Utils.Db.GetCurDwg(); + + Circle circ = null; + try + { + circ = new Circle(); + circ.ColorIndex = 4; + circ.Center = new Point3d(10.0, 10.0, 0.0); + circ.Radius = 6.0; + + Utils.Db.TransformToWcs(circ, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(circ, m_db); + } + catch (System.Exception e) + { + // maybe we want to do something here, maybe not? + throw e; + } + finally + { + if (circ != null) + circ.Dispose(); + } + } + + public void + SolidHardwired() + { + // To be exception safe, we need to keep things in a + // try/catch/finally block. Any error that happens + // within the try block will be caught and we will + // clean up our new Circle. However, it is painful + // to write all this housekeeping code each time we + // want to use an object. The other methods of creating + // objects makes the process a bit less tedious. + + m_db = Utils.Db.GetCurDwg(); + + Solid solid = null; + try + { + solid = new Solid(); + solid.ColorIndex = 4; + solid.SetPointAt(0, new Point3d(0.0, 0.0, 0.0)); + solid.SetPointAt(1, new Point3d(0.0, 100.0, 0.0)); + solid.SetPointAt(2, new Point3d(100.0, 0.0, 0.0)); + solid.SetPointAt(3, new Point3d(0.0, 0.0, 0.0)); + solid.Thickness = 20.0; + + Utils.Db.TransformToWcs(solid, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(solid, m_db); + } + catch (System.Exception e) + { + // maybe we want to do something here, maybe not? + throw e; + } + finally + { + if (solid != null) + solid.Dispose(); + } + } + + public void + CircleHardwiredWcsOnly() + { + m_db = Utils.Db.GetCurDwg(); + + // The using statement is equivalent to the try/catch/finally + // block in the above example. The finally clause will call + // Dispose() on the Circle and release the underlying unmanaged + // C++ object (AcDbCircle). + using (Circle circ = new Circle()) + { + circ.ColorIndex = 3; + circ.Center = new Point3d(10.0, 10.0, 0.0); + circ.Radius = 6.0; + + // NOTE: we are specifically not transforming from UCS, so everything + // is expressed directly in WCS space. This is to demonstrate what + // happens if you don't do it the way we are doing all the others. + + //Utils.Db.TransformToWcs(circ, m_db); // without this call, it won't be relative to the current UCS + + Utils.SymTbl.AddToCurrentSpaceAndClose(circ, m_db); + } + } + + public void + ArcHardwired() + { + m_db = Utils.Db.GetCurDwg(); + + using (Arc arc = new Arc()) + { + arc.ColorIndex = 4; + arc.Center = new Point3d(12.0, 12.0, 0.0); + arc.Radius = 6.0; + arc.StartAngle = Utils.Ge.DegreesToRadians(30.0); + arc.EndAngle = Utils.Ge.kRad90; + + Utils.Db.TransformToWcs(arc, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(arc, m_db); + } + } + + public void + PolylineHardwired() + { + m_db = Utils.Db.GetCurDwg(); + + using (Polyline pline = new Polyline()) + { + pline.Color = Color.FromRgb(42, 184, 185); + + Point2d[] pts = new Point2d[4]; + pts[0] = new Point2d(0.0, 0.0); + pts[1] = new Point2d(15.0, 0.0); + pts[2] = new Point2d(15.0, 8.0); + pts[3] = new Point2d(0.0, 8.0); + + for (int i = 0; i < pts.Length; i++) + pline.AddVertexAt(i, pts[i], 0.0, 0.0, 0.0); + + pline.Closed = true; + + Utils.Db.TransformToWcs(pline, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(pline, m_db); + } + } + + public void + PolylineWidthFillet() + { + m_db = Utils.Db.GetCurDwg(); + + // set up the input parameters for width/depth/filletRad + double xLen = 15.0; + double yLen = 8.0; + double filletDist = 2.0; + Point2d tmpPt = new Point2d(5.0, 5.0); // "origin" + + // we'll make a filleted Rectangle + Point2d[] pts = new Point2d[8]; + double[] bulges = new double[8]; + + // start at bottom left (after fillet) + tmpPt = new Point2d(tmpPt.X + filletDist, tmpPt.Y); + pts[0] = tmpPt; + + // bottom right (going into fillet) + tmpPt = new Point2d(tmpPt.X + (xLen - filletDist), tmpPt.Y); + pts[1] = tmpPt; + + // bottom right (after fillet) + tmpPt = new Point2d(tmpPt.X + filletDist, tmpPt.Y + filletDist); + pts[2] = tmpPt; + + // top right (going into fillet) + tmpPt = new Point2d(tmpPt.X, tmpPt.Y + (yLen - filletDist)); + pts[3] = tmpPt; + + // top right (after fillet) + tmpPt = new Point2d(tmpPt.X - filletDist, tmpPt.Y + filletDist); + pts[4] = tmpPt; + + // top left (going into fillet) + tmpPt = new Point2d(tmpPt.X - (xLen - filletDist), tmpPt.Y); + pts[5] = tmpPt; + + // top left (after fillet) + tmpPt = new Point2d(tmpPt.X - filletDist, tmpPt.Y - filletDist); + pts[6] = tmpPt; + + // bottom left (going into fillet) + tmpPt = new Point2d(tmpPt.X, tmpPt.Y - (yLen - filletDist)); + pts[7] = tmpPt; + + double bulge = Math.Tan(Utils.Ge.kRad90 / 4.0); // the bulge factor is tangent of a 4th of the included angle, here 90 degrees. + bulges[0] = bulges[2] = bulges[4] = bulges[6] = 0.0; + bulges[1] = bulges[3] = bulges[5] = bulges[7] = bulge; + + // now make the polyline entity + using (Polyline pline = new Polyline()) + { + pline.ColorIndex = 4; + for (int i = 0; i < pts.Length; i++) + pline.AddVertexAt(i, pts[i], bulges[i], 0.0, 0.0); + + pline.ConstantWidth = 1.0; + pline.Closed = true; + + Utils.Db.TransformToWcs(pline, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(pline, m_db); + } + } + + public void + HatchHardwired() + { + m_db = Utils.Db.GetCurDwg(); + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + // make boundary triangle + Polyline pline = new Polyline(); + pline.ColorIndex = 1; + pline.AddVertexAt(0, new Point2d(0.0, 0.0), 0.0, 0.0, 0.0); + pline.AddVertexAt(0, new Point2d(30.0, 0.0), 0.0, 0.0, 0.0); + pline.AddVertexAt(0, new Point2d(15.0, 30.0), 0.0, 0.0, 0.0); + pline.Closed = true; + + Utils.Db.TransformToWcs(pline, m_db); + Utils.SymTbl.AddToCurrentSpace(pline, m_db, tr); + + ObjectIdCollection boundaryIds = new ObjectIdCollection(); + boundaryIds.Add(pline.ObjectId); + + Hatch hatch = new Hatch(); + hatch.ColorIndex = 4; + + Utils.Db.TransformToWcs(hatch, m_db); // NOTE: need to transform to correct plane *BEFORE* setting pattern and boundary info + + hatch.PatternAngle = Utils.Ge.kRad45; + hatch.PatternScale = 4.0; + hatch.SetHatchPattern(HatchPatternType.PreDefined, "ESCHER"); + + hatch.Associative = false; // not in this sample + + hatch.AppendLoop(HatchLoopTypes.Default, boundaryIds); + hatch.EvaluateHatch(false); + + Utils.SymTbl.AddToCurrentSpace(hatch, m_db, tr); + + tr.Commit(); + } + } + + public void + HatchAssoc() + { + m_db = Utils.Db.GetCurDwg(); + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + // make boundary triangle + Polyline pline1 = new Polyline(); + pline1.ColorIndex = 211; + pline1.AddVertexAt(0, new Point2d(0.0, 0.0), 0.0, 0.0, 0.0); + pline1.AddVertexAt(0, new Point2d(30.0, 0.0), 0.0, 0.0, 0.0); + pline1.AddVertexAt(0, new Point2d(15.0, 30.0), 0.0, 0.0, 0.0); + pline1.Closed = true; + Utils.Db.TransformToWcs(pline1, m_db); + Utils.SymTbl.AddToCurrentSpace(pline1, m_db, tr); + + // offset the triangle and add those entities to the db + DBObjectCollection offsetCurves = pline1.GetOffsetCurves(5.0); + Utils.SymTbl.AddToCurrentSpace(offsetCurves, m_db, tr); + + ObjectIdCollection boundaryIds1 = new ObjectIdCollection(); + boundaryIds1.Add(pline1.ObjectId); + + ObjectIdCollection boundaryIds2 = new ObjectIdCollection(); + foreach (Entity tmpEnt in offsetCurves) + { + boundaryIds2.Add(tmpEnt.ObjectId); + } + + Hatch hatch = new Hatch(); + hatch.ColorIndex = 141; + + Utils.Db.TransformToWcs(hatch, m_db); // NOTE: need to transform to correct plane *BEFORE* setting pattern and boundary info + + hatch.PatternAngle = Utils.Ge.kRad0; + hatch.PatternScale = 4.0; + hatch.SetHatchPattern(HatchPatternType.PreDefined, "STARS"); + + hatch.HatchStyle = HatchStyle.Normal; + Utils.SymTbl.AddToCurrentSpace(hatch, m_db, tr); + + // To make an associative hatch we have to first add it to the database (above). + // When we call AppendLoop(), it will add the Persistent Reactor that keeps the + // boundary associative. + hatch.Associative = true; + hatch.AppendLoop(HatchLoopTypes.Default, boundaryIds1); + if (boundaryIds2.Count > 0) + hatch.AppendLoop(HatchLoopTypes.Default, boundaryIds2); + + hatch.EvaluateHatch(false); + + tr.Commit(); + } + } + + public void + FaceHardwired() + { + m_db = Utils.Db.GetCurDwg(); + + using (Face face = new Face()) + { + face.ColorIndex = 1; + + double sqSize = 10.0; + + // make a 10 x 10 square face + Point3d tmpPt = new Point3d(0.0, 0.0, 0.0); + face.SetVertexAt(0, tmpPt); + + tmpPt = new Point3d(tmpPt.X + sqSize, tmpPt.Y, tmpPt.Z); + face.SetVertexAt(1, tmpPt); + + tmpPt = new Point3d(tmpPt.X, tmpPt.Y + sqSize, tmpPt.Z); + face.SetVertexAt(2, tmpPt); + + tmpPt = new Point3d(tmpPt.X - sqSize, tmpPt.Y, tmpPt.Z); + face.SetVertexAt(3, tmpPt); + + Utils.Db.TransformToWcs(face, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(face, m_db); + } + } + + public void + DimAligned() + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Point3d pt1, pt2; + + // get end points and angle for extension lines + if (GetLineOrTwoPoints(out pt1, out pt2) != PromptStatus.OK) + return; + + PromptPointOptions prTextPtOpts = new PromptPointOptions("\nText point"); + prTextPtOpts.UseBasePoint = true; + prTextPtOpts.BasePoint = Utils.Ge.Midpoint(pt1, pt2); + PromptPointResult prTextPtRes = ed.GetPoint(prTextPtOpts); + if (prTextPtRes.Status != PromptStatus.OK) + return; + + using (AlignedDimension dim = new AlignedDimension()) + { + dim.XLine1Point = pt1; + dim.XLine2Point = pt2; + + // TBD: dimLinePt is supposed automatically set from where + // text was placed, unless you deliberately set the dimLinePt (and DIMFIT != 4) + // However, it doesn't seem to work unless you set to the same as TextPosition + // anyway. + dim.HorizontalRotation = GetDimHorizRotation(); + dim.UsingDefaultTextPosition = true; // make text go where user picked + dim.TextPosition = prTextPtRes.Value; + dim.DimLinePoint = prTextPtRes.Value; + + Utils.Db.TransformToWcs(dim, m_db); + Utils.SymTbl.AddToCurrentSpaceAndClose(dim, m_db); + } + } + + public void + Point() + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptPointOptions prPtOpt = new PromptPointOptions("\nPoint"); + PromptPointResult prPtRes = ed.GetPoint(prPtOpt); + if (prPtRes.Status != PromptStatus.OK) + return; + + using (DBPoint point = new DBPoint()) + { + point.Position = prPtRes.Value; + Utils.Db.TransformToWcs(point, m_db); + + // TBD: not sure why, but the call to set the EcsRotation must come + // after we do the TransformToWcs(). Need to investigate whether that + // is a bug or intended behavior. + point.EcsRotation = GetDimHorizRotation(); + Utils.SymTbl.AddToCurrentSpaceAndClose(point, m_db); + } + } + + /// + /// This will demonstrate how to use the CompBldr to manage alot of the low + /// level details of creating new entities. It's not quite ready yet, so this + /// example will come at a later date (but will probably be the way you want + /// to create entities in the future). + /// + /// TBD: finish this off and provide several examples. (jma - 04/28/04) + /// + public void + CompBldrCurSpace() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + + double tmpRadius = 1.0; + + Circle tmpCirc = null; + for (int i = 0; i < 10; i++) + { + tmpCirc = new Circle(); + tmpCirc.Radius = tmpRadius; + tmpCirc.ColorIndex = i; + + Utils.Db.TransformToWcs(tmpCirc, m_db); + compBldr.AddToDb(tmpCirc); + + tmpRadius += 1.0; + } + + Matrix3d mat = Matrix3d.Displacement(new Vector3d(10.0, 10.0, 0.0)); + compBldr.PushXform(mat); + + tmpCirc = new Circle(); + tmpCirc.Radius = 2.0; + Utils.Db.TransformToWcs(tmpCirc, m_db); + compBldr.AddToDb(tmpCirc); + + compBldr.PopXform(); + + compBldr.Commit(); + } + } + + public void + Lineweights() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Point3d startPt = new Point3d(0.0, 0.0, 0.0); + Point3d endPt = new Point3d(100.0, 0.0, 0.0); + + Vector3d offset = new Vector3d(0.0, 10.0, 0.0); + + foreach (Autodesk.AutoCAD.DatabaseServices.LineWeight lw in System.Enum.GetValues(typeof(LineWeight))) + { + Line line = new Line(startPt, endPt); + line.LineWeight = lw; + + compBldr.AddToDb(line); + + DBText text = new DBText(); + text.Height = 5.0; + text.Position = endPt; + text.TextString = lw.ToString(); + + compBldr.AddToDb(text); + + startPt += offset; + endPt += offset; + } + + compBldr.Commit(); + } + } + + public void + RayHardWired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Point3d basePoint = new Point3d(0.0, 0.0, 0.0); + Vector3d unitDir = new Vector3d(10.0, 10.0, 0.0); + + Ray ray = new Ray(); + ray.BasePoint = basePoint; + ray.UnitDir = unitDir; + + compBldr.AddToDb(ray); + compBldr.Commit(); + } + } + + public void + LeaderHardWired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Point3d startPoint = new Point3d(0.0, 0.0, 0.0); + Point3d midPoint = new Point3d(50.0, 50.0, 0.0); + Point3d endPoint = new Point3d(100.0, 50.0, 0.0); + + Point3dCollection pts = new Point3dCollection(); + pts.Add(startPoint); + pts.Add(midPoint); + pts.Add(endPoint); + + Leader leader = new Leader(); + foreach (Point3d pt in pts) + { + leader.AppendVertex(pt); + } + compBldr.AddToDb(leader); + compBldr.Commit(); + } + } + + public void + EllipseHardWired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Point3d center = new Point3d(50.0, 50.0, 0.0); + // laid out on the XY plane, with normal in Z + Vector3d uNormal = new Vector3d(0.0, 0.0, 10.0); + Vector3d majAxis = new Vector3d(10.0, 0.0, 0.0); + // default values + double rRatio = .5; + double startAngle = 0.0; + double endAngle = 6.28318530717958647692; + Ellipse ellipse = new Ellipse(center, uNormal, majAxis, rRatio, startAngle, endAngle); + compBldr.AddToDb(ellipse); + compBldr.Commit(); + } + } + + public void + SplineHardWired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Point3dCollection pts = new Point3dCollection(); + pts.Add(new Point3d(0.0, 0.0, 0.0)); + pts.Add(new Point3d(50.0, 50.0, 50.0)); + pts.Add(new Point3d(100.0, 50.0, 100.0)); + pts.Add(new Point3d(150.0, 100.0, 100.0)); + + // order of the curve can be between 2 and 26 + int order = 6; + // determines extent of interpolation through all the points + double fitTolerance = .5; + + Spline spline = new Spline(pts, order, fitTolerance); + compBldr.AddToDb(spline); + compBldr.Commit(); + } + } + + public void + HelixHardWired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Helix helix = new Helix(); + helix.Turns = 10.0; + helix.Twist = true; + helix.BaseRadius = 20.0; + //creates the helix geometry based on the values set in prior function calls + helix.CreateHelix(); + compBldr.AddToDb(helix); + compBldr.Commit(); + } + } + + public void + XlineHardWired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Xline xline = new Xline(); + xline.UnitDir = new Vector3d(1.0, 1.0, 0.0); + compBldr.AddToDb(xline); + compBldr.Commit(); + } + } + + public void + Polyline2dHardwired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Polyline2d pline2d = new Polyline2d(); + pline2d.Color = Color.FromRgb(42, 184, 185); + // polyline2d needs to be in database before the vertices + // can be added to it. The polyline2d owns the vertices. + compBldr.AddToDb(pline2d); + + Point3d[] pts = new Point3d[4]; + pts[0] = new Point3d(0.0, 0.0, 0.0); + pts[1] = new Point3d(15.0, 0.0, 0.0); + pts[2] = new Point3d(15.0, 8.0, 0.0); + pts[3] = new Point3d(0.0, 8.0, 0.0); + + Vertex2d vertX2d; + + for (int i = 0; i < pts.Length; i++) + { + vertX2d = new Vertex2d(pts[i], 0.0, 0.0, 0.0, 0.0); + pline2d.AppendVertex(vertX2d); + compBldr.Transaction.AddNewlyCreatedDBObject(vertX2d, true); + } + + pline2d.Closed = true; + compBldr.Commit(); + } + } + + public void + Polyline3dHardwired() + { + m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) + { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Point3d[] pts = new Point3d[4]; + pts[0] = new Point3d(0.0, 0.0, 0.0); + pts[1] = new Point3d(15.0, 0.0, 15.0); + pts[2] = new Point3d(15.0, 8.0, 15.0); + pts[3] = new Point3d(0.0, 8.0, 0.0); + Point3dCollection ptsColl = new Point3dCollection(pts); + + Polyline3d pline3d = new Polyline3d(Poly3dType.SimplePoly, ptsColl, true); + pline3d.Color = Color.FromRgb(42, 184, 185); + + compBldr.AddToDb(pline3d); + compBldr.Commit(); + } + } + + public void + TableHardWired() + { + /* m_db = Utils.Db.GetCurDwg(); + + using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) { + compBldr.Start(); + compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db)); + + Table table = new Table(); + table.NumColumns = 5; + table.NumRows = 5; + table.Height = 50; + table.Width = 15; + + for(int row=0; row + /// Find out the rotational difference between the current UCS XAxis + /// and the ECS XAxis. Dimensions need to know this to know which way + /// was horizontal when the dimension text was created. + /// + /// angle of ECS rotation + + public double + GetDimHorizRotation() + { + m_db = Utils.Db.GetCurDwg(); + + Matrix3d m = Utils.Db.GetUcsMatrix(m_db); + + Vector3d entXAxis = Utils.Db.GetEcsXAxis(m.CoordinateSystem3d.Zaxis); // get AutoCAD's arbitrary X-Axis + + return m.CoordinateSystem3d.Xaxis.GetAngleTo(entXAxis, m.CoordinateSystem3d.Zaxis); // get rotation from one to the other + } + + /// + /// Helper function for acquiring Dimension parameters from the user. It will return + /// two points, either from the user directly picking two points, or from them selecting + /// a line entity. + /// + /// First point + /// Second point + /// + + public PromptStatus + GetLineOrTwoPoints(out Point3d pt1, out Point3d pt2) + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + pt1 = pt2 = Utils.Ge.kOrigin; // initialize to make compiler happy + + PromptPointOptions prOpts = new PromptPointOptions("\nFirst extension line origin or RETURN to select"); + prOpts.AllowNone = true; + + PromptPointResult prPt1Res = ed.GetPoint(prOpts); + + // user wants to select a line to specify both points + if (prPt1Res.Status == PromptStatus.None) + { + PromptEntityOptions prEntOpts = new PromptEntityOptions("\nSelect a LINE"); + prEntOpts.SetRejectMessage("\nSelected entity must be of type Line"); + prEntOpts.AddAllowedClass(typeof(Line), false); + + PromptEntityResult prEntRes = ed.GetEntity(prEntOpts); + if (prEntRes.Status != PromptStatus.OK) + return prEntRes.Status; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Line line = (Line)tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead); + + pt1 = Utils.Db.WcsToUcs(line.StartPoint); + pt2 = Utils.Db.WcsToUcs(line.EndPoint); + tr.Commit(); + + return PromptStatus.OK; + } + } + else if (prPt1Res.Status == PromptStatus.OK) + { + PromptPointOptions prPt2Opts = new PromptPointOptions("\nSecond extension line origin"); + prPt2Opts.UseBasePoint = true; + prPt2Opts.BasePoint = prPt1Res.Value; + PromptPointResult prPt2Res = ed.GetPoint(prPt2Opts); + if (prPt2Res.Status != PromptStatus.OK) + return PromptStatus.Cancel; + + pt1 = prPt1Res.Value; + pt2 = prPt2Res.Value; + return prPt1Res.Status; + } + + return prPt1Res.Status; + } + + #endregion User Input Utils + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/MakeSymTblRecTests.cs b/MgdDbgLibrary/ObjTests/MakeSymTblRecTests.cs new file mode 100644 index 0000000..409ba51 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/MakeSymTblRecTests.cs @@ -0,0 +1,149 @@ +// +// (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.Colors; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using MgdDbg.CompBuilder; +using MgdDbg.ObjTests.TestFramework; + +namespace MgdDbg.ObjTests +{ + /// + /// Summary description for MakeSymTblRecTests. + /// + public class MakeSymTblRecTests : MgdDbgTestFuncs + { + private Database m_db = null; + + public + MakeSymTblRecTests() + { + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Block", "Hardwired block", typeof(BlockTableRecord), new MgdDbgTestFuncInfo.TestFunc(Block), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Block (CompBldr)", "Hardwired block (Using CompBldr)", typeof(BlockTableRecord), new MgdDbgTestFuncInfo.TestFunc(BlockCompBldr), MgdDbgTestFuncInfo.TestType.Create)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Layer", "Hardwired layer", typeof(LayerTableRecord), new MgdDbgTestFuncInfo.TestFunc(Layer), MgdDbgTestFuncInfo.TestType.Create)); + } + + #region Tests + + public void + Block() + { + m_db = Utils.Db.GetCurDwg(); + string symName = "Jimbo"; + + if (Utils.SymTbl.SymbolTableRecExists(typeof(BlockTableRecord), symName, m_db)) + { + bool answer; + PromptStatus stat = Utils.AcadUi.PromptYesNo(string.Format("\nBlock \"{0}\"already exists. Replace?", symName), false, out answer); + if ((stat != PromptStatus.OK) || (answer == false)) + return; + } + + using (TransactionHelper tr = new TransactionHelper(m_db)) + { + tr.Start(); + + BlockTableRecord blkRec = tr.DefineNewBlockRec(symName); + + Line line = new Line(new Point3d(0.0, 0.0, 0.0), new Point3d(10.0, 10.0, 0.0)); + blkRec.AppendEntity(line); + tr.Transaction.AddNewlyCreatedDBObject(line, true); + + Circle circ = new Circle(); + circ.Center = new Point3d(0.0, 0.0, 0.0); + circ.Radius = 5.0; + blkRec.AppendEntity(circ); + tr.Transaction.AddNewlyCreatedDBObject(circ, true); + + tr.Commit(); + Utils.AcadUi.PrintToCmdLine(string.Format("\nCreated block \"{0}\".", symName)); + } + } + + public void + BlockCompBldr() + { + m_db = Utils.Db.GetCurDwg(); + string symName = "Sophie"; + + if (Utils.SymTbl.SymbolTableRecExists(typeof(BlockTableRecord), symName, m_db)) + { + bool answer; + PromptStatus stat = Utils.AcadUi.PromptYesNo(string.Format("\nBlock \"{0}\"already exists. Replace?", symName), false, out answer); + if ((stat != PromptStatus.OK) || (answer == false)) + return; + } + + using (CompBldrNamedBlkDef compBldr = new CompBldrNamedBlkDef(m_db, symName)) + { + compBldr.Start(); + + Line line = new Line(new Point3d(0.0, 0.0, 0.0), new Point3d(-10.0, -10.0, 0.0)); + compBldr.SetToDefaultProps(line); + compBldr.AddToDb(line); + + Circle circ = new Circle(); + circ.Center = new Point3d(0.0, 0.0, 0.0); + circ.Radius = 5.0; + compBldr.SetToDefaultProps(circ); + compBldr.AddToDb(circ); + + compBldr.Commit(); + Utils.AcadUi.PrintToCmdLine(string.Format("\nCreated block \"{0}\".", symName)); + } + } + + public void + Layer() + { + m_db = Utils.Db.GetCurDwg(); + string symName = "Jimbo"; + + using (TransactionHelper tr = new TransactionHelper(m_db)) + { + tr.Start(); + + if (tr.SymbolTableRecExists(typeof(LayerTableRecord), symName)) + { + Utils.AcadUi.PrintToCmdLine(string.Format("\nLayer \"{0}\" already exists.", symName)); + return; + } + + LayerTableRecord lyr = new LayerTableRecord(); + lyr.Name = symName; + lyr.LinetypeObjectId = Utils.SymTbl.GetOrLoadLinetypeId("ZIGZAG", m_db); + //lyr.Description = "Layer created programmatically by MgdDbg"; // Can't set until after its added to the database! + + lyr.Color = Color.FromRgb(0, 130, 160); + + tr.AddNewSymbolRec(lyr); + + tr.Commit(); + Utils.AcadUi.PrintToCmdLine(string.Format("\nCreated layer \"{0}\".", symName)); + } + } + + #endregion Tests + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/ModifyEntTests.cs b/MgdDbgLibrary/ObjTests/ModifyEntTests.cs new file mode 100644 index 0000000..a471ad1 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/ModifyEntTests.cs @@ -0,0 +1,289 @@ +// +// (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.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using MgdDbg.ObjTests.TestFramework; +using System; +using System.Windows.Forms; + +namespace MgdDbg.ObjTests +{ + /// + /// Summary description for ModifyEntTests. + /// + public class ModifyEntTests : MgdDbgTestFuncs + { + private Database m_db = null; + + public ModifyEntTests() + { + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Xform - Move", "Move selected objects", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(XformMove), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Xform - Rotate", "Rotate selected objects", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(XformRotate), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Xform - Scale", "Scale selected objects", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(XformScale), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Xform - Mirror", "Mirror selected objects", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(XformMirror), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Xform - WCS Origin", "Transform selected objects to WCS origin (needed when making a block out of a set of entities)", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(XformWcsOrigin), MgdDbgTestFuncInfo.TestType.Modify)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Highlight Entity", "Higlight entity using handle", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(HighlightEntityFromHandle), MgdDbgTestFuncInfo.TestType.Modify)); + } + + #region Tests + + public void + XformMove() + { + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + ObjectIdCollection selSet = null; + if (Utils.AcadUi.GetSelSetFromUser(out selSet) == false) + return; + + PromptPointOptions prBasePtOpts = new PromptPointOptions("\nBase point or displacement"); + PromptPointResult prBasePtRes = ed.GetPoint(prBasePtOpts); + if (prBasePtRes.Status != PromptStatus.OK) + return; + + Vector3d transVec = new Vector3d(); + + PromptPointOptions prToPtOpts = new PromptPointOptions("\nTo point or "); + prToPtOpts.UseBasePoint = true; + prToPtOpts.BasePoint = prBasePtRes.Value; + prToPtOpts.AllowNone = true; + + PromptPointResult prToPtRes = ed.GetPoint(prToPtOpts); + if (prToPtRes.Status == PromptStatus.OK) + transVec = prToPtRes.Value - prBasePtRes.Value; + else if (prToPtRes.Status == PromptStatus.None) + transVec = prBasePtRes.Value.GetAsVector(); + else + return; // was a cancel + + DoXform(selSet, Matrix3d.Displacement(Utils.Db.UcsToWcs(transVec))); + } + + public void + XformRotate() + { + ObjectIdCollection selSet = null; + if (Utils.AcadUi.GetSelSetFromUser(out selSet) == false) + return; + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptPointResult prBasePtRes = ed.GetPoint("\nBase point"); + if (prBasePtRes.Status == PromptStatus.OK) + { + PromptDoubleResult prRotAngRes = ed.GetAngle("\nRotation angle"); + if (prRotAngRes.Status == PromptStatus.OK) + { + Vector3d axis = Utils.Db.GetUcsZAxis(Utils.Db.GetCurDwg()); + DoXform(selSet, Matrix3d.Rotation(prRotAngRes.Value, axis, Utils.Db.UcsToWcs(prBasePtRes.Value))); + } + } + } + + public void + XformScale() + { + ObjectIdCollection selSet = null; + if (Utils.AcadUi.GetSelSetFromUser(out selSet) == false) + return; + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptPointResult prBasePtRes = ed.GetPoint("\nBase point"); + if (prBasePtRes.Status == PromptStatus.OK) + { + PromptDistanceOptions prScaleOpts = new PromptDistanceOptions("\nScale factor"); + prScaleOpts.AllowZero = false; + prScaleOpts.AllowNegative = false; + + PromptDoubleResult prScaleRes = ed.GetDistance(prScaleOpts); + + if (prScaleRes.Status == PromptStatus.OK) + { + DoXform(selSet, Matrix3d.Scaling(prScaleRes.Value, Utils.Db.UcsToWcs(prBasePtRes.Value))); + } + } + } + + public void + XformMirror() + { + m_db = Utils.Db.GetCurDwg(); + ObjectIdCollection selSet = null; + + if (Utils.AcadUi.GetSelSetFromUser(out selSet) == false) + return; + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptPointResult prFirstPtRes = ed.GetPoint("\nFirst point on mirror line"); + if (prFirstPtRes.Status != PromptStatus.OK) + return; + + PromptPointOptions prSecondPtOpts = new PromptPointOptions("\nSecond point on mirror line"); + prSecondPtOpts.UseBasePoint = true; + prSecondPtOpts.BasePoint = prFirstPtRes.Value; + + PromptPointResult prSecondPtRes = ed.GetPoint(prSecondPtOpts); + if (prSecondPtRes.Status != PromptStatus.OK) + return; + + Line3d mirrorLine = new Line3d(Utils.Db.UcsToWcs(prFirstPtRes.Value), Utils.Db.UcsToWcs(prSecondPtRes.Value)); + + bool doCopy; + if (Utils.AcadUi.PromptYesNo("\nCopy the original entities", true, out doCopy) != PromptStatus.OK) + return; + + if (doCopy) + Utils.Db.CloneAndXformObjects(m_db, selSet, m_db.CurrentSpaceId, Matrix3d.Mirroring(mirrorLine)); + else + DoXform(selSet, Matrix3d.Mirroring(mirrorLine)); + } + + public void + XformWcsOrigin() + { + ObjectIdCollection selSet = null; + if (Utils.AcadUi.GetSelSetFromUser(out selSet) == false) + return; + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptPointResult prBasePtRes = ed.GetPoint("\nBase point"); + if (prBasePtRes.Status != PromptStatus.OK) + return; + + Matrix3d xform = Utils.Db.GetUcsToWcsOriginMatrix(Utils.Db.UcsToWcs(prBasePtRes.Value), Utils.Db.GetCurDwg()); + DoXform(selSet, xform); + } + + private void + DoXform(ObjectIdCollection objIds, Matrix3d m) + { + if (objIds.Count == 0) + return; + + Database db = objIds[0].Database; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager; + + using (Transaction tr = tm.StartTransaction()) + { + Entity tmpEnt; + foreach (ObjectId tmpId in objIds) + { + tmpEnt = (Entity)tr.GetObject(tmpId, OpenMode.ForWrite); + tmpEnt.TransformBy(m); + } + + tr.Commit(); + } + } + + public void + HighlightEntityFromHandle() + { + ObjectId id = ObjectId.Null; + DialogResult dlgResult; + + Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager; + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + PromptStringOptions options = new PromptStringOptions("Enter Handle"); + + String str = ed.GetString(options).StringResult; + + if (str != String.Empty) + { + Handle h = Utils.Db.StringToHandle(str); + + try + { + id = Utils.Db.HandleToObjectId(db, h); + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Entity ent = tr.GetObject(id, OpenMode.ForWrite) as Entity; + + if (ent != null) + { + ent.Highlight(); + } + else + { + Utils.AcadUi.PrintToCmdLine((tr.GetObject(id, OpenMode.ForWrite)).GetType().FullName); + } + tr.Commit(); + } + + dlgResult = MessageBox.Show("Do you want to continue?", "MgdDbg", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dlgResult == DialogResult.Yes) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Entity ent = tr.GetObject(id, OpenMode.ForWrite) as Entity; + + if (ent != null) + { + ent.Unhighlight(); + } + else + { + Utils.AcadUi.PrintToCmdLine((tr.GetObject(id, OpenMode.ForWrite)).GetType().FullName); + } + tr.Commit(); + } + } + } + catch (Autodesk.AutoCAD.Runtime.Exception x) + { + if (x.ErrorStatus != Autodesk.AutoCAD.Runtime.ErrorStatus.UnknownHandle) + { + throw x; + } + } + } + } + + public static Handle + StringToHandle(String strHandle) + { + Handle handle = new Handle(); + + try + { + Int64 nHandle = Convert.ToInt64(strHandle, 16); + handle = new Handle(nHandle); + } + catch (System.FormatException) + { + } + return handle; + } + + #endregion Tests + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/QueryCurveTests.cs b/MgdDbgLibrary/ObjTests/QueryCurveTests.cs new file mode 100644 index 0000000..354538e --- /dev/null +++ b/MgdDbgLibrary/ObjTests/QueryCurveTests.cs @@ -0,0 +1,1182 @@ +// +// (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.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using Autodesk.AutoCAD.Runtime; +using MgdDbg.ObjTests.TestFramework; +using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; + +namespace MgdDbg.ObjTests +{ + /// + /// Summary description for QueryCurveTests. + /// + public class QueryCurveTests : MgdDbgTestFuncs + { + private Database m_db = null; + private Editor m_ed = null; + + public + QueryCurveTests() + { + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Area", "Get the area of the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(Area), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Is closed", "Test whether the curve is closed", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(IsClosed), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Is periodic", "Test whether the curve is periodic", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(IsPeriodic), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get start/end points", "Add Point entity where the start and end points are", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(StartEndPoints), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get start/end params", "Get start and end params of the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(StartEndParams), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get point at param", "Get point at a given parameter of the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(PointAtParam), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get param at point", "Get param at a given point on the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(ParamAtPoint), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get distance at param", "Get distance at a given param of the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(DistanceAtParam), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get param at distance", "Get param at a given distance along the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(ParamAtDistance), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get distance at point", "Get distance at a given point on the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(DistanceAtPoint), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get point at distance", "Get point at a given distance along the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(PointAtDistance), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get derivatives at param", "Get first and second derivatives", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(DerivativesAtParam), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get derivatives at point", "Get first and second derivatives", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(DerivativesAtPoint), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get closest point", "Get point on the curve closest to point picked", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(ClosestPointTo), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get closest point using direction", "Get point on the curve closest to point picked (in the direction specified)", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(ClosestPointToDirection), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get offset curves", "Get the offset of the given curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(OffsetCurves), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get offset curves given plane normal", "Get the offset of the given curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(OffsetCurvesGivenPlaneNormal), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get projected curve", "Get the projected curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(ProjectedCurve), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get ortho projected curve", "Get the projected curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(OrthoProjectedCurve), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get split curves from params", "Get the sub-curves given certain params", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(SplitCurvesParams), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get split curves from points", "Get the sub-curves given certain points", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(SplitCurvesPoints), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Spline", "Get a Spline entity representing the curve", typeof(Curve), new MgdDbgTestFuncInfo.TestFunc(Spline), MgdDbgTestFuncInfo.TestType.Query)); + } + + #region Tests + + public void + Area() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + m_ed.WriteMessage(string.Format("\nAREA: {0}", Converter.DistanceToString(curve.Area, DistanceUnitFormat.Decimal, -1))); + + tr.Commit(); + } + } + } + + public void + IsClosed() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + m_ed.WriteMessage(string.Format("\nCLOSED: {0}", curve.Closed.ToString())); + + tr.Commit(); + } + } + } + + public void + IsPeriodic() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + m_ed.WriteMessage(string.Format("\nPERIODIC: {0}", curve.IsPeriodic.ToString())); + + tr.Commit(); + } + } + } + + public void + StartEndPoints() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + // get StartPoint (if appliacable) and make a point entity in Red + // to graphically depict it. + try + { + Point3d startPt = curve.StartPoint; + m_ed.WriteMessage(string.Format("\nSTART POINT: {0}", Utils.AcadUi.PtToStr(startPt))); + Utils.Db.MakePointEnt(startPt, 1, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + if (e.ErrorStatus == Autodesk.AutoCAD.Runtime.ErrorStatus.NotApplicable) + m_ed.WriteMessage("\nSTART POINT: Not Applicable"); + else + throw e; + } + + // get EndPoint (if appliacable) and make a point entity in Yellow + // to graphically depict it. + try + { + Point3d endPt = curve.EndPoint; + m_ed.WriteMessage(string.Format("\nEND POINT: {0}", Utils.AcadUi.PtToStr(endPt))); + Utils.Db.MakePointEnt(endPt, 2, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + if (e.ErrorStatus == Autodesk.AutoCAD.Runtime.ErrorStatus.NotApplicable) + m_ed.WriteMessage("\nEND POINT: Not Applicable"); + else + throw e; + } + + tr.Commit(); + } + } + } + + public void + StartEndParams() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + double startParam = curve.StartParam; + m_ed.WriteMessage(string.Format("\nSTART PARAM (as double): {0}", Converter.DistanceToString(startParam))); + m_ed.WriteMessage(string.Format("\nSTART PARAM (as angle): {0}", Converter.AngleToString(startParam))); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + if (e.ErrorStatus == Autodesk.AutoCAD.Runtime.ErrorStatus.NotApplicable) + m_ed.WriteMessage("\nSTART PARAM: Not Applicable"); + else + throw e; + } + + try + { + double endParam = curve.EndParam; + m_ed.WriteMessage(string.Format("\nEND PARAM (as double): {0}", Converter.DistanceToString(endParam))); + m_ed.WriteMessage(string.Format("\nEND PARAM (as angle): {0}", Converter.AngleToString(endParam))); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + if (e.ErrorStatus == Autodesk.AutoCAD.Runtime.ErrorStatus.NotApplicable) + m_ed.WriteMessage("\nEND PARAM: Not Applicable"); + else + throw e; + } + + tr.Commit(); + } + } + } + + public void + PointAtParam() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + PrintParamInterval(curve); + + double param; + if (GetCurveParam(out param)) + { + try + { + Point3d pt = curve.GetPointAtParameter(param); + m_ed.WriteMessage(string.Format("\nPOINT: {0}", Utils.AcadUi.PtToStr(pt))); + Utils.Db.MakePointEnt(pt, 3, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + } + + tr.Commit(); + } + } + } + + public void + ParamAtPoint() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + // the point picked is not necessarily on the curve (unless we used + // an OSNAP that forced it on the curve). We will first get the closest + // point on the curve from the picked point and then use that. + Point3d ptOnCurve = curve.GetClosestPointTo(Utils.Db.UcsToWcs(pickPt), false); + double param = curve.GetParameterAtPoint(ptOnCurve); + + m_ed.WriteMessage(string.Format("\nPARAM (as double): {0}", Converter.DistanceToString(param))); + m_ed.WriteMessage(string.Format("\nPARAM (as angle): {0}", Converter.AngleToString(param))); + Utils.Db.MakePointEnt(ptOnCurve, 3, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + DistanceAtParam() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + PrintParamInterval(curve); + + double param; + if (GetCurveParam(out param)) + { + try + { + double dist = curve.GetDistanceAtParameter(param); + m_ed.WriteMessage(string.Format("\nDISTANCE: {0}", Converter.DistanceToString(dist))); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + } + + tr.Commit(); + } + } + } + + public void + ParamAtDistance() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + // first prompt for distance along the curve + PromptDoubleResult res = m_ed.GetDistance("\nDistance along curve"); + if (res.Status != PromptStatus.OK) + { + return; + } + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + double param = curve.GetParameterAtDistance(res.Value); + m_ed.WriteMessage(string.Format("\nPARAM (as double): {0}", Converter.DistanceToString(param))); + m_ed.WriteMessage(string.Format("\nPARAM (as angle): {0}", Converter.AngleToString(param))); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + DistanceAtPoint() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + // the point picked is not necessarily on the curve (unless we used + // an OSNAP that forced it on the curve). We will first get the closest + // point on the curve from the picked point and then use that. + Point3d ptOnCurve = curve.GetClosestPointTo(Utils.Db.UcsToWcs(pickPt), false); + double dist = curve.GetDistAtPoint(ptOnCurve); // TBD: function should be called GetDistanceAtPoint() + + m_ed.WriteMessage(string.Format("\nDISTANCE: {0}", Converter.DistanceToString(dist))); + Utils.Db.MakePointEnt(ptOnCurve, 3, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + PointAtDistance() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + // first prompt for distance along the curve + PromptDoubleResult res = m_ed.GetDistance("\nDistance along curve"); + if (res.Status != PromptStatus.OK) + { + return; + } + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + Point3d ptOnCurve = curve.GetPointAtDist(res.Value); // TBD: function should be called GetPointAtDistance() + m_ed.WriteMessage(string.Format("\nPOINT: {0}", Utils.AcadUi.PtToStr(ptOnCurve))); + Utils.Db.MakePointEnt(ptOnCurve, 3, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + DerivativesAtParam() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + PrintParamInterval(curve); + + double param; + if (GetCurveParam(out param)) + { + // We need a point on the curve to create the Ray entities we will + // use to mark the two axes. If the user gives us an invalid param, + // we aren't catching it here, so it will throw an exception. Under + // normal circumstances, we could just put this in the try/catch block + // below. Here, we want to demonstrate each possible error. + try + { + Point3d ptOnCurve = curve.GetPointAtParameter(param); + try + { + Vector3d firstDeriv = curve.GetFirstDerivative(param); + m_ed.WriteMessage(string.Format("\nFIRST DERIV: {0}", Utils.AcadUi.VecToStr(firstDeriv))); + Utils.Db.MakeRayEnt(ptOnCurve, firstDeriv, 1, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nFirst Derivative ERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + try + { + Vector3d secondDeriv = curve.GetSecondDerivative(param); + m_ed.WriteMessage(string.Format("\nSECOND DERIV: {0}", Utils.AcadUi.VecToStr(secondDeriv))); + Utils.Db.MakeRayEnt(ptOnCurve, secondDeriv, 2, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nSecond Derivative ERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nParameter is not on curve: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + return; + } + } + + tr.Commit(); + } + } + } + + public void + DerivativesAtPoint() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + // Again, we could put these all in a single try/catch block, but we + // want to catch all errors individually so we can demonstrate how the + // functions behave. + try + { + // the point picked is not necessarily on the curve (unless we used + // an OSNAP that forced it on the curve). We will first get the closest + // point on the curve from the picked point and then use that. + Point3d ptOnCurve = curve.GetClosestPointTo(Utils.Db.UcsToWcs(pickPt), false); + Utils.Db.MakePointEnt(ptOnCurve, 3, tr, m_db); + + try + { + Vector3d firstDeriv = curve.GetFirstDerivative(ptOnCurve); + m_ed.WriteMessage(string.Format("\nFIRST DERIV: {0}", Utils.AcadUi.VecToStr(firstDeriv))); + Utils.Db.MakeRayEnt(ptOnCurve, firstDeriv, 1, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nFirst Derivative ERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + try + { + Vector3d secondDeriv = curve.GetSecondDerivative(ptOnCurve); + m_ed.WriteMessage(string.Format("\nSECOND DERIV: {0}", Utils.AcadUi.VecToStr(secondDeriv))); + Utils.Db.MakeRayEnt(ptOnCurve, secondDeriv, 2, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nSecond Derivative ERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nPoint is not on curve: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + return; + } + + tr.Commit(); + } + } + } + + public void + ClosestPointTo() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + // let user pick an arbitrary point + PromptPointResult prPtRes = m_ed.GetPoint("\nEnter a point"); + if (prPtRes.Status != PromptStatus.OK) + return; + + bool allowExtend = false; + if (Utils.AcadUi.PromptYesNo("\nExtend curve?", allowExtend, out allowExtend) != PromptStatus.OK) + return; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + Point3d ptOnCurve = curve.GetClosestPointTo(Utils.Db.UcsToWcs(prPtRes.Value), allowExtend); + + m_ed.WriteMessage(string.Format("\nCLOSEST PT: {0}", Utils.AcadUi.PtToStr(ptOnCurve))); + Utils.Db.MakePointEnt(Utils.Db.UcsToWcs(prPtRes.Value), 4, tr, m_db); + Utils.Db.MakePointEnt(ptOnCurve, 3, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + ClosestPointToDirection() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + // let user pick an arbitrary point + PromptPointResult prPtRes = m_ed.GetPoint("\nEnter a point"); + if (prPtRes.Status != PromptStatus.OK) + return; + + // find out which direction they want to go + PromptPointOptions prDirPtOpts = new PromptPointOptions("\nDirection"); + prDirPtOpts.BasePoint = prPtRes.Value; + prDirPtOpts.UseBasePoint = true; + + PromptPointResult prDirPtRes = m_ed.GetPoint(prDirPtOpts); + if (prDirPtRes.Status != PromptStatus.OK) + return; + + Vector3d dirVec = Utils.Db.UcsToWcs(prPtRes.Value - prDirPtRes.Value); + if (dirVec.IsZeroLength()) + { + m_ed.WriteMessage("\nDirection vector is zero-length!"); + return; + } + + bool allowExtend = false; + if (Utils.AcadUi.PromptYesNo("\nExtend curve?", allowExtend, out allowExtend) != PromptStatus.OK) + return; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + Point3d ptOnCurve = curve.GetClosestPointTo(Utils.Db.UcsToWcs(prPtRes.Value), dirVec, allowExtend); + + m_ed.WriteMessage(string.Format("\nCLOSEST PT: {0}", Utils.AcadUi.PtToStr(ptOnCurve))); + Utils.Db.MakePointEnt(Utils.Db.UcsToWcs(prPtRes.Value), 4, tr, m_db); + Utils.Db.MakePointEnt(ptOnCurve, 3, tr, m_db); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + OffsetCurves() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + // first prompt for offset distance (can be negative to go other direction) + PromptDoubleResult res = m_ed.GetDistance("\nOffset distance"); + if (res.Status != PromptStatus.OK) + { + return; + } + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + DBObjectCollection newCurves = curve.GetOffsetCurves(res.Value); + // bump the color index of each curve returned so we can see how + // many there are. + int colorIndex = 1; + foreach (Entity ent in newCurves) + ent.ColorIndex = colorIndex++; + + Utils.SymTbl.AddToCurrentSpace(newCurves, m_db, tr); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + /// + /// TBD: this one doesn't seem to work too well (or else I don't understand it) + /// + public void + OffsetCurvesGivenPlaneNormal() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + // first prompt for offset distance (can be negative to go other direction) + PromptDoubleResult res = m_ed.GetDistance("\nOffset distance"); + if (res.Status != PromptStatus.OK) + { + return; + } + + Vector3d planeVec = new Vector3d(1.0, 1.0, 1.0); // arbitrary plane normal + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + DBObjectCollection newCurves = curve.GetOffsetCurvesGivenPlaneNormal(planeVec, res.Value); + // bump the color index of each curve returned so we can see how + // many there are. + int colorIndex = 1; + foreach (Entity ent in newCurves) + ent.ColorIndex = colorIndex++; + + Utils.SymTbl.AddToCurrentSpace(newCurves, m_db, tr); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + /// + /// To see how this one works, do the following: + /// 1) Draw curves in WCS + /// 2) Create a new UCS with X, Y, and Z axes rotated 45 degrees each + /// 3) Go to PLAN view in the new UCS + /// 4) Run the test. You should see red curves overlap the originals + /// 5) Do command UCS,World + /// 6) Go to PLAN view in the now established WCS + /// 7) The red projected curves should now be in a totally different plane + /// + + public void + ProjectedCurve() + { + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + m_db = Utils.Db.GetCurDwg(); + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + m_ed.WriteMessage("\nProjecting onto current UCS plane with VIEWDIR as projection direction..."); + + Plane planeToProjectOn = Utils.Db.GetUcsPlane(m_db); + Point3d tmpPt = (Point3d)AcadApp.GetSystemVariable("viewdir"); + Vector3d projDir = Utils.Db.UcsToWcs(tmpPt.GetAsVector()); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + Curve projCurve = curve.GetProjectedCurve(planeToProjectOn, projDir); + projCurve.ColorIndex = 1; + + Utils.SymTbl.AddToCurrentSpace(projCurve, m_db, tr); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + /// + /// See notes for ProjecteCurve() for how to demonstrate this. + /// + + public void + OrthoProjectedCurve() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + Plane planeToProjectOn = Utils.Db.GetUcsPlane(m_db); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + Curve projCurve = curve.GetOrthoProjectedCurve(planeToProjectOn); + projCurve.ColorIndex = 1; + + Utils.SymTbl.AddToCurrentSpace(projCurve, m_db, tr); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + SplitCurvesParams() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + PrintParamInterval(curve); + + DoubleCollection paramVals; + if (GetCurveParams(out paramVals) == false) + return; + + try + { + DBObjectCollection splitCurves = curve.GetSplitCurves(paramVals); + + int colorIndex = 1; + foreach (Entity ent in splitCurves) + ent.ColorIndex = colorIndex++; + + Utils.SymTbl.AddToCurrentSpace(splitCurves, m_db, tr); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + SplitCurvesPoints() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + Point3dCollection pts; + if (GetCurvePoints(curve, out pts) == false) + return; + + try + { + DBObjectCollection splitCurves = curve.GetSplitCurves(pts); + + int colorIndex = 1; + foreach (Entity ent in splitCurves) + ent.ColorIndex = colorIndex++; + + Utils.SymTbl.AddToCurrentSpace(splitCurves, m_db, tr); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nERROR: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + + tr.Commit(); + } + } + } + + public void + Spline() + { + m_db = Utils.Db.GetCurDwg(); + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + ObjectId curveId = ObjectId.Null; + Point3d pickPt = new Point3d(); + + while (GetCurveEntity(ref curveId, ref pickPt)) + { + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + Curve curve = (Curve)tr.GetObject(curveId, OpenMode.ForRead); + + try + { + Spline newSpline = curve.Spline; + newSpline.ColorIndex = 1; + Utils.SymTbl.AddToCurrentSpace(newSpline, m_db, tr); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + if (e.ErrorStatus == Autodesk.AutoCAD.Runtime.ErrorStatus.NotApplicable) + m_ed.WriteMessage("\nSPLINE: Not Applicable"); + else + throw e; + } + + tr.Commit(); + } + } + } + + #endregion Tests + + #region Utils + + private bool + GetCurveEntity(ref ObjectId curveId, ref Point3d pickPt) + { + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptEntityOptions prCurveOpts = new PromptEntityOptions("\nSelect a Curve"); + prCurveOpts.SetRejectMessage("\nSelected entity must be of type Curve."); + prCurveOpts.AddAllowedClass(typeof(Curve), false); + + PromptEntityResult prCurveRes = ed.GetEntity(prCurveOpts); + if (prCurveRes.Status == PromptStatus.OK) + { + curveId = prCurveRes.ObjectId; + pickPt = prCurveRes.PickedPoint; + return true; + } + else + { + curveId = ObjectId.Null; + pickPt = Point3d.Origin; + return false; + } + } + + /// + /// Print the curve's param interval so that the user knows the range of valid values to input. + /// + /// The curve in question + + public void + PrintParamInterval(Curve curve) + { + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + try + { + double startParam = curve.StartParam; + double endParam = curve.EndParam; + + m_ed.WriteMessage("\nParam interval (as double): ({0} --> {1})", + Converter.DistanceToString(startParam), + Converter.DistanceToString(endParam)); + m_ed.WriteMessage("\nParam interval (as angle): ({0} --> {1})", + Converter.AngleToString(startParam), + Converter.AngleToString(endParam)); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + if (e.ErrorStatus == Autodesk.AutoCAD.Runtime.ErrorStatus.NotApplicable) + m_ed.WriteMessage("\nParam Interval: Not Applicable"); + else + throw e; + } + } + + private bool + GetCurveParam(out double param) + { + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + param = 0.0; + + bool asAngles; + if (Utils.AcadUi.PromptYesNo("\nInput param as angle", true, out asAngles) != PromptStatus.OK) + return false; + + if (asAngles) + { + PromptDoubleResult res = m_ed.GetAngle("\nParam angle of curve"); + if (res.Status == PromptStatus.OK) + { + param = res.Value; + return true; + } + } + else + { + PromptDoubleResult res = m_ed.GetDistance("\nParam of curve"); + if (res.Status == PromptStatus.OK) + { + param = res.Value; + return true; + } + } + return false; + } + + private bool + GetCurveParams(out DoubleCollection paramVals) + { + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + paramVals = new DoubleCollection(); + + bool asAngles; + if (Utils.AcadUi.PromptYesNo("\nInput params as angle", true, out asAngles) != PromptStatus.OK) + return false; + + if (asAngles) + { + PromptAngleOptions prAngOpts = new PromptAngleOptions("\nParam angle of curve"); + prAngOpts.AllowNone = true; + + while (true) + { + PromptDoubleResult prRes = m_ed.GetAngle(prAngOpts); + if (prRes.Status == PromptStatus.OK) + paramVals.Add(prRes.Value); + else if (prRes.Status == PromptStatus.None) + return true; // done inputting values + else + return false; // canceled + } + } + else + { + PromptDistanceOptions prDistOpts = new PromptDistanceOptions("\nParam of curve"); + prDistOpts.AllowNone = true; + + while (true) + { + PromptDoubleResult prRes = m_ed.GetDistance(prDistOpts); + if (prRes.Status == PromptStatus.OK) + paramVals.Add(prRes.Value); + else if (prRes.Status == PromptStatus.None) + return true; // done inputting values + else + return false; // canceled + } + } + } + + private bool + GetCurvePoints(Curve curve, out Point3dCollection pts) + { + m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + pts = new Point3dCollection(); + + PromptPointOptions prPtOpts = new PromptPointOptions("\nPoint on curve"); + prPtOpts.AllowNone = true; + + while (true) + { + PromptPointResult prRes = m_ed.GetPoint(prPtOpts); + if (prRes.Status == PromptStatus.OK) + { + try + { + Point3d ptOnCurve = curve.GetClosestPointTo(Utils.Db.UcsToWcs(prRes.Value), false); + pts.Add(ptOnCurve); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) + { + m_ed.WriteMessage("\nClosest point not on curve: {0}", ((ErrorStatus)e.ErrorStatus).ToString()); + } + } + else if (prRes.Status == PromptStatus.None) + return true; // done inputting values + else + return false; // canceled + } + } + + #endregion Utils + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/QueryEntTests.cs b/MgdDbgLibrary/ObjTests/QueryEntTests.cs new file mode 100644 index 0000000..15fa346 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/QueryEntTests.cs @@ -0,0 +1,435 @@ +// +// (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.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using MgdDbg.CompBuilder; +using MgdDbg.ObjTests.TestFramework; +using System; +using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; + +using AcDb = Autodesk.AutoCAD.DatabaseServices; + +namespace MgdDbg.ObjTests +{ + /// + /// Summary description for QueryEntTests. + /// + public class QueryEntTests : MgdDbgTestFuncs + { + private Database m_db = null; + + public + QueryEntTests() + { + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get Stretch Points", "Add Point entities where stretch points are", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(StretchPoints), MgdDbgTestFuncInfo.TestType.Query)); + //m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get Grip Points", "Add Point entities where grip points are", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(GripPoints), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Get Geometry Extents", "Add a block of Faces equal to extents cube", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(Extents), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Intersect With", "Add Point entities where intersection points are", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(IntersectWith), MgdDbgTestFuncInfo.TestType.Query)); + m_testFrameworkFuncs.Add(new MgdDbgTestFuncInfo("Bounding Box Intersect With", "Add Point entities where intersection points are", typeof(Entity), new MgdDbgTestFuncInfo.TestFunc(BoundingBoxIntersectWith), MgdDbgTestFuncInfo.TestType.Query)); + } + + #region Tests + + /// + /// Add Point entities where stretch points are + /// + public void + StretchPoints() + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Point3dCollection pts = new Point3dCollection(); + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + while (true) + { + PromptEntityResult prEntRes = ed.GetEntity("\nSelect entity to show stretch points"); + if (prEntRes.Status != PromptStatus.OK) + break; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + AcDb.Entity ent = (AcDb.Entity)tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead); + + pts.Clear(); // reset to no points each time through loop + ent.GetStretchPoints(pts); + + if (pts.Count == 0) + Utils.AcadUi.PrintToCmdLine("\nNo stretch points specified!"); + else + { + for (int i = 0; i < pts.Count; i++) + { + Utils.AcadUi.PrintToCmdLine(string.Format("\nSTRETCH[{0:d}]: {1}", i, Utils.AcadUi.PtToStr(pts[i]))); + MakePointEnt(pts[i], 1, tr); + } + } + + tr.Commit(); + } + } + } + + /// + /// Add Point entities where grip points are + /// + public void + GripPoints() + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Point3dCollection pts = new Point3dCollection(); + IntegerCollection osnapModes = new IntegerCollection(); + IntegerCollection geomIds = new IntegerCollection(); + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + while (true) + { + PromptEntityResult prEntRes = ed.GetEntity("\nSelect entity to show grip points"); + if (prEntRes.Status != PromptStatus.OK) + break; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + AcDb.Entity ent = (AcDb.Entity)tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead); + + pts.Clear(); // reset to no points each time through loop + osnapModes.Clear(); + geomIds.Clear(); + + //TBD: Throws a "Value cannot be null exception" + ent.GetGripPoints(pts, osnapModes, geomIds); + + if (pts.Count == 0) + Utils.AcadUi.PrintToCmdLine("\nNo grip points specified!"); + else + { + for (int i = 0; i < pts.Count; i++) + { + Utils.AcadUi.PrintToCmdLine(string.Format("\nGRIP[{0:d}]: {1}", i, Utils.AcadUi.PtToStr(pts[i]))); + MakePointEnt(pts[i], 2, tr); + } + } + + if (osnapModes.Count == 0) + Utils.AcadUi.PrintToCmdLine("\nNo osnap modes specified!"); + else + { + for (int i = 0; i < osnapModes.Count; i++) + { + Utils.AcadUi.PrintToCmdLine(string.Format("\nOSNAP MODE[{0:d}]: {1}", i, osnapModes[i])); + } + } + + if (geomIds.Count == 0) + Utils.AcadUi.PrintToCmdLine("\nNo geometry IDs specified!"); + else + { + for (int i = 0; i < geomIds.Count; i++) + { + Utils.AcadUi.PrintToCmdLine(string.Format("\nGEOM ID[{0:d}]: {1}", i, geomIds[i].ToString())); + } + } + + tr.Commit(); + } + } + } + + /// + /// Add a block of Faces equal to extents cube + /// + public void + Extents() + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + while (true) + { + PromptEntityResult prEntRes = ed.GetEntity("\nSelect entity to show extents"); + if (prEntRes.Status != PromptStatus.OK) + break; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + AcDb.Entity ent = (AcDb.Entity)tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead); + + Extents3d ext = ent.GeometricExtents; + Point3d centerPt = Utils.Ge.Midpoint(ext.MinPoint, ext.MaxPoint); + + Utils.AcadUi.PrintToCmdLine(string.Format("\nEXTMIN: {0}", Utils.AcadUi.PtToStr(ext.MinPoint))); + Utils.AcadUi.PrintToCmdLine(string.Format("\nEXTMAX: {0}", Utils.AcadUi.PtToStr(ext.MaxPoint))); + Utils.AcadUi.PrintToCmdLine(string.Format("\nCENTER PT: {0}", Utils.AcadUi.PtToStr(centerPt))); + + tr.Commit(); + + MakeExtentsBlock(ext); + } + } + } + + /// + /// + /// + /// + public void + MakeExtentsBlock(Extents3d ext) + { + m_db = Utils.Db.GetCurDwg(); + + double deltaX = Math.Abs(ext.MaxPoint.X - ext.MinPoint.X); + double deltaY = Math.Abs(ext.MaxPoint.Y - ext.MinPoint.Y); + double deltaZ = Math.Abs(ext.MaxPoint.Z - ext.MinPoint.Z); + + Point3d[] pts = new Point3d[8]; + + pts[0] = ext.MinPoint; + pts[6] = ext.MaxPoint; + + // make bottom face + pts[1] = new Point3d(pts[0].X + deltaX, pts[0].Y, pts[0].Z); + pts[2] = new Point3d(pts[1].X, pts[1].Y + deltaY, pts[1].Z); + pts[3] = new Point3d(pts[0].X, pts[0].Y + deltaY, pts[0].Z); + + // project up by Z + pts[4] = new Point3d(pts[0].X, pts[0].Y, pts[0].Z + deltaZ); + pts[5] = new Point3d(pts[1].X, pts[1].Y, pts[1].Z + deltaZ); + pts[7] = new Point3d(pts[3].X, pts[3].Y, pts[3].Z + deltaZ); + + Vector3d offset = ext.MinPoint.GetAsVector(); + + // move points so that they are centered at WCS origin + // for block creation. Express everything in WCS since + // that is what Entity.Extents works in. + for (int i = 0; i < pts.Length; i++) + { + pts[i] -= offset; + } + + DBObjectCollection faceEnts = new DBObjectCollection(); + faceEnts.Add(new Face(pts[0], pts[1], pts[2], pts[3], true, true, true, true)); // bottom face + faceEnts.Add(new Face(pts[4], pts[5], pts[6], pts[7], true, true, true, true)); // top face + faceEnts.Add(new Face(pts[0], pts[1], pts[5], pts[4], true, true, true, true)); // front face + faceEnts.Add(new Face(pts[1], pts[2], pts[6], pts[5], true, true, true, true)); // right side face + faceEnts.Add(new Face(pts[2], pts[3], pts[7], pts[6], true, true, true, true)); // back side face + faceEnts.Add(new Face(pts[3], pts[0], pts[4], pts[7], true, true, true, true)); // left side face + + CompBldrAnonBlkDef compBldr = new CompBldrAnonBlkDef(m_db); + compBldr.Start(); + + foreach (Entity ent in faceEnts) + { + compBldr.SetToDefaultProps(ent); + compBldr.AddToDb(ent); + } + + compBldr.Commit(); + + BlockReference blkRef = new BlockReference(ext.MinPoint, compBldr.BlockDefId); + blkRef.ColorIndex = 4; + Utils.SymTbl.AddToCurrentSpaceAndClose(blkRef, compBldr.Database); + } + + /// + /// Add Point entities where intersection points are + /// + public void + IntersectWith() + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + // get intersection type from user + PromptKeywordOptions prIntType = new PromptKeywordOptions("\nExtend objects"); + prIntType.Keywords.Add("None"); + prIntType.Keywords.Add("First"); + prIntType.Keywords.Add("Second"); + prIntType.Keywords.Add("Both"); + + PromptResult prIntTypeRes = ed.GetKeywords(prIntType); + if (prIntTypeRes.Status != PromptStatus.OK) + return; + + //Intersect intType = Intersect.ExtendBoth; + //if (prIntTypeRes.StringResult == "None") + // intType = Intersect.OnBothOperands; + //else if (prIntTypeRes.StringResult == "First") + // intType = Intersect.ExtendThis; + //else if (prIntTypeRes.StringResult == "Second") + // intType = Intersect.ExtendArgument; + //else + // intType = Intersect.ExtendBoth; + + PromptEntityOptions prEnt1 = new PromptEntityOptions("\nSelect first entity"); + PromptEntityOptions prEnt2 = new PromptEntityOptions("\nSelect intersecting entity"); + Point3dCollection pts = new Point3dCollection(); + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + while (true) + { + PromptEntityResult prEnt1Res = ed.GetEntity(prEnt1); + if (prEnt1Res.Status != PromptStatus.OK) + return; + + PromptEntityResult prEnt2Res = ed.GetEntity(prEnt2); + if (prEnt2Res.Status != PromptStatus.OK) + return; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + AcDb.Entity ent1 = (AcDb.Entity)tr.GetObject(prEnt1Res.ObjectId, OpenMode.ForRead); + AcDb.Entity ent2 = (AcDb.Entity)tr.GetObject(prEnt2Res.ObjectId, OpenMode.ForRead); + + pts.Clear(); + //ent1.IntersectWith(ent2, intType, pts, 0, 0); // TBD: Fix JMA + if (pts.Count == 0) + Utils.AcadUi.PrintToCmdLine("\nObjects do not intersect!"); + else + { + for (int i = 0; i < pts.Count; i++) + { + Utils.AcadUi.PrintToCmdLine(string.Format("\nINTERSECT PT: {0}", Utils.AcadUi.PtToStr(pts[i]))); + MakePointEnt(pts[i], 3, tr); + } + } + + tr.Commit(); + } + } + } + + /// + /// Add Point entities where intersection points are + /// + public void + BoundingBoxIntersectWith() + { + m_db = Utils.Db.GetCurDwg(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + // get intersection type from user + PromptKeywordOptions prIntType = new PromptKeywordOptions("\nExtend objects"); + prIntType.Keywords.Add("None"); + prIntType.Keywords.Add("First"); + prIntType.Keywords.Add("Second"); + prIntType.Keywords.Add("Both"); + + PromptResult prIntTypeRes = ed.GetKeywords(prIntType); + if (prIntTypeRes.Status != PromptStatus.OK) + return; + + //Intersect intType = Intersect.ExtendBoth; + //if (prIntTypeRes.StringResult == "None") + // intType = Intersect.OnBothOperands; + //else if (prIntTypeRes.StringResult == "First") + // intType = Intersect.ExtendThis; + //else if (prIntTypeRes.StringResult == "Second") + // intType = Intersect.ExtendArgument; + //else + // intType = Intersect.ExtendBoth; + + PromptEntityOptions prEnt1 = new PromptEntityOptions("\nSelect first entity"); + PromptEntityOptions prEnt2 = new PromptEntityOptions("\nSelect intersecting entity"); + Point3dCollection pts = new Point3dCollection(); + + Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; + + while (true) + { + PromptEntityResult prEnt1Res = ed.GetEntity(prEnt1); + if (prEnt1Res.Status != PromptStatus.OK) + return; + + PromptEntityResult prEnt2Res = ed.GetEntity(prEnt2); + if (prEnt2Res.Status != PromptStatus.OK) + return; + + using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) + { + AcDb.Entity ent1 = (AcDb.Entity)tr.GetObject(prEnt1Res.ObjectId, OpenMode.ForRead); + AcDb.Entity ent2 = (AcDb.Entity)tr.GetObject(prEnt2Res.ObjectId, OpenMode.ForRead); + + MakeExtentsBlock(ent1.GeometricExtents); + + pts.Clear(); + //ent1.BoundingBoxIntersectWith(ent2, intType, pts, 0, 0); // TBD: Fix JMA + if (pts.Count == 0) + Utils.AcadUi.PrintToCmdLine("\nObjects do not intersect!"); + else + { + for (int i = 0; i < pts.Count; i++) + { + Utils.AcadUi.PrintToCmdLine(string.Format("\nINTERSECT PT: {0}", Utils.AcadUi.PtToStr(pts[i]))); + MakePointEnt(pts[i], 3, tr); + } + } + + tr.Commit(); + } + } + } + + #endregion Tests + + #region Utils + + /// + /// + /// + /// + /// + /// + private void + MakePointEnt(Point3d pt, int colorIndex, Transaction tr) + { + m_db = Utils.Db.GetCurDwg(); + + short mode = (short)AcadApp.GetSystemVariable("pdmode"); + if (mode == 0) + AcadApp.SetSystemVariable("pdmode", 99); + + using (DBPoint dbPt = new DBPoint(Utils.Db.WcsToUcs(pt))) + { + dbPt.ColorIndex = colorIndex; + Utils.Db.TransformToWcs(dbPt, m_db); + Utils.SymTbl.AddToCurrentSpace(dbPt, m_db, tr); + } + } + + #endregion Utils + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestForm.cs b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestForm.cs new file mode 100644 index 0000000..04ba7ed --- /dev/null +++ b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestForm.cs @@ -0,0 +1,766 @@ +// +// (C) Copyright 2005 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 System; +using System.Collections; +using System.Diagnostics; +using System.Windows.Forms; + +namespace MgdDbg.ObjTests.TestFramework +{ + /// + /// This is a generic Test "Shell" that allows you to easily add new test functions and organize + /// them without much effort. The Tests are divided into two basic categories, those that are + /// organized by class hierarchy (e.g., this test applies to all objects at this level of the + /// class hierarchy), and Categorized tests (e.g., this test falls into the Category of "Data Extraction"). + /// The test funcs are collected and sorted into buckets that are then displayed in the correct + /// location in the tree. + /// + + public class TestForm : System.Windows.Forms.Form + { + private enum ImageIconList + { // indicies of images to use in the tree control + Test = 0, + Category = 1, + Class = 2, + }; + + private System.Windows.Forms.Label m_txtDesc; + private System.Windows.Forms.Button m_bnOk; + private System.Windows.Forms.Button m_bnCancel; + private System.Windows.Forms.ImageList m_imageList; + + private System.ComponentModel.IContainer components; + + private ArrayList m_treeNodes = new ArrayList(); + private ArrayList m_classTypes = new ArrayList(); + private ArrayList m_funcBuckets = new ArrayList(); // The original list of TestFuncs sorted into their Tree location + private ArrayList m_curFuncBucket = new ArrayList(); + private ArrayList m_placedClasses = new ArrayList(); + private ArrayList m_treeItems = new ArrayList(); + + private SplitContainer m_splitContainer; + private ListView m_lvData; + private ColumnHeader m_testName; + private ColumnHeader m_categoryName; + private ColumnHeader m_type; + private ColumnHeader m_description; + + private MgdDbgTestFuncInfo m_pickedTestFunc = null; + //private Rvt.Utils.Controls.TreeViewWithSearch m_treeViewWithSearch; + + private MgdDbg.Utils.ListViewColumnSorter m_colSorter; + private TreeView m_treeView; + private CheckBox m_checkBxBaseTestsInclude; + + // tree node to remember last selected node + private static TreeNode m_memoryNode = null; + + // list view item key to remember last selected test + private static string m_itemKey = string.Empty; + + // to remember last option + private static bool m_includeBaseTests = true; + + /// + /// Generic dialog that will display and organize a set of test functions + /// + /// Array of TestFuncInfo objects + + public + TestForm(ArrayList testFuncs) + { + InitializeComponent(); + + // Set the column sorter for the list view + m_colSorter = new MgdDbg.Utils.ListViewColumnSorter(); + m_lvData.ListViewItemSorter = m_colSorter; + + m_treeView.BeginUpdate(); + + // sort the TestFuncInfo objects into buckets + foreach (MgdDbgTestFuncs testFuncGroup in testFuncs) + { + foreach (MgdDbgTestFuncInfo testFuncInfo in testFuncGroup.m_testFrameworkFuncs) + { + AddFuncToBucket(testFuncInfo); + } + } + + BuildTree(); + + m_treeView.ExpandAll(); + m_treeView.EndUpdate(); + + m_treeView.AfterSelect += new TreeViewEventHandler(TreeView_AfterSelect); + + RestoreDialogState(); + } + + /// + /// Remember the last position selected in the tree + /// + + private void + RestoreDialogState() + { + // if we can remember the last selected node then select it + if (m_memoryNode != null) + { + TreeNode[] foundNodes = m_treeView.Nodes.Find(m_memoryNode.Name, true); + if (foundNodes.Length != 0) + m_treeView.SelectedNode = foundNodes[0]; + } + + // set to last selected option + m_checkBxBaseTestsInclude.Checked = m_includeBaseTests; + } + + /// + /// Clean up any resources being used. + /// + protected override void + Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TestForm)); + this.m_imageList = new System.Windows.Forms.ImageList(this.components); + this.m_txtDesc = new System.Windows.Forms.Label(); + this.m_bnOk = new System.Windows.Forms.Button(); + this.m_bnCancel = new System.Windows.Forms.Button(); + this.m_splitContainer = new System.Windows.Forms.SplitContainer(); + this.m_treeView = new System.Windows.Forms.TreeView(); + this.m_lvData = new System.Windows.Forms.ListView(); + this.m_testName = new System.Windows.Forms.ColumnHeader(); + this.m_categoryName = new System.Windows.Forms.ColumnHeader(); + this.m_type = new System.Windows.Forms.ColumnHeader(); + this.m_description = new System.Windows.Forms.ColumnHeader(); + this.m_checkBxBaseTestsInclude = new System.Windows.Forms.CheckBox(); + this.m_splitContainer.Panel1.SuspendLayout(); + this.m_splitContainer.Panel2.SuspendLayout(); + this.m_splitContainer.SuspendLayout(); + this.SuspendLayout(); + // + // m_imageList + // + this.m_imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_imageList.ImageStream"))); + this.m_imageList.TransparentColor = System.Drawing.Color.Transparent; + this.m_imageList.Images.SetKeyName(0, "ImageTreeTest.bmp"); + this.m_imageList.Images.SetKeyName(1, "ImageTreeCategory.bmp"); + this.m_imageList.Images.SetKeyName(2, "ImageTreeClass.bmp"); + // + // m_txtDesc + // + this.m_txtDesc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_txtDesc.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.m_txtDesc.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_txtDesc.Location = new System.Drawing.Point(292, 408); + this.m_txtDesc.Name = "m_txtDesc"; + this.m_txtDesc.Size = new System.Drawing.Size(621, 23); + this.m_txtDesc.TabIndex = 1; + // + // m_bnOk + // + this.m_bnOk.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.m_bnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.m_bnOk.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_bnOk.Location = new System.Drawing.Point(420, 447); + this.m_bnOk.Name = "m_bnOk"; + this.m_bnOk.Size = new System.Drawing.Size(75, 23); + this.m_bnOk.TabIndex = 2; + this.m_bnOk.Text = "OK"; + // + // m_bnCancel + // + this.m_bnCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.m_bnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.m_bnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_bnCancel.Location = new System.Drawing.Point(511, 447); + this.m_bnCancel.Name = "m_bnCancel"; + this.m_bnCancel.Size = new System.Drawing.Size(75, 23); + this.m_bnCancel.TabIndex = 3; + this.m_bnCancel.Text = "Cancel"; + // + // m_splitContainer + // + this.m_splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_splitContainer.Location = new System.Drawing.Point(24, 12); + this.m_splitContainer.Name = "m_splitContainer"; + // + // m_splitContainer.Panel1 + // + this.m_splitContainer.Panel1.Controls.Add(this.m_treeView); + // + // m_splitContainer.Panel2 + // + this.m_splitContainer.Panel2.Controls.Add(this.m_lvData); + this.m_splitContainer.Size = new System.Drawing.Size(897, 352); + this.m_splitContainer.SplitterDistance = 257; + this.m_splitContainer.TabIndex = 4; + // + // m_treeView + // + this.m_treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_treeView.HideSelection = false; + this.m_treeView.ImageIndex = 0; + this.m_treeView.ImageList = this.m_imageList; + this.m_treeView.Location = new System.Drawing.Point(3, 3); + this.m_treeView.Name = "m_treeView"; + this.m_treeView.SelectedImageIndex = 0; + this.m_treeView.ShowNodeToolTips = true; + this.m_treeView.Size = new System.Drawing.Size(251, 346); + this.m_treeView.TabIndex = 0; + // + // m_lvData + // + this.m_lvData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_lvData.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_testName, + this.m_categoryName, + this.m_type, + this.m_description}); + this.m_lvData.FullRowSelect = true; + this.m_lvData.GridLines = true; + this.m_lvData.HideSelection = false; + this.m_lvData.Location = new System.Drawing.Point(-1, 3); + this.m_lvData.Name = "m_lvData"; + this.m_lvData.Size = new System.Drawing.Size(638, 346); + this.m_lvData.TabIndex = 0; + this.m_lvData.UseCompatibleStateImageBehavior = false; + this.m_lvData.View = System.Windows.Forms.View.Details; + this.m_lvData.SelectedIndexChanged += new System.EventHandler(this.ItemSelected); + this.m_lvData.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.OnColumnClick); + // + // m_testName + // + this.m_testName.Text = "Test Name"; + this.m_testName.Width = 180; + // + // m_categoryName + // + this.m_categoryName.Text = "Category/Class"; + this.m_categoryName.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.m_categoryName.Width = 101; + // + // m_type + // + this.m_type.Text = "Type"; + this.m_type.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.m_type.Width = 96; + // + // m_description + // + this.m_description.Text = "Description"; + this.m_description.Width = 367; + // + // m_checkBxBaseTestsInclude + // + this.m_checkBxBaseTestsInclude.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_checkBxBaseTestsInclude.AutoSize = true; + this.m_checkBxBaseTestsInclude.Checked = true; + this.m_checkBxBaseTestsInclude.CheckState = System.Windows.Forms.CheckState.Checked; + this.m_checkBxBaseTestsInclude.Location = new System.Drawing.Point(293, 378); + this.m_checkBxBaseTestsInclude.Name = "m_checkBxBaseTestsInclude"; + this.m_checkBxBaseTestsInclude.Size = new System.Drawing.Size(137, 17); + this.m_checkBxBaseTestsInclude.TabIndex = 6; + this.m_checkBxBaseTestsInclude.Text = "Show Base Class Tests"; + this.m_checkBxBaseTestsInclude.UseVisualStyleBackColor = true; + this.m_checkBxBaseTestsInclude.CheckedChanged += new System.EventHandler(this.OnCheckChanged_IncludeBaseClass); + // + // TestForm + // + this.AcceptButton = this.m_bnOk; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.CancelButton = this.m_bnCancel; + this.ClientSize = new System.Drawing.Size(937, 478); + this.Controls.Add(this.m_checkBxBaseTestsInclude); + this.Controls.Add(this.m_splitContainer); + this.Controls.Add(this.m_bnCancel); + this.Controls.Add(this.m_bnOk); + this.Controls.Add(this.m_txtDesc); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(600, 225); + this.Name = "TestForm"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Tests"; + this.m_splitContainer.Panel1.ResumeLayout(false); + this.m_splitContainer.Panel2.ResumeLayout(false); + this.m_splitContainer.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + } + + #endregion Windows Form Designer generated code + + #region Tree + + /// + /// The functions have been sorted. Walk the list of buckets and add them to the appropriate + /// location in the TreeControl + /// + + private void + BuildTree() + { + TreeNode categoryItem, objHierItem; + + // extablish the two basic roots of the tree + categoryItem = AddTreeItem("Categories", null, null, ImageIconList.Test); + objHierItem = AddTreeItem("Object Hierarchy", null, null, ImageIconList.Test); + + // For the Object Hierarchy section of the tree, we need to add in the root + // type to anchor us (for us, the root only makes sense as APIObject) + System.Type rootType = typeof(Autodesk.AutoCAD.Runtime.RXObject); + + TreeNode rootNode = new TreeNode(rootType.Name); + rootNode.ImageIndex = (int)ImageIconList.Class; + rootNode.SelectedImageIndex = (int)ImageIconList.Class; + rootNode.Tag = rootType.Name; + rootNode.Tag = rootType; + objHierItem.Nodes.Add(rootNode); + + // Add to our cached items of what we've visited + m_classTypes.Add(rootType); + m_treeNodes.Add(rootNode); + m_placedClasses.Add(rootType); + m_treeItems.Add(rootNode); + + // walk through all the TestFunc buckets and place each function + // in the appropriate spot in the tree (sorted by class hierarchy). + // NOTE: they've already been sorted into unique buckets so we + // don't have to look for duplicates. + MgdDbgTestFuncInfo tmpTestFuncInfo = null; + ArrayList tmpBucket = null; + + int len = m_funcBuckets.Count; + for (int i = 0; i < len; i++) + { + tmpBucket = (ArrayList)m_funcBuckets[i]; + tmpTestFuncInfo = (MgdDbgTestFuncInfo)tmpBucket[0]; + + if (tmpTestFuncInfo.IsCategoryBased) + { + // just add the new Category to the tree + AddTreeItem(tmpTestFuncInfo.Category, tmpTestFuncInfo.Category, categoryItem, ImageIconList.Category); + } + else + { + // add an entry for this classType and any intermediate type in the hierarchy + AddNodeForClassType(tmpTestFuncInfo.ClassType); + } + } + } + + /// + /// This is the simple case of adding a root node to the tree or a simple Category-based node. + /// Category and ParentNode can be null. + /// + /// Text to display + /// Display string for the category + /// Parent node to add to + /// Which image to display for the TreeNode + /// The newly added node + + private TreeNode + AddTreeItem(string nodeName, string category, TreeNode parentNode, ImageIconList imageIndex) + { + TreeNode node = new TreeNode(nodeName); + node.Name = nodeName; + node.Tag = category; // can be null + + node.ImageIndex = (int)imageIndex; + node.SelectedImageIndex = (int)imageIndex; + + if (parentNode == null) + m_treeView.Nodes.Add(node); + else + parentNode.Nodes.Add(node); + + return node; + } + + /// + /// Given a classType, add a node to the tree in the correct spot to house + /// the tests from this level of the hierarchy. + /// + /// + /// + + private TreeNode + AddNodeForClassType(System.Type classType) + { + // if we've already placed this guy, then we already have + // a tree node available + int indexFoundAt = m_classTypes.IndexOf(classType); + if (indexFoundAt >= 0) + return (TreeNode)m_treeItems[indexFoundAt]; + + // we haven't placed it, so we need to generate all the nodes + // (if they haven't been yet) between us and the root. First + // collect all the base classes (including ourselves) + System.Type rootType = typeof(Autodesk.AutoCAD.Runtime.RXObject); + ArrayList familyTree = new ArrayList(); + do + { + familyTree.Add(classType); + classType = classType.BaseType; + } while (classType != rootType); + + // now add them to the tree in reverse order + int lastParentIndex = 0; // Root type + TreeNode tmpNode = null; + System.Type tmpType = null; + + int len = familyTree.Count; + for (int i = len - 1; i >= 0; i--) + { // no need to compare against Autodesk.Revit.APIObject + indexFoundAt = m_placedClasses.IndexOf(familyTree[i]); + if (indexFoundAt < 0) + { // we haven't seen this one yet, add it + tmpType = (System.Type)familyTree[i]; + + TreeNode newNode = new TreeNode(tmpType.Name); + tmpNode = (TreeNode)m_treeItems[lastParentIndex]; + newNode.Name = tmpType.Name; + newNode.Tag = tmpType; + newNode.ImageIndex = (int)ImageIconList.Class; + newNode.SelectedImageIndex = (int)ImageIconList.Class; + tmpNode.Nodes.Add(newNode); + + m_placedClasses.Add(tmpType); + m_treeItems.Add(newNode); + + lastParentIndex = m_placedClasses.Count - 1; + } + else + { + lastParentIndex = indexFoundAt; + } + } + return (TreeNode)m_treeItems[lastParentIndex]; + } + + /// + /// + /// + /// + /// + + private void + TreeView_AfterSelect(object sender, TreeViewEventArgs e) + { + ProcessAfterSelect(e.Node); + } + + /// + /// + /// + /// + + void + ProcessAfterSelect(TreeNode treeNode) + { + if (treeNode != null) + { + // remember this node for later + m_memoryNode = treeNode; + + // don't sort initially, just insert according to the hierarchy + m_colSorter.Order = SortOrder.None; + m_txtDesc.Text = string.Empty; + + if (treeNode.Tag == null) + { + m_pickedTestFunc = null; + m_curFuncBucket.Clear(); + } + else + { // see if it is Category based or Hierarchy based + string categoryStr = treeNode.Tag as string; + if (categoryStr == null) // if tag is a class type + GetTests((System.Type)treeNode.Tag, m_checkBxBaseTestsInclude.Checked); + else + GetTests(categoryStr); + } + DisplayCurrent(); + } + } + + /// + /// Recursive function to get tests from a type and its base types + /// + /// the type to get tests from + /// switch to turn ON for including base classes + + private void + GetTests(Type type, bool includeBaseType) + { + if (type == null) + return; + + foreach (ArrayList tmpBucket in m_funcBuckets) + { + foreach (MgdDbgTestFuncInfo tempInfo in tmpBucket) + { + if (tempInfo.IsCategoryBased == false) + { + if (tempInfo.ClassType.FullName == type.FullName) + { + // base classes should appear before derived, + // so manipulate the order + m_curFuncBucket.Insert(0, tempInfo); + } + } + } + } + + if (includeBaseType) + { + GetTests(type.BaseType, true); + } + } + + /// + /// Walk the list of Function Buckets and collect all the functions in this bucket + /// + /// Category to get tests for + + private void + GetTests(string categoryStr) + { + foreach (ArrayList tmpBucket in m_funcBuckets) + { + foreach (MgdDbgTestFuncInfo tempInfo in tmpBucket) + { + if (tempInfo.IsCategoryBased && (tempInfo.Category == categoryStr)) + { + m_curFuncBucket.Insert(0, tempInfo); + } + } + } + } + + #endregion Tree + + /// + /// Sort the in-coming collection of tests in to like-buckets. + /// + /// the test to find a bucket for + + private void + AddFuncToBucket(MgdDbgTestFuncInfo newTestFuncInfo) + { + MgdDbgTestFuncInfo tempFuncInfo = null; + ArrayList tmpBucket = null; + + // walk the list of buckets. If we see one already there that we belong + // to, just add ourselves. If not, then add a new bucket with the passed + // in testFuncInfo as the first member. + int len = m_funcBuckets.Count; + for (int i = 0; i < len; i++) + { + tmpBucket = (ArrayList)m_funcBuckets[i]; + tempFuncInfo = (MgdDbgTestFuncInfo)tmpBucket[0]; // get the first element to compare against + + if (newTestFuncInfo.IsCategoryBased) + { + if ((tempFuncInfo.IsCategoryBased) && (tempFuncInfo.Category.CompareTo(newTestFuncInfo.Category) == 0)) + { + tmpBucket.Add(newTestFuncInfo); + return; + } + } + else + { + if (!(tempFuncInfo.IsCategoryBased) && (tempFuncInfo.ClassType == newTestFuncInfo.ClassType)) + { + tmpBucket.Add(newTestFuncInfo); + return; + } + } + } + + // we didn't find an existing bucket, so make a new one and add this as the first item + ArrayList newBucket = new ArrayList(); + newBucket.Add(newTestFuncInfo); + m_funcBuckets.Add(newBucket); + } + + #region List + + /// + /// User has selected a node in the tree, update the ListCtrl with the appropriate tests + /// + + private void + DisplayCurrent() + { + m_lvData.BeginUpdate(); + m_lvData.Items.Clear(); + + int len = m_curFuncBucket.Count; + for (int i = 0; i < len; i++) + { + MgdDbgTestFuncInfo tmpTestFuncInfo = (MgdDbgTestFuncInfo)m_curFuncBucket[i]; + ListViewItem lvItem = new ListViewItem(tmpTestFuncInfo.Label); + lvItem.Name = tmpTestFuncInfo.Label; + + if (tmpTestFuncInfo.IsCategoryBased) + { + lvItem.SubItems.Add(tmpTestFuncInfo.Category); + } + else + { + lvItem.SubItems.Add(tmpTestFuncInfo.ClassType.Name); + } + lvItem.SubItems.Add(tmpTestFuncInfo.GetTestType().ToString()); + lvItem.SubItems.Add(tmpTestFuncInfo.Description); + lvItem.Tag = tmpTestFuncInfo; + m_lvData.Items.Add(lvItem); + } + m_lvData.EndUpdate(); + + // if we can remember the last selected test then select it + if (m_itemKey.Length != 0) + { + if (m_lvData.Items[m_itemKey] != null) + { + m_lvData.FocusedItem = m_lvData.Items[m_itemKey]; + m_lvData.Items[m_itemKey].Selected = true; + } + } + + // remove all from current bucket for next selection + m_curFuncBucket.Clear(); + } + + /// + /// + /// + /// + /// + + private void + ItemSelected(object sender, System.EventArgs e) + { + Debug.Assert((m_lvData.SelectedItems.Count > 1) == false); + + if (m_lvData.SelectedItems.Count != 0) + { + m_pickedTestFunc = (MgdDbgTestFuncInfo)m_lvData.SelectedItems[0].Tag; + m_txtDesc.Text = m_pickedTestFunc.Description; + + // remember the key of the last selected test + m_itemKey = m_lvData.SelectedItems[0].Name; + } + else + { + m_pickedTestFunc = null; + } + } + + /// + /// Sort the columns according to the column sorter object mandate + /// + /// + /// + + private void + OnColumnClick(object sender, ColumnClickEventArgs e) + { + // Determine if clicked column is already the column that is being sorted. + if (e.Column == m_colSorter.SortColumn) + { + // Reverse the current sort direction for this column. + if (m_colSorter.Order == SortOrder.Ascending) + { + m_colSorter.Order = SortOrder.Descending; + } + else + { + m_colSorter.Order = SortOrder.Ascending; + } + } + else + { + // Set the column number that is to be sorted; default to ascending. + m_colSorter.SortColumn = e.Column; + m_colSorter.Order = SortOrder.Ascending; + } + + // Perform the sort with these new sort options. + m_lvData.Sort(); + } + + #endregion List + + /// + /// Run the Test function + /// + + public void + DoTest() + { + if (m_pickedTestFunc != null) + { + m_pickedTestFunc.RunTest(); + } + } + + private void + OnCheckChanged_IncludeBaseClass(object sender, EventArgs e) + { + ProcessAfterSelect(m_treeView.SelectedNode); + m_includeBaseTests = m_checkBxBaseTestsInclude.Checked; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestForm.resx b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestForm.resx new file mode 100644 index 0000000..b5756b1 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestForm.resx @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADa + AwAAAk1TRnQBSQFMAgEBAwEAAQQBAAEEAQABEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA + AwABEAMAAQEBAAEYBgABDBIAkP8wAJD/MAAkwAz/AYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGA + AgABgAIAAYACAAGAAgABgAIAAYACAAn/JAAM/zAAD8AB/wIAAf8CABLACf8BgAIAAYACAAGAAgABgAIA + AYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAb/JwAJ/zAADMAB/wIAAf8CAAH/ + AgAVwAb/AYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGA + AgABgAIAA/8qAAb/MAAGwAH/AgAB/wIAAf8CAAPAAf8CAAH/AgAVwAP/AYACAAGAAgABgAIABv8BgAIA + A/8BgAIAA/8BgAIAAYACAAP/AYACAAGAAgABgAIAAYAIAAb/BgAJ/wMACf8GAAP/MAAVwAH/AgAB/wIA + FcABgAIAAYACAAP/AYACAAGAAgABgAIAA/8BgAIAA/8BgAIAAYACAAP/AYACAAGAAgABgAIAAYAFAAP/ + BgAD/wMAA/8SAAP/NgAYwAH/AgAVwAGAAgABgAIAA/8BgAIAAYACAAGAAgAJ/wGAAgABgAIAA/8BgAIA + AYACAAGAAgABgAUAA/8MAAP/DAAG/zkAGMAB/wIAAf8CABLAAYACAAGAAgAD/wGAAgABgAIAAYACAAP/ + AYACAAP/AYACAAGAAgAD/wGAAgABgAIAAYACAAGABQAD/wYAA/8DAAP/CQAD/z8AG8AB/wIAAf8CAAzA + A/8BgAIAAYACAAGAAgAG/wGAAgABgAIAA/8BgAIAAYACAAn/AYACAAGAAgABgAgABv8GAAP/DAAJ/wMA + A/8wAB7AAf8CAAH/AgAGwAb/AYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGA + AgABgAIAAYACAAGAAgABgAIAA/8qAAb/MAAnwAn/AYACAAGAAgABgAIAAYACAAGAAgABgAIAAYACAAGA + AgABgAIAAYACAAGAAgABgAIAAYACAAGAAgAG/ycACf8wACTADP8BgAIAAYACAAGAAgABgAIAAYACAAGA + AgABgAIAAYACAAGAAgABgAIAAYACAAGAAgABgAIACf8kAAz/MACQ/zAAkP8wAJD/MAABQgFNAT4HAAE+ + AwABKAMAAUADAAEQAwABAQEAAQEFAAGAFwAD/4EACw== + + + \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestFuncInfo.cs b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestFuncInfo.cs new file mode 100644 index 0000000..6b3a6f2 --- /dev/null +++ b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestFuncInfo.cs @@ -0,0 +1,124 @@ +// +// (C) Copyright 2005 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 System; + +namespace MgdDbg.ObjTests.TestFramework +{ + /// + /// This is a simple package of data about a given Test function. Create new instances + /// of this object and add it to a MgdDbgTestFuncInfo-derived class. + /// + + public class MgdDbgTestFuncInfo + { + public enum TestType + { + Create, + Modify, + Query, + Other + } + + public delegate void TestFunc(); + + private string m_label = null; // label that will appear as the Test name. E.g., "Rotate Elements 45 degrees" + private string m_desc = null; // Description string (if you want something longer than the Label to explain it) + private System.Type m_classType = null; // What point of the class hierarchy does it test (E.g., only Walls or any Element) + private TestFunc m_testFunc = null; // The actual function to call to perform the test + private string m_categoryStr = null; + private Boolean m_isCategoryBased = false; + private TestType m_testType; + + public + MgdDbgTestFuncInfo(string label, string desc, System.Type classType, TestFunc func, TestType tType) + { + m_label = label; + m_desc = desc; + m_classType = classType; + m_isCategoryBased = false; + m_testFunc = func; + m_testType = tType; + } + + public + MgdDbgTestFuncInfo(string label, string desc, string categoryStr, TestFunc func, TestType tType) + { + m_label = label; + m_desc = desc; + m_isCategoryBased = true; + m_categoryStr = categoryStr; + m_testFunc = func; + m_testType = tType; + } + + public string + Label + { + get { return m_label; } + set { m_label = value; } + } + + public string + Description + { + get { return m_desc; } + set { m_desc = value; } + } + + public System.Type + ClassType + { + get { return m_classType; } + set { m_classType = value; } + } + + public void + RunTest() + { + if (m_testFunc != null) + { + m_testFunc(); + } + } + + public string + Category + { + get { return m_categoryStr; } + set { m_categoryStr = value; } + } + + public Boolean + IsCategoryBased + { + get { return m_isCategoryBased; } + set { m_isCategoryBased = value; } + } + + public TestType + GetTestType() + { + return m_testType; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestFuncs.cs b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestFuncs.cs new file mode 100644 index 0000000..3778d1a --- /dev/null +++ b/MgdDbgLibrary/ObjTests/TestFramework/MgdDbgTestFuncs.cs @@ -0,0 +1,64 @@ +// +// (C) Copyright 2005 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 System.Collections; + +namespace MgdDbg.ObjTests.TestFramework +{ + /// + /// Summary description for MgdDbgTestFuncs. + /// + public abstract class MgdDbgTestFuncs + { + // TBD: public for now + public ArrayList m_testFrameworkFuncs = new ArrayList(); + + private static ArrayList m_testFuncs = new ArrayList(); + + // other modules can extend the tests available to the Test Framework UI + // by adding groups of TestFuncs here. Allocate them in your app's constructor + // and register them with this class. In your app's destructor, remove them + // from here and delete them. + public static void + AddTestFuncsToFramework(MgdDbgTestFuncs testFuncs) + { + m_testFuncs.Add(testFuncs); + } + + public static void + RemoveTestFuncsFromFramework(MgdDbgTestFuncs testFuncs) + { + m_testFuncs.Remove(testFuncs); + } + + protected + MgdDbgTestFuncs() + { + } + + public static ArrayList + RegisteredTestFuncs() + { + return m_testFuncs; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Prompts/KeywordsForm.cs b/MgdDbgLibrary/Prompts/KeywordsForm.cs new file mode 100644 index 0000000..f23e171 --- /dev/null +++ b/MgdDbgLibrary/Prompts/KeywordsForm.cs @@ -0,0 +1,230 @@ +// $Header: //Desktop/Source/TestTools/MgdDbg/Prompts/KeywordsForm.cs#1 $ +// $Author: fergusja $ $DateTime: 2007/03/16 08:08:08 $ $Change: 68854 $ +// +// (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.EditorInput; + +namespace MgdDbg.Prompts +{ + /// + /// Summary description for KeywordsForm. + /// + public class KeywordsForm : System.Windows.Forms.Form + { + private System.Windows.Forms.Button m_bnOK; + private System.Windows.Forms.Button m_bnCancel; + private System.Windows.Forms.Label m_label1; + private System.Windows.Forms.TextBox m_ebGlobal; + private System.Windows.Forms.Label m_label2; + private System.Windows.Forms.Label m_label3; + private System.Windows.Forms.TextBox m_ebLocal; + private System.Windows.Forms.TextBox m_ebDisplay; + private System.Windows.Forms.CheckBox m_cbEnabled; + private System.Windows.Forms.CheckBox m_cbVisible; + + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + private Keyword m_kword = null; + + public + KeywordsForm(Keyword kword) + { + m_kword = kword; + + InitializeComponent(); + + m_ebGlobal.Text = kword.GlobalName; + m_ebLocal.Text = kword.LocalName; + m_ebDisplay.Text = kword.DisplayName; + m_cbEnabled.Checked = kword.Enabled; + m_cbVisible.Checked = kword.Visible; + } + + /// + /// Clean up any resources being used. + /// + protected override void + Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.m_bnOK = new System.Windows.Forms.Button(); + this.m_bnCancel = new System.Windows.Forms.Button(); + this.m_label1 = new System.Windows.Forms.Label(); + this.m_ebGlobal = new System.Windows.Forms.TextBox(); + this.m_label2 = new System.Windows.Forms.Label(); + this.m_label3 = new System.Windows.Forms.Label(); + this.m_ebLocal = new System.Windows.Forms.TextBox(); + this.m_ebDisplay = new System.Windows.Forms.TextBox(); + this.m_cbEnabled = new System.Windows.Forms.CheckBox(); + this.m_cbVisible = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // m_bnOK + // + this.m_bnOK.DialogResult = System.Windows.Forms.DialogResult.OK; + this.m_bnOK.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_bnOK.Location = new System.Drawing.Point(83, 128); + this.m_bnOK.Name = "m_bnOK"; + this.m_bnOK.TabIndex = 0; + this.m_bnOK.Text = "OK"; + this.m_bnOK.Click += new System.EventHandler(this.OnOk); + // + // m_bnCancel + // + this.m_bnCancel.CausesValidation = false; + this.m_bnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.m_bnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_bnCancel.Location = new System.Drawing.Point(171, 128); + this.m_bnCancel.Name = "m_bnCancel"; + this.m_bnCancel.TabIndex = 1; + this.m_bnCancel.Text = "Cancel"; + // + // m_label1 + // + this.m_label1.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_label1.Location = new System.Drawing.Point(24, 24); + this.m_label1.Name = "m_label1"; + this.m_label1.Size = new System.Drawing.Size(48, 23); + this.m_label1.TabIndex = 2; + this.m_label1.Text = "Global"; + // + // m_ebGlobal + // + this.m_ebGlobal.Location = new System.Drawing.Point(88, 24); + this.m_ebGlobal.Name = "m_ebGlobal"; + this.m_ebGlobal.Size = new System.Drawing.Size(120, 20); + this.m_ebGlobal.TabIndex = 3; + this.m_ebGlobal.Text = ""; + // + // m_label2 + // + this.m_label2.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_label2.Location = new System.Drawing.Point(24, 48); + this.m_label2.Name = "m_label2"; + this.m_label2.Size = new System.Drawing.Size(48, 23); + this.m_label2.TabIndex = 4; + this.m_label2.Text = "Local"; + // + // m_label3 + // + this.m_label3.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_label3.Location = new System.Drawing.Point(24, 72); + this.m_label3.Name = "m_label3"; + this.m_label3.Size = new System.Drawing.Size(48, 23); + this.m_label3.TabIndex = 5; + this.m_label3.Text = "Display"; + // + // m_ebLocal + // + this.m_ebLocal.Location = new System.Drawing.Point(88, 48); + this.m_ebLocal.Name = "m_ebLocal"; + this.m_ebLocal.Size = new System.Drawing.Size(120, 20); + this.m_ebLocal.TabIndex = 6; + this.m_ebLocal.Text = ""; + // + // m_ebDisplay + // + this.m_ebDisplay.Location = new System.Drawing.Point(88, 72); + this.m_ebDisplay.Name = "m_ebDisplay"; + this.m_ebDisplay.Size = new System.Drawing.Size(120, 20); + this.m_ebDisplay.TabIndex = 7; + this.m_ebDisplay.Text = ""; + // + // m_cbEnabled + // + this.m_cbEnabled.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbEnabled.Location = new System.Drawing.Point(240, 24); + this.m_cbEnabled.Name = "m_cbEnabled"; + this.m_cbEnabled.Size = new System.Drawing.Size(72, 24); + this.m_cbEnabled.TabIndex = 8; + this.m_cbEnabled.Text = "Enabled"; + // + // m_cbVisible + // + this.m_cbVisible.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbVisible.Location = new System.Drawing.Point(240, 48); + this.m_cbVisible.Name = "m_cbVisible"; + this.m_cbVisible.Size = new System.Drawing.Size(64, 24); + this.m_cbVisible.TabIndex = 9; + this.m_cbVisible.Text = "Visible"; + // + // KeywordsForm + // + this.AcceptButton = this.m_bnOK; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.m_bnCancel; + this.ClientSize = new System.Drawing.Size(328, 166); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbVisible, + this.m_cbEnabled, + this.m_ebDisplay, + this.m_ebLocal, + this.m_label3, + this.m_label2, + this.m_ebGlobal, + this.m_label1, + this.m_bnCancel, + this.m_bnOK}); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "KeywordsForm"; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Key Word Settings"; + this.ResumeLayout(false); + } + + #endregion Windows Form Designer generated code + + private void + OnOk(object sender, System.EventArgs e) + { + m_kword.GlobalName = m_ebGlobal.Text; + m_kword.LocalName = m_ebLocal.Text; + m_kword.DisplayName = m_ebDisplay.Text; + m_kword.Enabled = m_cbEnabled.Checked; + m_kword.Visible = m_cbVisible.Checked; + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Prompts/KeywordsForm.resx b/MgdDbgLibrary/Prompts/KeywordsForm.resx new file mode 100644 index 0000000..c8c0d8a --- /dev/null +++ b/MgdDbgLibrary/Prompts/KeywordsForm.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + KeywordsForm + + \ No newline at end of file diff --git a/MgdDbgLibrary/Prompts/PromptTestForm.cs b/MgdDbgLibrary/Prompts/PromptTestForm.cs new file mode 100644 index 0000000..5b94056 --- /dev/null +++ b/MgdDbgLibrary/Prompts/PromptTestForm.cs @@ -0,0 +1,3216 @@ +// $Header: //Desktop/Source/TestTools/MgdDbg/Prompts/PromptTestForm.cs#1 $ +// $Author: fergusja $ $DateTime: 2007/03/16 08:08:08 $ $Change: 68854 $ +// +// (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.EditorInput; +using Autodesk.AutoCAD.Geometry; +using System.Diagnostics; +using System.Windows.Forms; + +namespace MgdDbg.Prompts +{ + /// + /// Summary description for PromptTestForm. + /// + public class PromptTestForm : System.Windows.Forms.Form + { + // Tab page for each type of prompt + private System.Windows.Forms.TabControl m_tcMain; + + private System.Windows.Forms.TabPage m_tpInteger; + private System.Windows.Forms.TabPage m_tpDouble; + private System.Windows.Forms.TabPage m_tpDistance; + private System.Windows.Forms.TabPage m_tpAngle; + private System.Windows.Forms.TabPage m_tpCorner; + private System.Windows.Forms.TabPage m_tpPoint; + private System.Windows.Forms.TabPage m_tpString; + private System.Windows.Forms.TabPage m_tpKeyword; + private System.Windows.Forms.TabPage m_tpEntity; + private System.Windows.Forms.TabPage m_tpNested; + + // controls for each page + private System.Windows.Forms.GroupBox m_gbOptionsInt; + + private System.Windows.Forms.Label m_txtMessage; + private System.Windows.Forms.CheckBox m_cbIntAllowArbitraryInput; + private System.Windows.Forms.CheckBox m_cbIntAllowNone; + private System.Windows.Forms.CheckBox m_cbIntAllowZero; + private System.Windows.Forms.CheckBox m_cbIntAllowNegative; + private System.Windows.Forms.TextBox m_ebIntMessage; + private System.Windows.Forms.CheckBox m_cbIntUseDefault; + private System.Windows.Forms.TextBox m_ebIntDefault; + private System.Windows.Forms.Label m_txtIntDefault; + private System.Windows.Forms.Button m_bnRunTest; + private System.Windows.Forms.Button m_bnCancel; + private System.Windows.Forms.GroupBox m_gbKeywords; + private System.Windows.Forms.ListView m_lvIntKeywords; + private System.Windows.Forms.ColumnHeader m_lvColKwordGlobal; + private System.Windows.Forms.ColumnHeader m_lvColKwordLocal; + private System.Windows.Forms.ColumnHeader m_lvColKwordDisplay; + private System.Windows.Forms.ColumnHeader m_lvColKwordEnabled; + private System.Windows.Forms.ColumnHeader m_lvColKwordVisible; + private System.Windows.Forms.Button m_bnIntKwordHardwire; + private System.Windows.Forms.Button m_bnIntKwordAdd; + private System.Windows.Forms.Button m_bnIntKwordEdit; + private System.Windows.Forms.Button m_bnIntKwordClear; + private System.Windows.Forms.Label m_txtIntKwordDef; + private System.Windows.Forms.TextBox m_ebIntKwordDef; + + private System.Windows.Forms.GroupBox m_gbDblOpts; + private System.Windows.Forms.TextBox m_ebDblDefault; + private System.Windows.Forms.Label m_txtDblDefault; + private System.Windows.Forms.CheckBox m_cbDblUseDefault; + private System.Windows.Forms.CheckBox m_cbDblAllowNegative; + private System.Windows.Forms.CheckBox m_cbDblAllowZero; + private System.Windows.Forms.CheckBox m_cbDblAllowNone; + private System.Windows.Forms.CheckBox m_cbDblAllowArbitraryInput; + private System.Windows.Forms.Label m_txtDblMessage; + private System.Windows.Forms.TextBox m_ebDblMessage; + private System.Windows.Forms.GroupBox m_gbDblKwords; + private System.Windows.Forms.Button m_bnDblKwordClear; + private System.Windows.Forms.Button m_bnDblKwordEdit; + private System.Windows.Forms.Button m_bnDblKwordAdd; + private System.Windows.Forms.ListView m_lvDblKwords; + private System.Windows.Forms.ColumnHeader m_lvColDblGlobal; + private System.Windows.Forms.ColumnHeader m_lvColDblLocal; + private System.Windows.Forms.ColumnHeader m_lvColDblDisplay; + private System.Windows.Forms.ColumnHeader m_lvColDblEnabled; + private System.Windows.Forms.ColumnHeader m_lvColDblVisible; + private System.Windows.Forms.TextBox m_ebDblKwordDef; + private System.Windows.Forms.Label m_txtDblKwordDef; + private System.Windows.Forms.Button m_bnDblKwordHardwire; + + private System.Windows.Forms.GroupBox m_gbDistKwords; + private System.Windows.Forms.Button m_bnDistKwordClear; + private System.Windows.Forms.Button m_bnDistKwordEdit; + private System.Windows.Forms.Button m_bnDistKwordAdd; + private System.Windows.Forms.ListView m_lvDistKwords; + private System.Windows.Forms.ColumnHeader m_lvColDistGlobal; + private System.Windows.Forms.ColumnHeader m_lvColDistLocal; + private System.Windows.Forms.ColumnHeader m_lvColDistDisplay; + private System.Windows.Forms.ColumnHeader m_lvColDistEnabled; + private System.Windows.Forms.ColumnHeader m_lvColDistVisible; + private System.Windows.Forms.GroupBox m_gbDistOptions; + private System.Windows.Forms.TextBox m_ebDistDefault; + private System.Windows.Forms.Label m_txtDistDefault; + private System.Windows.Forms.CheckBox m_cbDistUseDefault; + private System.Windows.Forms.CheckBox m_cbDistAllowNegative; + private System.Windows.Forms.CheckBox m_cbDistAllowZero; + private System.Windows.Forms.CheckBox m_cbDistAllowNone; + private System.Windows.Forms.CheckBox m_cbDistAllowArbitraryInput; + private System.Windows.Forms.CheckBox m_cbDistUseDashedLine; + private System.Windows.Forms.CheckBox m_cbDistUseBasePt; + private System.Windows.Forms.CheckBox m_cbDistOnly2d; + private System.Windows.Forms.Label m_txtDistMessage; + private System.Windows.Forms.TextBox m_ebDistMessage; + private System.Windows.Forms.Button m_bnDistKwordHardwire; + private System.Windows.Forms.TextBox m_ebDistKwordDef; + private System.Windows.Forms.Label m_txtDistKwordDef; + + private System.Windows.Forms.Label m_txtAngMessage; + private System.Windows.Forms.TextBox m_ebAngMessage; + private System.Windows.Forms.GroupBox m_gbAngOptions; + private System.Windows.Forms.ColumnHeader m_lvColAngGlobal; + private System.Windows.Forms.ColumnHeader m_lvColAngLocal; + private System.Windows.Forms.ColumnHeader m_lvColAngDisplay; + private System.Windows.Forms.ColumnHeader m_lvColAngEnabled; + private System.Windows.Forms.ColumnHeader m_lvColAngVisible; + private System.Windows.Forms.GroupBox m_gbAngKwords; + private System.Windows.Forms.Button m_bnAngKwordClear; + private System.Windows.Forms.Button m_bnAngKwordEdit; + private System.Windows.Forms.Button m_bnAngKwordAdd; + private System.Windows.Forms.ListView m_lvAngKwords; + private System.Windows.Forms.CheckBox m_cbAngUseBasePt; + private System.Windows.Forms.CheckBox m_cbAngAllowZero; + private System.Windows.Forms.CheckBox m_cbAngAllowNone; + private System.Windows.Forms.CheckBox m_cbAngAllowArbitraryInput; + private System.Windows.Forms.TextBox m_ebAngDefault; + private System.Windows.Forms.Label m_txtAngDefault; + private System.Windows.Forms.CheckBox m_cbAngUseDashedLine; + private System.Windows.Forms.CheckBox m_cbAngUseDefault; + private System.Windows.Forms.Button m_bnAngKwordHardwire; + private System.Windows.Forms.TextBox m_ebAngKwordDef; + private System.Windows.Forms.Label m_txtAngKwordDef; + + private System.Windows.Forms.GroupBox m_gbCrnOptions; + private System.Windows.Forms.CheckBox m_cbCrnUseDashedLine; + private System.Windows.Forms.CheckBox m_cbCrnAllowNone; + private System.Windows.Forms.CheckBox m_cbCrnAllowArbitraryInput; + private System.Windows.Forms.ColumnHeader m_lvColCrnGlobal; + private System.Windows.Forms.ColumnHeader m_lvColCrnLocal; + private System.Windows.Forms.ColumnHeader m_lvColCrnDisplay; + private System.Windows.Forms.ColumnHeader m_lvColCrnEnabled; + private System.Windows.Forms.ColumnHeader m_lvColCrnVisible; + private System.Windows.Forms.GroupBox m_gbCrnKwords; + private System.Windows.Forms.Button m_bnCrnKwordClear; + private System.Windows.Forms.Button m_bnCrnKwordEdit; + private System.Windows.Forms.Button m_bnCrnKwordAdd; + private System.Windows.Forms.ListView m_lvCrnKwords; + private System.Windows.Forms.TextBox m_ebCrnMessage; + private System.Windows.Forms.Label m_txtCrnMessage; + private System.Windows.Forms.CheckBox m_cbCrnLimitsChecked; + private System.Windows.Forms.Button m_bnCrnKwordHardwire; + private System.Windows.Forms.TextBox m_ebCrnKwordDef; + private System.Windows.Forms.Label m_txtCrnKwordDef; + + private System.Windows.Forms.GroupBox m_gbPtOptions; + private System.Windows.Forms.CheckBox m_cbPtUseDashedLine; + private System.Windows.Forms.CheckBox m_cbPtLimitsChecked; + private System.Windows.Forms.CheckBox m_cbPtAllowNone; + private System.Windows.Forms.CheckBox m_cbPtAllowArbitraryInput; + private System.Windows.Forms.GroupBox m_gbPtKwords; + private System.Windows.Forms.Button m_bnPtKwordClear; + private System.Windows.Forms.Button m_bnPtKwordEdit; + private System.Windows.Forms.Button m_bnPtKwordAdd; + private System.Windows.Forms.ListView m_lvPtKwords; + private System.Windows.Forms.ColumnHeader m_lvColPtGlobal; + private System.Windows.Forms.ColumnHeader m_lvColPtLocal; + private System.Windows.Forms.ColumnHeader m_lvColPtDisplay; + private System.Windows.Forms.ColumnHeader m_lvColPtEnabled; + private System.Windows.Forms.ColumnHeader m_lvColPtVisible; + private System.Windows.Forms.TextBox m_ebPtMessage; + private System.Windows.Forms.Label m_txtPtMessage; + private System.Windows.Forms.CheckBox m_cbPtUseBasePt; + private System.Windows.Forms.Button m_bnPtKwordHardwire; + private System.Windows.Forms.TextBox m_ebPtKwordDef; + private System.Windows.Forms.Label m_txtPtKwordDef; + + private System.Windows.Forms.GroupBox m_gbStrOptions; + private System.Windows.Forms.CheckBox m_cbStrAllowSpaces; + private System.Windows.Forms.TextBox m_ebStrMessage; + private System.Windows.Forms.Label m_txtStrMessage; + + private System.Windows.Forms.GroupBox m_gbKwdOptions; + private System.Windows.Forms.CheckBox m_cbKwdAllowArbitraryInput; + private System.Windows.Forms.CheckBox m_cbKwdAllowNone; + private System.Windows.Forms.GroupBox m_gbKwdKwords; + private System.Windows.Forms.Button m_bnKwdKwordClear; + private System.Windows.Forms.Button m_bnKwdKwordEdit; + private System.Windows.Forms.Button m_bnKwdKwordAdd; + private System.Windows.Forms.ListView m_lvKwdKwords; + private System.Windows.Forms.ColumnHeader m_lvColKwdGlobal; + private System.Windows.Forms.ColumnHeader m_lvColKwdLocal; + private System.Windows.Forms.ColumnHeader m_lvColKwdDisplay; + private System.Windows.Forms.ColumnHeader m_lvColKwdEnabled; + private System.Windows.Forms.ColumnHeader m_lvColKwdVisible; + private System.Windows.Forms.TextBox m_ebKwdMessage; + private System.Windows.Forms.Label m_txtKwdMessage; + private System.Windows.Forms.Button m_bnKwdKwordHardwire; + private System.Windows.Forms.TextBox m_ebKwdKwordDef; + private System.Windows.Forms.Label m_txtKwdKwordDef; + + private System.Windows.Forms.GroupBox m_gbEntOptions; + private System.Windows.Forms.CheckBox m_cbEntAllowNone; + private System.Windows.Forms.TextBox m_ebEntMessage; + private System.Windows.Forms.Label m_txtEntMessage; + private System.Windows.Forms.GroupBox m_gbEntKwords; + private System.Windows.Forms.Button m_bnEntKwordClear; + private System.Windows.Forms.Button m_bnEntKwordEdit; + private System.Windows.Forms.Button m_bnEntKwordAdd; + private System.Windows.Forms.ListView m_lvEntKwords; + private System.Windows.Forms.ColumnHeader m_lvColEntKwordGlobal; + private System.Windows.Forms.ColumnHeader m_lvColEntKwordLocal; + private System.Windows.Forms.ColumnHeader m_lvColEntKwordDisplay; + private System.Windows.Forms.ColumnHeader m_lvColEntKwordEnabled; + private System.Windows.Forms.ColumnHeader m_lvColEntKwordVisible; + private System.Windows.Forms.Button m_bnEntKwordHardwire; + private System.Windows.Forms.TextBox m_ebEntKwordDef; + private System.Windows.Forms.Label m_txtEntKwordDef; + private System.Windows.Forms.GroupBox m_gbEntFilterClasses; + private System.Windows.Forms.CheckBox m_ebEntDoIsATest; + private System.Windows.Forms.CheckBox m_cbEntAllowCircles; + private System.Windows.Forms.CheckBox m_cbEntAllowLines; + private System.Windows.Forms.TextBox m_ebEntRejectMessage; + private System.Windows.Forms.Label m_txtEntRejectMessage; + private System.Windows.Forms.Label m_txtEntSampleFilter; + private System.Windows.Forms.CheckBox m_cbEntAllowCurves; + private System.Windows.Forms.CheckBox m_cbEntAllowLockedLayer; + + private System.Windows.Forms.GroupBox m_gbNentKwords; + private System.Windows.Forms.Button m_bnNentKwordHardwire; + private System.Windows.Forms.TextBox m_ebNentKwordDef; + private System.Windows.Forms.Label m_txtNentKwordDef; + private System.Windows.Forms.Button m_bnNentKwordClear; + private System.Windows.Forms.Button m_bnNentKwordEdit; + private System.Windows.Forms.Button m_bnNentKwordAdd; + private System.Windows.Forms.ListView m_lvNentKwords; + private System.Windows.Forms.ColumnHeader m_lvColNentKwordsGlobal; + private System.Windows.Forms.ColumnHeader m_lvColNentKwordsLocal; + private System.Windows.Forms.ColumnHeader m_lvColNentKwordsDisplay; + private System.Windows.Forms.ColumnHeader m_lvColNentKwordsEnabled; + private System.Windows.Forms.ColumnHeader m_lvColNentKwordsVisible; + private System.Windows.Forms.GroupBox m_gbNentOptions; + private System.Windows.Forms.CheckBox m_cbNentAllowNone; + private System.Windows.Forms.TextBox m_ebNentMessage; + private System.Windows.Forms.Label m_txtNentMessage; + private System.Windows.Forms.CheckBox m_cbNentNonInterPickPt; + + private System.ComponentModel.Container components = null; + + // we're keeping a separate keyword collection for each page. + // Not sure I had to, but I wanted each prompt to be easy and + // quick to test. + private KeywordCollection m_kwordsInt = new KeywordCollection(); + + private KeywordCollection m_kwordsDbl = new KeywordCollection(); + private KeywordCollection m_kwordsDist = new KeywordCollection(); + private KeywordCollection m_kwordsAng = new KeywordCollection(); + private KeywordCollection m_kwordsCrn = new KeywordCollection(); + private KeywordCollection m_kwordsPt = new KeywordCollection(); + private KeywordCollection m_kwordsKwd = new KeywordCollection(); + private KeywordCollection m_kwordsEnt = new KeywordCollection(); + private KeywordCollection m_kwordsNent = new KeywordCollection(); + + public + PromptTestForm() + { + InitializeComponent(); + + // hook up the backing data with controls so that we + // can deal with them generically later when we get + // event notification for the keywords on each page. + m_lvIntKeywords.Tag = m_kwordsInt; + m_bnIntKwordAdd.Tag = m_lvIntKeywords; + m_bnIntKwordEdit.Tag = m_lvIntKeywords; + m_bnIntKwordClear.Tag = m_lvIntKeywords; + m_bnIntKwordHardwire.Tag = m_lvIntKeywords; + + m_lvDblKwords.Tag = m_kwordsDbl; + m_bnDblKwordAdd.Tag = m_lvDblKwords; + m_bnDblKwordEdit.Tag = m_lvDblKwords; + m_bnDblKwordClear.Tag = m_lvDblKwords; + m_bnDblKwordHardwire.Tag = m_lvDblKwords; + + m_lvDistKwords.Tag = m_kwordsDist; + m_bnDistKwordAdd.Tag = m_lvDistKwords; + m_bnDistKwordEdit.Tag = m_lvDistKwords; + m_bnDistKwordClear.Tag = m_lvDistKwords; + m_bnDistKwordHardwire.Tag = m_lvDistKwords; + + m_lvAngKwords.Tag = m_kwordsAng; + m_bnAngKwordAdd.Tag = m_lvAngKwords; + m_bnAngKwordEdit.Tag = m_lvAngKwords; + m_bnAngKwordClear.Tag = m_lvAngKwords; + m_bnAngKwordHardwire.Tag = m_lvAngKwords; + + m_lvCrnKwords.Tag = m_kwordsCrn; + m_bnCrnKwordAdd.Tag = m_lvCrnKwords; + m_bnCrnKwordEdit.Tag = m_lvCrnKwords; + m_bnCrnKwordClear.Tag = m_lvCrnKwords; + m_bnCrnKwordHardwire.Tag = m_lvCrnKwords; + + m_lvPtKwords.Tag = m_kwordsPt; + m_bnPtKwordAdd.Tag = m_lvPtKwords; + m_bnPtKwordEdit.Tag = m_lvPtKwords; + m_bnPtKwordClear.Tag = m_lvPtKwords; + m_bnPtKwordHardwire.Tag = m_lvPtKwords; + + m_lvKwdKwords.Tag = m_kwordsKwd; + m_bnKwdKwordAdd.Tag = m_lvKwdKwords; + m_bnKwdKwordEdit.Tag = m_lvKwdKwords; + m_bnKwdKwordClear.Tag = m_lvKwdKwords; + m_bnKwdKwordHardwire.Tag = m_lvKwdKwords; + + m_lvEntKwords.Tag = m_kwordsEnt; + m_bnEntKwordAdd.Tag = m_lvEntKwords; + m_bnEntKwordEdit.Tag = m_lvEntKwords; + m_bnEntKwordClear.Tag = m_lvEntKwords; + m_bnEntKwordHardwire.Tag = m_lvEntKwords; + + m_lvNentKwords.Tag = m_kwordsNent; + m_bnNentKwordAdd.Tag = m_lvNentKwords; + m_bnNentKwordEdit.Tag = m_lvNentKwords; + m_bnNentKwordClear.Tag = m_lvNentKwords; + m_bnNentKwordHardwire.Tag = m_lvNentKwords; + + // allocate a new PromptOptions and set the initial dialog + // state to these values. This way, we can see what the defaults + // are if you don't change any of the standard settings. + + // PromptInteger + PromptIntegerOptions prOptInt = new PromptIntegerOptions(""); + m_cbIntAllowArbitraryInput.Checked = prOptInt.AllowArbitraryInput; + m_cbIntAllowNone.Checked = prOptInt.AllowNone; + m_cbIntAllowZero.Checked = prOptInt.AllowZero; + m_cbIntAllowNegative.Checked = prOptInt.AllowNegative; + m_cbIntUseDefault.Checked = prOptInt.UseDefaultValue; + m_ebIntDefault.Enabled = prOptInt.UseDefaultValue; + m_ebIntDefault.Text = 0.ToString(); + + // PromptDouble + PromptDoubleOptions prOptDbl = new PromptDoubleOptions(""); + m_cbDblAllowArbitraryInput.Checked = prOptDbl.AllowArbitraryInput; + m_cbDblAllowNone.Checked = prOptDbl.AllowNone; + m_cbDblAllowZero.Checked = prOptDbl.AllowZero; + m_cbDblAllowNegative.Checked = prOptDbl.AllowNegative; + m_cbDblUseDefault.Checked = prOptDbl.UseDefaultValue; + m_ebDblDefault.Enabled = prOptDbl.UseDefaultValue; + m_ebDblDefault.Text = 0.0.ToString(); + + // PromptDistance + PromptDistanceOptions prOptDist = new PromptDistanceOptions(""); + m_cbDistAllowArbitraryInput.Checked = prOptDist.AllowArbitraryInput; + m_cbDistAllowNone.Checked = prOptDist.AllowNone; + m_cbDistAllowZero.Checked = prOptDist.AllowZero; + m_cbDistAllowNegative.Checked = prOptDist.AllowNegative; + m_cbDistUseBasePt.Checked = prOptDist.UseBasePoint; + m_cbDistUseDashedLine.Checked = prOptDist.UseDashedLine; + m_cbDistOnly2d.Checked = prOptDist.Only2d; + m_cbDistUseDefault.Checked = prOptDist.UseDefaultValue; + m_ebDistDefault.Enabled = prOptDist.UseDefaultValue; + m_ebDistDefault.Text = 0.0.ToString(); + + // PromptAngle + PromptAngleOptions prOptAng = new PromptAngleOptions(""); + m_cbAngAllowArbitraryInput.Checked = prOptAng.AllowArbitraryInput; + m_cbAngAllowNone.Checked = prOptAng.AllowNone; + m_cbAngAllowZero.Checked = prOptAng.AllowZero; + m_cbAngUseBasePt.Checked = prOptAng.UseBasePoint; + m_cbAngUseDashedLine.Checked = prOptAng.UseDashedLine; + m_cbAngUseDefault.Checked = prOptAng.UseDefaultValue; + m_ebAngDefault.Enabled = prOptAng.UseDefaultValue; + m_ebAngDefault.Text = 0.0.ToString(); + + // PromptCorner + PromptCornerOptions prOptCrn = new PromptCornerOptions("", new Point3d(0.0, 0.0, 0.0)); + m_cbCrnAllowArbitraryInput.Checked = prOptCrn.AllowArbitraryInput; + m_cbCrnAllowNone.Checked = prOptCrn.AllowNone; + m_cbCrnLimitsChecked.Checked = prOptCrn.LimitsChecked; + m_cbCrnUseDashedLine.Checked = prOptCrn.UseDashedLine; + + // PromptPoint + PromptPointOptions prOptPt = new PromptPointOptions(""); + m_cbPtAllowArbitraryInput.Checked = prOptPt.AllowArbitraryInput; + m_cbPtAllowNone.Checked = prOptPt.AllowNone; + m_cbPtLimitsChecked.Checked = prOptPt.LimitsChecked; + m_cbPtUseDashedLine.Checked = prOptPt.UseDashedLine; + m_cbPtUseBasePt.Checked = prOptPt.UseBasePoint; + + // PromptString + PromptStringOptions prOptStr = new PromptStringOptions(""); + m_cbStrAllowSpaces.Checked = prOptStr.AllowSpaces; + + // PromptKeyword + PromptKeywordOptions prOptKwd = new PromptKeywordOptions(""); + m_cbKwdAllowArbitraryInput.Checked = prOptKwd.AllowArbitraryInput; + m_cbKwdAllowNone.Checked = prOptKwd.AllowNone; + + // PromptEntity + PromptEntityOptions prOptEnt = new PromptEntityOptions(""); + m_cbEntAllowNone.Checked = prOptEnt.AllowNone; + + // PromptNestedEntity + PromptNestedEntityOptions prOptNent = new PromptNestedEntityOptions(""); + m_cbNentAllowNone.Checked = prOptNent.AllowNone; + m_cbNentNonInterPickPt.Checked = prOptNent.UseNonInteractivePickPoint; + } + + /// + /// Clean up any resources being used. + /// + protected override void + Dispose(bool disposing) + { + if (disposing) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.m_tcMain = new System.Windows.Forms.TabControl(); + this.m_tpInteger = new System.Windows.Forms.TabPage(); + this.m_gbKeywords = new System.Windows.Forms.GroupBox(); + this.m_ebIntKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtIntKwordDef = new System.Windows.Forms.Label(); + this.m_bnIntKwordHardwire = new System.Windows.Forms.Button(); + this.m_bnIntKwordClear = new System.Windows.Forms.Button(); + this.m_bnIntKwordEdit = new System.Windows.Forms.Button(); + this.m_bnIntKwordAdd = new System.Windows.Forms.Button(); + this.m_lvIntKeywords = new System.Windows.Forms.ListView(); + this.m_lvColKwordGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwordLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwordDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwordEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwordVisible = new System.Windows.Forms.ColumnHeader(); + this.m_gbOptionsInt = new System.Windows.Forms.GroupBox(); + this.m_ebIntDefault = new System.Windows.Forms.TextBox(); + this.m_txtIntDefault = new System.Windows.Forms.Label(); + this.m_cbIntUseDefault = new System.Windows.Forms.CheckBox(); + this.m_cbIntAllowNegative = new System.Windows.Forms.CheckBox(); + this.m_cbIntAllowZero = new System.Windows.Forms.CheckBox(); + this.m_cbIntAllowNone = new System.Windows.Forms.CheckBox(); + this.m_cbIntAllowArbitraryInput = new System.Windows.Forms.CheckBox(); + this.m_txtMessage = new System.Windows.Forms.Label(); + this.m_ebIntMessage = new System.Windows.Forms.TextBox(); + this.m_tpDouble = new System.Windows.Forms.TabPage(); + this.m_gbDblKwords = new System.Windows.Forms.GroupBox(); + this.m_bnDblKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebDblKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtDblKwordDef = new System.Windows.Forms.Label(); + this.m_bnDblKwordClear = new System.Windows.Forms.Button(); + this.m_bnDblKwordEdit = new System.Windows.Forms.Button(); + this.m_bnDblKwordAdd = new System.Windows.Forms.Button(); + this.m_lvDblKwords = new System.Windows.Forms.ListView(); + this.m_lvColDblGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDblLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDblDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDblEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDblVisible = new System.Windows.Forms.ColumnHeader(); + this.m_gbDblOpts = new System.Windows.Forms.GroupBox(); + this.m_ebDblDefault = new System.Windows.Forms.TextBox(); + this.m_txtDblDefault = new System.Windows.Forms.Label(); + this.m_cbDblUseDefault = new System.Windows.Forms.CheckBox(); + this.m_cbDblAllowNegative = new System.Windows.Forms.CheckBox(); + this.m_cbDblAllowZero = new System.Windows.Forms.CheckBox(); + this.m_cbDblAllowNone = new System.Windows.Forms.CheckBox(); + this.m_cbDblAllowArbitraryInput = new System.Windows.Forms.CheckBox(); + this.m_txtDblMessage = new System.Windows.Forms.Label(); + this.m_ebDblMessage = new System.Windows.Forms.TextBox(); + this.m_tpDistance = new System.Windows.Forms.TabPage(); + this.m_gbDistKwords = new System.Windows.Forms.GroupBox(); + this.m_bnDistKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebDistKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtDistKwordDef = new System.Windows.Forms.Label(); + this.m_bnDistKwordClear = new System.Windows.Forms.Button(); + this.m_bnDistKwordEdit = new System.Windows.Forms.Button(); + this.m_bnDistKwordAdd = new System.Windows.Forms.Button(); + this.m_lvDistKwords = new System.Windows.Forms.ListView(); + this.m_lvColDistGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDistLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDistDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDistEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColDistVisible = new System.Windows.Forms.ColumnHeader(); + this.m_gbDistOptions = new System.Windows.Forms.GroupBox(); + this.m_cbDistOnly2d = new System.Windows.Forms.CheckBox(); + this.m_cbDistUseDashedLine = new System.Windows.Forms.CheckBox(); + this.m_cbDistUseBasePt = new System.Windows.Forms.CheckBox(); + this.m_ebDistDefault = new System.Windows.Forms.TextBox(); + this.m_txtDistDefault = new System.Windows.Forms.Label(); + this.m_cbDistUseDefault = new System.Windows.Forms.CheckBox(); + this.m_cbDistAllowNegative = new System.Windows.Forms.CheckBox(); + this.m_cbDistAllowZero = new System.Windows.Forms.CheckBox(); + this.m_cbDistAllowNone = new System.Windows.Forms.CheckBox(); + this.m_cbDistAllowArbitraryInput = new System.Windows.Forms.CheckBox(); + this.m_txtDistMessage = new System.Windows.Forms.Label(); + this.m_ebDistMessage = new System.Windows.Forms.TextBox(); + this.m_tpAngle = new System.Windows.Forms.TabPage(); + this.m_txtAngMessage = new System.Windows.Forms.Label(); + this.m_ebAngMessage = new System.Windows.Forms.TextBox(); + this.m_gbAngOptions = new System.Windows.Forms.GroupBox(); + this.m_cbAngUseDefault = new System.Windows.Forms.CheckBox(); + this.m_cbAngUseDashedLine = new System.Windows.Forms.CheckBox(); + this.m_ebAngDefault = new System.Windows.Forms.TextBox(); + this.m_txtAngDefault = new System.Windows.Forms.Label(); + this.m_cbAngUseBasePt = new System.Windows.Forms.CheckBox(); + this.m_cbAngAllowZero = new System.Windows.Forms.CheckBox(); + this.m_cbAngAllowNone = new System.Windows.Forms.CheckBox(); + this.m_cbAngAllowArbitraryInput = new System.Windows.Forms.CheckBox(); + this.m_gbAngKwords = new System.Windows.Forms.GroupBox(); + this.m_bnAngKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebAngKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtAngKwordDef = new System.Windows.Forms.Label(); + this.m_bnAngKwordClear = new System.Windows.Forms.Button(); + this.m_bnAngKwordEdit = new System.Windows.Forms.Button(); + this.m_bnAngKwordAdd = new System.Windows.Forms.Button(); + this.m_lvAngKwords = new System.Windows.Forms.ListView(); + this.m_lvColAngGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColAngLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColAngDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColAngEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColAngVisible = new System.Windows.Forms.ColumnHeader(); + this.m_tpCorner = new System.Windows.Forms.TabPage(); + this.m_gbCrnOptions = new System.Windows.Forms.GroupBox(); + this.m_cbCrnUseDashedLine = new System.Windows.Forms.CheckBox(); + this.m_cbCrnLimitsChecked = new System.Windows.Forms.CheckBox(); + this.m_cbCrnAllowNone = new System.Windows.Forms.CheckBox(); + this.m_cbCrnAllowArbitraryInput = new System.Windows.Forms.CheckBox(); + this.m_gbCrnKwords = new System.Windows.Forms.GroupBox(); + this.m_bnCrnKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebCrnKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtCrnKwordDef = new System.Windows.Forms.Label(); + this.m_bnCrnKwordClear = new System.Windows.Forms.Button(); + this.m_bnCrnKwordEdit = new System.Windows.Forms.Button(); + this.m_bnCrnKwordAdd = new System.Windows.Forms.Button(); + this.m_lvCrnKwords = new System.Windows.Forms.ListView(); + this.m_lvColCrnGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColCrnLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColCrnDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColCrnEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColCrnVisible = new System.Windows.Forms.ColumnHeader(); + this.m_ebCrnMessage = new System.Windows.Forms.TextBox(); + this.m_txtCrnMessage = new System.Windows.Forms.Label(); + this.m_tpPoint = new System.Windows.Forms.TabPage(); + this.m_gbPtOptions = new System.Windows.Forms.GroupBox(); + this.m_cbPtUseBasePt = new System.Windows.Forms.CheckBox(); + this.m_cbPtUseDashedLine = new System.Windows.Forms.CheckBox(); + this.m_cbPtLimitsChecked = new System.Windows.Forms.CheckBox(); + this.m_cbPtAllowNone = new System.Windows.Forms.CheckBox(); + this.m_cbPtAllowArbitraryInput = new System.Windows.Forms.CheckBox(); + this.m_gbPtKwords = new System.Windows.Forms.GroupBox(); + this.m_bnPtKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebPtKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtPtKwordDef = new System.Windows.Forms.Label(); + this.m_bnPtKwordClear = new System.Windows.Forms.Button(); + this.m_bnPtKwordEdit = new System.Windows.Forms.Button(); + this.m_bnPtKwordAdd = new System.Windows.Forms.Button(); + this.m_lvPtKwords = new System.Windows.Forms.ListView(); + this.m_lvColPtGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColPtLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColPtDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColPtEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColPtVisible = new System.Windows.Forms.ColumnHeader(); + this.m_ebPtMessage = new System.Windows.Forms.TextBox(); + this.m_txtPtMessage = new System.Windows.Forms.Label(); + this.m_tpString = new System.Windows.Forms.TabPage(); + this.m_gbStrOptions = new System.Windows.Forms.GroupBox(); + this.m_cbStrAllowSpaces = new System.Windows.Forms.CheckBox(); + this.m_ebStrMessage = new System.Windows.Forms.TextBox(); + this.m_txtStrMessage = new System.Windows.Forms.Label(); + this.m_tpKeyword = new System.Windows.Forms.TabPage(); + this.m_gbKwdOptions = new System.Windows.Forms.GroupBox(); + this.m_cbKwdAllowArbitraryInput = new System.Windows.Forms.CheckBox(); + this.m_cbKwdAllowNone = new System.Windows.Forms.CheckBox(); + this.m_gbKwdKwords = new System.Windows.Forms.GroupBox(); + this.m_bnKwdKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebKwdKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtKwdKwordDef = new System.Windows.Forms.Label(); + this.m_bnKwdKwordClear = new System.Windows.Forms.Button(); + this.m_bnKwdKwordEdit = new System.Windows.Forms.Button(); + this.m_bnKwdKwordAdd = new System.Windows.Forms.Button(); + this.m_lvKwdKwords = new System.Windows.Forms.ListView(); + this.m_lvColKwdGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwdLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwdDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwdEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColKwdVisible = new System.Windows.Forms.ColumnHeader(); + this.m_ebKwdMessage = new System.Windows.Forms.TextBox(); + this.m_txtKwdMessage = new System.Windows.Forms.Label(); + this.m_tpEntity = new System.Windows.Forms.TabPage(); + this.m_gbEntFilterClasses = new System.Windows.Forms.GroupBox(); + this.m_cbEntAllowCurves = new System.Windows.Forms.CheckBox(); + this.m_txtEntSampleFilter = new System.Windows.Forms.Label(); + this.m_ebEntDoIsATest = new System.Windows.Forms.CheckBox(); + this.m_cbEntAllowCircles = new System.Windows.Forms.CheckBox(); + this.m_cbEntAllowLines = new System.Windows.Forms.CheckBox(); + this.m_ebEntRejectMessage = new System.Windows.Forms.TextBox(); + this.m_txtEntRejectMessage = new System.Windows.Forms.Label(); + this.m_gbEntKwords = new System.Windows.Forms.GroupBox(); + this.m_bnEntKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebEntKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtEntKwordDef = new System.Windows.Forms.Label(); + this.m_bnEntKwordClear = new System.Windows.Forms.Button(); + this.m_bnEntKwordEdit = new System.Windows.Forms.Button(); + this.m_bnEntKwordAdd = new System.Windows.Forms.Button(); + this.m_lvEntKwords = new System.Windows.Forms.ListView(); + this.m_lvColEntKwordGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColEntKwordLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColEntKwordDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColEntKwordEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColEntKwordVisible = new System.Windows.Forms.ColumnHeader(); + this.m_gbEntOptions = new System.Windows.Forms.GroupBox(); + this.m_cbEntAllowLockedLayer = new System.Windows.Forms.CheckBox(); + this.m_cbEntAllowNone = new System.Windows.Forms.CheckBox(); + this.m_ebEntMessage = new System.Windows.Forms.TextBox(); + this.m_txtEntMessage = new System.Windows.Forms.Label(); + this.m_tpNested = new System.Windows.Forms.TabPage(); + this.m_gbNentKwords = new System.Windows.Forms.GroupBox(); + this.m_bnNentKwordHardwire = new System.Windows.Forms.Button(); + this.m_ebNentKwordDef = new System.Windows.Forms.TextBox(); + this.m_txtNentKwordDef = new System.Windows.Forms.Label(); + this.m_bnNentKwordClear = new System.Windows.Forms.Button(); + this.m_bnNentKwordEdit = new System.Windows.Forms.Button(); + this.m_bnNentKwordAdd = new System.Windows.Forms.Button(); + this.m_lvNentKwords = new System.Windows.Forms.ListView(); + this.m_lvColNentKwordsGlobal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColNentKwordsLocal = new System.Windows.Forms.ColumnHeader(); + this.m_lvColNentKwordsDisplay = new System.Windows.Forms.ColumnHeader(); + this.m_lvColNentKwordsEnabled = new System.Windows.Forms.ColumnHeader(); + this.m_lvColNentKwordsVisible = new System.Windows.Forms.ColumnHeader(); + this.m_gbNentOptions = new System.Windows.Forms.GroupBox(); + this.m_cbNentNonInterPickPt = new System.Windows.Forms.CheckBox(); + this.m_cbNentAllowNone = new System.Windows.Forms.CheckBox(); + this.m_ebNentMessage = new System.Windows.Forms.TextBox(); + this.m_txtNentMessage = new System.Windows.Forms.Label(); + this.m_bnRunTest = new System.Windows.Forms.Button(); + this.m_bnCancel = new System.Windows.Forms.Button(); + this.m_tcMain.SuspendLayout(); + this.m_tpInteger.SuspendLayout(); + this.m_gbKeywords.SuspendLayout(); + this.m_gbOptionsInt.SuspendLayout(); + this.m_tpDouble.SuspendLayout(); + this.m_gbDblKwords.SuspendLayout(); + this.m_gbDblOpts.SuspendLayout(); + this.m_tpDistance.SuspendLayout(); + this.m_gbDistKwords.SuspendLayout(); + this.m_gbDistOptions.SuspendLayout(); + this.m_tpAngle.SuspendLayout(); + this.m_gbAngOptions.SuspendLayout(); + this.m_gbAngKwords.SuspendLayout(); + this.m_tpCorner.SuspendLayout(); + this.m_gbCrnOptions.SuspendLayout(); + this.m_gbCrnKwords.SuspendLayout(); + this.m_tpPoint.SuspendLayout(); + this.m_gbPtOptions.SuspendLayout(); + this.m_gbPtKwords.SuspendLayout(); + this.m_tpString.SuspendLayout(); + this.m_gbStrOptions.SuspendLayout(); + this.m_tpKeyword.SuspendLayout(); + this.m_gbKwdOptions.SuspendLayout(); + this.m_gbKwdKwords.SuspendLayout(); + this.m_tpEntity.SuspendLayout(); + this.m_gbEntFilterClasses.SuspendLayout(); + this.m_gbEntKwords.SuspendLayout(); + this.m_gbEntOptions.SuspendLayout(); + this.m_tpNested.SuspendLayout(); + this.m_gbNentKwords.SuspendLayout(); + this.m_gbNentOptions.SuspendLayout(); + this.SuspendLayout(); + // + // m_tcMain + // + this.m_tcMain.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_tpInteger, + this.m_tpDouble, + this.m_tpDistance, + this.m_tpAngle, + this.m_tpCorner, + this.m_tpPoint, + this.m_tpString, + this.m_tpKeyword, + this.m_tpEntity, + this.m_tpNested}); + this.m_tcMain.Location = new System.Drawing.Point(16, 16); + this.m_tcMain.Name = "m_tcMain"; + this.m_tcMain.SelectedIndex = 0; + this.m_tcMain.Size = new System.Drawing.Size(616, 344); + this.m_tcMain.TabIndex = 0; + this.m_tcMain.Click += new System.EventHandler(this.OnEntAllowLines); + // + // m_tpInteger + // + this.m_tpInteger.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbKeywords, + this.m_gbOptionsInt, + this.m_txtMessage, + this.m_ebIntMessage}); + this.m_tpInteger.Location = new System.Drawing.Point(4, 22); + this.m_tpInteger.Name = "m_tpInteger"; + this.m_tpInteger.Size = new System.Drawing.Size(608, 318); + this.m_tpInteger.TabIndex = 0; + this.m_tpInteger.Text = "Integer"; + // + // m_gbKeywords + // + this.m_gbKeywords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_ebIntKwordDef, + this.m_txtIntKwordDef, + this.m_bnIntKwordHardwire, + this.m_bnIntKwordClear, + this.m_bnIntKwordEdit, + this.m_bnIntKwordAdd, + this.m_lvIntKeywords}); + this.m_gbKeywords.Location = new System.Drawing.Point(200, 48); + this.m_gbKeywords.Name = "m_gbKeywords"; + this.m_gbKeywords.Size = new System.Drawing.Size(392, 264); + this.m_gbKeywords.TabIndex = 2; + this.m_gbKeywords.TabStop = false; + this.m_gbKeywords.Text = "Key Words"; + // + // m_ebIntKwordDef + // + this.m_ebIntKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebIntKwordDef.Name = "m_ebIntKwordDef"; + this.m_ebIntKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebIntKwordDef.TabIndex = 6; + this.m_ebIntKwordDef.Text = ""; + // + // m_txtIntKwordDef + // + this.m_txtIntKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtIntKwordDef.Name = "m_txtIntKwordDef"; + this.m_txtIntKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtIntKwordDef.TabIndex = 5; + this.m_txtIntKwordDef.Text = "Default"; + // + // m_bnIntKwordHardwire + // + this.m_bnIntKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnIntKwordHardwire.Name = "m_bnIntKwordHardwire"; + this.m_bnIntKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnIntKwordHardwire.TabIndex = 4; + this.m_bnIntKwordHardwire.Text = "Hardwire"; + this.m_bnIntKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_bnIntKwordClear + // + this.m_bnIntKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnIntKwordClear.Name = "m_bnIntKwordClear"; + this.m_bnIntKwordClear.TabIndex = 3; + this.m_bnIntKwordClear.Text = "Clear"; + this.m_bnIntKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnIntKwordEdit + // + this.m_bnIntKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnIntKwordEdit.Name = "m_bnIntKwordEdit"; + this.m_bnIntKwordEdit.TabIndex = 2; + this.m_bnIntKwordEdit.Text = "Edit..."; + this.m_bnIntKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnIntKwordAdd + // + this.m_bnIntKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnIntKwordAdd.Name = "m_bnIntKwordAdd"; + this.m_bnIntKwordAdd.TabIndex = 1; + this.m_bnIntKwordAdd.Text = "Add..."; + this.m_bnIntKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvIntKeywords + // + this.m_lvIntKeywords.CausesValidation = false; + this.m_lvIntKeywords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColKwordGlobal, + this.m_lvColKwordLocal, + this.m_lvColKwordDisplay, + this.m_lvColKwordEnabled, + this.m_lvColKwordVisible}); + this.m_lvIntKeywords.FullRowSelect = true; + this.m_lvIntKeywords.GridLines = true; + this.m_lvIntKeywords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvIntKeywords.HideSelection = false; + this.m_lvIntKeywords.Location = new System.Drawing.Point(16, 24); + this.m_lvIntKeywords.MultiSelect = false; + this.m_lvIntKeywords.Name = "m_lvIntKeywords"; + this.m_lvIntKeywords.Size = new System.Drawing.Size(360, 168); + this.m_lvIntKeywords.TabIndex = 0; + this.m_lvIntKeywords.View = System.Windows.Forms.View.Details; + // + // m_lvColKwordGlobal + // + this.m_lvColKwordGlobal.Text = "Global"; + this.m_lvColKwordGlobal.Width = 80; + // + // m_lvColKwordLocal + // + this.m_lvColKwordLocal.Text = "Local"; + this.m_lvColKwordLocal.Width = 80; + // + // m_lvColKwordDisplay + // + this.m_lvColKwordDisplay.Text = "Display"; + this.m_lvColKwordDisplay.Width = 80; + // + // m_lvColKwordEnabled + // + this.m_lvColKwordEnabled.Text = "Enabled"; + // + // m_lvColKwordVisible + // + this.m_lvColKwordVisible.Text = "Visible"; + // + // m_gbOptionsInt + // + this.m_gbOptionsInt.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_ebIntDefault, + this.m_txtIntDefault, + this.m_cbIntUseDefault, + this.m_cbIntAllowNegative, + this.m_cbIntAllowZero, + this.m_cbIntAllowNone, + this.m_cbIntAllowArbitraryInput}); + this.m_gbOptionsInt.Location = new System.Drawing.Point(16, 48); + this.m_gbOptionsInt.Name = "m_gbOptionsInt"; + this.m_gbOptionsInt.Size = new System.Drawing.Size(168, 264); + this.m_gbOptionsInt.TabIndex = 0; + this.m_gbOptionsInt.TabStop = false; + this.m_gbOptionsInt.Text = "Options"; + // + // m_ebIntDefault + // + this.m_ebIntDefault.Location = new System.Drawing.Point(64, 152); + this.m_ebIntDefault.Name = "m_ebIntDefault"; + this.m_ebIntDefault.Size = new System.Drawing.Size(88, 20); + this.m_ebIntDefault.TabIndex = 6; + this.m_ebIntDefault.Text = ""; + // + // m_txtIntDefault + // + this.m_txtIntDefault.Location = new System.Drawing.Point(8, 152); + this.m_txtIntDefault.Name = "m_txtIntDefault"; + this.m_txtIntDefault.Size = new System.Drawing.Size(56, 23); + this.m_txtIntDefault.TabIndex = 5; + this.m_txtIntDefault.Text = "Default"; + // + // m_cbIntUseDefault + // + this.m_cbIntUseDefault.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbIntUseDefault.Location = new System.Drawing.Point(8, 120); + this.m_cbIntUseDefault.Name = "m_cbIntUseDefault"; + this.m_cbIntUseDefault.Size = new System.Drawing.Size(144, 24); + this.m_cbIntUseDefault.TabIndex = 4; + this.m_cbIntUseDefault.Text = "Use Default Value"; + this.m_cbIntUseDefault.Click += new System.EventHandler(this.OnIntUseDefaultValue); + // + // m_cbIntAllowNegative + // + this.m_cbIntAllowNegative.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbIntAllowNegative.Location = new System.Drawing.Point(8, 96); + this.m_cbIntAllowNegative.Name = "m_cbIntAllowNegative"; + this.m_cbIntAllowNegative.TabIndex = 3; + this.m_cbIntAllowNegative.Text = "Allow Negative"; + // + // m_cbIntAllowZero + // + this.m_cbIntAllowZero.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbIntAllowZero.Location = new System.Drawing.Point(8, 72); + this.m_cbIntAllowZero.Name = "m_cbIntAllowZero"; + this.m_cbIntAllowZero.TabIndex = 2; + this.m_cbIntAllowZero.Text = "Allow Zero"; + // + // m_cbIntAllowNone + // + this.m_cbIntAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbIntAllowNone.Location = new System.Drawing.Point(8, 48); + this.m_cbIntAllowNone.Name = "m_cbIntAllowNone"; + this.m_cbIntAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbIntAllowNone.TabIndex = 1; + this.m_cbIntAllowNone.Text = "Allow None"; + // + // m_cbIntAllowArbitraryInput + // + this.m_cbIntAllowArbitraryInput.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbIntAllowArbitraryInput.Location = new System.Drawing.Point(8, 24); + this.m_cbIntAllowArbitraryInput.Name = "m_cbIntAllowArbitraryInput"; + this.m_cbIntAllowArbitraryInput.Size = new System.Drawing.Size(136, 24); + this.m_cbIntAllowArbitraryInput.TabIndex = 0; + this.m_cbIntAllowArbitraryInput.Text = "Allow Arbitrary Input"; + // + // m_txtMessage + // + this.m_txtMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtMessage.Name = "m_txtMessage"; + this.m_txtMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtMessage.TabIndex = 1; + this.m_txtMessage.Text = "Message"; + // + // m_ebIntMessage + // + this.m_ebIntMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebIntMessage.Name = "m_ebIntMessage"; + this.m_ebIntMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebIntMessage.TabIndex = 0; + this.m_ebIntMessage.Text = "Enter an integer"; + // + // m_tpDouble + // + this.m_tpDouble.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbDblKwords, + this.m_gbDblOpts, + this.m_txtDblMessage, + this.m_ebDblMessage}); + this.m_tpDouble.Location = new System.Drawing.Point(4, 22); + this.m_tpDouble.Name = "m_tpDouble"; + this.m_tpDouble.Size = new System.Drawing.Size(608, 318); + this.m_tpDouble.TabIndex = 1; + this.m_tpDouble.Text = "Double"; + // + // m_gbDblKwords + // + this.m_gbDblKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnDblKwordHardwire, + this.m_ebDblKwordDef, + this.m_txtDblKwordDef, + this.m_bnDblKwordClear, + this.m_bnDblKwordEdit, + this.m_bnDblKwordAdd, + this.m_lvDblKwords}); + this.m_gbDblKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbDblKwords.Name = "m_gbDblKwords"; + this.m_gbDblKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbDblKwords.TabIndex = 5; + this.m_gbDblKwords.TabStop = false; + this.m_gbDblKwords.Text = "Key Words"; + // + // m_bnDblKwordHardwire + // + this.m_bnDblKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnDblKwordHardwire.Name = "m_bnDblKwordHardwire"; + this.m_bnDblKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnDblKwordHardwire.TabIndex = 9; + this.m_bnDblKwordHardwire.Text = "Hardwire"; + this.m_bnDblKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebDblKwordDef + // + this.m_ebDblKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebDblKwordDef.Name = "m_ebDblKwordDef"; + this.m_ebDblKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebDblKwordDef.TabIndex = 8; + this.m_ebDblKwordDef.Text = ""; + // + // m_txtDblKwordDef + // + this.m_txtDblKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtDblKwordDef.Name = "m_txtDblKwordDef"; + this.m_txtDblKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtDblKwordDef.TabIndex = 7; + this.m_txtDblKwordDef.Text = "Default"; + // + // m_bnDblKwordClear + // + this.m_bnDblKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnDblKwordClear.Name = "m_bnDblKwordClear"; + this.m_bnDblKwordClear.TabIndex = 3; + this.m_bnDblKwordClear.Text = "Clear"; + this.m_bnDblKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnDblKwordEdit + // + this.m_bnDblKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnDblKwordEdit.Name = "m_bnDblKwordEdit"; + this.m_bnDblKwordEdit.TabIndex = 2; + this.m_bnDblKwordEdit.Text = "Edit..."; + this.m_bnDblKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnDblKwordAdd + // + this.m_bnDblKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnDblKwordAdd.Name = "m_bnDblKwordAdd"; + this.m_bnDblKwordAdd.TabIndex = 1; + this.m_bnDblKwordAdd.Text = "Add..."; + this.m_bnDblKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvDblKwords + // + this.m_lvDblKwords.CausesValidation = false; + this.m_lvDblKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColDblGlobal, + this.m_lvColDblLocal, + this.m_lvColDblDisplay, + this.m_lvColDblEnabled, + this.m_lvColDblVisible}); + this.m_lvDblKwords.FullRowSelect = true; + this.m_lvDblKwords.GridLines = true; + this.m_lvDblKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvDblKwords.HideSelection = false; + this.m_lvDblKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvDblKwords.MultiSelect = false; + this.m_lvDblKwords.Name = "m_lvDblKwords"; + this.m_lvDblKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvDblKwords.TabIndex = 0; + this.m_lvDblKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColDblGlobal + // + this.m_lvColDblGlobal.Text = "Global"; + this.m_lvColDblGlobal.Width = 80; + // + // m_lvColDblLocal + // + this.m_lvColDblLocal.Text = "Local"; + this.m_lvColDblLocal.Width = 80; + // + // m_lvColDblDisplay + // + this.m_lvColDblDisplay.Text = "Display"; + this.m_lvColDblDisplay.Width = 80; + // + // m_lvColDblEnabled + // + this.m_lvColDblEnabled.Text = "Enabled"; + // + // m_lvColDblVisible + // + this.m_lvColDblVisible.Text = "Visible"; + // + // m_gbDblOpts + // + this.m_gbDblOpts.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_ebDblDefault, + this.m_txtDblDefault, + this.m_cbDblUseDefault, + this.m_cbDblAllowNegative, + this.m_cbDblAllowZero, + this.m_cbDblAllowNone, + this.m_cbDblAllowArbitraryInput}); + this.m_gbDblOpts.Location = new System.Drawing.Point(16, 48); + this.m_gbDblOpts.Name = "m_gbDblOpts"; + this.m_gbDblOpts.Size = new System.Drawing.Size(168, 264); + this.m_gbDblOpts.TabIndex = 3; + this.m_gbDblOpts.TabStop = false; + this.m_gbDblOpts.Text = "Options"; + // + // m_ebDblDefault + // + this.m_ebDblDefault.Location = new System.Drawing.Point(64, 152); + this.m_ebDblDefault.Name = "m_ebDblDefault"; + this.m_ebDblDefault.Size = new System.Drawing.Size(88, 20); + this.m_ebDblDefault.TabIndex = 6; + this.m_ebDblDefault.Text = ""; + // + // m_txtDblDefault + // + this.m_txtDblDefault.Location = new System.Drawing.Point(8, 152); + this.m_txtDblDefault.Name = "m_txtDblDefault"; + this.m_txtDblDefault.Size = new System.Drawing.Size(56, 23); + this.m_txtDblDefault.TabIndex = 5; + this.m_txtDblDefault.Text = "Default"; + // + // m_cbDblUseDefault + // + this.m_cbDblUseDefault.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDblUseDefault.Location = new System.Drawing.Point(8, 120); + this.m_cbDblUseDefault.Name = "m_cbDblUseDefault"; + this.m_cbDblUseDefault.Size = new System.Drawing.Size(144, 24); + this.m_cbDblUseDefault.TabIndex = 4; + this.m_cbDblUseDefault.Text = "Use Default Value"; + this.m_cbDblUseDefault.Click += new System.EventHandler(this.OnDblUseDefaultValue); + // + // m_cbDblAllowNegative + // + this.m_cbDblAllowNegative.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDblAllowNegative.Location = new System.Drawing.Point(8, 96); + this.m_cbDblAllowNegative.Name = "m_cbDblAllowNegative"; + this.m_cbDblAllowNegative.TabIndex = 3; + this.m_cbDblAllowNegative.Text = "Allow Negative"; + // + // m_cbDblAllowZero + // + this.m_cbDblAllowZero.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDblAllowZero.Location = new System.Drawing.Point(8, 72); + this.m_cbDblAllowZero.Name = "m_cbDblAllowZero"; + this.m_cbDblAllowZero.TabIndex = 2; + this.m_cbDblAllowZero.Text = "Allow Zero"; + // + // m_cbDblAllowNone + // + this.m_cbDblAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDblAllowNone.Location = new System.Drawing.Point(8, 48); + this.m_cbDblAllowNone.Name = "m_cbDblAllowNone"; + this.m_cbDblAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbDblAllowNone.TabIndex = 1; + this.m_cbDblAllowNone.Text = "Allow None"; + // + // m_cbDblAllowArbitraryInput + // + this.m_cbDblAllowArbitraryInput.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDblAllowArbitraryInput.Location = new System.Drawing.Point(8, 24); + this.m_cbDblAllowArbitraryInput.Name = "m_cbDblAllowArbitraryInput"; + this.m_cbDblAllowArbitraryInput.Size = new System.Drawing.Size(136, 24); + this.m_cbDblAllowArbitraryInput.TabIndex = 0; + this.m_cbDblAllowArbitraryInput.Text = "Allow Arbitrary Input"; + // + // m_txtDblMessage + // + this.m_txtDblMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtDblMessage.Name = "m_txtDblMessage"; + this.m_txtDblMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtDblMessage.TabIndex = 4; + this.m_txtDblMessage.Text = "Message"; + // + // m_ebDblMessage + // + this.m_ebDblMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebDblMessage.Name = "m_ebDblMessage"; + this.m_ebDblMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebDblMessage.TabIndex = 2; + this.m_ebDblMessage.Text = "Enter a double"; + // + // m_tpDistance + // + this.m_tpDistance.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbDistKwords, + this.m_gbDistOptions, + this.m_txtDistMessage, + this.m_ebDistMessage}); + this.m_tpDistance.Location = new System.Drawing.Point(4, 22); + this.m_tpDistance.Name = "m_tpDistance"; + this.m_tpDistance.Size = new System.Drawing.Size(608, 318); + this.m_tpDistance.TabIndex = 2; + this.m_tpDistance.Text = "Distance"; + // + // m_gbDistKwords + // + this.m_gbDistKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnDistKwordHardwire, + this.m_ebDistKwordDef, + this.m_txtDistKwordDef, + this.m_bnDistKwordClear, + this.m_bnDistKwordEdit, + this.m_bnDistKwordAdd, + this.m_lvDistKwords}); + this.m_gbDistKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbDistKwords.Name = "m_gbDistKwords"; + this.m_gbDistKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbDistKwords.TabIndex = 6; + this.m_gbDistKwords.TabStop = false; + this.m_gbDistKwords.Text = "Key Words"; + // + // m_bnDistKwordHardwire + // + this.m_bnDistKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnDistKwordHardwire.Name = "m_bnDistKwordHardwire"; + this.m_bnDistKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnDistKwordHardwire.TabIndex = 12; + this.m_bnDistKwordHardwire.Text = "Hardwire"; + this.m_bnDistKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebDistKwordDef + // + this.m_ebDistKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebDistKwordDef.Name = "m_ebDistKwordDef"; + this.m_ebDistKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebDistKwordDef.TabIndex = 11; + this.m_ebDistKwordDef.Text = ""; + // + // m_txtDistKwordDef + // + this.m_txtDistKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtDistKwordDef.Name = "m_txtDistKwordDef"; + this.m_txtDistKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtDistKwordDef.TabIndex = 10; + this.m_txtDistKwordDef.Text = "Default"; + // + // m_bnDistKwordClear + // + this.m_bnDistKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnDistKwordClear.Name = "m_bnDistKwordClear"; + this.m_bnDistKwordClear.TabIndex = 3; + this.m_bnDistKwordClear.Text = "Clear"; + this.m_bnDistKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnDistKwordEdit + // + this.m_bnDistKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnDistKwordEdit.Name = "m_bnDistKwordEdit"; + this.m_bnDistKwordEdit.TabIndex = 2; + this.m_bnDistKwordEdit.Text = "Edit..."; + this.m_bnDistKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnDistKwordAdd + // + this.m_bnDistKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnDistKwordAdd.Name = "m_bnDistKwordAdd"; + this.m_bnDistKwordAdd.TabIndex = 1; + this.m_bnDistKwordAdd.Text = "Add..."; + this.m_bnDistKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvDistKwords + // + this.m_lvDistKwords.CausesValidation = false; + this.m_lvDistKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColDistGlobal, + this.m_lvColDistLocal, + this.m_lvColDistDisplay, + this.m_lvColDistEnabled, + this.m_lvColDistVisible}); + this.m_lvDistKwords.FullRowSelect = true; + this.m_lvDistKwords.GridLines = true; + this.m_lvDistKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvDistKwords.HideSelection = false; + this.m_lvDistKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvDistKwords.MultiSelect = false; + this.m_lvDistKwords.Name = "m_lvDistKwords"; + this.m_lvDistKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvDistKwords.TabIndex = 0; + this.m_lvDistKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColDistGlobal + // + this.m_lvColDistGlobal.Text = "Global"; + this.m_lvColDistGlobal.Width = 80; + // + // m_lvColDistLocal + // + this.m_lvColDistLocal.Text = "Local"; + this.m_lvColDistLocal.Width = 80; + // + // m_lvColDistDisplay + // + this.m_lvColDistDisplay.Text = "Display"; + this.m_lvColDistDisplay.Width = 80; + // + // m_lvColDistEnabled + // + this.m_lvColDistEnabled.Text = "Enabled"; + // + // m_lvColDistVisible + // + this.m_lvColDistVisible.Text = "Visible"; + // + // m_gbDistOptions + // + this.m_gbDistOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbDistOnly2d, + this.m_cbDistUseDashedLine, + this.m_cbDistUseBasePt, + this.m_ebDistDefault, + this.m_txtDistDefault, + this.m_cbDistUseDefault, + this.m_cbDistAllowNegative, + this.m_cbDistAllowZero, + this.m_cbDistAllowNone, + this.m_cbDistAllowArbitraryInput}); + this.m_gbDistOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbDistOptions.Name = "m_gbDistOptions"; + this.m_gbDistOptions.Size = new System.Drawing.Size(168, 264); + this.m_gbDistOptions.TabIndex = 4; + this.m_gbDistOptions.TabStop = false; + this.m_gbDistOptions.Text = "Options"; + // + // m_cbDistOnly2d + // + this.m_cbDistOnly2d.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistOnly2d.Location = new System.Drawing.Point(8, 168); + this.m_cbDistOnly2d.Name = "m_cbDistOnly2d"; + this.m_cbDistOnly2d.TabIndex = 10; + this.m_cbDistOnly2d.Text = "Only 2D"; + // + // m_cbDistUseDashedLine + // + this.m_cbDistUseDashedLine.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistUseDashedLine.Location = new System.Drawing.Point(8, 144); + this.m_cbDistUseDashedLine.Name = "m_cbDistUseDashedLine"; + this.m_cbDistUseDashedLine.Size = new System.Drawing.Size(144, 24); + this.m_cbDistUseDashedLine.TabIndex = 9; + this.m_cbDistUseDashedLine.Text = "Use Dashed Line"; + // + // m_cbDistUseBasePt + // + this.m_cbDistUseBasePt.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistUseBasePt.Location = new System.Drawing.Point(8, 120); + this.m_cbDistUseBasePt.Name = "m_cbDistUseBasePt"; + this.m_cbDistUseBasePt.Size = new System.Drawing.Size(144, 24); + this.m_cbDistUseBasePt.TabIndex = 8; + this.m_cbDistUseBasePt.Text = "Use Base Point"; + // + // m_ebDistDefault + // + this.m_ebDistDefault.Location = new System.Drawing.Point(64, 224); + this.m_ebDistDefault.Name = "m_ebDistDefault"; + this.m_ebDistDefault.Size = new System.Drawing.Size(88, 20); + this.m_ebDistDefault.TabIndex = 6; + this.m_ebDistDefault.Text = ""; + // + // m_txtDistDefault + // + this.m_txtDistDefault.Location = new System.Drawing.Point(8, 224); + this.m_txtDistDefault.Name = "m_txtDistDefault"; + this.m_txtDistDefault.Size = new System.Drawing.Size(56, 23); + this.m_txtDistDefault.TabIndex = 5; + this.m_txtDistDefault.Text = "Default"; + // + // m_cbDistUseDefault + // + this.m_cbDistUseDefault.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistUseDefault.Location = new System.Drawing.Point(8, 192); + this.m_cbDistUseDefault.Name = "m_cbDistUseDefault"; + this.m_cbDistUseDefault.Size = new System.Drawing.Size(144, 24); + this.m_cbDistUseDefault.TabIndex = 4; + this.m_cbDistUseDefault.Text = "Use Default Value"; + this.m_cbDistUseDefault.Click += new System.EventHandler(this.OnDistUseDefaultValue); + // + // m_cbDistAllowNegative + // + this.m_cbDistAllowNegative.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistAllowNegative.Location = new System.Drawing.Point(8, 96); + this.m_cbDistAllowNegative.Name = "m_cbDistAllowNegative"; + this.m_cbDistAllowNegative.TabIndex = 3; + this.m_cbDistAllowNegative.Text = "Allow Negative"; + // + // m_cbDistAllowZero + // + this.m_cbDistAllowZero.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistAllowZero.Location = new System.Drawing.Point(8, 72); + this.m_cbDistAllowZero.Name = "m_cbDistAllowZero"; + this.m_cbDistAllowZero.TabIndex = 2; + this.m_cbDistAllowZero.Text = "Allow Zero"; + // + // m_cbDistAllowNone + // + this.m_cbDistAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistAllowNone.Location = new System.Drawing.Point(8, 48); + this.m_cbDistAllowNone.Name = "m_cbDistAllowNone"; + this.m_cbDistAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbDistAllowNone.TabIndex = 1; + this.m_cbDistAllowNone.Text = "Allow None"; + // + // m_cbDistAllowArbitraryInput + // + this.m_cbDistAllowArbitraryInput.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbDistAllowArbitraryInput.Location = new System.Drawing.Point(8, 24); + this.m_cbDistAllowArbitraryInput.Name = "m_cbDistAllowArbitraryInput"; + this.m_cbDistAllowArbitraryInput.Size = new System.Drawing.Size(136, 24); + this.m_cbDistAllowArbitraryInput.TabIndex = 0; + this.m_cbDistAllowArbitraryInput.Text = "Allow Arbitrary Input"; + // + // m_txtDistMessage + // + this.m_txtDistMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtDistMessage.Name = "m_txtDistMessage"; + this.m_txtDistMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtDistMessage.TabIndex = 5; + this.m_txtDistMessage.Text = "Message"; + // + // m_ebDistMessage + // + this.m_ebDistMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebDistMessage.Name = "m_ebDistMessage"; + this.m_ebDistMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebDistMessage.TabIndex = 3; + this.m_ebDistMessage.Text = "Enter a distance"; + // + // m_tpAngle + // + this.m_tpAngle.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_txtAngMessage, + this.m_ebAngMessage, + this.m_gbAngOptions, + this.m_gbAngKwords}); + this.m_tpAngle.Location = new System.Drawing.Point(4, 22); + this.m_tpAngle.Name = "m_tpAngle"; + this.m_tpAngle.Size = new System.Drawing.Size(608, 318); + this.m_tpAngle.TabIndex = 7; + this.m_tpAngle.Text = "Angle"; + // + // m_txtAngMessage + // + this.m_txtAngMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtAngMessage.Name = "m_txtAngMessage"; + this.m_txtAngMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtAngMessage.TabIndex = 9; + this.m_txtAngMessage.Text = "Message"; + // + // m_ebAngMessage + // + this.m_ebAngMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebAngMessage.Name = "m_ebAngMessage"; + this.m_ebAngMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebAngMessage.TabIndex = 7; + this.m_ebAngMessage.Text = "Enter an angle"; + // + // m_gbAngOptions + // + this.m_gbAngOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbAngUseDefault, + this.m_cbAngUseDashedLine, + this.m_ebAngDefault, + this.m_txtAngDefault, + this.m_cbAngUseBasePt, + this.m_cbAngAllowZero, + this.m_cbAngAllowNone, + this.m_cbAngAllowArbitraryInput}); + this.m_gbAngOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbAngOptions.Name = "m_gbAngOptions"; + this.m_gbAngOptions.Size = new System.Drawing.Size(168, 264); + this.m_gbAngOptions.TabIndex = 8; + this.m_gbAngOptions.TabStop = false; + this.m_gbAngOptions.Text = "Options"; + // + // m_cbAngUseDefault + // + this.m_cbAngUseDefault.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbAngUseDefault.Location = new System.Drawing.Point(8, 144); + this.m_cbAngUseDefault.Name = "m_cbAngUseDefault"; + this.m_cbAngUseDefault.Size = new System.Drawing.Size(120, 24); + this.m_cbAngUseDefault.TabIndex = 8; + this.m_cbAngUseDefault.Text = "Use Default"; + this.m_cbAngUseDefault.Click += new System.EventHandler(this.OnAngUseDefaultValue); + // + // m_cbAngUseDashedLine + // + this.m_cbAngUseDashedLine.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbAngUseDashedLine.Location = new System.Drawing.Point(8, 120); + this.m_cbAngUseDashedLine.Name = "m_cbAngUseDashedLine"; + this.m_cbAngUseDashedLine.Size = new System.Drawing.Size(144, 24); + this.m_cbAngUseDashedLine.TabIndex = 7; + this.m_cbAngUseDashedLine.Text = "Use Dashed Line"; + // + // m_ebAngDefault + // + this.m_ebAngDefault.Location = new System.Drawing.Point(64, 176); + this.m_ebAngDefault.Name = "m_ebAngDefault"; + this.m_ebAngDefault.Size = new System.Drawing.Size(88, 20); + this.m_ebAngDefault.TabIndex = 6; + this.m_ebAngDefault.Text = ""; + // + // m_txtAngDefault + // + this.m_txtAngDefault.Location = new System.Drawing.Point(8, 176); + this.m_txtAngDefault.Name = "m_txtAngDefault"; + this.m_txtAngDefault.Size = new System.Drawing.Size(56, 23); + this.m_txtAngDefault.TabIndex = 5; + this.m_txtAngDefault.Text = "Default"; + // + // m_cbAngUseBasePt + // + this.m_cbAngUseBasePt.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbAngUseBasePt.Location = new System.Drawing.Point(8, 96); + this.m_cbAngUseBasePt.Name = "m_cbAngUseBasePt"; + this.m_cbAngUseBasePt.Size = new System.Drawing.Size(144, 24); + this.m_cbAngUseBasePt.TabIndex = 4; + this.m_cbAngUseBasePt.Text = "Use Base Point"; + // + // m_cbAngAllowZero + // + this.m_cbAngAllowZero.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbAngAllowZero.Location = new System.Drawing.Point(8, 72); + this.m_cbAngAllowZero.Name = "m_cbAngAllowZero"; + this.m_cbAngAllowZero.TabIndex = 2; + this.m_cbAngAllowZero.Text = "Allow Zero"; + // + // m_cbAngAllowNone + // + this.m_cbAngAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbAngAllowNone.Location = new System.Drawing.Point(8, 48); + this.m_cbAngAllowNone.Name = "m_cbAngAllowNone"; + this.m_cbAngAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbAngAllowNone.TabIndex = 1; + this.m_cbAngAllowNone.Text = "Allow None"; + // + // m_cbAngAllowArbitraryInput + // + this.m_cbAngAllowArbitraryInput.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbAngAllowArbitraryInput.Location = new System.Drawing.Point(8, 24); + this.m_cbAngAllowArbitraryInput.Name = "m_cbAngAllowArbitraryInput"; + this.m_cbAngAllowArbitraryInput.Size = new System.Drawing.Size(136, 24); + this.m_cbAngAllowArbitraryInput.TabIndex = 0; + this.m_cbAngAllowArbitraryInput.Text = "Allow Arbitrary Input"; + // + // m_gbAngKwords + // + this.m_gbAngKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnAngKwordHardwire, + this.m_ebAngKwordDef, + this.m_txtAngKwordDef, + this.m_bnAngKwordClear, + this.m_bnAngKwordEdit, + this.m_bnAngKwordAdd, + this.m_lvAngKwords}); + this.m_gbAngKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbAngKwords.Name = "m_gbAngKwords"; + this.m_gbAngKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbAngKwords.TabIndex = 10; + this.m_gbAngKwords.TabStop = false; + this.m_gbAngKwords.Text = "Key Words"; + // + // m_bnAngKwordHardwire + // + this.m_bnAngKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnAngKwordHardwire.Name = "m_bnAngKwordHardwire"; + this.m_bnAngKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnAngKwordHardwire.TabIndex = 15; + this.m_bnAngKwordHardwire.Text = "Hardwire"; + this.m_bnAngKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebAngKwordDef + // + this.m_ebAngKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebAngKwordDef.Name = "m_ebAngKwordDef"; + this.m_ebAngKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebAngKwordDef.TabIndex = 14; + this.m_ebAngKwordDef.Text = ""; + // + // m_txtAngKwordDef + // + this.m_txtAngKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtAngKwordDef.Name = "m_txtAngKwordDef"; + this.m_txtAngKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtAngKwordDef.TabIndex = 13; + this.m_txtAngKwordDef.Text = "Default"; + // + // m_bnAngKwordClear + // + this.m_bnAngKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnAngKwordClear.Name = "m_bnAngKwordClear"; + this.m_bnAngKwordClear.TabIndex = 3; + this.m_bnAngKwordClear.Text = "Clear"; + this.m_bnAngKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnAngKwordEdit + // + this.m_bnAngKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnAngKwordEdit.Name = "m_bnAngKwordEdit"; + this.m_bnAngKwordEdit.TabIndex = 2; + this.m_bnAngKwordEdit.Text = "Edit..."; + this.m_bnAngKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnAngKwordAdd + // + this.m_bnAngKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnAngKwordAdd.Name = "m_bnAngKwordAdd"; + this.m_bnAngKwordAdd.TabIndex = 1; + this.m_bnAngKwordAdd.Text = "Add..."; + this.m_bnAngKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvAngKwords + // + this.m_lvAngKwords.CausesValidation = false; + this.m_lvAngKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColAngGlobal, + this.m_lvColAngLocal, + this.m_lvColAngDisplay, + this.m_lvColAngEnabled, + this.m_lvColAngVisible}); + this.m_lvAngKwords.FullRowSelect = true; + this.m_lvAngKwords.GridLines = true; + this.m_lvAngKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvAngKwords.HideSelection = false; + this.m_lvAngKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvAngKwords.MultiSelect = false; + this.m_lvAngKwords.Name = "m_lvAngKwords"; + this.m_lvAngKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvAngKwords.TabIndex = 0; + this.m_lvAngKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColAngGlobal + // + this.m_lvColAngGlobal.Text = "Global"; + this.m_lvColAngGlobal.Width = 80; + // + // m_lvColAngLocal + // + this.m_lvColAngLocal.Text = "Local"; + this.m_lvColAngLocal.Width = 80; + // + // m_lvColAngDisplay + // + this.m_lvColAngDisplay.Text = "Display"; + this.m_lvColAngDisplay.Width = 80; + // + // m_lvColAngEnabled + // + this.m_lvColAngEnabled.Text = "Enabled"; + // + // m_lvColAngVisible + // + this.m_lvColAngVisible.Text = "Visible"; + // + // m_tpCorner + // + this.m_tpCorner.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbCrnOptions, + this.m_gbCrnKwords, + this.m_ebCrnMessage, + this.m_txtCrnMessage}); + this.m_tpCorner.Location = new System.Drawing.Point(4, 22); + this.m_tpCorner.Name = "m_tpCorner"; + this.m_tpCorner.Size = new System.Drawing.Size(608, 318); + this.m_tpCorner.TabIndex = 3; + this.m_tpCorner.Text = "Corner"; + // + // m_gbCrnOptions + // + this.m_gbCrnOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbCrnUseDashedLine, + this.m_cbCrnLimitsChecked, + this.m_cbCrnAllowNone, + this.m_cbCrnAllowArbitraryInput}); + this.m_gbCrnOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbCrnOptions.Name = "m_gbCrnOptions"; + this.m_gbCrnOptions.Size = new System.Drawing.Size(168, 264); + this.m_gbCrnOptions.TabIndex = 12; + this.m_gbCrnOptions.TabStop = false; + this.m_gbCrnOptions.Text = "Options"; + // + // m_cbCrnUseDashedLine + // + this.m_cbCrnUseDashedLine.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbCrnUseDashedLine.Location = new System.Drawing.Point(8, 96); + this.m_cbCrnUseDashedLine.Name = "m_cbCrnUseDashedLine"; + this.m_cbCrnUseDashedLine.Size = new System.Drawing.Size(144, 24); + this.m_cbCrnUseDashedLine.TabIndex = 7; + this.m_cbCrnUseDashedLine.Text = "Use Dashed Line"; + // + // m_cbCrnLimitsChecked + // + this.m_cbCrnLimitsChecked.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbCrnLimitsChecked.Location = new System.Drawing.Point(8, 72); + this.m_cbCrnLimitsChecked.Name = "m_cbCrnLimitsChecked"; + this.m_cbCrnLimitsChecked.TabIndex = 2; + this.m_cbCrnLimitsChecked.Text = "Limits Checked"; + // + // m_cbCrnAllowNone + // + this.m_cbCrnAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbCrnAllowNone.Location = new System.Drawing.Point(8, 48); + this.m_cbCrnAllowNone.Name = "m_cbCrnAllowNone"; + this.m_cbCrnAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbCrnAllowNone.TabIndex = 1; + this.m_cbCrnAllowNone.Text = "Allow None"; + // + // m_cbCrnAllowArbitraryInput + // + this.m_cbCrnAllowArbitraryInput.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbCrnAllowArbitraryInput.Location = new System.Drawing.Point(8, 24); + this.m_cbCrnAllowArbitraryInput.Name = "m_cbCrnAllowArbitraryInput"; + this.m_cbCrnAllowArbitraryInput.Size = new System.Drawing.Size(136, 24); + this.m_cbCrnAllowArbitraryInput.TabIndex = 0; + this.m_cbCrnAllowArbitraryInput.Text = "Allow Arbitrary Input"; + // + // m_gbCrnKwords + // + this.m_gbCrnKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnCrnKwordHardwire, + this.m_ebCrnKwordDef, + this.m_txtCrnKwordDef, + this.m_bnCrnKwordClear, + this.m_bnCrnKwordEdit, + this.m_bnCrnKwordAdd, + this.m_lvCrnKwords}); + this.m_gbCrnKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbCrnKwords.Name = "m_gbCrnKwords"; + this.m_gbCrnKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbCrnKwords.TabIndex = 14; + this.m_gbCrnKwords.TabStop = false; + this.m_gbCrnKwords.Text = "Key Words"; + // + // m_bnCrnKwordHardwire + // + this.m_bnCrnKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnCrnKwordHardwire.Name = "m_bnCrnKwordHardwire"; + this.m_bnCrnKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnCrnKwordHardwire.TabIndex = 18; + this.m_bnCrnKwordHardwire.Text = "Hardwire"; + this.m_bnCrnKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebCrnKwordDef + // + this.m_ebCrnKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebCrnKwordDef.Name = "m_ebCrnKwordDef"; + this.m_ebCrnKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebCrnKwordDef.TabIndex = 17; + this.m_ebCrnKwordDef.Text = ""; + // + // m_txtCrnKwordDef + // + this.m_txtCrnKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtCrnKwordDef.Name = "m_txtCrnKwordDef"; + this.m_txtCrnKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtCrnKwordDef.TabIndex = 16; + this.m_txtCrnKwordDef.Text = "Default"; + // + // m_bnCrnKwordClear + // + this.m_bnCrnKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnCrnKwordClear.Name = "m_bnCrnKwordClear"; + this.m_bnCrnKwordClear.TabIndex = 3; + this.m_bnCrnKwordClear.Text = "Clear"; + this.m_bnCrnKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnCrnKwordEdit + // + this.m_bnCrnKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnCrnKwordEdit.Name = "m_bnCrnKwordEdit"; + this.m_bnCrnKwordEdit.TabIndex = 2; + this.m_bnCrnKwordEdit.Text = "Edit..."; + this.m_bnCrnKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnCrnKwordAdd + // + this.m_bnCrnKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnCrnKwordAdd.Name = "m_bnCrnKwordAdd"; + this.m_bnCrnKwordAdd.TabIndex = 1; + this.m_bnCrnKwordAdd.Text = "Add..."; + this.m_bnCrnKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvCrnKwords + // + this.m_lvCrnKwords.CausesValidation = false; + this.m_lvCrnKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColCrnGlobal, + this.m_lvColCrnLocal, + this.m_lvColCrnDisplay, + this.m_lvColCrnEnabled, + this.m_lvColCrnVisible}); + this.m_lvCrnKwords.FullRowSelect = true; + this.m_lvCrnKwords.GridLines = true; + this.m_lvCrnKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvCrnKwords.HideSelection = false; + this.m_lvCrnKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvCrnKwords.MultiSelect = false; + this.m_lvCrnKwords.Name = "m_lvCrnKwords"; + this.m_lvCrnKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvCrnKwords.TabIndex = 0; + this.m_lvCrnKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColCrnGlobal + // + this.m_lvColCrnGlobal.Text = "Global"; + this.m_lvColCrnGlobal.Width = 80; + // + // m_lvColCrnLocal + // + this.m_lvColCrnLocal.Text = "Local"; + this.m_lvColCrnLocal.Width = 80; + // + // m_lvColCrnDisplay + // + this.m_lvColCrnDisplay.Text = "Display"; + this.m_lvColCrnDisplay.Width = 80; + // + // m_lvColCrnEnabled + // + this.m_lvColCrnEnabled.Text = "Enabled"; + // + // m_lvColCrnVisible + // + this.m_lvColCrnVisible.Text = "Visible"; + // + // m_ebCrnMessage + // + this.m_ebCrnMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebCrnMessage.Name = "m_ebCrnMessage"; + this.m_ebCrnMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebCrnMessage.TabIndex = 11; + this.m_ebCrnMessage.Text = "Enter other corner"; + // + // m_txtCrnMessage + // + this.m_txtCrnMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtCrnMessage.Name = "m_txtCrnMessage"; + this.m_txtCrnMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtCrnMessage.TabIndex = 13; + this.m_txtCrnMessage.Text = "Message"; + // + // m_tpPoint + // + this.m_tpPoint.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbPtOptions, + this.m_gbPtKwords, + this.m_ebPtMessage, + this.m_txtPtMessage}); + this.m_tpPoint.Location = new System.Drawing.Point(4, 22); + this.m_tpPoint.Name = "m_tpPoint"; + this.m_tpPoint.Size = new System.Drawing.Size(608, 318); + this.m_tpPoint.TabIndex = 4; + this.m_tpPoint.Text = "Point"; + // + // m_gbPtOptions + // + this.m_gbPtOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbPtUseBasePt, + this.m_cbPtUseDashedLine, + this.m_cbPtLimitsChecked, + this.m_cbPtAllowNone, + this.m_cbPtAllowArbitraryInput}); + this.m_gbPtOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbPtOptions.Name = "m_gbPtOptions"; + this.m_gbPtOptions.Size = new System.Drawing.Size(168, 264); + this.m_gbPtOptions.TabIndex = 16; + this.m_gbPtOptions.TabStop = false; + this.m_gbPtOptions.Text = "Options"; + // + // m_cbPtUseBasePt + // + this.m_cbPtUseBasePt.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbPtUseBasePt.Location = new System.Drawing.Point(8, 120); + this.m_cbPtUseBasePt.Name = "m_cbPtUseBasePt"; + this.m_cbPtUseBasePt.Size = new System.Drawing.Size(128, 24); + this.m_cbPtUseBasePt.TabIndex = 8; + this.m_cbPtUseBasePt.Text = "Use Base Point"; + // + // m_cbPtUseDashedLine + // + this.m_cbPtUseDashedLine.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbPtUseDashedLine.Location = new System.Drawing.Point(8, 96); + this.m_cbPtUseDashedLine.Name = "m_cbPtUseDashedLine"; + this.m_cbPtUseDashedLine.Size = new System.Drawing.Size(144, 24); + this.m_cbPtUseDashedLine.TabIndex = 7; + this.m_cbPtUseDashedLine.Text = "Use Dashed Line"; + // + // m_cbPtLimitsChecked + // + this.m_cbPtLimitsChecked.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbPtLimitsChecked.Location = new System.Drawing.Point(8, 72); + this.m_cbPtLimitsChecked.Name = "m_cbPtLimitsChecked"; + this.m_cbPtLimitsChecked.TabIndex = 2; + this.m_cbPtLimitsChecked.Text = "Limits Checked"; + // + // m_cbPtAllowNone + // + this.m_cbPtAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbPtAllowNone.Location = new System.Drawing.Point(8, 48); + this.m_cbPtAllowNone.Name = "m_cbPtAllowNone"; + this.m_cbPtAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbPtAllowNone.TabIndex = 1; + this.m_cbPtAllowNone.Text = "Allow None"; + // + // m_cbPtAllowArbitraryInput + // + this.m_cbPtAllowArbitraryInput.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbPtAllowArbitraryInput.Location = new System.Drawing.Point(8, 24); + this.m_cbPtAllowArbitraryInput.Name = "m_cbPtAllowArbitraryInput"; + this.m_cbPtAllowArbitraryInput.Size = new System.Drawing.Size(136, 24); + this.m_cbPtAllowArbitraryInput.TabIndex = 0; + this.m_cbPtAllowArbitraryInput.Text = "Allow Arbitrary Input"; + // + // m_gbPtKwords + // + this.m_gbPtKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnPtKwordHardwire, + this.m_ebPtKwordDef, + this.m_txtPtKwordDef, + this.m_bnPtKwordClear, + this.m_bnPtKwordEdit, + this.m_bnPtKwordAdd, + this.m_lvPtKwords}); + this.m_gbPtKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbPtKwords.Name = "m_gbPtKwords"; + this.m_gbPtKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbPtKwords.TabIndex = 18; + this.m_gbPtKwords.TabStop = false; + this.m_gbPtKwords.Text = "Key Words"; + // + // m_bnPtKwordHardwire + // + this.m_bnPtKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnPtKwordHardwire.Name = "m_bnPtKwordHardwire"; + this.m_bnPtKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnPtKwordHardwire.TabIndex = 21; + this.m_bnPtKwordHardwire.Text = "Hardwire"; + this.m_bnPtKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebPtKwordDef + // + this.m_ebPtKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebPtKwordDef.Name = "m_ebPtKwordDef"; + this.m_ebPtKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebPtKwordDef.TabIndex = 20; + this.m_ebPtKwordDef.Text = ""; + // + // m_txtPtKwordDef + // + this.m_txtPtKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtPtKwordDef.Name = "m_txtPtKwordDef"; + this.m_txtPtKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtPtKwordDef.TabIndex = 19; + this.m_txtPtKwordDef.Text = "Default"; + // + // m_bnPtKwordClear + // + this.m_bnPtKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnPtKwordClear.Name = "m_bnPtKwordClear"; + this.m_bnPtKwordClear.TabIndex = 3; + this.m_bnPtKwordClear.Text = "Clear"; + this.m_bnPtKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnPtKwordEdit + // + this.m_bnPtKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnPtKwordEdit.Name = "m_bnPtKwordEdit"; + this.m_bnPtKwordEdit.TabIndex = 2; + this.m_bnPtKwordEdit.Text = "Edit..."; + this.m_bnPtKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnPtKwordAdd + // + this.m_bnPtKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnPtKwordAdd.Name = "m_bnPtKwordAdd"; + this.m_bnPtKwordAdd.TabIndex = 1; + this.m_bnPtKwordAdd.Text = "Add..."; + this.m_bnPtKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvPtKwords + // + this.m_lvPtKwords.CausesValidation = false; + this.m_lvPtKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColPtGlobal, + this.m_lvColPtLocal, + this.m_lvColPtDisplay, + this.m_lvColPtEnabled, + this.m_lvColPtVisible}); + this.m_lvPtKwords.FullRowSelect = true; + this.m_lvPtKwords.GridLines = true; + this.m_lvPtKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvPtKwords.HideSelection = false; + this.m_lvPtKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvPtKwords.MultiSelect = false; + this.m_lvPtKwords.Name = "m_lvPtKwords"; + this.m_lvPtKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvPtKwords.TabIndex = 0; + this.m_lvPtKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColPtGlobal + // + this.m_lvColPtGlobal.Text = "Global"; + this.m_lvColPtGlobal.Width = 80; + // + // m_lvColPtLocal + // + this.m_lvColPtLocal.Text = "Local"; + this.m_lvColPtLocal.Width = 80; + // + // m_lvColPtDisplay + // + this.m_lvColPtDisplay.Text = "Display"; + this.m_lvColPtDisplay.Width = 80; + // + // m_lvColPtEnabled + // + this.m_lvColPtEnabled.Text = "Enabled"; + // + // m_lvColPtVisible + // + this.m_lvColPtVisible.Text = "Visible"; + // + // m_ebPtMessage + // + this.m_ebPtMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebPtMessage.Name = "m_ebPtMessage"; + this.m_ebPtMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebPtMessage.TabIndex = 15; + this.m_ebPtMessage.Text = "Enter a point"; + // + // m_txtPtMessage + // + this.m_txtPtMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtPtMessage.Name = "m_txtPtMessage"; + this.m_txtPtMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtPtMessage.TabIndex = 17; + this.m_txtPtMessage.Text = "Message"; + // + // m_tpString + // + this.m_tpString.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbStrOptions, + this.m_ebStrMessage, + this.m_txtStrMessage}); + this.m_tpString.Location = new System.Drawing.Point(4, 22); + this.m_tpString.Name = "m_tpString"; + this.m_tpString.Size = new System.Drawing.Size(608, 318); + this.m_tpString.TabIndex = 5; + this.m_tpString.Text = "String"; + // + // m_gbStrOptions + // + this.m_gbStrOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbStrAllowSpaces}); + this.m_gbStrOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbStrOptions.Name = "m_gbStrOptions"; + this.m_gbStrOptions.Size = new System.Drawing.Size(168, 232); + this.m_gbStrOptions.TabIndex = 20; + this.m_gbStrOptions.TabStop = false; + this.m_gbStrOptions.Text = "Options"; + // + // m_cbStrAllowSpaces + // + this.m_cbStrAllowSpaces.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbStrAllowSpaces.Location = new System.Drawing.Point(8, 24); + this.m_cbStrAllowSpaces.Name = "m_cbStrAllowSpaces"; + this.m_cbStrAllowSpaces.Size = new System.Drawing.Size(136, 24); + this.m_cbStrAllowSpaces.TabIndex = 0; + this.m_cbStrAllowSpaces.Text = "Allow Spaces"; + // + // m_ebStrMessage + // + this.m_ebStrMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebStrMessage.Name = "m_ebStrMessage"; + this.m_ebStrMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebStrMessage.TabIndex = 19; + this.m_ebStrMessage.Text = "Enter a string"; + // + // m_txtStrMessage + // + this.m_txtStrMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtStrMessage.Name = "m_txtStrMessage"; + this.m_txtStrMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtStrMessage.TabIndex = 21; + this.m_txtStrMessage.Text = "Message"; + // + // m_tpKeyword + // + this.m_tpKeyword.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbKwdOptions, + this.m_gbKwdKwords, + this.m_ebKwdMessage, + this.m_txtKwdMessage}); + this.m_tpKeyword.Location = new System.Drawing.Point(4, 22); + this.m_tpKeyword.Name = "m_tpKeyword"; + this.m_tpKeyword.Size = new System.Drawing.Size(608, 318); + this.m_tpKeyword.TabIndex = 8; + this.m_tpKeyword.Text = "Keyword"; + // + // m_gbKwdOptions + // + this.m_gbKwdOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbKwdAllowArbitraryInput, + this.m_cbKwdAllowNone}); + this.m_gbKwdOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbKwdOptions.Name = "m_gbKwdOptions"; + this.m_gbKwdOptions.Size = new System.Drawing.Size(168, 264); + this.m_gbKwdOptions.TabIndex = 20; + this.m_gbKwdOptions.TabStop = false; + this.m_gbKwdOptions.Text = "Options"; + // + // m_cbKwdAllowArbitraryInput + // + this.m_cbKwdAllowArbitraryInput.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbKwdAllowArbitraryInput.Location = new System.Drawing.Point(8, 24); + this.m_cbKwdAllowArbitraryInput.Name = "m_cbKwdAllowArbitraryInput"; + this.m_cbKwdAllowArbitraryInput.Size = new System.Drawing.Size(136, 24); + this.m_cbKwdAllowArbitraryInput.TabIndex = 2; + this.m_cbKwdAllowArbitraryInput.Text = "Allow Arbitrary Input"; + // + // m_cbKwdAllowNone + // + this.m_cbKwdAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbKwdAllowNone.Location = new System.Drawing.Point(8, 48); + this.m_cbKwdAllowNone.Name = "m_cbKwdAllowNone"; + this.m_cbKwdAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbKwdAllowNone.TabIndex = 1; + this.m_cbKwdAllowNone.Text = "Allow None"; + // + // m_gbKwdKwords + // + this.m_gbKwdKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnKwdKwordHardwire, + this.m_ebKwdKwordDef, + this.m_txtKwdKwordDef, + this.m_bnKwdKwordClear, + this.m_bnKwdKwordEdit, + this.m_bnKwdKwordAdd, + this.m_lvKwdKwords}); + this.m_gbKwdKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbKwdKwords.Name = "m_gbKwdKwords"; + this.m_gbKwdKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbKwdKwords.TabIndex = 22; + this.m_gbKwdKwords.TabStop = false; + this.m_gbKwdKwords.Text = "Key Words"; + // + // m_bnKwdKwordHardwire + // + this.m_bnKwdKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnKwdKwordHardwire.Name = "m_bnKwdKwordHardwire"; + this.m_bnKwdKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnKwdKwordHardwire.TabIndex = 24; + this.m_bnKwdKwordHardwire.Text = "Hardwire"; + this.m_bnKwdKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebKwdKwordDef + // + this.m_ebKwdKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebKwdKwordDef.Name = "m_ebKwdKwordDef"; + this.m_ebKwdKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebKwdKwordDef.TabIndex = 23; + this.m_ebKwdKwordDef.Text = ""; + // + // m_txtKwdKwordDef + // + this.m_txtKwdKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtKwdKwordDef.Name = "m_txtKwdKwordDef"; + this.m_txtKwdKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtKwdKwordDef.TabIndex = 22; + this.m_txtKwdKwordDef.Text = "Default"; + // + // m_bnKwdKwordClear + // + this.m_bnKwdKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnKwdKwordClear.Name = "m_bnKwdKwordClear"; + this.m_bnKwdKwordClear.TabIndex = 3; + this.m_bnKwdKwordClear.Text = "Clear"; + this.m_bnKwdKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnKwdKwordEdit + // + this.m_bnKwdKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnKwdKwordEdit.Name = "m_bnKwdKwordEdit"; + this.m_bnKwdKwordEdit.TabIndex = 2; + this.m_bnKwdKwordEdit.Text = "Edit..."; + this.m_bnKwdKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnKwdKwordAdd + // + this.m_bnKwdKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnKwdKwordAdd.Name = "m_bnKwdKwordAdd"; + this.m_bnKwdKwordAdd.TabIndex = 1; + this.m_bnKwdKwordAdd.Text = "Add..."; + this.m_bnKwdKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvKwdKwords + // + this.m_lvKwdKwords.CausesValidation = false; + this.m_lvKwdKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColKwdGlobal, + this.m_lvColKwdLocal, + this.m_lvColKwdDisplay, + this.m_lvColKwdEnabled, + this.m_lvColKwdVisible}); + this.m_lvKwdKwords.FullRowSelect = true; + this.m_lvKwdKwords.GridLines = true; + this.m_lvKwdKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvKwdKwords.HideSelection = false; + this.m_lvKwdKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvKwdKwords.MultiSelect = false; + this.m_lvKwdKwords.Name = "m_lvKwdKwords"; + this.m_lvKwdKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvKwdKwords.TabIndex = 0; + this.m_lvKwdKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColKwdGlobal + // + this.m_lvColKwdGlobal.Text = "Global"; + this.m_lvColKwdGlobal.Width = 80; + // + // m_lvColKwdLocal + // + this.m_lvColKwdLocal.Text = "Local"; + this.m_lvColKwdLocal.Width = 80; + // + // m_lvColKwdDisplay + // + this.m_lvColKwdDisplay.Text = "Display"; + this.m_lvColKwdDisplay.Width = 80; + // + // m_lvColKwdEnabled + // + this.m_lvColKwdEnabled.Text = "Enabled"; + // + // m_lvColKwdVisible + // + this.m_lvColKwdVisible.Text = "Visible"; + // + // m_ebKwdMessage + // + this.m_ebKwdMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebKwdMessage.Name = "m_ebKwdMessage"; + this.m_ebKwdMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebKwdMessage.TabIndex = 19; + this.m_ebKwdMessage.Text = "Enter a keyword"; + // + // m_txtKwdMessage + // + this.m_txtKwdMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtKwdMessage.Name = "m_txtKwdMessage"; + this.m_txtKwdMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtKwdMessage.TabIndex = 21; + this.m_txtKwdMessage.Text = "Message"; + // + // m_tpEntity + // + this.m_tpEntity.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbEntFilterClasses, + this.m_gbEntKwords, + this.m_gbEntOptions, + this.m_ebEntMessage, + this.m_txtEntMessage}); + this.m_tpEntity.Location = new System.Drawing.Point(4, 22); + this.m_tpEntity.Name = "m_tpEntity"; + this.m_tpEntity.Size = new System.Drawing.Size(608, 318); + this.m_tpEntity.TabIndex = 6; + this.m_tpEntity.Text = "Entity"; + // + // m_gbEntFilterClasses + // + this.m_gbEntFilterClasses.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbEntAllowCurves, + this.m_txtEntSampleFilter, + this.m_ebEntDoIsATest, + this.m_cbEntAllowCircles, + this.m_cbEntAllowLines, + this.m_ebEntRejectMessage, + this.m_txtEntRejectMessage}); + this.m_gbEntFilterClasses.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_gbEntFilterClasses.Location = new System.Drawing.Point(16, 136); + this.m_gbEntFilterClasses.Name = "m_gbEntFilterClasses"; + this.m_gbEntFilterClasses.Size = new System.Drawing.Size(168, 176); + this.m_gbEntFilterClasses.TabIndex = 26; + this.m_gbEntFilterClasses.TabStop = false; + this.m_gbEntFilterClasses.Text = "Filter Classes"; + // + // m_cbEntAllowCurves + // + this.m_cbEntAllowCurves.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbEntAllowCurves.Location = new System.Drawing.Point(8, 72); + this.m_cbEntAllowCurves.Name = "m_cbEntAllowCurves"; + this.m_cbEntAllowCurves.Size = new System.Drawing.Size(144, 24); + this.m_cbEntAllowCurves.TabIndex = 13; + this.m_cbEntAllowCurves.Text = "Allow Curves"; + this.m_cbEntAllowCurves.Click += new System.EventHandler(this.OnEntAllowLines); + // + // m_txtEntSampleFilter + // + this.m_txtEntSampleFilter.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_txtEntSampleFilter.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.m_txtEntSampleFilter.ForeColor = System.Drawing.Color.MediumBlue; + this.m_txtEntSampleFilter.Location = new System.Drawing.Point(80, 0); + this.m_txtEntSampleFilter.Name = "m_txtEntSampleFilter"; + this.m_txtEntSampleFilter.TabIndex = 12; + this.m_txtEntSampleFilter.Text = "(Sample)"; + // + // m_ebEntDoIsATest + // + this.m_ebEntDoIsATest.Enabled = false; + this.m_ebEntDoIsATest.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_ebEntDoIsATest.Location = new System.Drawing.Point(8, 96); + this.m_ebEntDoIsATest.Name = "m_ebEntDoIsATest"; + this.m_ebEntDoIsATest.Size = new System.Drawing.Size(128, 24); + this.m_ebEntDoIsATest.TabIndex = 11; + this.m_ebEntDoIsATest.Text = "Exact Class Match"; + // + // m_cbEntAllowCircles + // + this.m_cbEntAllowCircles.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbEntAllowCircles.Location = new System.Drawing.Point(8, 48); + this.m_cbEntAllowCircles.Name = "m_cbEntAllowCircles"; + this.m_cbEntAllowCircles.Size = new System.Drawing.Size(144, 24); + this.m_cbEntAllowCircles.TabIndex = 10; + this.m_cbEntAllowCircles.Text = "Allow Circles"; + this.m_cbEntAllowCircles.Click += new System.EventHandler(this.OnEntAllowLines); + // + // m_cbEntAllowLines + // + this.m_cbEntAllowLines.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbEntAllowLines.Location = new System.Drawing.Point(8, 24); + this.m_cbEntAllowLines.Name = "m_cbEntAllowLines"; + this.m_cbEntAllowLines.Size = new System.Drawing.Size(144, 24); + this.m_cbEntAllowLines.TabIndex = 9; + this.m_cbEntAllowLines.Text = "Allow Lines"; + this.m_cbEntAllowLines.Click += new System.EventHandler(this.OnEntAllowLines); + // + // m_ebEntRejectMessage + // + this.m_ebEntRejectMessage.Enabled = false; + this.m_ebEntRejectMessage.Location = new System.Drawing.Point(8, 144); + this.m_ebEntRejectMessage.Name = "m_ebEntRejectMessage"; + this.m_ebEntRejectMessage.Size = new System.Drawing.Size(152, 20); + this.m_ebEntRejectMessage.TabIndex = 8; + this.m_ebEntRejectMessage.Text = "Wrong type of entity selected!"; + // + // m_txtEntRejectMessage + // + this.m_txtEntRejectMessage.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_txtEntRejectMessage.Location = new System.Drawing.Point(8, 120); + this.m_txtEntRejectMessage.Name = "m_txtEntRejectMessage"; + this.m_txtEntRejectMessage.Size = new System.Drawing.Size(96, 23); + this.m_txtEntRejectMessage.TabIndex = 7; + this.m_txtEntRejectMessage.Text = "Reject Message"; + // + // m_gbEntKwords + // + this.m_gbEntKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnEntKwordHardwire, + this.m_ebEntKwordDef, + this.m_txtEntKwordDef, + this.m_bnEntKwordClear, + this.m_bnEntKwordEdit, + this.m_bnEntKwordAdd, + this.m_lvEntKwords}); + this.m_gbEntKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbEntKwords.Name = "m_gbEntKwords"; + this.m_gbEntKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbEntKwords.TabIndex = 25; + this.m_gbEntKwords.TabStop = false; + this.m_gbEntKwords.Text = "Key Words"; + // + // m_bnEntKwordHardwire + // + this.m_bnEntKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnEntKwordHardwire.Name = "m_bnEntKwordHardwire"; + this.m_bnEntKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnEntKwordHardwire.TabIndex = 27; + this.m_bnEntKwordHardwire.Text = "Hardwire"; + this.m_bnEntKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebEntKwordDef + // + this.m_ebEntKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebEntKwordDef.Name = "m_ebEntKwordDef"; + this.m_ebEntKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebEntKwordDef.TabIndex = 26; + this.m_ebEntKwordDef.Text = ""; + // + // m_txtEntKwordDef + // + this.m_txtEntKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtEntKwordDef.Name = "m_txtEntKwordDef"; + this.m_txtEntKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtEntKwordDef.TabIndex = 25; + this.m_txtEntKwordDef.Text = "Default"; + // + // m_bnEntKwordClear + // + this.m_bnEntKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnEntKwordClear.Name = "m_bnEntKwordClear"; + this.m_bnEntKwordClear.TabIndex = 3; + this.m_bnEntKwordClear.Text = "Clear"; + this.m_bnEntKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnEntKwordEdit + // + this.m_bnEntKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnEntKwordEdit.Name = "m_bnEntKwordEdit"; + this.m_bnEntKwordEdit.TabIndex = 2; + this.m_bnEntKwordEdit.Text = "Edit..."; + this.m_bnEntKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnEntKwordAdd + // + this.m_bnEntKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnEntKwordAdd.Name = "m_bnEntKwordAdd"; + this.m_bnEntKwordAdd.TabIndex = 1; + this.m_bnEntKwordAdd.Text = "Add..."; + this.m_bnEntKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvEntKwords + // + this.m_lvEntKwords.CausesValidation = false; + this.m_lvEntKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColEntKwordGlobal, + this.m_lvColEntKwordLocal, + this.m_lvColEntKwordDisplay, + this.m_lvColEntKwordEnabled, + this.m_lvColEntKwordVisible}); + this.m_lvEntKwords.FullRowSelect = true; + this.m_lvEntKwords.GridLines = true; + this.m_lvEntKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvEntKwords.HideSelection = false; + this.m_lvEntKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvEntKwords.MultiSelect = false; + this.m_lvEntKwords.Name = "m_lvEntKwords"; + this.m_lvEntKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvEntKwords.TabIndex = 0; + this.m_lvEntKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColEntKwordGlobal + // + this.m_lvColEntKwordGlobal.Text = "Global"; + this.m_lvColEntKwordGlobal.Width = 80; + // + // m_lvColEntKwordLocal + // + this.m_lvColEntKwordLocal.Text = "Local"; + this.m_lvColEntKwordLocal.Width = 80; + // + // m_lvColEntKwordDisplay + // + this.m_lvColEntKwordDisplay.Text = "Display"; + this.m_lvColEntKwordDisplay.Width = 80; + // + // m_lvColEntKwordEnabled + // + this.m_lvColEntKwordEnabled.Text = "Enabled"; + // + // m_lvColEntKwordVisible + // + this.m_lvColEntKwordVisible.Text = "Visible"; + // + // m_gbEntOptions + // + this.m_gbEntOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbEntAllowLockedLayer, + this.m_cbEntAllowNone}); + this.m_gbEntOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbEntOptions.Name = "m_gbEntOptions"; + this.m_gbEntOptions.Size = new System.Drawing.Size(168, 80); + this.m_gbEntOptions.TabIndex = 23; + this.m_gbEntOptions.TabStop = false; + this.m_gbEntOptions.Text = "Options"; + // + // m_cbEntAllowLockedLayer + // + this.m_cbEntAllowLockedLayer.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbEntAllowLockedLayer.Location = new System.Drawing.Point(8, 48); + this.m_cbEntAllowLockedLayer.Name = "m_cbEntAllowLockedLayer"; + this.m_cbEntAllowLockedLayer.Size = new System.Drawing.Size(144, 24); + this.m_cbEntAllowLockedLayer.TabIndex = 2; + this.m_cbEntAllowLockedLayer.Text = "Allow Locked Layer"; + // + // m_cbEntAllowNone + // + this.m_cbEntAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbEntAllowNone.Location = new System.Drawing.Point(8, 24); + this.m_cbEntAllowNone.Name = "m_cbEntAllowNone"; + this.m_cbEntAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbEntAllowNone.TabIndex = 1; + this.m_cbEntAllowNone.Text = "Allow None"; + // + // m_ebEntMessage + // + this.m_ebEntMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebEntMessage.Name = "m_ebEntMessage"; + this.m_ebEntMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebEntMessage.TabIndex = 22; + this.m_ebEntMessage.Text = "Select entity"; + // + // m_txtEntMessage + // + this.m_txtEntMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtEntMessage.Name = "m_txtEntMessage"; + this.m_txtEntMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtEntMessage.TabIndex = 24; + this.m_txtEntMessage.Text = "Message"; + // + // m_tpNested + // + this.m_tpNested.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_gbNentKwords, + this.m_gbNentOptions, + this.m_ebNentMessage, + this.m_txtNentMessage}); + this.m_tpNested.Location = new System.Drawing.Point(4, 22); + this.m_tpNested.Name = "m_tpNested"; + this.m_tpNested.Size = new System.Drawing.Size(608, 318); + this.m_tpNested.TabIndex = 9; + this.m_tpNested.Text = "Nested Entity"; + // + // m_gbNentKwords + // + this.m_gbNentKwords.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnNentKwordHardwire, + this.m_ebNentKwordDef, + this.m_txtNentKwordDef, + this.m_bnNentKwordClear, + this.m_bnNentKwordEdit, + this.m_bnNentKwordAdd, + this.m_lvNentKwords}); + this.m_gbNentKwords.Location = new System.Drawing.Point(200, 48); + this.m_gbNentKwords.Name = "m_gbNentKwords"; + this.m_gbNentKwords.Size = new System.Drawing.Size(392, 264); + this.m_gbNentKwords.TabIndex = 29; + this.m_gbNentKwords.TabStop = false; + this.m_gbNentKwords.Text = "Key Words"; + // + // m_bnNentKwordHardwire + // + this.m_bnNentKwordHardwire.Location = new System.Drawing.Point(24, 200); + this.m_bnNentKwordHardwire.Name = "m_bnNentKwordHardwire"; + this.m_bnNentKwordHardwire.Size = new System.Drawing.Size(88, 23); + this.m_bnNentKwordHardwire.TabIndex = 27; + this.m_bnNentKwordHardwire.Text = "Hardwire"; + this.m_bnNentKwordHardwire.Click += new System.EventHandler(this.OnKwordHardwire); + // + // m_ebNentKwordDef + // + this.m_ebNentKwordDef.Location = new System.Drawing.Point(272, 232); + this.m_ebNentKwordDef.Name = "m_ebNentKwordDef"; + this.m_ebNentKwordDef.Size = new System.Drawing.Size(96, 20); + this.m_ebNentKwordDef.TabIndex = 26; + this.m_ebNentKwordDef.Text = ""; + // + // m_txtNentKwordDef + // + this.m_txtNentKwordDef.Location = new System.Drawing.Point(216, 232); + this.m_txtNentKwordDef.Name = "m_txtNentKwordDef"; + this.m_txtNentKwordDef.Size = new System.Drawing.Size(48, 23); + this.m_txtNentKwordDef.TabIndex = 25; + this.m_txtNentKwordDef.Text = "Default"; + // + // m_bnNentKwordClear + // + this.m_bnNentKwordClear.Location = new System.Drawing.Point(296, 200); + this.m_bnNentKwordClear.Name = "m_bnNentKwordClear"; + this.m_bnNentKwordClear.TabIndex = 3; + this.m_bnNentKwordClear.Text = "Clear"; + this.m_bnNentKwordClear.Click += new System.EventHandler(this.OnKwordClear); + // + // m_bnNentKwordEdit + // + this.m_bnNentKwordEdit.Location = new System.Drawing.Point(208, 200); + this.m_bnNentKwordEdit.Name = "m_bnNentKwordEdit"; + this.m_bnNentKwordEdit.TabIndex = 2; + this.m_bnNentKwordEdit.Text = "Edit..."; + this.m_bnNentKwordEdit.Click += new System.EventHandler(this.OnKwordEdit); + // + // m_bnNentKwordAdd + // + this.m_bnNentKwordAdd.Location = new System.Drawing.Point(120, 200); + this.m_bnNentKwordAdd.Name = "m_bnNentKwordAdd"; + this.m_bnNentKwordAdd.TabIndex = 1; + this.m_bnNentKwordAdd.Text = "Add..."; + this.m_bnNentKwordAdd.Click += new System.EventHandler(this.OnKwordAdd); + // + // m_lvNentKwords + // + this.m_lvNentKwords.CausesValidation = false; + this.m_lvNentKwords.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_lvColNentKwordsGlobal, + this.m_lvColNentKwordsLocal, + this.m_lvColNentKwordsDisplay, + this.m_lvColNentKwordsEnabled, + this.m_lvColNentKwordsVisible}); + this.m_lvNentKwords.FullRowSelect = true; + this.m_lvNentKwords.GridLines = true; + this.m_lvNentKwords.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_lvNentKwords.HideSelection = false; + this.m_lvNentKwords.Location = new System.Drawing.Point(16, 24); + this.m_lvNentKwords.MultiSelect = false; + this.m_lvNentKwords.Name = "m_lvNentKwords"; + this.m_lvNentKwords.Size = new System.Drawing.Size(360, 168); + this.m_lvNentKwords.TabIndex = 0; + this.m_lvNentKwords.View = System.Windows.Forms.View.Details; + // + // m_lvColNentKwordsGlobal + // + this.m_lvColNentKwordsGlobal.Text = "Global"; + this.m_lvColNentKwordsGlobal.Width = 80; + // + // m_lvColNentKwordsLocal + // + this.m_lvColNentKwordsLocal.Text = "Local"; + this.m_lvColNentKwordsLocal.Width = 80; + // + // m_lvColNentKwordsDisplay + // + this.m_lvColNentKwordsDisplay.Text = "Display"; + this.m_lvColNentKwordsDisplay.Width = 80; + // + // m_lvColNentKwordsEnabled + // + this.m_lvColNentKwordsEnabled.Text = "Enabled"; + // + // m_lvColNentKwordsVisible + // + this.m_lvColNentKwordsVisible.Text = "Visible"; + // + // m_gbNentOptions + // + this.m_gbNentOptions.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_cbNentNonInterPickPt, + this.m_cbNentAllowNone}); + this.m_gbNentOptions.Location = new System.Drawing.Point(16, 48); + this.m_gbNentOptions.Name = "m_gbNentOptions"; + this.m_gbNentOptions.Size = new System.Drawing.Size(168, 264); + this.m_gbNentOptions.TabIndex = 27; + this.m_gbNentOptions.TabStop = false; + this.m_gbNentOptions.Text = "Options"; + // + // m_cbNentNonInterPickPt + // + this.m_cbNentNonInterPickPt.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbNentNonInterPickPt.Location = new System.Drawing.Point(8, 48); + this.m_cbNentNonInterPickPt.Name = "m_cbNentNonInterPickPt"; + this.m_cbNentNonInterPickPt.Size = new System.Drawing.Size(136, 24); + this.m_cbNentNonInterPickPt.TabIndex = 2; + this.m_cbNentNonInterPickPt.Text = "Use Non-Interactive Pick Point"; + // + // m_cbNentAllowNone + // + this.m_cbNentAllowNone.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_cbNentAllowNone.Location = new System.Drawing.Point(8, 24); + this.m_cbNentAllowNone.Name = "m_cbNentAllowNone"; + this.m_cbNentAllowNone.Size = new System.Drawing.Size(128, 24); + this.m_cbNentAllowNone.TabIndex = 1; + this.m_cbNentAllowNone.Text = "Allow None"; + // + // m_ebNentMessage + // + this.m_ebNentMessage.Location = new System.Drawing.Point(88, 16); + this.m_ebNentMessage.Name = "m_ebNentMessage"; + this.m_ebNentMessage.Size = new System.Drawing.Size(504, 20); + this.m_ebNentMessage.TabIndex = 26; + this.m_ebNentMessage.Text = "Select nested entity"; + // + // m_txtNentMessage + // + this.m_txtNentMessage.Location = new System.Drawing.Point(16, 16); + this.m_txtNentMessage.Name = "m_txtNentMessage"; + this.m_txtNentMessage.Size = new System.Drawing.Size(56, 23); + this.m_txtNentMessage.TabIndex = 28; + this.m_txtNentMessage.Text = "Message"; + // + // m_bnRunTest + // + this.m_bnRunTest.DialogResult = System.Windows.Forms.DialogResult.OK; + this.m_bnRunTest.Location = new System.Drawing.Point(464, 368); + this.m_bnRunTest.Name = "m_bnRunTest"; + this.m_bnRunTest.TabIndex = 1; + this.m_bnRunTest.Text = "< Run Test"; + // + // m_bnCancel + // + this.m_bnCancel.CausesValidation = false; + this.m_bnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.m_bnCancel.Location = new System.Drawing.Point(552, 368); + this.m_bnCancel.Name = "m_bnCancel"; + this.m_bnCancel.TabIndex = 2; + this.m_bnCancel.Text = "Cancel"; + // + // PromptTestForm + // + this.AcceptButton = this.m_bnRunTest; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.CancelButton = this.m_bnCancel; + this.ClientSize = new System.Drawing.Size(648, 398); + this.Controls.AddRange(new System.Windows.Forms.Control[] { + this.m_bnCancel, + this.m_bnRunTest, + this.m_tcMain}); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "PromptTestForm"; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Prompts"; + this.m_tcMain.ResumeLayout(false); + this.m_tpInteger.ResumeLayout(false); + this.m_gbKeywords.ResumeLayout(false); + this.m_gbOptionsInt.ResumeLayout(false); + this.m_tpDouble.ResumeLayout(false); + this.m_gbDblKwords.ResumeLayout(false); + this.m_gbDblOpts.ResumeLayout(false); + this.m_tpDistance.ResumeLayout(false); + this.m_gbDistKwords.ResumeLayout(false); + this.m_gbDistOptions.ResumeLayout(false); + this.m_tpAngle.ResumeLayout(false); + this.m_gbAngOptions.ResumeLayout(false); + this.m_gbAngKwords.ResumeLayout(false); + this.m_tpCorner.ResumeLayout(false); + this.m_gbCrnOptions.ResumeLayout(false); + this.m_gbCrnKwords.ResumeLayout(false); + this.m_tpPoint.ResumeLayout(false); + this.m_gbPtOptions.ResumeLayout(false); + this.m_gbPtKwords.ResumeLayout(false); + this.m_tpString.ResumeLayout(false); + this.m_gbStrOptions.ResumeLayout(false); + this.m_tpKeyword.ResumeLayout(false); + this.m_gbKwdOptions.ResumeLayout(false); + this.m_gbKwdKwords.ResumeLayout(false); + this.m_tpEntity.ResumeLayout(false); + this.m_gbEntFilterClasses.ResumeLayout(false); + this.m_gbEntKwords.ResumeLayout(false); + this.m_gbEntOptions.ResumeLayout(false); + this.m_tpNested.ResumeLayout(false); + this.m_gbNentKwords.ResumeLayout(false); + this.m_gbNentOptions.ResumeLayout(false); + this.ResumeLayout(false); + } + + #endregion Windows Form Designer generated code + + /// + /// Disable the default value if they aren't going to use it + /// + + private void + OnIntUseDefaultValue(object sender, System.EventArgs e) + { + m_ebIntDefault.Enabled = m_cbIntUseDefault.Checked; + } + + private void + OnDblUseDefaultValue(object sender, System.EventArgs e) + { + m_ebDblDefault.Enabled = m_cbDblUseDefault.Checked; + } + + private void + OnDistUseDefaultValue(object sender, System.EventArgs e) + { + m_ebDistDefault.Enabled = m_cbDistUseDefault.Checked; + } + + private void + OnAngUseDefaultValue(object sender, System.EventArgs e) + { + m_ebAngDefault.Enabled = m_cbAngUseDefault.Checked; + } + + /// + /// After the form has been dismissed, figure out which page + /// was active and run that specific prompt. + /// + + public void + RunPrompt() + { + if (m_tcMain.SelectedTab == m_tpInteger) + { + RunIntegerPrompt(); + } + else if (m_tcMain.SelectedTab == m_tpDouble) + { + RunDoublePrompt(); + } + else if (m_tcMain.SelectedTab == m_tpDistance) + { + RunDistancePrompt(); + } + else if (m_tcMain.SelectedTab == m_tpAngle) + { + RunAnglePrompt(); + } + else if (m_tcMain.SelectedTab == m_tpCorner) + { + RunCornerPrompt(); + } + else if (m_tcMain.SelectedTab == m_tpPoint) + { + RunPointPrompt(); + } + else if (m_tcMain.SelectedTab == m_tpString) + { + RunStringPrompt(); + } + else if (m_tcMain.SelectedTab == m_tpKeyword) + { + RunKeywordPrompt(); + } + else if (m_tcMain.SelectedTab == m_tpEntity) + { + RunEntityPrompt(); + } + else if (m_tcMain.SelectedTab == m_tpNested) + { + RunNestedEntityPrompt(); + } + else + { + Debug.Assert(false, "Not a tab!"); + } + } + + private void + RunIntegerPrompt() + { + PromptIntegerOptions prOpts = new PromptIntegerOptions(string.Format("\n{0}", m_ebIntMessage.Text)); + prOpts.AllowArbitraryInput = m_cbIntAllowArbitraryInput.Checked; + prOpts.AllowNone = m_cbIntAllowNone.Checked; + prOpts.AllowZero = m_cbIntAllowZero.Checked; + prOpts.AllowNegative = m_cbIntAllowNegative.Checked; + prOpts.UseDefaultValue = m_cbIntUseDefault.Checked; + if (m_cbIntUseDefault.Checked) + prOpts.DefaultValue = int.Parse(m_ebIntDefault.Text); // TBD: need a validating EditBoxInteger + + AddKeywordsToPrompt(prOpts, m_kwordsInt, m_ebIntKwordDef.Text); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptIntegerResult prRes = ed.GetInteger(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunDoublePrompt() + { + PromptDoubleOptions prOpts = new PromptDoubleOptions(string.Format("\n{0}", m_ebDblMessage.Text)); + prOpts.AllowArbitraryInput = m_cbDblAllowArbitraryInput.Checked; + prOpts.AllowNone = m_cbDblAllowNone.Checked; + prOpts.AllowZero = m_cbDblAllowZero.Checked; + prOpts.AllowNegative = m_cbDblAllowNegative.Checked; + prOpts.UseDefaultValue = m_cbDblUseDefault.Checked; + if (m_cbDblUseDefault.Checked) + prOpts.DefaultValue = double.Parse(m_ebDblDefault.Text); // TBD: need a validating EditBoxDbleger + + AddKeywordsToPrompt(prOpts, m_kwordsDbl, m_ebDblKwordDef.Text); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptDoubleResult prRes = ed.GetDouble(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunDistancePrompt() + { + PromptDistanceOptions prOpts = new PromptDistanceOptions(string.Format("\n{0}", m_ebDistMessage.Text)); + prOpts.AllowArbitraryInput = m_cbDistAllowArbitraryInput.Checked; + prOpts.AllowNone = m_cbDistAllowNone.Checked; + prOpts.AllowZero = m_cbDistAllowZero.Checked; + prOpts.AllowNegative = m_cbDistAllowNegative.Checked; + prOpts.UseBasePoint = m_cbDistUseBasePt.Checked; + prOpts.UseDashedLine = m_cbDistUseDashedLine.Checked; + prOpts.Only2d = m_cbDistOnly2d.Checked; + prOpts.UseDefaultValue = m_cbDistUseDefault.Checked; + if (m_cbDistUseDefault.Checked) + prOpts.DefaultValue = double.Parse(m_ebDistDefault.Text); // TBD: need a validating EditBoxDbleger + + AddKeywordsToPrompt(prOpts, m_kwordsDist, m_ebDistKwordDef.Text); + + if (m_cbDistUseBasePt.Checked) + prOpts.BasePoint = GetBasePt(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptDoubleResult prRes = ed.GetDistance(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunAnglePrompt() + { + PromptAngleOptions prOpts = new PromptAngleOptions(string.Format("\n{0}", m_ebAngMessage.Text)); + prOpts.AllowArbitraryInput = m_cbAngAllowArbitraryInput.Checked; + prOpts.AllowNone = m_cbAngAllowNone.Checked; + prOpts.AllowZero = m_cbAngAllowZero.Checked; + prOpts.UseBasePoint = m_cbAngUseBasePt.Checked; + prOpts.UseDashedLine = m_cbAngUseDashedLine.Checked; + prOpts.UseDefaultValue = m_cbAngUseDefault.Checked; + if (m_cbAngUseDefault.Checked) + prOpts.DefaultValue = MgdDbg.Utils.Ge.DegreesToRadians(double.Parse(m_ebAngDefault.Text)); // TBD: need a validating EditBoxDbleger + + AddKeywordsToPrompt(prOpts, m_kwordsAng, m_ebAngKwordDef.Text); + + if (m_cbAngUseBasePt.Checked) + prOpts.BasePoint = GetBasePt(); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptDoubleResult prRes = ed.GetAngle(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunCornerPrompt() + { + Point3d basePt = GetBasePt(); // nees a base point to corner from + + PromptCornerOptions prOpts = new PromptCornerOptions(string.Format("\n{0}", m_ebCrnMessage.Text), basePt); + prOpts.AllowArbitraryInput = m_cbCrnAllowArbitraryInput.Checked; + prOpts.AllowNone = m_cbCrnAllowNone.Checked; + prOpts.LimitsChecked = m_cbCrnLimitsChecked.Checked; + prOpts.UseDashedLine = m_cbCrnUseDashedLine.Checked; + + AddKeywordsToPrompt(prOpts, m_kwordsCrn, m_ebCrnKwordDef.Text); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptPointResult prRes = ed.GetCorner(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunPointPrompt() + { + PromptPointOptions prOpts = new PromptPointOptions(string.Format("\n{0}", m_ebPtMessage.Text)); + prOpts.AllowArbitraryInput = m_cbPtAllowArbitraryInput.Checked; + prOpts.AllowNone = m_cbPtAllowNone.Checked; + prOpts.LimitsChecked = m_cbPtLimitsChecked.Checked; + prOpts.UseDashedLine = m_cbPtUseDashedLine.Checked; + prOpts.UseBasePoint = m_cbPtUseBasePt.Checked; + if (m_cbPtUseBasePt.Checked) + prOpts.BasePoint = GetBasePt(); + + AddKeywordsToPrompt(prOpts, m_kwordsPt, m_ebPtKwordDef.Text); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptPointResult prRes = ed.GetPoint(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunStringPrompt() + { + PromptStringOptions prOpts = new PromptStringOptions(string.Format("\n{0}", m_ebStrMessage.Text)); + prOpts.AllowSpaces = m_cbStrAllowSpaces.Checked; + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptResult prRes = ed.GetString(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunKeywordPrompt() + { + PromptKeywordOptions prOpts = new PromptKeywordOptions(string.Format("\n{0}", m_ebKwdMessage.Text)); + prOpts.AllowArbitraryInput = m_cbKwdAllowArbitraryInput.Checked; + prOpts.AllowNone = m_cbKwdAllowNone.Checked; + + AddKeywordsToPrompt(prOpts, m_kwordsKwd, m_ebKwdKwordDef.Text); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptResult prRes = ed.GetKeywords(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunEntityPrompt() + { + PromptEntityOptions prOpts = new PromptEntityOptions(string.Format("\n{0}", m_ebEntMessage.Text)); + prOpts.AllowNone = m_cbEntAllowNone.Checked; + + // You can add whatever classes you want to filter for, but you must + // first add a RejectMessage + if (m_cbEntAllowLines.Checked || m_cbEntAllowCircles.Checked || m_cbEntAllowCurves.Checked) + prOpts.SetRejectMessage(string.Format("\n{0}", m_ebEntRejectMessage.Text)); + + if (m_cbEntAllowLines.Checked) + prOpts.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Line), m_ebEntDoIsATest.Checked); + + if (m_cbEntAllowCircles.Checked) + prOpts.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Circle), m_ebEntDoIsATest.Checked); + + if (m_cbEntAllowCurves.Checked) + { + if (m_ebEntDoIsATest.Checked == true) + MessageBox.Show("There are no entities with an exact match of type Curve.\nYou should uncheck Exact Match to select any type of curve."); + prOpts.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Curve), m_ebEntDoIsATest.Checked); + } + + if (m_cbEntAllowLockedLayer.Checked) + prOpts.AllowObjectOnLockedLayer = true; + + AddKeywordsToPrompt(prOpts, m_kwordsEnt, m_ebEntKwordDef.Text); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptEntityResult prRes = ed.GetEntity(prOpts); + + ShowPromptResult(prRes); + } + + private void + RunNestedEntityPrompt() + { + PromptNestedEntityOptions prOpts = new PromptNestedEntityOptions(string.Format("\n{0}", m_ebNentMessage.Text)); + prOpts.AllowNone = m_cbNentAllowNone.Checked; + prOpts.UseNonInteractivePickPoint = m_cbNentNonInterPickPt.Checked; + if (m_cbNentNonInterPickPt.Checked) + prOpts.NonInteractivePickPoint = GetPickPt(); + + AddKeywordsToPrompt(prOpts, m_kwordsNent, m_ebNentKwordDef.Text); + + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + + PromptEntityResult prRes = ed.GetNestedEntity(prOpts); + + ShowPromptResult(prRes); + } + + /// + /// Some prompts have an optional base point to use. This just retrives that dynamically + /// before the actual prompt is issued (otherwise, we'd be typing in a point value in the + /// dialog, which would be no fun). + /// + /// the desired base point + + private Point3d + GetBasePt() + { + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + PromptPointResult prRes = ed.GetPoint("\nBase point to use for prompt"); + if (prRes.Status == PromptStatus.OK) + return prRes.Value; + else + return new Point3d(0.0, 0.0, 0.0); // TBD: should probably cancel prompt here + } + + private Point3d + GetPickPt() + { + Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; + PromptPointResult prRes = ed.GetPoint("\nPick point to use for prompt"); + if (prRes.Status == PromptStatus.OK) + return prRes.Value; + else + return new Point3d(0.0, 0.0, 0.0); // TBD: should probably cancel prompt here + } + + /// + /// Show all the values available from the PromptResult object + /// + /// the result of the prompt + + private void + ShowPromptResult(PromptResult prRes) + { + Snoop.Forms.Objects resForm = new Snoop.Forms.Objects(prRes); + resForm.ShowDialog(); + } + + /// + /// If any keywords were specified for the prompt, set those up here. + /// + /// The options that own the prompt keywords + /// The temporary collection of keywords the dialog collected + /// The default keyword (if any) to use. Pass string.Empty for no default + + private void + AddKeywordsToPrompt(PromptOptions prOpts, KeywordCollection kwords, string defKword) + { + foreach (Keyword kword in kwords) + prOpts.Keywords.Add(kword.GlobalName, kword.LocalName, kword.DisplayName, kword.Visible, kword.Enabled); + + if (defKword != string.Empty) + prOpts.Keywords.Default = defKword; + } + + /// + /// Add a new keyord to the collection. We add one with a default value and then + /// immediately go into Edit mode. + /// + /// + /// + + private void + OnKwordAdd(object sender, System.EventArgs e) + { + // we stashed away pointers to the relevant objects so that + // we wouldn't have to know which specific page was active. + // Retrieve the appropriate objects for the current page and + // do the common work. + Button bnClear = (Button)sender; + ListView lvKwords = (ListView)bnClear.Tag; + KeywordCollection kwords = (KeywordCollection)lvKwords.Tag; + + // add a new default kword to the collection and then + // immediately edit it. + kwords.Add("Global", "Local", "Display", true, true); + Keyword kword = kwords[kwords.Count - 1]; + + KeywordsForm kwordForm = new KeywordsForm(kword); + if (kwordForm.ShowDialog() == DialogResult.OK) + { + ListViewItem lvItem = new ListViewItem(kword.GlobalName); + lvItem.SubItems.Add(kword.LocalName); + lvItem.SubItems.Add(kword.DisplayName); + lvItem.SubItems.Add(kword.Enabled.ToString()); + lvItem.SubItems.Add(kword.Visible.ToString()); + lvItem.Selected = true; + + lvKwords.Items.Add(lvItem); + } + } + + /// + /// Edit the selected keyword values + /// + /// + /// + + private void + OnKwordEdit(object sender, System.EventArgs e) + { + // we stashed away pointers to the relevant objects so that + // we wouldn't have to know which specific page was active. + // Retrieve the appropriate objects for the current page and + // do the common work. + Button bnClear = (Button)sender; + ListView lvKwords = (ListView)bnClear.Tag; + KeywordCollection kwords = (KeywordCollection)lvKwords.Tag; + + if (lvKwords.SelectedItems.Count > 0) + { + ListViewItem lvItem = lvKwords.SelectedItems[0]; + Keyword kword = kwords[lvItem.Index]; + + KeywordsForm kwordForm = new KeywordsForm(kword); + + if (kwordForm.ShowDialog() == DialogResult.OK) + { + lvItem.Text = kword.GlobalName; + lvItem.SubItems[1].Text = kword.LocalName; + lvItem.SubItems[2].Text = kword.DisplayName; + lvItem.SubItems[3].Text = kword.Enabled.ToString(); + lvItem.SubItems[4].Text = kword.Visible.ToString(); + } + } + } + + /// + /// Remove all the keywords from the collection + /// + /// + /// + + private void + OnKwordClear(object sender, System.EventArgs e) + { + // we stashed away pointers to the relevant objects so that + // we wouldn't have to know which specific page was active. + // Retrieve the appropriate objects for the current page and + // do the common work. + Button bnClear = (Button)sender; + ListView lvKwords = (ListView)bnClear.Tag; + KeywordCollection kwords = (KeywordCollection)lvKwords.Tag; + + kwords.Clear(); + lvKwords.Items.Clear(); + } + + /// + /// Hardwire a set of test values so we don't have to go through + /// a bunch of steps when we don't really care what the atual keywords are. + /// + /// + /// + + private void + OnKwordHardwire(object sender, System.EventArgs e) + { + Button bnHardwire = (Button)sender; + ListView lvKwords = (ListView)bnHardwire.Tag; + KeywordCollection kwords = (KeywordCollection)lvKwords.Tag; + + // clear whatever is currently there + kwords.Clear(); + lvKwords.Items.Clear(); + + // hardwire some keywords so we don't have to do it for + // *EVERY* test case. + kwords.Add("Red", "Rojo", "Rojo", true, true); + kwords.Add("Green", "Verde", "Verde", true, true); + kwords.Add("Blue", "Azul", "Azul", true, true); + + foreach (Keyword kword in kwords) + { + ListViewItem lvItem = new ListViewItem(kword.GlobalName); + lvItem.SubItems.Add(kword.LocalName); + lvItem.SubItems.Add(kword.DisplayName); + lvItem.SubItems.Add(kword.Enabled.ToString()); + lvItem.SubItems.Add(kword.Visible.ToString()); + + lvKwords.Items.Add(lvItem); + } + } + + private void + OnEntAllowLines(object sender, System.EventArgs e) + { + if (m_cbEntAllowLines.Checked || m_cbEntAllowCircles.Checked || m_cbEntAllowCurves.Checked) + { + m_ebEntDoIsATest.Enabled = true; + m_ebEntRejectMessage.Enabled = true; + } + else + { + m_ebEntDoIsATest.Enabled = false; + m_ebEntRejectMessage.Enabled = false; + } + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Prompts/PromptTestForm.resx b/MgdDbgLibrary/Prompts/PromptTestForm.resx new file mode 100644 index 0000000..0bcff75 --- /dev/null +++ b/MgdDbgLibrary/Prompts/PromptTestForm.resx @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + PromptTestForm + + \ No newline at end of file diff --git a/MgdDbgLibrary/Prompts/SelectionSet.Designer.cs b/MgdDbgLibrary/Prompts/SelectionSet.Designer.cs new file mode 100644 index 0000000..c4eb036 --- /dev/null +++ b/MgdDbgLibrary/Prompts/SelectionSet.Designer.cs @@ -0,0 +1,417 @@ +namespace MgdDbg.Prompts { + partial class SelectionSet { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.m_bnCancel = new System.Windows.Forms.Button(); + this.m_bnOk = new System.Windows.Forms.Button(); + this.m_puMainSelectionMethod = new System.Windows.Forms.ComboBox(); + this.m_txtMainSelectionMethod = new System.Windows.Forms.Label(); + this.m_grpFlags = new System.Windows.Forms.GroupBox(); + this.m_cbSinglePickInSpace = new System.Windows.Forms.CheckBox(); + this.m_cbSingleOnly = new System.Windows.Forms.CheckBox(); + this.m_cbSelectEverythingInAperature = new System.Windows.Forms.CheckBox(); + this.m_cbRejectPaperSpaceViewport = new System.Windows.Forms.CheckBox(); + this.m_cbForceSubSelections = new System.Windows.Forms.CheckBox(); + this.m_cbAllowSubSelections = new System.Windows.Forms.CheckBox(); + this.m_cbAllowDuplicates = new System.Windows.Forms.CheckBox(); + this.m_cbRejectNonCurrentSpace = new System.Windows.Forms.CheckBox(); + this.m_cbFilterLockedLayers = new System.Windows.Forms.CheckBox(); + this.m_grpMessages = new System.Windows.Forms.GroupBox(); + this.m_cbMsgRemove = new System.Windows.Forms.CheckBox(); + this.m_cbMsgAdd = new System.Windows.Forms.CheckBox(); + this.m_ebMsgRemove = new System.Windows.Forms.TextBox(); + this.m_ebMsgAdd = new System.Windows.Forms.TextBox(); + this.m_grpFilter = new System.Windows.Forms.GroupBox(); + this.m_puClassType = new System.Windows.Forms.ComboBox(); + this.m_cbDoIsKindOfTest = new System.Windows.Forms.CheckBox(); + this.m_txtClassType = new System.Windows.Forms.Label(); + this.m_cbApplyFilter = new System.Windows.Forms.CheckBox(); + this.m_grpEvents = new System.Windows.Forms.GroupBox(); + this.m_cbUnknownEvent = new System.Windows.Forms.CheckBox(); + this.m_cbKeywordEvent = new System.Windows.Forms.CheckBox(); + this.m_grpFlags.SuspendLayout(); + this.m_grpMessages.SuspendLayout(); + this.m_grpFilter.SuspendLayout(); + this.m_grpEvents.SuspendLayout(); + this.SuspendLayout(); + // + // m_bnCancel + // + this.m_bnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.m_bnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.m_bnCancel.Location = new System.Drawing.Point(261, 345); + this.m_bnCancel.Name = "m_bnCancel"; + this.m_bnCancel.Size = new System.Drawing.Size(75, 23); + this.m_bnCancel.TabIndex = 1; + this.m_bnCancel.Text = "Cancel"; + this.m_bnCancel.UseVisualStyleBackColor = true; + // + // m_bnOk + // + this.m_bnOk.Location = new System.Drawing.Point(181, 345); + this.m_bnOk.Name = "m_bnOk"; + this.m_bnOk.Size = new System.Drawing.Size(75, 23); + this.m_bnOk.TabIndex = 0; + this.m_bnOk.Text = "< Run Test"; + this.m_bnOk.UseVisualStyleBackColor = true; + this.m_bnOk.Click += new System.EventHandler(this.OnRunTest); + // + // m_puMainSelectionMethod + // + this.m_puMainSelectionMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.m_puMainSelectionMethod.FormattingEnabled = true; + this.m_puMainSelectionMethod.Items.AddRange(new object[] { + "User", + "All", + "Implied", + "Crossing", + "Crossing Polygon", + "Fence", + "Last", + "Previous", + "Window", + "Window Polygon"}); + this.m_puMainSelectionMethod.Location = new System.Drawing.Point(138, 23); + this.m_puMainSelectionMethod.MaxDropDownItems = 13; + this.m_puMainSelectionMethod.Name = "m_puMainSelectionMethod"; + this.m_puMainSelectionMethod.Size = new System.Drawing.Size(219, 21); + this.m_puMainSelectionMethod.TabIndex = 3; + this.m_puMainSelectionMethod.SelectedIndexChanged += new System.EventHandler(this.OnSelectionMethodChanged); + // + // m_txtMainSelectionMethod + // + this.m_txtMainSelectionMethod.AutoSize = true; + this.m_txtMainSelectionMethod.Location = new System.Drawing.Point(13, 26); + this.m_txtMainSelectionMethod.Name = "m_txtMainSelectionMethod"; + this.m_txtMainSelectionMethod.Size = new System.Drawing.Size(119, 13); + this.m_txtMainSelectionMethod.TabIndex = 2; + this.m_txtMainSelectionMethod.Text = "Main Selection Method:"; + // + // m_grpFlags + // + this.m_grpFlags.Controls.Add(this.m_cbSinglePickInSpace); + this.m_grpFlags.Controls.Add(this.m_cbSingleOnly); + this.m_grpFlags.Controls.Add(this.m_cbSelectEverythingInAperature); + this.m_grpFlags.Controls.Add(this.m_cbRejectPaperSpaceViewport); + this.m_grpFlags.Controls.Add(this.m_cbForceSubSelections); + this.m_grpFlags.Controls.Add(this.m_cbAllowSubSelections); + this.m_grpFlags.Controls.Add(this.m_cbAllowDuplicates); + this.m_grpFlags.Controls.Add(this.m_cbRejectNonCurrentSpace); + this.m_grpFlags.Controls.Add(this.m_cbFilterLockedLayers); + this.m_grpFlags.Location = new System.Drawing.Point(16, 64); + this.m_grpFlags.Name = "m_grpFlags"; + this.m_grpFlags.Size = new System.Drawing.Size(195, 259); + this.m_grpFlags.TabIndex = 4; + this.m_grpFlags.TabStop = false; + this.m_grpFlags.Text = "Options"; + // + // m_cbSinglePickInSpace + // + this.m_cbSinglePickInSpace.AutoSize = true; + this.m_cbSinglePickInSpace.Location = new System.Drawing.Point(7, 211); + this.m_cbSinglePickInSpace.Name = "m_cbSinglePickInSpace"; + this.m_cbSinglePickInSpace.Size = new System.Drawing.Size(125, 17); + this.m_cbSinglePickInSpace.TabIndex = 8; + this.m_cbSinglePickInSpace.Text = "Single Pick In Space"; + this.m_cbSinglePickInSpace.UseVisualStyleBackColor = true; + // + // m_cbSingleOnly + // + this.m_cbSingleOnly.AutoSize = true; + this.m_cbSingleOnly.Location = new System.Drawing.Point(7, 187); + this.m_cbSingleOnly.Name = "m_cbSingleOnly"; + this.m_cbSingleOnly.Size = new System.Drawing.Size(79, 17); + this.m_cbSingleOnly.TabIndex = 7; + this.m_cbSingleOnly.Text = "Single Only"; + this.m_cbSingleOnly.UseVisualStyleBackColor = true; + // + // m_cbSelectEverythingInAperature + // + this.m_cbSelectEverythingInAperature.AutoSize = true; + this.m_cbSelectEverythingInAperature.Location = new System.Drawing.Point(7, 163); + this.m_cbSelectEverythingInAperature.Name = "m_cbSelectEverythingInAperature"; + this.m_cbSelectEverythingInAperature.Size = new System.Drawing.Size(164, 17); + this.m_cbSelectEverythingInAperature.TabIndex = 6; + this.m_cbSelectEverythingInAperature.Text = "Select Everything In Aperture"; + this.m_cbSelectEverythingInAperature.UseVisualStyleBackColor = true; + // + // m_cbRejectPaperSpaceViewport + // + this.m_cbRejectPaperSpaceViewport.AutoSize = true; + this.m_cbRejectPaperSpaceViewport.Location = new System.Drawing.Point(7, 69); + this.m_cbRejectPaperSpaceViewport.Name = "m_cbRejectPaperSpaceViewport"; + this.m_cbRejectPaperSpaceViewport.Size = new System.Drawing.Size(166, 17); + this.m_cbRejectPaperSpaceViewport.TabIndex = 5; + this.m_cbRejectPaperSpaceViewport.Text = "Reject Paper Space Viewport"; + this.m_cbRejectPaperSpaceViewport.UseVisualStyleBackColor = true; + // + // m_cbForceSubSelections + // + this.m_cbForceSubSelections.AutoSize = true; + this.m_cbForceSubSelections.Location = new System.Drawing.Point(7, 140); + this.m_cbForceSubSelections.Name = "m_cbForceSubSelections"; + this.m_cbForceSubSelections.Size = new System.Drawing.Size(127, 17); + this.m_cbForceSubSelections.TabIndex = 4; + this.m_cbForceSubSelections.Text = "Force Sub-Selections"; + this.m_cbForceSubSelections.UseVisualStyleBackColor = true; + this.m_cbForceSubSelections.CheckedChanged += new System.EventHandler(this.OnAllowSubSelectionChecked); + // + // m_cbAllowSubSelections + // + this.m_cbAllowSubSelections.AutoSize = true; + this.m_cbAllowSubSelections.Location = new System.Drawing.Point(7, 116); + this.m_cbAllowSubSelections.Name = "m_cbAllowSubSelections"; + this.m_cbAllowSubSelections.Size = new System.Drawing.Size(125, 17); + this.m_cbAllowSubSelections.TabIndex = 3; + this.m_cbAllowSubSelections.Text = "Allow Sub-Selections"; + this.m_cbAllowSubSelections.UseVisualStyleBackColor = true; + this.m_cbAllowSubSelections.CheckedChanged += new System.EventHandler(this.OnAllowSubSelectionChecked); + // + // m_cbAllowDuplicates + // + this.m_cbAllowDuplicates.AutoSize = true; + this.m_cbAllowDuplicates.Location = new System.Drawing.Point(7, 92); + this.m_cbAllowDuplicates.Name = "m_cbAllowDuplicates"; + this.m_cbAllowDuplicates.Size = new System.Drawing.Size(104, 17); + this.m_cbAllowDuplicates.TabIndex = 2; + this.m_cbAllowDuplicates.Text = "Allow Duplicates"; + this.m_cbAllowDuplicates.UseVisualStyleBackColor = true; + // + // m_cbRejectNonCurrentSpace + // + this.m_cbRejectNonCurrentSpace.AutoSize = true; + this.m_cbRejectNonCurrentSpace.Location = new System.Drawing.Point(7, 44); + this.m_cbRejectNonCurrentSpace.Name = "m_cbRejectNonCurrentSpace"; + this.m_cbRejectNonCurrentSpace.Size = new System.Drawing.Size(151, 17); + this.m_cbRejectNonCurrentSpace.TabIndex = 1; + this.m_cbRejectNonCurrentSpace.Text = "Reject Non-Current Space"; + this.m_cbRejectNonCurrentSpace.UseVisualStyleBackColor = true; + // + // m_cbFilterLockedLayers + // + this.m_cbFilterLockedLayers.AutoSize = true; + this.m_cbFilterLockedLayers.Location = new System.Drawing.Point(7, 20); + this.m_cbFilterLockedLayers.Name = "m_cbFilterLockedLayers"; + this.m_cbFilterLockedLayers.Size = new System.Drawing.Size(121, 17); + this.m_cbFilterLockedLayers.TabIndex = 0; + this.m_cbFilterLockedLayers.Text = "Filter Locked Layers"; + this.m_cbFilterLockedLayers.UseVisualStyleBackColor = true; + // + // m_grpMessages + // + this.m_grpMessages.Controls.Add(this.m_cbMsgRemove); + this.m_grpMessages.Controls.Add(this.m_cbMsgAdd); + this.m_grpMessages.Controls.Add(this.m_ebMsgRemove); + this.m_grpMessages.Controls.Add(this.m_ebMsgAdd); + this.m_grpMessages.Location = new System.Drawing.Point(234, 64); + this.m_grpMessages.Name = "m_grpMessages"; + this.m_grpMessages.Size = new System.Drawing.Size(268, 77); + this.m_grpMessages.TabIndex = 5; + this.m_grpMessages.TabStop = false; + this.m_grpMessages.Text = "Messages"; + // + // m_cbMsgRemove + // + this.m_cbMsgRemove.AutoSize = true; + this.m_cbMsgRemove.Location = new System.Drawing.Point(6, 46); + this.m_cbMsgRemove.Name = "m_cbMsgRemove"; + this.m_cbMsgRemove.Size = new System.Drawing.Size(69, 17); + this.m_cbMsgRemove.TabIndex = 5; + this.m_cbMsgRemove.Text = "Remove:"; + this.m_cbMsgRemove.UseVisualStyleBackColor = true; + this.m_cbMsgRemove.CheckedChanged += new System.EventHandler(this.OnMessageRemoveChecked); + // + // m_cbMsgAdd + // + this.m_cbMsgAdd.AutoSize = true; + this.m_cbMsgAdd.Location = new System.Drawing.Point(7, 20); + this.m_cbMsgAdd.Name = "m_cbMsgAdd"; + this.m_cbMsgAdd.Size = new System.Drawing.Size(48, 17); + this.m_cbMsgAdd.TabIndex = 4; + this.m_cbMsgAdd.Text = "Add:"; + this.m_cbMsgAdd.UseVisualStyleBackColor = true; + this.m_cbMsgAdd.CheckedChanged += new System.EventHandler(this.OnMessageAddChecked); + // + // m_ebMsgRemove + // + this.m_ebMsgRemove.Location = new System.Drawing.Point(78, 46); + this.m_ebMsgRemove.Name = "m_ebMsgRemove"; + this.m_ebMsgRemove.Size = new System.Drawing.Size(172, 20); + this.m_ebMsgRemove.TabIndex = 3; + // + // m_ebMsgAdd + // + this.m_ebMsgAdd.Location = new System.Drawing.Point(78, 20); + this.m_ebMsgAdd.Name = "m_ebMsgAdd"; + this.m_ebMsgAdd.Size = new System.Drawing.Size(172, 20); + this.m_ebMsgAdd.TabIndex = 0; + // + // m_grpFilter + // + this.m_grpFilter.Controls.Add(this.m_puClassType); + this.m_grpFilter.Controls.Add(this.m_cbDoIsKindOfTest); + this.m_grpFilter.Controls.Add(this.m_txtClassType); + this.m_grpFilter.Controls.Add(this.m_cbApplyFilter); + this.m_grpFilter.Location = new System.Drawing.Point(234, 147); + this.m_grpFilter.Name = "m_grpFilter"; + this.m_grpFilter.Size = new System.Drawing.Size(268, 100); + this.m_grpFilter.TabIndex = 6; + this.m_grpFilter.TabStop = false; + this.m_grpFilter.Text = "Filter"; + // + // m_puClassType + // + this.m_puClassType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.m_puClassType.FormattingEnabled = true; + this.m_puClassType.Location = new System.Drawing.Point(78, 41); + this.m_puClassType.Name = "m_puClassType"; + this.m_puClassType.Size = new System.Drawing.Size(171, 21); + this.m_puClassType.TabIndex = 4; + // + // m_cbDoIsKindOfTest + // + this.m_cbDoIsKindOfTest.AutoSize = true; + this.m_cbDoIsKindOfTest.Location = new System.Drawing.Point(10, 71); + this.m_cbDoIsKindOfTest.Name = "m_cbDoIsKindOfTest"; + this.m_cbDoIsKindOfTest.Size = new System.Drawing.Size(140, 17); + this.m_cbDoIsKindOfTest.TabIndex = 3; + this.m_cbDoIsKindOfTest.Text = "Include Derived Classes"; + this.m_cbDoIsKindOfTest.UseVisualStyleBackColor = true; + // + // m_txtClassType + // + this.m_txtClassType.AutoSize = true; + this.m_txtClassType.Location = new System.Drawing.Point(10, 44); + this.m_txtClassType.Name = "m_txtClassType"; + this.m_txtClassType.Size = new System.Drawing.Size(62, 13); + this.m_txtClassType.TabIndex = 1; + this.m_txtClassType.Text = "Class Type:"; + // + // m_cbApplyFilter + // + this.m_cbApplyFilter.AutoSize = true; + this.m_cbApplyFilter.Location = new System.Drawing.Point(10, 20); + this.m_cbApplyFilter.Name = "m_cbApplyFilter"; + this.m_cbApplyFilter.Size = new System.Drawing.Size(77, 17); + this.m_cbApplyFilter.TabIndex = 0; + this.m_cbApplyFilter.Text = "Apply Filter"; + this.m_cbApplyFilter.UseVisualStyleBackColor = true; + this.m_cbApplyFilter.CheckedChanged += new System.EventHandler(this.OnApplyFilterChecked); + // + // m_grpEvents + // + this.m_grpEvents.Controls.Add(this.m_cbUnknownEvent); + this.m_grpEvents.Controls.Add(this.m_cbKeywordEvent); + this.m_grpEvents.Location = new System.Drawing.Point(234, 253); + this.m_grpEvents.Name = "m_grpEvents"; + this.m_grpEvents.Size = new System.Drawing.Size(268, 70); + this.m_grpEvents.TabIndex = 7; + this.m_grpEvents.TabStop = false; + this.m_grpEvents.Text = "Events"; + // + // m_cbUnknownEvent + // + this.m_cbUnknownEvent.AutoSize = true; + this.m_cbUnknownEvent.Location = new System.Drawing.Point(7, 44); + this.m_cbUnknownEvent.Name = "m_cbUnknownEvent"; + this.m_cbUnknownEvent.Size = new System.Drawing.Size(103, 17); + this.m_cbUnknownEvent.TabIndex = 1; + this.m_cbUnknownEvent.Text = "Unknown Event"; + this.m_cbUnknownEvent.UseVisualStyleBackColor = true; + // + // m_cbKeywordEvent + // + this.m_cbKeywordEvent.AutoSize = true; + this.m_cbKeywordEvent.Location = new System.Drawing.Point(7, 20); + this.m_cbKeywordEvent.Name = "m_cbKeywordEvent"; + this.m_cbKeywordEvent.Size = new System.Drawing.Size(239, 17); + this.m_cbKeywordEvent.TabIndex = 0; + this.m_cbKeywordEvent.Text = "Keyword Event (will use \"Red Green Blue\")"; + this.m_cbKeywordEvent.UseVisualStyleBackColor = true; + // + // SelectionSet + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.m_bnCancel; + this.ClientSize = new System.Drawing.Size(517, 380); + this.Controls.Add(this.m_grpEvents); + this.Controls.Add(this.m_grpFilter); + this.Controls.Add(this.m_grpMessages); + this.Controls.Add(this.m_grpFlags); + this.Controls.Add(this.m_txtMainSelectionMethod); + this.Controls.Add(this.m_puMainSelectionMethod); + this.Controls.Add(this.m_bnOk); + this.Controls.Add(this.m_bnCancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "SelectionSet"; + this.Text = "SelectionSet"; + this.m_grpFlags.ResumeLayout(false); + this.m_grpFlags.PerformLayout(); + this.m_grpMessages.ResumeLayout(false); + this.m_grpMessages.PerformLayout(); + this.m_grpFilter.ResumeLayout(false); + this.m_grpFilter.PerformLayout(); + this.m_grpEvents.ResumeLayout(false); + this.m_grpEvents.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button m_bnCancel; + private System.Windows.Forms.Button m_bnOk; + private System.Windows.Forms.ComboBox m_puMainSelectionMethod; + private System.Windows.Forms.Label m_txtMainSelectionMethod; + private System.Windows.Forms.GroupBox m_grpFlags; + private System.Windows.Forms.CheckBox m_cbForceSubSelections; + private System.Windows.Forms.CheckBox m_cbAllowSubSelections; + private System.Windows.Forms.CheckBox m_cbAllowDuplicates; + private System.Windows.Forms.CheckBox m_cbRejectNonCurrentSpace; + private System.Windows.Forms.CheckBox m_cbFilterLockedLayers; + private System.Windows.Forms.GroupBox m_grpMessages; + private System.Windows.Forms.TextBox m_ebMsgAdd; + private System.Windows.Forms.TextBox m_ebMsgRemove; + private System.Windows.Forms.CheckBox m_cbSinglePickInSpace; + private System.Windows.Forms.CheckBox m_cbSingleOnly; + private System.Windows.Forms.CheckBox m_cbSelectEverythingInAperature; + private System.Windows.Forms.CheckBox m_cbRejectPaperSpaceViewport; + private System.Windows.Forms.GroupBox m_grpFilter; + private System.Windows.Forms.CheckBox m_cbDoIsKindOfTest; + private System.Windows.Forms.Label m_txtClassType; + private System.Windows.Forms.CheckBox m_cbApplyFilter; + private System.Windows.Forms.GroupBox m_grpEvents; + private System.Windows.Forms.CheckBox m_cbKeywordEvent; + private System.Windows.Forms.CheckBox m_cbUnknownEvent; + private System.Windows.Forms.ComboBox m_puClassType; + private System.Windows.Forms.CheckBox m_cbMsgRemove; + private System.Windows.Forms.CheckBox m_cbMsgAdd; + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Prompts/SelectionSet.cs b/MgdDbgLibrary/Prompts/SelectionSet.cs new file mode 100644 index 0000000..08de1b3 --- /dev/null +++ b/MgdDbgLibrary/Prompts/SelectionSet.cs @@ -0,0 +1,481 @@ + +// +// (C) Copyright 2006 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 System; +using System.Collections; +using System.Diagnostics; +using System.Windows.Forms; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.EditorInput; +using Autodesk.AutoCAD.Geometry; +using Autodesk.AutoCAD.Runtime; +using AcadApp = Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.Prompts { + + public partial class SelectionSet : Form { + + enum SelectionMethod { + kUser = 0, + kAll, + kImplied, + kCrossing, + kCrossingPolygon, + kFence, + kLast, + kPrevious, + kWindow, + kWindowPolygon, + }; + + private Editor m_editor; + private ArrayList m_entityClasses = new ArrayList(); + + public + SelectionSet() + { + m_editor = AcadApp.Application.DocumentManager.MdiActiveDocument.Editor; + + InitializeComponent(); + + m_puMainSelectionMethod.SelectedIndex = 0; // Select user mode by default + + GetClassesDerivedFrom((RXClass)SystemObjects.ClassDictionary["AcDbEntity"], m_entityClasses, true); + foreach (RXClass tmpClass in m_entityClasses) { + m_puClassType.Items.Add(tmpClass.Name); + } + + m_puClassType.SelectedItem = "AcDbEntity"; // have this be the default class + } + + private void + OnRunTest(object sender, EventArgs e) + { + /// start user interaction object so that this form + /// does not interfere with user selection in editor + EditorUserInteraction userInteraction = m_editor.StartUserInteraction(this); + + SelectionMethod selMethod = (SelectionMethod)m_puMainSelectionMethod.SelectedIndex; + + if (selMethod == SelectionMethod.kUser) + SelectionUser(); + else if (selMethod == SelectionMethod.kAll) + SelectionAll(); + else if (selMethod == SelectionMethod.kImplied) + SelectionImplied(); + else if (selMethod == SelectionMethod.kCrossing) + SelectionCrossing(); + else if (selMethod == SelectionMethod.kCrossingPolygon) + SelectionCrossingPolygon(); + else if (selMethod == SelectionMethod.kFence) + SelectionFence(); + else if (selMethod == SelectionMethod.kLast) + SelectionLast(); + else if (selMethod == SelectionMethod.kPrevious) + SelectionPrevious(); + else if (selMethod == SelectionMethod.kWindow) + SelectionWindow(); + else if (selMethod == SelectionMethod.kWindowPolygon) + SelectionWindowPolygon(); + else { + Debug.Assert(false); + } + + userInteraction.End(); + } + + #region Selection Methods + + private void + SelectionUser() + { + PromptSelectionOptions selOpts = new PromptSelectionOptions(); + + selOpts.AllowSubSelections = m_cbAllowSubSelections.Checked; + selOpts.ForceSubSelections = m_cbForceSubSelections.Checked; + if (m_cbAllowDuplicates.Checked) { // only if not in combination with the others + if ((selOpts.AllowSubSelections == false) && (selOpts.ForceSubSelections == false)) + selOpts.AllowDuplicates = true; + } + selOpts.RejectObjectsFromNonCurrentSpace = m_cbRejectNonCurrentSpace.Checked; + selOpts.RejectObjectsOnLockedLayers = m_cbFilterLockedLayers.Checked; + selOpts.RejectPaperspaceViewport = m_cbRejectPaperSpaceViewport.Checked; + selOpts.SelectEverythingInAperture = m_cbSelectEverythingInAperature.Checked; + selOpts.SingleOnly = m_cbSingleOnly.Checked; + selOpts.SinglePickInSpace = m_cbSinglePickInSpace.Checked; + + if (m_cbMsgAdd.Checked) + selOpts.MessageForAdding = m_ebMsgAdd.Text; + + if (m_cbMsgRemove.Checked) + selOpts.MessageForRemoval = m_ebMsgRemove.Text; + + if (m_cbKeywordEvent.Checked) { + selOpts.Keywords.Add("Red"); + selOpts.Keywords.Add("Green"); + selOpts.Keywords.Add("Blue"); + + selOpts.KeywordInput += new SelectionTextInputEventHandler(event_KeywordInput); + } + + if (m_cbUnknownEvent.Checked) { + selOpts.UnknownInput += new SelectionTextInputEventHandler(event_UnknownInput); + } + + selOpts.PrepareOptionalDetails = true; // always turn this on so we get all info available for the test + + PromptSelectionResult result; + if (m_cbApplyFilter.Checked) + result = m_editor.GetSelection(selOpts, GetSelectionFilter()); + else + result = m_editor.GetSelection(selOpts); + + ShowPromptResult("Select: User", result); + } + + /// + /// Callback function for our keywords + /// + /// + /// + + void + event_KeywordInput(object sender, SelectionTextInputEventArgs e) + { + MessageBox.Show(string.Format("Keyword event: {0}", e.Input), "KeywordInput Event"); + } + + /// + /// Callback function for when we get input that isn't recognized as anything else + /// + /// + /// + + void + event_UnknownInput(object sender, SelectionTextInputEventArgs e) + { + MessageBox.Show(string.Format("Unknown event: {0}", e.Input), "UnknownInput Event"); + } + + private void + SelectionImplied() + { + PromptSelectionResult result = m_editor.SelectImplied(); + + ShowPromptResult("Select: Implied", result); + } + + private void + SelectionCrossing() + { + Point3d pt1, pt2; + if (Utils.AcadUi.GetCorners(out pt1, out pt2)) { + PromptSelectionResult result; + if (m_cbApplyFilter.Checked) + result = m_editor.SelectCrossingWindow(pt1, pt2, GetSelectionFilter()); + else + result = m_editor.SelectCrossingWindow(pt1, pt2); + + ShowPromptResult("Select: Crossing Window", result); + } + } + + private void + SelectionCrossingPolygon() + { + Point3dCollection pts = new Point3dCollection(); + if (Utils.AcadUi.GetPline3dCollection(pts)) { + PromptSelectionResult result; + if (m_cbApplyFilter.Checked) + result = m_editor.SelectCrossingPolygon(pts, GetSelectionFilter()); + else + result = m_editor.SelectCrossingPolygon(pts); + + ShowPromptResult("Select: Crossing Polygon", result); + } + } + + private void + SelectionFence() + { + Point3dCollection pts = new Point3dCollection(); + if (Utils.AcadUi.GetPline3dCollection(pts)) { + PromptSelectionResult result; + if (m_cbApplyFilter.Checked) + result = m_editor.SelectFence(pts, GetSelectionFilter()); + else + result = m_editor.SelectFence(pts); + + ShowPromptResult("Select: Fence", result); + } + } + + private void + SelectionLast() + { + PromptSelectionResult result = m_editor.SelectLast(); + + ShowPromptResult("Select: Last", result); + } + + private void + SelectionPrevious() + { + PromptSelectionResult result = m_editor.SelectPrevious(); + + ShowPromptResult("Select: Previous", result); + } + + private void + SelectionWindow() + { + Point3d pt1, pt2; + if (Utils.AcadUi.GetCorners(out pt1, out pt2)) { + PromptSelectionResult result; + if (m_cbApplyFilter.Checked) + result = m_editor.SelectWindow(pt1, pt2, GetSelectionFilter()); + else + result = m_editor.SelectWindow(pt1, pt2); + + ShowPromptResult("Select: Window", result); + } + } + + private void + SelectionWindowPolygon() + { + Point3dCollection pts = new Point3dCollection(); + if (Utils.AcadUi.GetPline3dCollection(pts)) { + PromptSelectionResult result; + if (m_cbApplyFilter.Checked) + result = m_editor.SelectWindowPolygon(pts, GetSelectionFilter()); + else + result = m_editor.SelectWindowPolygon(pts); + + ShowPromptResult("Select: Window Polygon", result); + } + } + + private void + SelectionAll() + { + PromptSelectionResult result; + if (m_cbApplyFilter.Checked) + result = m_editor.SelectAll(GetSelectionFilter()); + else + result = m_editor.SelectAll(); + + ShowPromptResult("Select: All", result); + } + + #endregion + + private void + ShowPromptResult(string dboxTitle, PromptSelectionResult result) + { + if (result.Status == PromptStatus.OK) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(result.Value); + dbox.Text = dboxTitle; + AcadApp.Application.ShowModalDialog(dbox); + } + else { + MessageBox.Show(string.Format("Prompt status: {0}", result.Status.ToString()), "PromptSelectionResult"); + } + } + + private void + OnSelectionMethodChanged(object sender, EventArgs e) + { + SelectionMethod selMethod = (SelectionMethod)m_puMainSelectionMethod.SelectedIndex; + + if (selMethod == SelectionMethod.kUser) { + SetFlagModes(true); + SetKeywordModes(true); + SetPromptModes(true); + SetFilterModes(true); + } + else if ((selMethod == SelectionMethod.kLast) || + (selMethod == SelectionMethod.kImplied) || + (selMethod == SelectionMethod.kPrevious)) { + SetFlagModes(false); + SetKeywordModes(false); + SetPromptModes(false); + SetFilterModes(false); + } + else { + SetFlagModes(false); + SetKeywordModes(false); + SetPromptModes(false); + SetFilterModes(true); + } + } + + private void + SetFlagModes(bool allowed) + { + m_grpFlags.Enabled = allowed; + + if (allowed) { + if ((m_cbAllowSubSelections.Checked) || (m_cbForceSubSelections.Checked)) { + m_cbAllowDuplicates.Enabled = false; // can't combine Duplicates and sub-entity + } + } + } + + private void + SetKeywordModes(bool allowed) + { + m_grpEvents.Enabled = allowed; + } + + private void + SetPromptModes(bool allowed) + { + if (allowed == false) { + m_grpMessages.Enabled = false; + } + else { + m_grpMessages.Enabled = true; + m_cbMsgAdd.Enabled = true; + m_cbMsgRemove.Enabled = true; + + m_ebMsgAdd.Enabled = m_cbMsgAdd.Checked; + m_ebMsgRemove.Enabled = m_cbMsgRemove.Checked; + } + } + + private void + SetFilterModes(bool allowed) + { + if (allowed == false) { + m_grpFilter.Enabled = false; + } + else { + m_grpFilter.Enabled = true; + m_cbApplyFilter.Enabled = true; + + m_puClassType.Enabled = m_cbApplyFilter.Checked; + m_txtClassType.Enabled = m_cbApplyFilter.Checked; + m_cbDoIsKindOfTest.Enabled = m_cbApplyFilter.Checked; + } + } + + private void + OnApplyFilterChecked(object sender, EventArgs e) + { + m_puClassType.Enabled = m_cbApplyFilter.Checked; + m_txtClassType.Enabled = m_cbApplyFilter.Checked; + m_cbDoIsKindOfTest.Enabled = m_cbApplyFilter.Checked; + } + + private void + OnMessageAddChecked(object sender, EventArgs e) + { + m_ebMsgAdd.Enabled = m_cbMsgAdd.Checked; + } + + private void + OnMessageRemoveChecked(object sender, EventArgs e) + { + m_ebMsgRemove.Enabled = m_cbMsgRemove.Checked; + } + + private void + OnAllowSubSelectionChecked(object sender, EventArgs e) + { + if ((m_cbAllowSubSelections.Checked) || (m_cbForceSubSelections.Checked)) + m_cbAllowDuplicates.Enabled = false; // can't combine Duplicates and sub-entity + else + m_cbAllowDuplicates.Enabled = true; + } + + private void + GetClassesDerivedFrom(RXClass searchClassType, ArrayList derivedClasses, bool allowClassesWithoutDxfName) + { + Debug.Assert(derivedClasses != null); + + Dictionary dict = SystemObjects.ClassDictionary; + if (dict != null) { + IEnumerable enumerable = dict as IEnumerable; + if (enumerable != null) { + IEnumerator enumerator = enumerable.GetEnumerator(); + while (enumerator.MoveNext()) { + RXClass rxClass = (RXClass)((DictionaryEntry)enumerator.Current).Value; + if (rxClass.IsDerivedFrom(searchClassType)) { + if (!allowClassesWithoutDxfName && ((rxClass.DxfName == null) || (rxClass.DxfName == string.Empty))) { + // skip it + } + else { + if (derivedClasses.Contains(rxClass) == false) + derivedClasses.Add(rxClass); + } + } + } + } + } + } + + private SelectionFilter + GetSelectionFilter() + { + RXClass selectedClass = (RXClass)SystemObjects.ClassDictionary[(string)m_puClassType.SelectedItem]; + if (selectedClass != null) { + // see if they want this class plus all derived classes + if (m_cbDoIsKindOfTest.Checked == false) { + // just this class, use a simple filter + TypedValue[] fitlerPairs = { + new TypedValue((int)DxfCode.Start, selectedClass.DxfName), + }; + return new SelectionFilter(fitlerPairs); + } + else { + // look up all derived classes and use a big "OR" statement + ArrayList filterClasses = new ArrayList(); + GetClassesDerivedFrom(selectedClass, filterClasses, false /* don't allow classes without a DXF name*/); + + int i=0; + TypedValue[] values = new TypedValue[filterClasses.Count+2]; + + values[i++] = new TypedValue((int)DxfCode.Operator, ""); + + // in case you want to see what the filter looks like + //foreach (TypedValue tv in values) { + // m_editor.WriteMessage(string.Format("\nFilter Pair: {0}", tv.ToString())); + //} + + return new SelectionFilter(values); + } + } + + return null; + } + + + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Prompts/SelectionSet.resx b/MgdDbgLibrary/Prompts/SelectionSet.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/MgdDbgLibrary/Prompts/SelectionSet.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MgdDbgLibrary/Properties/Resources.Designer.cs b/MgdDbgLibrary/Properties/Resources.Designer.cs new file mode 100644 index 0000000..835d782 --- /dev/null +++ b/MgdDbgLibrary/Properties/Resources.Designer.cs @@ -0,0 +1,93 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MgdDbg.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MgdDbg.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap COPY1 { + get { + object obj = ResourceManager.GetObject("COPY1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Preview1 { + get { + object obj = ResourceManager.GetObject("Preview1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Print1 { + get { + object obj = ResourceManager.GetObject("Print1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/MgdDbgLibrary/Properties/Resources.resx b/MgdDbgLibrary/Properties/Resources.resx new file mode 100644 index 0000000..66d9b7a --- /dev/null +++ b/MgdDbgLibrary/Properties/Resources.resx @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\res\Preview.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\res\Print.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\res\COPY.ico;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/MgdDbgLibrary/README.md b/MgdDbgLibrary/README.md new file mode 100644 index 0000000..c1622d9 --- /dev/null +++ b/MgdDbgLibrary/README.md @@ -0,0 +1,9 @@ +# MgdDbg + +Inspection tool for AutoCAD Database (DWG) created with .NET. + +# Setup + +Open the MgdDbg.sln with Visual Studio (this version was tested with Visual Studio 2015). It should Build as is. If references are missing, go to project properties, Reference Path tab and adjust the AutoCAD install path. + +Start AutoCAD, type NETLOAD command, select the DLL under /bin/debug/MgdDbg.dll. Right click on the drawing area, the menu item MgdDbg should appear with the options. diff --git a/MgdDbgLibrary/Reactors/Events/ApplicationEvents.cs b/MgdDbgLibrary/Reactors/Events/ApplicationEvents.cs new file mode 100644 index 0000000..2cb10c4 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/ApplicationEvents.cs @@ -0,0 +1,140 @@ + +// +// (C) Copyright 2006 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 System; +using Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.Reactors.Events +{ + + public class ApplicationEvents : EventsBase + { + + public + ApplicationEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nApplication Events Turned On ...\n"); + + Application.BeginQuit += Application_BeginQuit; + Application.DisplayingCustomizeDialog += new TabbedDialogEventHandler(event_DisplayingCustomizeDialog); + Application.DisplayingDraftingSettingsDialog += new TabbedDialogEventHandler(event_DisplayingDraftingSettingsDialog); + Application.DisplayingOptionDialog += new TabbedDialogEventHandler(event_DisplayingOptionDialog); + Application.QuitAborted += new EventHandler(event_QuitAborted); + Application.QuitWillStart += new EventHandler(event_QuitWillStart); + Application.SystemVariableChanged += new SystemVariableChangedEventHandler(event_SystemVariableChanged); + Application.SystemVariableChanging += new SystemVariableChangingEventHandler(event_SystemVariableChanging); + } + + private void Application_BeginQuit(object sender, BeginQuitEventArgs e) + { + PrintEventMessage("Begin Quit"); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nApplication Events Turned Off ...\n"); + + Application.BeginQuit -= Application_BeginQuit; + Application.DisplayingCustomizeDialog -= new TabbedDialogEventHandler(event_DisplayingCustomizeDialog); + Application.DisplayingDraftingSettingsDialog -= new TabbedDialogEventHandler(event_DisplayingDraftingSettingsDialog); + Application.DisplayingOptionDialog -= new TabbedDialogEventHandler(event_DisplayingOptionDialog); + Application.QuitAborted -= new EventHandler(event_QuitAborted); + Application.QuitWillStart -= new EventHandler(event_QuitWillStart); + Application.SystemVariableChanged -= new SystemVariableChangedEventHandler(event_SystemVariableChanged); + Application.SystemVariableChanging -= new SystemVariableChangingEventHandler(event_SystemVariableChanging); + } + + + private void + event_DisplayingCustomizeDialog(object sender, TabbedDialogEventArgs e) + { + PrintEventMessage("Displaying Customize Dialog"); + } + + private void + event_DisplayingDraftingSettingsDialog(object sender, TabbedDialogEventArgs e) + { + PrintEventMessage("Displaying Drafting Settings Dialog"); + } + + private void + event_DisplayingOptionDialog(object sender, TabbedDialogEventArgs e) + { + PrintEventMessage("Displaying Option Dialog"); + } + + private void + event_QuitAborted(object sender, EventArgs e) + { + PrintEventMessage("Quit Aborted"); + } + + private void + event_QuitWillStart(object sender, EventArgs e) + { + PrintEventMessage("Quit Will Start"); + } + + private void + event_SystemVariableChanged(object sender, SystemVariableChangedEventArgs e) + { + if (e.Changed) + PrintEventMessage("System Var Changed", e.Name); + else + PrintEventMessage("System Var Not Changed Successfully", e.Name); + } + + private void + event_SystemVariableChanging(object sender, SystemVariableChangingEventArgs e) + { + PrintEventMessage("System Var Changing", e.Name); + } + + + + #region Print Abstraction + + private void + PrintEventMessage(string eventStr) + { + string printString = string.Format("\n[App Event] : {0,-25}", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private void + PrintEventMessage(string eventStr, string msg) + { + string printString = string.Format("\n[App Event] : {0,-25} : {1}", eventStr, msg); + Utils.AcadUi.PrintToCmdLine(printString); + } + + #endregion + + } +} diff --git a/MgdDbgLibrary/Reactors/Events/DatabaseEvents.cs b/MgdDbgLibrary/Reactors/Events/DatabaseEvents.cs new file mode 100644 index 0000000..172b436 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/DatabaseEvents.cs @@ -0,0 +1,596 @@ + +// +// (C) Copyright 2006 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 System; +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.ApplicationServices; +using MgdDbg.CompBuilder; +using MgdDbg.Utils; + +namespace MgdDbg.Reactors.Events { + + public class DatabaseEvents : EventsBase { + + public + DatabaseEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDatabase Events Turned On ...\n"); + + // attach event handlers to each database we know about + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + EnableEvents(doc.Database); + } + } + + public void + EnableEvents(Database db) + { + db.AbortDxfIn += new EventHandler(event_AbortDxfIn); + db.AbortDxfOut += new EventHandler(event_AbortDxfOut); + db.AbortSave += new EventHandler(event_AbortSave); + db.BeginDeepClone += new IdMappingEventHandler(event_BeginDeepClone); + db.BeginDeepCloneTranslation += new IdMappingEventHandler(event_BeginDeepCloneTranslation); + db.BeginDxfIn += new EventHandler(event_BeginDxfIn); + db.BeginDxfOut += new EventHandler(event_BeginDxfOut); + db.BeginInsert += new BeginInsertEventHandler(event_BeginInsert); + db.BeginSave += new DatabaseIOEventHandler(event_BeginSave); + db.BeginWblockBlock += new BeginWblockBlockEventHandler(event_BeginWblockBlock); + db.BeginWblockEntireDatabase += new BeginWblockEntireDatabaseEventHandler(event_BeginWblockEntireDatabase); + db.BeginWblockObjects += new BeginWblockObjectsEventHandler(event_BeginWblockObjects); + db.BeginWblockSelectedObjects += new BeginWblockSelectedObjectsEventHandler(event_BeginWblockSelectedObjects); + # if !ACAD2007 + Database.DatabaseConstructed += new EventHandler(event_DatabaseConstructed); + # endif + db.DatabaseToBeDestroyed += new EventHandler(event_DatabaseToBeDestroyed); + db.DeepCloneAborted += new EventHandler(event_DeepCloneAborted); + db.DeepCloneEnded += new EventHandler(event_DeepCloneEnded); + db.DwgFileOpened += new DatabaseIOEventHandler(event_DwgFileOpened); + db.DxfInComplete += new EventHandler(event_DxfInComplete); + db.DxfOutComplete += new EventHandler(event_DxfOutComplete); + db.InitialDwgFileOpenComplete += new EventHandler(event_InitialDwgFileOpenComplete); + db.InsertAborted += new EventHandler(event_InsertAborted); + db.InsertEnded += new EventHandler(event_InsertEnded); + db.InsertMappingAvailable += new IdMappingEventHandler(event_InsertMappingAvailable); + db.PartialOpenNotice += new EventHandler(event_PartialOpenNotice); + db.ProxyResurrectionCompleted += new ProxyResurrectionCompletedEventHandler(event_ProxyResurrectionCompleted); + db.SaveComplete += new DatabaseIOEventHandler(event_SaveComplete); + db.SystemVariableChanged += new Autodesk.AutoCAD.DatabaseServices.SystemVariableChangedEventHandler(event_SystemVariableChanged); + db.SystemVariableWillChange += new Autodesk.AutoCAD.DatabaseServices.SystemVariableChangingEventHandler(event_SystemVariableWillChange); + db.WblockAborted += new EventHandler(event_WblockAborted); + db.WblockEnded += new EventHandler(event_WblockEnded); + db.WblockMappingAvailable += new IdMappingEventHandler(event_WblockMappingAvailable); + db.WblockNotice += new WblockNoticeEventHandler(event_WblockNotice); + # if !ACAD2007 + Database.XrefAttachAborted += new EventHandler(event_XrefAttachAborted); + #endif + db.XrefAttachEnded += new EventHandler(event_XrefAttachEnded); + db.XrefBeginAttached += new XrefBeginOperationEventHandler(event_XrefBeginAttached); + db.XrefBeginOtherAttached +=new XrefBeginOperationEventHandler(event_XrefBeginOtherAttached); + db.XrefBeginRestore += new XrefBeginOperationEventHandler(event_XrefBeginRestore); + db.XrefComandeered += new XrefComandeeredEventHandler(event_XrefComandeered); + db.XrefPreXrefLockFile += new XrefPreXrefLockFileEventHandler(event_XrefPreXrefLockFile); + db.XrefRedirected += new XrefRedirectedEventHandler(event_XrefRedirected); + db.XrefRestoreAborted += new EventHandler(event_XrefRestoreAborted); + db.XrefRestoreEnded += new EventHandler(event_XrefRestoreEnded); + db.XrefSubCommandAborted += new XrefSubCommandAbortedEventHandler(event_XrefSubCommandAborted); + //see why this is commented out below in the DisableNotifications() + //db.XrefSubCommandStart += new XrefSubCommandStartEventHandler(event_XrefSubCommandStart); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDatabase Events Turned Off ...\n"); + + // detach event handlers from each doc + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + DisableEvents(doc.Database); + } + } + + public void + DisableEvents(Database db) + { + db.AbortDxfIn -= new EventHandler(event_AbortDxfIn); + db.AbortDxfOut -= new EventHandler(event_AbortDxfOut); + db.AbortSave -= new EventHandler(event_AbortSave); + db.BeginDeepClone -= new IdMappingEventHandler(event_BeginDeepClone); + db.BeginDeepCloneTranslation -= new IdMappingEventHandler(event_BeginDeepCloneTranslation); + db.BeginDxfIn -= new EventHandler(event_BeginDxfIn); + db.BeginDxfOut -= new EventHandler(event_BeginDxfOut); + db.BeginInsert -= new BeginInsertEventHandler(event_BeginInsert); + db.BeginSave -= new DatabaseIOEventHandler(event_BeginSave); + db.BeginWblockBlock -= new BeginWblockBlockEventHandler(event_BeginWblockBlock); + db.BeginWblockEntireDatabase -= new BeginWblockEntireDatabaseEventHandler(event_BeginWblockEntireDatabase); + db.BeginWblockObjects -= new BeginWblockObjectsEventHandler(event_BeginWblockObjects); + db.BeginWblockSelectedObjects -= new BeginWblockSelectedObjectsEventHandler(event_BeginWblockSelectedObjects); + # if !ACAD2007 + Database.DatabaseConstructed -= new EventHandler(event_DatabaseConstructed); + #endif + db.DatabaseToBeDestroyed -= new EventHandler(event_DatabaseToBeDestroyed); + db.DeepCloneAborted -= new EventHandler(event_DeepCloneAborted); + db.DeepCloneEnded -= new EventHandler(event_DeepCloneEnded); + db.DwgFileOpened -= new DatabaseIOEventHandler(event_DwgFileOpened); + db.DxfInComplete -= new EventHandler(event_DxfInComplete); + db.DxfOutComplete -= new EventHandler(event_DxfOutComplete); + db.InitialDwgFileOpenComplete -= new EventHandler(event_InitialDwgFileOpenComplete); + db.InsertAborted -= new EventHandler(event_InsertAborted); + db.InsertEnded -= new EventHandler(event_InsertEnded); + db.InsertMappingAvailable -= new IdMappingEventHandler(event_InsertMappingAvailable); + db.PartialOpenNotice -= new EventHandler(event_PartialOpenNotice); + db.ProxyResurrectionCompleted -= new ProxyResurrectionCompletedEventHandler(event_ProxyResurrectionCompleted); + db.SaveComplete -= new DatabaseIOEventHandler(event_SaveComplete); + db.SystemVariableChanged -= new Autodesk.AutoCAD.DatabaseServices.SystemVariableChangedEventHandler(event_SystemVariableChanged); + db.SystemVariableWillChange -= new Autodesk.AutoCAD.DatabaseServices.SystemVariableChangingEventHandler(event_SystemVariableWillChange); + db.WblockAborted -= new EventHandler(event_WblockAborted); + db.WblockEnded -= new EventHandler(event_WblockEnded); + db.WblockMappingAvailable -= new IdMappingEventHandler(event_WblockMappingAvailable); + db.WblockNotice -= new WblockNoticeEventHandler(event_WblockNotice); + # if !ACAD2007 + Database.XrefAttachAborted -= new EventHandler(event_XrefAttachAborted); + #endif + db.XrefAttachEnded -= new EventHandler(event_XrefAttachEnded); + db.XrefBeginAttached -= new XrefBeginOperationEventHandler(event_XrefBeginAttached); + db.XrefBeginOtherAttached -=new XrefBeginOperationEventHandler(event_XrefBeginOtherAttached); + db.XrefBeginRestore -= new XrefBeginOperationEventHandler(event_XrefBeginRestore); + db.XrefComandeered -= new XrefComandeeredEventHandler(event_XrefComandeered); + db.XrefPreXrefLockFile -= new XrefPreXrefLockFileEventHandler(event_XrefPreXrefLockFile); + db.XrefRedirected -= new XrefRedirectedEventHandler(event_XrefRedirected); + db.XrefRestoreAborted -= new EventHandler(event_XrefRestoreAborted); + db.XrefRestoreEnded -= new EventHandler(event_XrefRestoreEnded); + db.XrefSubCommandAborted -= new XrefSubCommandAbortedEventHandler(event_XrefSubCommandAborted); + //see why this is commented out below in the DisableNotifications() + //db.XrefSubCommandStart -= new XrefSubCommandStartEventHandler(event_XrefSubCommandStart); + } + + #region Notifications + + private void + event_AbortDxfIn(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Abort Dxf In"); + } + + private void + event_AbortDxfOut(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Abort Dxf Out"); + } + + private void + event_AbortSave(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Abort Save"); + } + + private void + event_BeginDeepClone(object sender, IdMappingEventArgs e) + { + string str2 = string.Format("Context = {0}", e.IdMapping.DeepCloneContext.ToString()); + PrintEventMessage((Database)sender, "Begin Deep Clone", str2); + if (m_showDetails) { + MgdDbg.Reactors.Forms.Details details = new MgdDbg.Reactors.Forms.Details("Begin Deep Clone", e.IdMapping); + details.ShowDialog(); + } + } + + private void + event_BeginDeepCloneTranslation(object sender, IdMappingEventArgs e) + { + PrintEventMessage((Database)sender, "Begin Deep Clone Translation"); + if (m_showDetails) { + MgdDbg.Reactors.Forms.Details details = new MgdDbg.Reactors.Forms.Details("Begin Deep Clone Translation", e.IdMapping); + details.ShowDialog(); + } + } + + private void + event_BeginDxfIn(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Begin Dxf In"); + } + + private void + event_BeginDxfOut(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Begin Dxf Out"); + } + + private void + event_BeginInsert(object sender, BeginInsertEventArgs e) + { + PrintEventMessage((Database)sender, "Begin Insert", AcadUi.DbToStr(e.From)); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.From)) { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(e.From, trHlp); + dbox.Text = "From Database"; + + trHlp.Commit(); + } + } + } + + private void + event_BeginSave(object sender, DatabaseIOEventArgs e) + { + string str2 = string.Format("Intended Name = \"{0}\"", e.FileName); + PrintEventMessage((Database)sender, "Begin Save", str2); + } + + private void + event_BeginWblockBlock(object sender, BeginWblockBlockEventArgs e) + { + string str2 = string.Format("Block Name = {0}, DB = {1}", AcadUi.ObjToTypeAndHandleStr(e.BlockId), AcadUi.DbToStr(e.From)); + PrintEventMessage((Database)sender, "Begin Wblock", str2); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.From)) { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(e.From, trHlp); + dbox.Text = "From Database"; + + trHlp.Commit(); + } + } + } + + private void + event_BeginWblockEntireDatabase(object sender, BeginWblockEntireDatabaseEventArgs e) + { + string str2 = string.Format("DB = {0}", AcadUi.DbToStr(e.From)); + PrintEventMessage((Database)sender, "Begin Wblock Entire Database", str2); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.From)) { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(e.From, trHlp); + dbox.Text = "From Database"; + + trHlp.Commit(); + } + } + } + + private void + event_BeginWblockObjects(object sender, BeginWblockObjectsEventArgs e) + { + string str2 = string.Format("DB = {0}", AcadUi.DbToStr(e.From)); + PrintEventMessage((Database)sender, "Begin Wblock Objects", str2); + if (m_showDetails) { + MgdDbg.Reactors.Forms.Details details = new MgdDbg.Reactors.Forms.Details("Begin Wblock Objects", e.IdMapping); + details.ShowDialog(); + } + } + + private void + event_BeginWblockSelectedObjects(object sender, BeginWblockSelectedObjectsEventArgs e) + { + string str2 = string.Format("Insert Pt. = {0}, {1}", AcadUi.PtToStr(e.InsertionPoint), AcadUi.DbToStr(e.From)); + PrintEventMessage((Database)sender, "Begin Wblock Selected Objects", str2); + } + + private void + event_DatabaseConstructed(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Database Constructed"); + } + + private void + event_DatabaseToBeDestroyed(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Database To Be Destroyed"); + } + + private void + event_DeepCloneAborted(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Deep Clone Aborted"); + } + + private void + event_DeepCloneEnded(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Deep Clone Ended"); + } + + private void + event_DwgFileOpened(object sender, DatabaseIOEventArgs e) + { + PrintEventMessage((Database)sender, "Dwg File Opened", e.FileName); + } + + private void + event_DxfInComplete(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Dxf In Complete"); + } + + private void + event_DxfOutComplete(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Dxf Out Complete"); + } + + private void + event_InitialDwgFileOpenComplete(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Initial Dwg File Open Complete"); + } + + private void + event_InsertAborted(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Insert Aborted"); + } + + private void + event_InsertEnded(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Insert Ended"); + } + + private void + event_InsertMappingAvailable(object sender, IdMappingEventArgs e) + { + PrintEventMessage((Database)sender, "Insert Mapping Available"); + if (m_showDetails) { + MgdDbg.Reactors.Forms.Details details = new MgdDbg.Reactors.Forms.Details("Insert Mapping Available", e.IdMapping); + details.ShowDialog(); + } + } + + private void + event_PartialOpenNotice(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Partial Open Notice"); + } + + private void + event_ProxyResurrectionCompleted(object sender, ProxyResurrectionCompletedEventArgs e) + { + PrintEventMessage((Database)sender, "Proxy Resurrection Completed", e.ApplicationName); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.Ids[0].Database)) { + trHlp.Start(); + + Snoop.Forms.DBObjects form = new Snoop.Forms.DBObjects(e.Ids, trHlp); + form.ShowDialog(); + + trHlp.Commit(); + } + } + } + + private void + event_SaveComplete(object sender, DatabaseIOEventArgs e) + { + string str2 = string.Format("Actual Name = \"{0}\"", e.FileName); + PrintEventMessage((Database)sender, "Save Complete", str2); + } + + private void + event_SystemVariableChanged(object sender, Autodesk.AutoCAD.DatabaseServices.SystemVariableChangedEventArgs e) + { + if (e.Changed) + PrintEventMessage((Database)sender, "System Var Changed", e.Name); + else + PrintEventMessage((Database)sender, "System Var Not Changed Successfully", e.Name); + } + + private void + event_SystemVariableWillChange(object sender, Autodesk.AutoCAD.DatabaseServices.SystemVariableChangingEventArgs e) + { + PrintEventMessage((Database)sender, "System Var Will Change", e.Name); + } + + private void + event_WblockAborted(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Wblock Aborted"); + } + + private void + event_WblockEnded(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Wblock Ended"); + } + + private void + event_WblockMappingAvailable(object sender, IdMappingEventArgs e) + { + PrintEventMessage((Database)sender, "Wblock Mapping Available"); + + if (m_showDetails) { + MgdDbg.Reactors.Forms.Details details = new MgdDbg.Reactors.Forms.Details("Wblock Mapping Available", e.IdMapping); + details.ShowDialog(); + } + } + + private void + event_WblockNotice(object sender, WblockNoticeEventArgs e) + { + string str2 = string.Format("To = {0}", AcadUi.DbToStr(e.To)); + PrintEventMessage((Database)sender, "Wblock Notice", str2); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.To)) { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(e.To, trHlp); + dbox.Text = "To Database"; + + trHlp.Commit(); + } + } + } + + private void + event_XrefAttachAborted(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Attach Aborted"); + } + + private void + event_XrefAttachEnded(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Attach Ended"); + } + + private void + event_XrefBeginAttached(object sender, XrefBeginOperationEventArgs e) + { + PrintEventMessage((Database)sender, "Begin Attached", AcadUi.DbToStr(e.From)); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.From)) { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(e.From, trHlp); + dbox.Text = "From Database"; + + trHlp.Commit(); + } + } + } + + private void + event_XrefBeginOtherAttached(object sender, XrefBeginOperationEventArgs e) + { + PrintEventMessage((Database)sender, "Begin Other Attached", AcadUi.DbToStr(e.From)); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.From)) { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(e.From, trHlp); + dbox.Text = "From Database"; + + trHlp.Commit(); + } + } + } + + private void + event_XrefBeginRestore(object sender, XrefBeginOperationEventArgs e) + { + PrintEventMessage((Database)sender, "BeginRestore", AcadUi.DbToStr(e.From)); + if (m_showDetails) { + using (TransactionHelper trHlp = new TransactionHelper(e.From)) { + trHlp.Start(); + + Snoop.Forms.Database dbox = new Snoop.Forms.Database(e.From, trHlp); + dbox.Text = "From Database"; + + trHlp.Commit(); + } + } + } + + private void + event_XrefComandeered(object sender, XrefComandeeredEventArgs e) + { + string str2 = string.Format("{0} {1}", AcadUi.ObjToTypeAndHandleStr(e.Id), AcadUi.DbToStr(e.From)); + PrintEventMessage((Database)sender, "Comandeered", str2); + } + + private void + event_XrefPreXrefLockFile(object sender, XrefPreXrefLockFileEventArgs e) + { + PrintEventMessage((Database)sender, "Xref Pre Xref Lock File", AcadUi.ObjToTypeAndHandleStr(e.btrId)); + } + + private void + event_XrefRedirected(object sender, XrefRedirectedEventArgs e) + { + string str2 = string.Format("From = {0} , To = {1}", AcadUi.ObjToTypeAndHandleStr(e.OldId), AcadUi.ObjToTypeAndHandleStr(e.NewId)); + PrintEventMessage((Database)sender, "Redirected", str2); + } + + private void + event_XrefRestoreAborted(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Restore Aborted"); + } + + private void + event_XrefRestoreEnded(object sender, EventArgs e) + { + PrintEventMessage((Database)sender, "Restore Ended"); + } + + private void + event_XrefSubCommandAborted(object sender, XrefSubCommandEventArgs e) + { + PrintEventMessage((Database)sender, "Xref Sub-Command Aborted"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "XrefSubCommandAborted"; + dbox.ShowDialog(); + } + } + + private void + event_XrefSubCommandStart(object sender, XrefVetoableSubCommandEventArgs e) + { + PrintEventMessage((Database)sender, "Xref Sub-Command Start"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "XrefSubCommandStart"; + dbox.ShowDialog(); + } + } + + #endregion + + + # region Print Abstraction + + private void + PrintEventMessage(Database db, string eventStr) + { + string printString = string.Format("\n[DB Event : {0}] : {1}", DbToStr(db), eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private void + PrintEventMessage(Database db, string eventStr, string str2) + { + string printString = string.Format("\n[DB Event : {0}] : {1,-25} : {2}", DbToStr(db), eventStr, str2); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private string + DbToStr(Database db) + { + return db.GetHashCode().ToString(); + } + + #endregion + } +} diff --git a/MgdDbgLibrary/Reactors/Events/DatabaseObjEvents.cs b/MgdDbgLibrary/Reactors/Events/DatabaseObjEvents.cs new file mode 100644 index 0000000..a778d9b --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/DatabaseObjEvents.cs @@ -0,0 +1,154 @@ + +// +// (C) Copyright 2006 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 System.Diagnostics; + +using Autodesk.AutoCAD.DatabaseServices; +using Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.Reactors.Events { + + public class DatabaseObjEvents : EventsBase { + + public + DatabaseObjEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDatabase Object Events Turned On ...\n"); + + // attach event handlers to each database we know about + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + EnableEvents(doc.Database); + } + } + + public void + EnableEvents(Database db) + { + db.ObjectAppended += new ObjectEventHandler(event_ObjectAppended); + db.ObjectErased += new ObjectErasedEventHandler(event_ObjectErased); + db.ObjectModified += new ObjectEventHandler(event_ObjectModified); + db.ObjectOpenedForModify += new ObjectEventHandler(event_ObjectOpenedForModify); + db.ObjectReappended += new ObjectEventHandler(event_ObjectReappended); + db.ObjectUnappended += new ObjectEventHandler(event_ObjectUnappended); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDatabase Object Events Turned Off ...\n"); + + // detach event handlers from each doc + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + DisableEvents(doc.Database); + } + } + + public void + DisableEvents(Database db) + { + db.ObjectAppended -= new ObjectEventHandler(event_ObjectAppended); + db.ObjectErased -= new ObjectErasedEventHandler(event_ObjectErased); + db.ObjectModified -= new ObjectEventHandler(event_ObjectModified); + db.ObjectOpenedForModify -= new ObjectEventHandler(event_ObjectOpenedForModify); + db.ObjectReappended -= new ObjectEventHandler(event_ObjectReappended); + db.ObjectUnappended -= new ObjectEventHandler(event_ObjectUnappended); + } + + #region Notifications + + private void + event_ObjectAppended(object sender, ObjectEventArgs e) + { + PrintEventMessage((Database)sender, "Object Appended", e.DBObject); + } + + private void + event_ObjectErased(object sender, ObjectErasedEventArgs e) + { + if (e.Erased) + PrintEventMessage((Database)sender, "Object Erased", e.DBObject); + else + PrintEventMessage((Database)sender, "Object Un-Erased", e.DBObject); + } + + private void + event_ObjectModified(object sender, ObjectEventArgs e) + { + PrintEventMessage((Database)sender, "Object Modified", e.DBObject); + } + + private void + event_ObjectOpenedForModify(object sender, ObjectEventArgs e) + { + PrintEventMessage((Database)sender, "Object Opened For Modify", e.DBObject); + } + + private void + event_ObjectReappended(object sender, ObjectEventArgs e) + { + PrintEventMessage((Database)sender, "Object Reappended", e.DBObject); + } + + private void + event_ObjectUnappended(object sender, ObjectEventArgs e) + { + PrintEventMessage((Database)sender, "Object Unappended", e.DBObject); + } + + #endregion + + + # region Print Abstraction + + private void + PrintEventMessage(Database db, string eventStr, DBObject dbObj) + { + string printString = string.Format("\n[DB Event : {0}] : {1,-25} : {2}", DbToStr(db), eventStr, ObjToTypeAndHandleStr(dbObj)); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private string + DbToStr(Database db) + { + return db.GetHashCode().ToString(); + } + + private string + ObjToTypeAndHandleStr(DBObject dbObj) + { + Debug.Assert(dbObj != null); + return string.Format("<{0}, {1}>", dbObj.GetType().Name, dbObj.Handle.ToString()); + } + + + #endregion + } +} + diff --git a/MgdDbgLibrary/Reactors/Events/DocumentEvents.cs b/MgdDbgLibrary/Reactors/Events/DocumentEvents.cs new file mode 100644 index 0000000..064cc70 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/DocumentEvents.cs @@ -0,0 +1,183 @@ + +// +// (C) Copyright 2006 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 System; +using Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.Reactors.Events { + + public class DocumentEvents : EventsBase { + + public + DocumentEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDocument Events Turned On ...\n"); + + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + EnableEvents(doc); + } + } + + public void + EnableEvents(Document doc) + { + doc.BeginDocumentClose += new DocumentBeginCloseEventHandler(event_BeginDocumentClose); + doc.CloseAborted += new EventHandler(event_CloseAborted); + doc.CloseWillStart += new EventHandler(event_CloseWillStart); + doc.CommandCancelled += new CommandEventHandler(event_CommandCancelled); + doc.CommandEnded += new CommandEventHandler(event_CommandEnded); + doc.CommandFailed += new CommandEventHandler(event_CommandFailed); + doc.CommandWillStart += new CommandEventHandler(event_CommandWillStart); + doc.ImpliedSelectionChanged += new EventHandler(event_ImpliedSelectionChanged); + doc.LispCancelled += new EventHandler(event_LispCancelled); + doc.LispEnded += new EventHandler(event_LispEnded); + doc.LispWillStart += new LispWillStartEventHandler(event_LispWillStart); + doc.UnknownCommand += new UnknownCommandEventHandler(event_UnknownCommand); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDocument Events Turned Off ...\n"); + + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + DisableEvents(doc); + } + } + + public void + DisableEvents(Document doc) + { + doc.BeginDocumentClose -= new DocumentBeginCloseEventHandler(event_BeginDocumentClose); + doc.CloseAborted -= new EventHandler(event_CloseAborted); + doc.CloseWillStart -= new EventHandler(event_CloseWillStart); + doc.CommandCancelled -= new CommandEventHandler(event_CommandCancelled); + doc.CommandEnded -= new CommandEventHandler(event_CommandEnded); + doc.CommandFailed -= new CommandEventHandler(event_CommandFailed); + doc.CommandWillStart -= new CommandEventHandler(event_CommandWillStart); + doc.ImpliedSelectionChanged -= new EventHandler(event_ImpliedSelectionChanged); + doc.LispCancelled -= new EventHandler(event_LispCancelled); + doc.LispEnded -= new EventHandler(event_LispEnded); + doc.LispWillStart -= new LispWillStartEventHandler(event_LispWillStart); + doc.UnknownCommand -= new UnknownCommandEventHandler(event_UnknownCommand); + } + + private void + event_BeginDocumentClose(object sender, DocumentBeginCloseEventArgs e) + { + PrintEventMessage("Begin Document Close"); + } + + private void + event_CloseAborted(object sender, EventArgs e) + { + PrintEventMessage("Close Aborted"); + } + + private void + event_CloseWillStart(object sender, EventArgs e) + { + PrintEventMessage("Close will Start"); + } + + private void + event_CommandCancelled(object sender, CommandEventArgs e) + { + PrintEventMessage("Command Cancelled", e.GlobalCommandName); + } + + private void + event_CommandEnded(object sender, CommandEventArgs e) + { + PrintEventMessage("Command Ended", e.GlobalCommandName); + } + + private void + event_CommandFailed(object sender, CommandEventArgs e) + { + PrintEventMessage("Command Failed", e.GlobalCommandName); + } + + private void + event_CommandWillStart(object sender, CommandEventArgs e) + { + PrintEventMessage("Command will Start", e.GlobalCommandName); + } + + private void + event_ImpliedSelectionChanged(object sender, EventArgs e) + { + PrintEventMessage("Implied Selection Changed"); + } + + private void + event_LispCancelled(object sender, EventArgs e) + { + PrintEventMessage("Lisp Cancelled"); + } + + private void + event_LispEnded(object sender, EventArgs e) + { + PrintEventMessage("Lisp ended"); + } + + private void + event_LispWillStart(object sender, LispWillStartEventArgs e) + { + PrintEventMessage("Lisp will Start", e.FirstLine); + } + + private void + event_UnknownCommand(object sender, UnknownCommandEventArgs e) + { + PrintEventMessage("Unknown Command", e.GlobalCommandName); + } + + #region Print Abstraction + + private void + PrintEventMessage(string eventStr) + { + string printString = string.Format("\n[Doc Event] : {0,-25}", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private void + PrintEventMessage(string eventStr, string msg) + { + string printString = string.Format("\n[Doc Event] : {0,-25} : {1}", eventStr, msg); + Utils.AcadUi.PrintToCmdLine(printString); + } + + #endregion + + } +} diff --git a/MgdDbgLibrary/Reactors/Events/DocumentMgrEvents.cs b/MgdDbgLibrary/Reactors/Events/DocumentMgrEvents.cs new file mode 100644 index 0000000..31dcf7e --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/DocumentMgrEvents.cs @@ -0,0 +1,205 @@ + +// +// (C) Copyright 2006 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 AcApp = Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.Reactors.Events { + + public class DocumentMgrEvents : EventsBase { + + public + DocumentMgrEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDocument Manager Events Turned On ...\n"); + + AcApp.DocumentCollection docs = AcApp.Application.DocumentManager; + + docs.DocumentActivated += new AcApp.DocumentCollectionEventHandler(event_DocumentActivated); + docs.DocumentActivationChanged += new AcApp.DocumentActivationChangedEventHandler(event_DocumentActivationChanged); + docs.DocumentBecameCurrent += new AcApp.DocumentCollectionEventHandler(event_DocumentBecameCurrent); + docs.DocumentCreated += new AcApp.DocumentCollectionEventHandler(event_DocumentCreated); + docs.DocumentCreateStarted += new AcApp.DocumentCollectionEventHandler(event_DocumentCreateStarted); + docs.DocumentCreationCanceled += new AcApp.DocumentCollectionEventHandler(event_DocumentCreationCanceled); + docs.DocumentDestroyed += new AcApp.DocumentDestroyedEventHandler(event_DocumentDestroyed); + docs.DocumentLockModeChanged += new AcApp.DocumentLockModeChangedEventHandler(event_DocumentLockModeChanged); + docs.DocumentLockModeChangeVetoed += new AcApp.DocumentLockModeChangeVetoedEventHandler(event_DocumentLockModeChangeVetoed); + docs.DocumentLockModeWillChange += new AcApp.DocumentLockModeWillChangeEventHandler(event_DocumentLockModeWillChange); + docs.DocumentToBeActivated += new AcApp.DocumentCollectionEventHandler(event_DocumentToBeActivated); + docs.DocumentToBeDeactivated += new AcApp.DocumentCollectionEventHandler(event_DocumentToBeDeactivated); + docs.DocumentToBeDestroyed += new AcApp.DocumentCollectionEventHandler(event_DocumentToBeDestroyed); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDocument Manager Events Turned Off ...\n"); + + AcApp.DocumentCollection docs = AcApp.Application.DocumentManager; + + docs.DocumentActivated -= new AcApp.DocumentCollectionEventHandler(event_DocumentActivated); + docs.DocumentActivationChanged -= new AcApp.DocumentActivationChangedEventHandler(event_DocumentActivationChanged); + docs.DocumentBecameCurrent -= new AcApp.DocumentCollectionEventHandler(event_DocumentBecameCurrent); + docs.DocumentCreated -= new AcApp.DocumentCollectionEventHandler(event_DocumentCreated); + docs.DocumentCreateStarted -= new AcApp.DocumentCollectionEventHandler(event_DocumentCreateStarted); + docs.DocumentCreationCanceled -= new AcApp.DocumentCollectionEventHandler(event_DocumentCreationCanceled); + docs.DocumentDestroyed -= new AcApp.DocumentDestroyedEventHandler(event_DocumentDestroyed); + docs.DocumentLockModeChanged -= new AcApp.DocumentLockModeChangedEventHandler(event_DocumentLockModeChanged); + docs.DocumentLockModeChangeVetoed -= new AcApp.DocumentLockModeChangeVetoedEventHandler(event_DocumentLockModeChangeVetoed); + docs.DocumentLockModeWillChange -= new AcApp.DocumentLockModeWillChangeEventHandler(event_DocumentLockModeWillChange); + docs.DocumentToBeActivated -= new AcApp.DocumentCollectionEventHandler(event_DocumentToBeActivated); + docs.DocumentToBeDeactivated -= new AcApp.DocumentCollectionEventHandler(event_DocumentToBeDeactivated); + docs.DocumentToBeDestroyed -= new AcApp.DocumentCollectionEventHandler(event_DocumentToBeDestroyed); + } + + private void + event_DocumentToBeDestroyed(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document To Be Destroyed", e.Document); + } + + private void + event_DocumentToBeDeactivated(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document To Be Deactivated", e.Document); + } + + private void + event_DocumentToBeActivated(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document To Be Activated", e.Document); + } + + private void + event_DocumentLockModeWillChange(object sender, AcApp.DocumentLockModeWillChangeEventArgs e) + { + PrintEventMessage("Document Lock Mode Will Change", e.Document); + if (m_showDetails) { + PrintSubEventMessage("Global Command Name", e.GlobalCommandName); + PrintSubEventMessage("Current Mode", e.CurrentMode.ToString()); + PrintSubEventMessage("My Current Mode", e.MyCurrentMode.ToString()); + PrintSubEventMessage("My New Mode", e.MyNewMode.ToString()); + } + } + + private void + event_DocumentLockModeChangeVetoed(object sender, AcApp.DocumentLockModeChangeVetoedEventArgs e) + { + PrintEventMessage("Document Lock Mode Change Vetoed", e.Document); + if (m_showDetails) { + PrintSubEventMessage("Global Command Name", e.GlobalCommandName); + } + } + + private void + event_DocumentLockModeChanged(object sender, AcApp.DocumentLockModeChangedEventArgs e) + { + PrintEventMessage("Document Lock Mode Changed", e.Document); + if (m_showDetails) { + PrintSubEventMessage("Global Command Name", e.GlobalCommandName); + PrintSubEventMessage("Current Mode", e.CurrentMode.ToString()); + PrintSubEventMessage("My Current Mode", e.MyCurrentMode.ToString()); + PrintSubEventMessage("My Previous Mode", e.MyPreviousMode.ToString()); + } + } + + private void + event_DocumentDestroyed(object sender, AcApp.DocumentDestroyedEventArgs e) + { + PrintEventMessage("Document Destroyed", e.FileName); + } + + private void + event_DocumentCreationCanceled(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document Creation Canceled", e.Document); + } + + private void + event_DocumentCreateStarted(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document Create Started", e.Document); + } + + private void + event_DocumentCreated(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document Created", e.Document); + } + + private void + event_DocumentBecameCurrent(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document Became Current", e.Document); + } + + private void + event_DocumentActivationChanged(object sender, AcApp.DocumentActivationChangedEventArgs e) + { + PrintEventMessage("Document Activation Changed", e.NewValue.ToString()); + } + + private void + event_DocumentActivated(object sender, AcApp.DocumentCollectionEventArgs e) + { + PrintEventMessage("Document Activated", e.Document); + } + + #region Print Abstraction + + private void + PrintEventMessage(string eventStr) + { + string printString = string.Format("\n[Doc Mgr Event] : {0,-25}", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private void + PrintEventMessage(string eventStr, AcApp.Document doc) + { + string printString = string.Format("\n[Doc Mgr Event] : {0,-25} : {1}", eventStr, doc.Name); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private void + PrintEventMessage(string eventStr, string msg) + { + string printString = string.Format("\n[Doc Mgr Event] : {0,-25} : {1}", eventStr, msg); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private void + PrintSubEventMessage(string eventStr, string msg) + { + string printString = string.Format("\n {0,-20} : {1}", eventStr, msg); + Utils.AcadUi.PrintToCmdLine(printString); + } + + + #endregion + } +} diff --git a/MgdDbgLibrary/Reactors/Events/DynamicLinkerEvents.cs b/MgdDbgLibrary/Reactors/Events/DynamicLinkerEvents.cs new file mode 100644 index 0000000..5c7d967 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/DynamicLinkerEvents.cs @@ -0,0 +1,112 @@ + +// +// (C) Copyright 2006 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; + +namespace MgdDbg.Reactors.Events { + + public class DynamicLinkerEvents : EventsBase { + + public + DynamicLinkerEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDynamic Linker Events Turned On ...\n"); + + DynamicLinker dLinker = SystemObjects.DynamicLinker; + + dLinker.ModuleLoadAborted += new ModuleLoadAbortedEventHandler(event_ModuleLoadAborted); + dLinker.ModuleLoaded += new ModuleLoadedEventHandler(event_ModuleLoaded); + dLinker.ModuleLoading += new ModuleLoadingEventHandler(event_ModuleLoading); + dLinker.ModuleUnloadAborted += new ModuleUnloadAbortedEventHandler(event_ModuleUnloadAborted); + dLinker.ModuleUnloaded += new ModuleUnloadedEventHandler(event_ModuleUnloaded); + dLinker.ModuleUnloading += new ModuleUnloadingEventHandler(event_ModuleUnloading); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nDynamic Linker Events Turned Off ...\n"); + + DynamicLinker dLinker = SystemObjects.DynamicLinker; + + dLinker.ModuleLoadAborted -= new ModuleLoadAbortedEventHandler(event_ModuleLoadAborted); + dLinker.ModuleLoaded -= new ModuleLoadedEventHandler(event_ModuleLoaded); + dLinker.ModuleLoading -= new ModuleLoadingEventHandler(event_ModuleLoading); + dLinker.ModuleUnloadAborted -= new ModuleUnloadAbortedEventHandler(event_ModuleUnloadAborted); + dLinker.ModuleUnloaded -= new ModuleUnloadedEventHandler(event_ModuleUnloaded); + dLinker.ModuleUnloading -= new ModuleUnloadingEventHandler(event_ModuleUnloading); + } + + private void + event_ModuleUnloading(object sender, DynamicLinkerEventArgs e) + { + PrintEventMessage("Module Unloading", e.FileName); + } + + private void + event_ModuleUnloaded(object sender, DynamicLinkerEventArgs e) + { + PrintEventMessage("Module Unloaded", e.FileName); + } + + private void + event_ModuleUnloadAborted(object sender, DynamicLinkerEventArgs e) + { + PrintEventMessage("Module Unload Aborted", e.FileName); + } + + private void + event_ModuleLoading(object sender, DynamicLinkerEventArgs e) + { + PrintEventMessage("Module Loading", e.FileName); + } + + private void + event_ModuleLoaded(object sender, DynamicLinkerEventArgs e) + { + PrintEventMessage("Module Loaded", e.FileName); + } + + private void + event_ModuleLoadAborted(object sender, DynamicLinkerEventArgs e) + { + PrintEventMessage("Module Load Aborted", e.FileName); + } + + #region Print Abstraction + + private void + PrintEventMessage(string eventStr, string fileName) + { + string printString = string.Format("\n[Dynamic Linker Event] : {0,-25} : {1}", eventStr, fileName); + Utils.AcadUi.PrintToCmdLine(printString); + } + + #endregion + } +} diff --git a/MgdDbgLibrary/Reactors/Events/EditorEvents.cs b/MgdDbgLibrary/Reactors/Events/EditorEvents.cs new file mode 100644 index 0000000..1a764af --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/EditorEvents.cs @@ -0,0 +1,464 @@ + +// +// (C) Copyright 2006 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 System; +using Autodesk.AutoCAD.ApplicationServices; +using Autodesk.AutoCAD.EditorInput; + +namespace MgdDbg.Reactors.Events { + + public class EditorEvents : EventsBase { + + public bool m_suppressDuringDrag = true; + + public + EditorEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nEditor Events Turned On ...\n"); + + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + EnableEvents(doc.Editor); + } + } + + public void + EnableEvents(Editor ed) + { + ed.EnteringQuiescentState += new EventHandler(event_EnteringQuiescentState); + ed.LeavingQuiescentState += new EventHandler(event_LeavingQuiescentState); + + ed.PointFilter += new PointFilterEventHandler(event_PointFilter); + ed.PointMonitor += new PointMonitorEventHandler(event_PointMonitor); + + ed.PromptingForAngle += new PromptAngleOptionsEventHandler(event_PromptingForAngle); + ed.PromptedForAngle += new PromptDoubleResultEventHandler(event_PromptedForAngle); + + ed.PromptingForCorner += new PromptPointOptionsEventHandler(event_PromptingForCorner); + ed.PromptedForCorner += new PromptPointResultEventHandler(event_PromptedForCorner); + + ed.PromptingForDistance += new PromptDistanceOptionsEventHandler(event_PromptingForDistance); + ed.PromptedForDistance += new PromptDoubleResultEventHandler(event_PromptedForDistance); + + ed.PromptingForDouble += new PromptDoubleOptionsEventHandler(event_PromptingForDouble); + ed.PromptedForDouble += new PromptDoubleResultEventHandler(event_PromptedForDouble); + + ed.PromptingForEntity += new PromptEntityOptionsEventHandler(event_PromptingForEntity); + ed.PromptedForEntity += new PromptEntityResultEventHandler(event_PromptedForEntity); + ed.PromptForEntityEnding += new PromptForEntityEndingEventHandler(event_PromptForEntityEnding); + + ed.PromptingForInteger += new PromptIntegerOptionsEventHandler(event_PromptingForInteger); + ed.PromptedForInteger += new PromptIntegerResultEventHandler(event_PromptedForInteger); + + ed.PromptingForKeyword += new PromptKeywordOptionsEventHandler(event_PromptingForKeyword); + ed.PromptedForKeyword += new PromptStringResultEventHandler(event_PromptedForKeyword); + + ed.PromptingForNestedEntity += new PromptNestedEntityOptionsEventHandler(event_PromptingForNestedEntity); + ed.PromptedForNestedEntity += new PromptNestedEntityResultEventHandler(event_PromptedForNestedEntity); + + ed.PromptingForPoint += new PromptPointOptionsEventHandler(event_PromptingForPoint); + ed.PromptedForPoint += new PromptPointResultEventHandler(event_PromptedForPoint); + + ed.PromptingForSelection += new PromptSelectionOptionsEventHandler(event_PromptingForSelection); + ed.PromptedForSelection += new PromptSelectionResultEventHandler(event_PromptedForSelection); + ed.PromptForSelectionEnding += new PromptForSelectionEndingEventHandler(event_PromptForSelectionEnding); + ed.SelectionAdded += new SelectionAddedEventHandler(event_SelectionAdded); + ed.SelectionRemoved += new SelectionRemovedEventHandler(event_SelectionRemoved); + + ed.PromptingForString += new PromptStringOptionsEventHandler(event_PromptingForString); + ed.PromptedForString += new PromptStringResultEventHandler(event_PromptedForString); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nEditor Events Turned Off ...\n"); + + DocumentCollection docs = Application.DocumentManager; + foreach (Document doc in docs) { + DisableEvents(doc.Editor); + } + } + + public void + DisableEvents(Editor ed) + { + ed.EnteringQuiescentState -= new EventHandler(event_EnteringQuiescentState); + ed.LeavingQuiescentState -= new EventHandler(event_LeavingQuiescentState); + + ed.PointFilter -= new PointFilterEventHandler(event_PointFilter); + ed.PointMonitor -= new PointMonitorEventHandler(event_PointMonitor); + + ed.PromptingForAngle -= new PromptAngleOptionsEventHandler(event_PromptingForAngle); + ed.PromptedForAngle -= new PromptDoubleResultEventHandler(event_PromptedForAngle); + + ed.PromptingForCorner -= new PromptPointOptionsEventHandler(event_PromptingForCorner); + ed.PromptedForCorner -= new PromptPointResultEventHandler(event_PromptedForCorner); + + ed.PromptingForDistance -= new PromptDistanceOptionsEventHandler(event_PromptingForDistance); + ed.PromptedForDistance -= new PromptDoubleResultEventHandler(event_PromptedForDistance); + + ed.PromptingForDouble -= new PromptDoubleOptionsEventHandler(event_PromptingForDouble); + ed.PromptedForDouble -= new PromptDoubleResultEventHandler(event_PromptedForDouble); + + ed.PromptingForEntity -= new PromptEntityOptionsEventHandler(event_PromptingForEntity); + ed.PromptedForEntity -= new PromptEntityResultEventHandler(event_PromptedForEntity); + ed.PromptForEntityEnding -= new PromptForEntityEndingEventHandler(event_PromptForEntityEnding); + + ed.PromptingForInteger -= new PromptIntegerOptionsEventHandler(event_PromptingForInteger); + ed.PromptedForInteger -= new PromptIntegerResultEventHandler(event_PromptedForInteger); + + ed.PromptingForKeyword -= new PromptKeywordOptionsEventHandler(event_PromptingForKeyword); + ed.PromptedForKeyword -= new PromptStringResultEventHandler(event_PromptedForKeyword); + + ed.PromptingForNestedEntity -= new PromptNestedEntityOptionsEventHandler(event_PromptingForNestedEntity); + ed.PromptedForNestedEntity -= new PromptNestedEntityResultEventHandler(event_PromptedForNestedEntity); + + ed.PromptingForPoint -= new PromptPointOptionsEventHandler(event_PromptingForPoint); + ed.PromptedForPoint -= new PromptPointResultEventHandler(event_PromptedForPoint); + + ed.PromptingForSelection -= new PromptSelectionOptionsEventHandler(event_PromptingForSelection); + ed.PromptedForSelection -= new PromptSelectionResultEventHandler(event_PromptedForSelection); + ed.PromptForSelectionEnding -= new PromptForSelectionEndingEventHandler(event_PromptForSelectionEnding); + ed.SelectionAdded -= new SelectionAddedEventHandler(event_SelectionAdded); + ed.SelectionRemoved -= new SelectionRemovedEventHandler(event_SelectionRemoved); + + ed.PromptingForString -= new PromptStringOptionsEventHandler(event_PromptingForString); + ed.PromptedForString -= new PromptStringResultEventHandler(event_PromptedForString); + } + + private void + event_SelectionRemoved(object sender, SelectionRemovedEventArgs e) + { + PrintEventMessage(sender, "Selection Removed"); + /*if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "SelectionRemoved"; + dbox.ShowDialog(); + }*/ + } + + private void + event_SelectionAdded(object sender, SelectionAddedEventArgs e) + { + PrintEventMessage(sender, "Selection Added"); + /*if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "SelectionAdded"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForString(object sender, PromptStringOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For String"); + /*if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForString"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForSelection(object sender, PromptSelectionOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Selection"); + /*if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForSelection"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForPoint(object sender, PromptPointOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Point"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForPoint"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForNestedEntity(object sender, PromptNestedEntityOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Nested Entity"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForNestedEntity"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForKeyword(object sender, PromptKeywordOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Keyword"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForKeyword"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForInteger(object sender, PromptIntegerOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Integer"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForInteger"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForEntity(object sender, PromptEntityOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Entity"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForEntity"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForDouble(object sender, PromptDoubleOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Double"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForDouble"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForDistance(object sender, PromptDistanceOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Distance"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForDistance"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForCorner(object sender, PromptPointOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Corner"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForCorner"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptingForAngle(object sender, PromptAngleOptionsEventArgs e) + { + PrintEventMessage(sender, "Prompting For Angle"); + /*if (PrintDetails(sender)) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PromptingForAngle"; + dbox.ShowDialog(); + }*/ + } + + private void + event_PromptForSelectionEnding(object sender, PromptForSelectionEndingEventArgs e) + { + PrintEventMessage(sender, "Prompt For Selection Ending"); + if (m_showDetails) { + } + } + + private void + event_PromptForEntityEnding(object sender, PromptForEntityEndingEventArgs e) + { + PrintEventMessage(sender, "Prompt For Entity Ending"); + if (m_showDetails) { + } + } + + private void + event_PromptedForString(object sender, PromptStringResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For String"); + if (m_showDetails) { + } + } + + private void + event_PromptedForSelection(object sender, PromptSelectionResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Selection"); + if (m_showDetails) { + } + } + + private void + event_PromptedForPoint(object sender, PromptPointResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Point"); + if (m_showDetails) { + } + } + + private void + event_PromptedForNestedEntity(object sender, PromptNestedEntityResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Nested Entity"); + if (m_showDetails) { + } + } + + private void + event_PromptedForKeyword(object sender, PromptStringResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Keyword"); + if (m_showDetails) { + } + } + + private void + event_PromptedForInteger(object sender, PromptIntegerResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Integer"); + if (m_showDetails) { + } + } + + private void + event_PromptedForEntity(object sender, PromptEntityResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Entity"); + if (m_showDetails) { + } + } + + private void + event_PromptedForDouble(object sender, PromptDoubleResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Double"); + if (m_showDetails) { + } + } + + private void + event_PromptedForDistance(object sender, PromptDoubleResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Distance"); + if (m_showDetails) { + } + } + + private void + event_PromptedForCorner(object sender, PromptPointResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Corner"); + if (m_showDetails) { + } + } + + private void + event_PromptedForAngle(object sender, PromptDoubleResultEventArgs e) + { + PrintEventMessage(sender, "Prompted For Angle"); + if (m_showDetails) { + } + } + + private void + event_PointMonitor(object sender, PointMonitorEventArgs e) + { + PrintEventMessage(sender, "Point Monitor"); + if (m_showDetails) { + } + } + + private void + event_PointFilter(object sender, PointFilterEventArgs e) + { + PrintEventMessage(sender, "Point Filter"); + if (m_showDetails) { + } + } + + private void + event_LeavingQuiescentState(object sender, EventArgs e) + { + PrintEventMessage(sender, "Leaving Quiescent State"); + } + + private void + event_EnteringQuiescentState(object sender, EventArgs e) + { + PrintEventMessage(sender, "Entering Quiescent State"); + } + + #region Print Abstraction + + private void + PrintEventMessage(object obj, string eventStr) + { + //Editor ed = (Editor)obj; + //if (!(ed.IsDragging && m_suppressDuringDrag)) { + string printString = string.Format("\n[Editor Event] : {0,-20} ", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + //} + } + + private bool + PrintDetails(object obj) + { + // TBD: getting so many messages during drag that they become worthless. On C++ side + // there was a beginDragSequence() event that allowed us to filter the extras out. Can't + // find a way to do that on .NET side (jma - 09/08/06) + Editor ed = (Editor)obj; + if (ed.IsDragging) { + // print the first drag message, but suppress the rest until the + // end of the drag sequence + //if (m_dragJustStarted) { + // m_dragJustStarted = false; + // return true; + return false; + } + else { + return m_showDetails; + } + } + + #endregion + } +} diff --git a/MgdDbgLibrary/Reactors/Events/EventsBase.cs b/MgdDbgLibrary/Reactors/Events/EventsBase.cs new file mode 100644 index 0000000..7ab4306 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/EventsBase.cs @@ -0,0 +1,75 @@ + +// +// (C) Copyright 2006 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 System.Diagnostics; + +namespace MgdDbg.Reactors.Events { + + public abstract class EventsBase { + + protected bool m_showDetails = false; + protected bool m_areEventsEnabled = false; + + protected + EventsBase() + { + } + + public bool + ShowDetails + { + get { return m_showDetails; } + set { m_showDetails = value; } + } + + + public bool + AreEventsEnabled + { + get { return m_areEventsEnabled; } + } + + public void + EnableEvents() + { + Debug.Assert(m_areEventsEnabled == false); + + EnableEventsImp(); + m_areEventsEnabled = true; + } + + public void + DisableEvents() + { + Debug.Assert(m_areEventsEnabled == true); + + DisableEventsImp(); + m_areEventsEnabled = false; + } + + // override these to enable and diable events in derived classes + protected abstract void EnableEventsImp(); + protected abstract void DisableEventsImp(); + + } +} diff --git a/MgdDbgLibrary/Reactors/Events/GraphicsSystemEvents.cs b/MgdDbgLibrary/Reactors/Events/GraphicsSystemEvents.cs new file mode 100644 index 0000000..4620c18 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/GraphicsSystemEvents.cs @@ -0,0 +1,139 @@ + +// +// (C) Copyright 2006 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 System; +using Autodesk.AutoCAD.ApplicationServices; + + +namespace MgdDbg.Reactors.Events { + + public class GraphicsSystemEvents : EventsBase { + + public + GraphicsSystemEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nGraphics System Events Turned On ...\n"); + + DocumentCollection docs = Application.DocumentManager; + + foreach (Document doc in docs) { + EnableEvents(doc.GraphicsManager); + } + } + + public void + EnableEvents(Autodesk.AutoCAD.GraphicsSystem.Manager mgr) + { + mgr.ConfigWasModified += new Autodesk.AutoCAD.GraphicsSystem.ConfigWasModifiedEventHandler(event_ConfigWasModified); + mgr.GsToBeUnloaded += new Autodesk.AutoCAD.GraphicsSystem.GsToBeUnloadedEventHandler(event_GsToBeUnloaded); + mgr.ViewToBeDestroyed += new Autodesk.AutoCAD.GraphicsSystem.ViewToBeDestroyedEventHandler(event_ViewToBeDestroyed); + mgr.ViewWasCreated += new Autodesk.AutoCAD.GraphicsSystem.ViewWasCreatedEventHandler(event_ViewWasCreated); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nGraphics System Events Turned Off ...\n"); + + DocumentCollection docs = Application.DocumentManager; + + foreach (Document doc in docs) { + DisableEvents(doc.GraphicsManager); + } + } + + public void + DisableEvents(Autodesk.AutoCAD.GraphicsSystem.Manager mgr) + { + mgr.ConfigWasModified -= new Autodesk.AutoCAD.GraphicsSystem.ConfigWasModifiedEventHandler(event_ConfigWasModified); + mgr.GsToBeUnloaded -= new Autodesk.AutoCAD.GraphicsSystem.GsToBeUnloadedEventHandler(event_GsToBeUnloaded); + mgr.ViewToBeDestroyed -= new Autodesk.AutoCAD.GraphicsSystem.ViewToBeDestroyedEventHandler(event_ViewToBeDestroyed); + mgr.ViewWasCreated -= new Autodesk.AutoCAD.GraphicsSystem.ViewWasCreatedEventHandler(event_ViewWasCreated); + } + + + private void + event_ViewWasCreated(object sender, Autodesk.AutoCAD.GraphicsSystem.ViewEventArgs e) + { +#if(AC2012) +#else + PrintReactorMessage("View Was Created", e.View.ViewportExtents.ToString()); +#endif + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "ViewWasCreated"; + dbox.ShowDialog(); + } + } + + private void + event_ViewToBeDestroyed(object sender, Autodesk.AutoCAD.GraphicsSystem.ViewEventArgs e) + { +#if(AC2012) +#else + PrintReactorMessage("View To Be Destroyed", e.View.ViewportExtents.ToString()); +#endif + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "ViewToBeDestroyed"; + dbox.ShowDialog(); + } + } + + private void + event_GsToBeUnloaded(object sender, EventArgs e) + { + PrintReactorMessage("Gs To Be Unloaded"); + } + + private void + event_ConfigWasModified(object sender, EventArgs e) + { + PrintReactorMessage("Config Was Modified"); + } + + #region Print Abstraction + + private void + PrintReactorMessage(string eventStr) + { + string printString = string.Format("\n[Graphics System Event] : {0,-20} ", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + private void + PrintReactorMessage(string eventStr, string viewName) + { + string printString = string.Format("\n[Graphics System Event] : {0,-20} : {1}", eventStr, viewName); + Utils.AcadUi.PrintToCmdLine(printString); + } + + #endregion + + } +} diff --git a/MgdDbgLibrary/Reactors/Events/LayoutManagerEvents.cs b/MgdDbgLibrary/Reactors/Events/LayoutManagerEvents.cs new file mode 100644 index 0000000..ee5dfc9 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/LayoutManagerEvents.cs @@ -0,0 +1,230 @@ + +// +// (C) Copyright 2006 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 System; +using AcDb = Autodesk.AutoCAD.DatabaseServices; + +namespace MgdDbg.Reactors.Events { + + public class LayoutManagerEvents : EventsBase { + + private AcDb.LayoutManager m_lMgr; + + public + LayoutManagerEvents() + { + m_lMgr = null; + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nLayout Manager Events Turned On ...\n"); + + m_lMgr = AcDb.LayoutManager.Current; + + m_lMgr.AbortLayoutCopied += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_AbortLayoutCopied); + m_lMgr.AbortLayoutRemoved += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_AbortLayoutRemoved); + m_lMgr.AbortLayoutRename += new Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventHandler(event_AbortLayoutRename); + m_lMgr.LayoutCopied += new Autodesk.AutoCAD.DatabaseServices.LayoutCopiedEventHandler(event_LayoutCopied); + m_lMgr.LayoutCreated += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutCreated); + m_lMgr.LayoutRemoved += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutRemoved); + m_lMgr.LayoutRenamed += new Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventHandler(event_LayoutRenamed); + m_lMgr.LayoutsReordered += new EventHandler(event_LayoutsReordered); + m_lMgr.LayoutSwitched += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutSwitched); + m_lMgr.LayoutToBeCopied += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutToBeCopied); + m_lMgr.LayoutToBeRemoved += new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutToBeRemoved); + m_lMgr.LayoutToBeRenamed += new Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventHandler(event_LayoutToBeRenamed); + m_lMgr.PlotStyleTableChanged += new Autodesk.AutoCAD.DatabaseServices.PlotStyleTableChangedEventHandler(event_PlotStyleTableChanged); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nLayout Manager Events Turned Off ...\n"); + + m_lMgr.AbortLayoutCopied -= new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_AbortLayoutCopied); + m_lMgr.AbortLayoutRemoved -= new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_AbortLayoutRemoved); + m_lMgr.AbortLayoutRename -= new Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventHandler(event_AbortLayoutRename); + m_lMgr.LayoutCopied -= new Autodesk.AutoCAD.DatabaseServices.LayoutCopiedEventHandler(event_LayoutCopied); + m_lMgr.LayoutCreated -= new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutCreated); + m_lMgr.LayoutRemoved -= new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutRemoved); + m_lMgr.LayoutRenamed -= new Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventHandler(event_LayoutRenamed); + m_lMgr.LayoutsReordered -= new EventHandler(event_LayoutsReordered); + m_lMgr.LayoutSwitched -= new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutSwitched); + m_lMgr.LayoutToBeCopied -= new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutToBeCopied); + m_lMgr.LayoutToBeRemoved -= new Autodesk.AutoCAD.DatabaseServices.LayoutEventHandler(event_LayoutToBeRemoved); + m_lMgr.LayoutToBeRenamed -= new Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventHandler(event_LayoutToBeRenamed); + m_lMgr.PlotStyleTableChanged -= new Autodesk.AutoCAD.DatabaseServices.PlotStyleTableChangedEventHandler(event_PlotStyleTableChanged); + } + + private void + event_PlotStyleTableChanged(object sender, Autodesk.AutoCAD.DatabaseServices.PlotStyleTableChangedEventArgs e) + { + PrintReactorMessage("Plot Style Table Changed"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "PlotStyleTableChanged"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutToBeRenamed(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventArgs e) + { + PrintReactorMessage("Layout To Be Renamed"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutToBeRenamed"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutToBeRemoved(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutEventArgs e) + { + PrintReactorMessage("Layout To Be Removed"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutToBeRemoved"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutToBeCopied(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutEventArgs e) + { + PrintReactorMessage("Layout To Be Copied"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutToBeCopied"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutSwitched(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutEventArgs e) + { + PrintReactorMessage("Layout Switched"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutToBeSwitched"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutsReordered(object sender, EventArgs e) + { + PrintReactorMessage("Layouts Reordered"); + } + + private void + event_LayoutRenamed(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventArgs e) + { + PrintReactorMessage("Layout Renamed"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutRenamed"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutRemoved(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutEventArgs e) + { + PrintReactorMessage("Layout Removed"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutRemoved"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutCreated(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutEventArgs e) + { + PrintReactorMessage("Layout Created"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutCreated"; + dbox.ShowDialog(); + } + } + + private void + event_LayoutCopied(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutCopiedEventArgs e) + { + PrintReactorMessage("Layout Copied"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "LayoutCopied"; + dbox.ShowDialog(); + } + } + + private void + event_AbortLayoutRename(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutRenamedEventArgs e) + { + PrintReactorMessage("Abort Layout Rename"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "AbortLayoutRename"; + dbox.ShowDialog(); + } + } + + private void + event_AbortLayoutRemoved(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutEventArgs e) + { + PrintReactorMessage("Abort Layout Removed"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "AbortLayoutRemoved"; + dbox.ShowDialog(); + } + } + + private void + event_AbortLayoutCopied(object sender, Autodesk.AutoCAD.DatabaseServices.LayoutEventArgs e) + { + PrintReactorMessage("Abort Layout Copied"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "AbortLayoutCopied"; + dbox.ShowDialog(); + } + } + + #region Print Abstraction + + private void + PrintReactorMessage(string eventStr) + { + string printString = string.Format("\n[Layout Manager Event] : {0,-20} ", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + #endregion + } +} diff --git a/MgdDbgLibrary/Reactors/Events/PlotEvents.cs b/MgdDbgLibrary/Reactors/Events/PlotEvents.cs new file mode 100644 index 0000000..d6ff9cd --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/PlotEvents.cs @@ -0,0 +1,160 @@ + +// +// (C) Copyright 2006 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 System; +using AcPl = Autodesk.AutoCAD.PlottingServices; +using AcApp = Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.Reactors.Events { + + public class PlotEvents : EventsBase { + + public + PlotEvents() + { + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nPlot Events Turned On ...\n"); + + AcPl.PlotReactorManager plot = new AcPl.PlotReactorManager(); + + plot.BeginDocument += new Autodesk.AutoCAD.PlottingServices.BeginDocumentEventHandler(event_BeginDocument); + plot.BeginPage += new Autodesk.AutoCAD.PlottingServices.BeginPageEventHandler(event_BeginPage); + plot.BeginPlot += new Autodesk.AutoCAD.PlottingServices.BeginPlotEventHandler(event_BeginPlot); + plot.EndDocument += new Autodesk.AutoCAD.PlottingServices.EndDocumentEventHandler(event_EndDocument); + plot.EndPage += new Autodesk.AutoCAD.PlottingServices.EndPageEventHandler(event_EndPage); + plot.EndPlot += new Autodesk.AutoCAD.PlottingServices.EndPlotEventHandler(event_EndPlot); + plot.PageCancelled += new Autodesk.AutoCAD.PlottingServices.PageCancelledEventHandler(event_PageCancelled); + plot.PlotCancelled += new Autodesk.AutoCAD.PlottingServices.PlotCancelledEventHandler(event_PlotCancelled); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nPlot Events Turned Off ...\n"); + + AcPl.PlotReactorManager plot = new AcPl.PlotReactorManager(); + + plot.BeginDocument -= new Autodesk.AutoCAD.PlottingServices.BeginDocumentEventHandler(event_BeginDocument); + plot.BeginPage -= new Autodesk.AutoCAD.PlottingServices.BeginPageEventHandler(event_BeginPage); + plot.BeginPlot -= new Autodesk.AutoCAD.PlottingServices.BeginPlotEventHandler(event_BeginPlot); + plot.EndDocument -= new Autodesk.AutoCAD.PlottingServices.EndDocumentEventHandler(event_EndDocument); + plot.EndPage -= new Autodesk.AutoCAD.PlottingServices.EndPageEventHandler(event_EndPage); + plot.EndPlot -= new Autodesk.AutoCAD.PlottingServices.EndPlotEventHandler(event_EndPlot); + plot.PageCancelled -= new Autodesk.AutoCAD.PlottingServices.PageCancelledEventHandler(event_PageCancelled); + plot.PlotCancelled -= new Autodesk.AutoCAD.PlottingServices.PlotCancelledEventHandler(event_PlotCancelled); + } + + private void + event_PlotCancelled(object sender, EventArgs e) + { + PrintReactorMessage("Plot Cancelled"); + } + + private void + event_PageCancelled(object sender, EventArgs e) + { + PrintReactorMessage("Page Cancelled"); + } + + private void + event_EndPlot(object sender, Autodesk.AutoCAD.PlottingServices.EndPlotEventArgs e) + { + PrintReactorMessage("End Plot"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "EndPlot"; + dbox.ShowDialog(); + } + } + + private void + event_EndPage(object sender, Autodesk.AutoCAD.PlottingServices.EndPageEventArgs e) + { + PrintReactorMessage("Plot End Page"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "EndPage"; + dbox.ShowDialog(); + } + } + + private void + event_EndDocument(object sender, Autodesk.AutoCAD.PlottingServices.EndDocumentEventArgs e) + { + PrintReactorMessage("End Document"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "EndDocument"; + dbox.ShowDialog(); + } + } + + private void + event_BeginPlot(object sender, Autodesk.AutoCAD.PlottingServices.BeginPlotEventArgs e) + { + PrintReactorMessage("Begin Plot"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "BeginPlot"; + dbox.ShowDialog(); + } + } + + private void + event_BeginPage(object sender, Autodesk.AutoCAD.PlottingServices.BeginPageEventArgs e) + { + PrintReactorMessage("Begin Page"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "BeginPage"; + dbox.ShowDialog(); + } + } + + private void + event_BeginDocument(object sender, Autodesk.AutoCAD.PlottingServices.BeginDocumentEventArgs e) + { + PrintReactorMessage("Begin Document"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "BeginDocument"; + dbox.ShowDialog(); + } + } + + #region Print Abstraction + + private void + PrintReactorMessage(string eventStr) + { + string printString = string.Format("\n[Plot Event] : {0,-20} ", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + #endregion + } +} diff --git a/MgdDbgLibrary/Reactors/Events/PublishEvents.cs b/MgdDbgLibrary/Reactors/Events/PublishEvents.cs new file mode 100644 index 0000000..6287b9c --- /dev/null +++ b/MgdDbgLibrary/Reactors/Events/PublishEvents.cs @@ -0,0 +1,396 @@ +// +// (C) Copyright 2006 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 System; +using AcPb = Autodesk.AutoCAD.Publishing; +using AcApp = Autodesk.AutoCAD.ApplicationServices; +using AcDb = Autodesk.AutoCAD.DatabaseServices; + +namespace MgdDbg.Reactors.Events { + + /// + /// Handle all the events exposed by the Publish namespace + /// + + public class PublishEvents : EventsBase { + + private bool m_publishProps; + + public + PublishEvents() + { + m_publishProps = false; + } + + protected override void + EnableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nPublish Events Turned On ...\n"); + + Autodesk.AutoCAD.Publishing.Publisher pub = AcApp.Application.Publisher; + + pub.AboutToBeginBackgroundPublishing += new Autodesk.AutoCAD.Publishing.AboutToBeginBackgroundPublishingEventHandler(event_AboutToBeginBackgroundPublishing); + pub.AboutToBeginPublishing += new Autodesk.AutoCAD.Publishing.AboutToBeginPublishingEventHandler(event_AboutToBeginPublishing); + pub.AboutToEndPublishing += new Autodesk.AutoCAD.Publishing.AboutToEndPublishingEventHandler(event_AboutToEndPublishing); + pub.AboutToMoveFile += new Autodesk.AutoCAD.Publishing.AboutToMoveFileEventHandler(event_AboutToMoveFile); + pub.BeginAggregation += new Autodesk.AutoCAD.Publishing.BeginAggregationEventHandler(event_BeginAggregation); + pub.BeginEntity += new Autodesk.AutoCAD.Publishing.BeginEntityEventHandler(event_BeginEntity); + pub.BeginPublishingSheet += new Autodesk.AutoCAD.Publishing.BeginPublishingSheetEventHandler(event_BeginPublishingSheet); + pub.BeginSheet += new Autodesk.AutoCAD.Publishing.BeginSheetEventHandler(event_BeginSheet); + pub.CancelledOrFailedPublishing += new Autodesk.AutoCAD.Publishing.CancelledOrFailedPublishingEventHandler(event_CancelledOrFailedPublishing); + pub.EndEntity += new Autodesk.AutoCAD.Publishing.EndEntityEventHandler(event_EndEntity); + pub.EndPublish += new Autodesk.AutoCAD.Publishing.EndPublishEventHandler(event_EndPublish); + pub.EndSheet += new Autodesk.AutoCAD.Publishing.EndSheetEventHandler(event_EndSheet); + pub.InitPublishOptionsDialog += new Autodesk.AutoCAD.Publishing.InitPublishOptionsDialogEventHandler(event_InitPublishOptionsDialog); + } + + protected override void + DisableEventsImp() + { + Utils.AcadUi.PrintToCmdLine("\nPublish Events Turned Off ...\n"); + + Autodesk.AutoCAD.Publishing.Publisher pub = AcApp.Application.Publisher; + + pub.AboutToBeginBackgroundPublishing -= new Autodesk.AutoCAD.Publishing.AboutToBeginBackgroundPublishingEventHandler(event_AboutToBeginBackgroundPublishing); + pub.AboutToBeginPublishing -= new Autodesk.AutoCAD.Publishing.AboutToBeginPublishingEventHandler(event_AboutToBeginPublishing); + pub.AboutToEndPublishing -= new Autodesk.AutoCAD.Publishing.AboutToEndPublishingEventHandler(event_AboutToEndPublishing); + pub.AboutToMoveFile -= new Autodesk.AutoCAD.Publishing.AboutToMoveFileEventHandler(event_AboutToMoveFile); + pub.BeginAggregation -= new Autodesk.AutoCAD.Publishing.BeginAggregationEventHandler(event_BeginAggregation); + pub.BeginEntity -= new Autodesk.AutoCAD.Publishing.BeginEntityEventHandler(event_BeginEntity); + pub.BeginPublishingSheet -= new Autodesk.AutoCAD.Publishing.BeginPublishingSheetEventHandler(event_BeginPublishingSheet); + pub.BeginSheet -= new Autodesk.AutoCAD.Publishing.BeginSheetEventHandler(event_BeginSheet); + pub.CancelledOrFailedPublishing -= new Autodesk.AutoCAD.Publishing.CancelledOrFailedPublishingEventHandler(event_CancelledOrFailedPublishing); + pub.EndEntity -= new Autodesk.AutoCAD.Publishing.EndEntityEventHandler(event_EndEntity); + pub.EndPublish -= new Autodesk.AutoCAD.Publishing.EndPublishEventHandler(event_EndPublish); + pub.EndSheet -= new Autodesk.AutoCAD.Publishing.EndSheetEventHandler(event_EndSheet); + pub.InitPublishOptionsDialog -= new Autodesk.AutoCAD.Publishing.InitPublishOptionsDialogEventHandler(event_InitPublishOptionsDialog); + } + + private void + event_AboutToBeginBackgroundPublishing(object sender, Autodesk.AutoCAD.Publishing.AboutToBeginBackgroundPublishingEventArgs e) + { + PrintReactorMessage("About To Begin Background Publishing"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "AboutToBeginBackgroundPublishing"; + dbox.ShowDialog(); + } + } + + private void + event_AboutToBeginPublishing(object sender, Autodesk.AutoCAD.Publishing.AboutToBeginPublishingEventArgs e) + { + PrintReactorMessage("About To Begin Publishing"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "AboutToBeginPublishing"; + dbox.ShowDialog(); + } + } + + private void + event_AboutToEndPublishing(object sender, Autodesk.AutoCAD.Publishing.PublishEventArgs e) + { + PrintReactorMessage("About To End Publishing"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "AboutToEndPublishing"; + dbox.ShowDialog(); + } + } + + private void + event_EndPublish(object sender, Autodesk.AutoCAD.Publishing.PublishEventArgs e) + { + PrintReactorMessage("End Publish"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "EndPublish"; + dbox.ShowDialog(); + } + } + + private void + event_CancelledOrFailedPublishing(object sender, Autodesk.AutoCAD.Publishing.PublishEventArgs e) + { + PrintReactorMessage("Cancelled Or Failed Publishing"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "CancelledOrFailedPublishing"; + dbox.ShowDialog(); + } + } + + private void + event_BeginPublishingSheet(object sender, Autodesk.AutoCAD.Publishing.BeginPublishingSheetEventArgs e) + { + PrintReactorMessage("Begin Publishing Sheet"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "BeginPublishingSheet"; + dbox.ShowDialog(); + } + } + + private void + event_BeginAggregation(object sender, Autodesk.AutoCAD.Publishing.BeginAggregationEventArgs e) + { + PrintReactorMessage("Begin Aggregation"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "BeginAggregation"; + dbox.ShowDialog(); + } + } + + private void + event_AboutToMoveFile(object sender, Autodesk.AutoCAD.Publishing.PublishEventArgs e) + { + PrintReactorMessage("About To Move File"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "AboutToMoveFile"; + dbox.ShowDialog(); + } + } + + private void + event_EndSheet(object sender, Autodesk.AutoCAD.Publishing.PublishSheetEventArgs e) + { + PrintReactorMessage("End Sheet"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "EndSheet"; + dbox.ShowDialog(); + } + } + + private void + event_EndEntity(object sender, Autodesk.AutoCAD.Publishing.PublishEntityEventArgs e) + { + PrintReactorMessage("End Entity"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "EndEntity"; + dbox.ShowDialog(); + } + } + + private void + event_BeginSheet(object sender, Autodesk.AutoCAD.Publishing.PublishSheetEventArgs e) + { + PrintReactorMessage("Begin Sheet"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "BeginSheet"; + dbox.ShowDialog(); + } + + if (m_publishProps) { + PublishSheetProperties(e); + } + } + + + private void + event_BeginEntity(object sender, Autodesk.AutoCAD.Publishing.PublishEntityEventArgs e) + { + PrintReactorMessage("Begin Entity"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "BeginEntity"; + dbox.ShowDialog(); + } + + if (m_publishProps) { + PublishEntityProperties(e); + } + } + + private void + event_InitPublishOptionsDialog(object sender, Autodesk.AutoCAD.Publishing.PublishUIEventArgs e) + { + PrintReactorMessage("Init Publish Options Dialog"); + if (m_showDetails) { + Snoop.Forms.Objects dbox = new Snoop.Forms.Objects(e); + dbox.Text = "InitPublishOptionsDialog"; + dbox.ShowDialog(); + } + } + + private void + PublishEntityProperties (Autodesk.AutoCAD.Publishing.PublishEntityEventArgs e) + { + Int32 curNodeId = -1; + AcDb.ObjectIdCollection refPathIds; + + refPathIds = e.getEntityBlockRefPath(); + curNodeId = e.GetEntityNode(e.Entity.ObjectId, refPathIds); + + AcPb.EPlotPropertyBag propBag = new AcPb.EPlotPropertyBag(); + AcPb.EPlotProperty prop; + AcPb.EPlotAttribute attrib; + + //Add the property + // + prop = new AcPb.EPlotProperty(); + prop.Name = "Cast Shadows"; + prop.Category = "Entity Properties"; + prop.Value = e.Entity.CastShadows.ToString(); + + //Add the hidden attribute data to the property + // + attrib = new AcPb.EPlotAttribute(); + attrib.Ns = "MgdDbg"; + attrib.NsUrl = "http://adsk/MgdDbg.xsd"; + attrib.Name = "value"; + attrib.Value = System.Convert.ToInt32(e.Entity.CastShadows).ToString(); + + prop.Attributes.Add(attrib); + propBag.Properties.Add(prop); + + //Add the property + // + prop = new AcPb.EPlotProperty(); + prop.Name = "Clone Me For Dragging"; + prop.Category = "Entity Properties"; + prop.Value = e.Entity.CloneMeForDragging.ToString(); + + //Add the hidden attribute data to the property + // + attrib = new AcPb.EPlotAttribute(); + attrib.Ns = "MgdDbg"; + attrib.NsUrl = "http://adsk/MgdDbg.xsd"; + attrib.Name = "value"; + attrib.Value = System.Convert.ToInt32(e.Entity.CloneMeForDragging).ToString(); + + prop.Attributes.Add(attrib); + propBag.Properties.Add(prop); + + //Add the property + // + prop = new AcPb.EPlotProperty(); + prop.Name = "Collision Type"; + prop.Category = "Entity Properties"; + prop.Value = e.Entity.CollisionType.ToString(); + + //Add the hidden attribute data to the property + // + attrib = new AcPb.EPlotAttribute(); + attrib.Ns = "MgdDbg"; + attrib.NsUrl = "http://adsk/MgdDbg.xsd"; + attrib.Name = "value"; + attrib.Value = System.Convert.ToInt32(e.Entity.CollisionType).ToString(); + + prop.Attributes.Add(attrib); + propBag.Properties.Add(prop); + + //Add the property + // + prop = new AcPb.EPlotProperty(); + prop.Name = "Color"; + prop.Category = "Entity Properties"; + prop.Value = e.Entity.Color.ColorNameForDisplay; + + //Add the hidden attribute data to the property + // + attrib = new AcPb.EPlotAttribute(); + attrib.Ns = "MgdDbg"; + attrib.NsUrl = "http://adsk/MgdDbg.xsd"; + attrib.Name = "value"; + attrib.Value = e.Entity.ColorIndex.ToString(); + + prop.Attributes.Add(attrib); + propBag.Properties.Add(prop); + + //Now that all the properties have been setup, associate them with the node + // + AcPb.DwfNode dwfNode = null; + + if (curNodeId == -1) + { + curNodeId = e.GetNextAvailableNode(); + dwfNode = new AcPb.DwfNode(curNodeId, "MgdDbg"); + + e.AddNodeToMap(e.Entity.ObjectId, refPathIds, curNodeId); + } + else + { + dwfNode = e.GetNode(curNodeId); + } + + propBag.Id = "MGDDBG-" + e.UniqueEntityId; + propBag.References.Add(propBag.Id); + + e.AddPropertyBag(propBag); + e.AddPropertiesIds(propBag, dwfNode); + } + + private void + PublishSheetProperties (Autodesk.AutoCAD.Publishing.PublishSheetEventArgs e) + { + AcPb.EPlotProperty prop; + AcPb.EPlotProperty[] propArray = new AcPb.EPlotProperty[4]; + + //Get the linear units + // + prop = new AcPb.EPlotProperty(); + prop.Name = "_UnitLinear"; + prop.Value = "inch"; + propArray[0] = prop; + + //Get the angular units + // + prop = new AcPb.EPlotProperty(); + prop.Name = "_UnitAngular"; + prop.Value = "radian"; + propArray[1] = prop; + + //Get the area units. + // + prop = new AcPb.EPlotProperty(); + prop.Name = "_UnitArea"; + prop.Value = "square_foot"; + propArray[2] = prop; + + //Get the volume units + // + prop = new AcPb.EPlotProperty(); + prop.Name = "_UnitVolume"; + prop.Value = "cubic_foot"; + propArray[3] = prop; + + e.AddPagePropertyRange(propArray); + } + + # region Print Abstraction + + private void + PrintReactorMessage(string eventStr) + { + string printString = string.Format("\n[Publish Event] : {0,-20} ", eventStr); + Utils.AcadUi.PrintToCmdLine(printString); + } + + #endregion + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Reactors/Forms/Details.Designer.cs b/MgdDbgLibrary/Reactors/Forms/Details.Designer.cs new file mode 100644 index 0000000..f92b184 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Forms/Details.Designer.cs @@ -0,0 +1,195 @@ +namespace MgdDbg.Reactors.Forms { + partial class Details { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.m_listViewMap = new System.Windows.Forms.ListView(); + this.m_idMapkeyCol = new System.Windows.Forms.ColumnHeader(); + this.m_idMapValCol = new System.Windows.Forms.ColumnHeader(); + this.m_listViewMapItem = new System.Windows.Forms.ListView(); + this.m_objCol = new System.Windows.Forms.ColumnHeader(); + this.m_keyCol = new System.Windows.Forms.ColumnHeader(); + this.m_valCol = new System.Windows.Forms.ColumnHeader(); + this.m_clonedCol = new System.Windows.Forms.ColumnHeader(); + this.m_primCol = new System.Windows.Forms.ColumnHeader(); + this.m_ownerCol = new System.Windows.Forms.ColumnHeader(); + this.m_bnOk = new System.Windows.Forms.Button(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Location = new System.Drawing.Point(12, 23); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(818, 353); + this.tabControl1.TabIndex = 0; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.m_listViewMap); + this.tabPage1.Controls.Add(this.m_listViewMapItem); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(810, 327); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Id Mapping"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // m_listViewMap + // + this.m_listViewMap.Alignment = System.Windows.Forms.ListViewAlignment.Left; + this.m_listViewMap.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_listViewMap.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_idMapkeyCol, + this.m_idMapValCol}); + this.m_listViewMap.FullRowSelect = true; + this.m_listViewMap.GridLines = true; + this.m_listViewMap.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.m_listViewMap.HideSelection = false; + this.m_listViewMap.LabelWrap = false; + this.m_listViewMap.Location = new System.Drawing.Point(6, 6); + this.m_listViewMap.Name = "m_listViewMap"; + this.m_listViewMap.Size = new System.Drawing.Size(242, 315); + this.m_listViewMap.TabIndex = 2; + this.m_listViewMap.UseCompatibleStateImageBehavior = false; + this.m_listViewMap.View = System.Windows.Forms.View.Details; + // + // m_idMapkeyCol + // + this.m_idMapkeyCol.Text = "Key"; + this.m_idMapkeyCol.Width = 150; + // + // m_idMapValCol + // + this.m_idMapValCol.Text = "Value"; + this.m_idMapValCol.Width = 300; + // + // m_listViewMapItem + // + this.m_listViewMapItem.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.m_listViewMapItem.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.m_objCol, + this.m_keyCol, + this.m_valCol, + this.m_clonedCol, + this.m_primCol, + this.m_ownerCol}); + this.m_listViewMapItem.FullRowSelect = true; + this.m_listViewMapItem.GridLines = true; + this.m_listViewMapItem.Location = new System.Drawing.Point(266, 6); + this.m_listViewMapItem.Name = "m_listViewMapItem"; + this.m_listViewMapItem.Size = new System.Drawing.Size(538, 315); + this.m_listViewMapItem.TabIndex = 1; + this.m_listViewMapItem.UseCompatibleStateImageBehavior = false; + this.m_listViewMapItem.View = System.Windows.Forms.View.Details; + this.m_listViewMapItem.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.m_listViewMapItem_ColumnClick); + // + // m_objCol + // + this.m_objCol.Text = ""; + this.m_objCol.Width = 136; + // + // m_keyCol + // + this.m_keyCol.Text = "Key"; + this.m_keyCol.Width = 79; + // + // m_valCol + // + this.m_valCol.Text = "Value"; + this.m_valCol.Width = 116; + // + // m_clonedCol + // + this.m_clonedCol.Text = "Is Cloned"; + this.m_clonedCol.Width = 62; + // + // m_primCol + // + this.m_primCol.Text = "Is Primary"; + this.m_primCol.Width = 63; + // + // m_ownerCol + // + this.m_ownerCol.Text = "Is OwnerXlated"; + this.m_ownerCol.Width = 84; + // + // m_bnOk + // + this.m_bnOk.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.m_bnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.m_bnOk.Location = new System.Drawing.Point(371, 400); + this.m_bnOk.Name = "m_bnOk"; + this.m_bnOk.Size = new System.Drawing.Size(75, 23); + this.m_bnOk.TabIndex = 1; + this.m_bnOk.Text = "OK"; + this.m_bnOk.UseVisualStyleBackColor = true; + // + // Details + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(842, 444); + this.Controls.Add(this.m_bnOk); + this.Controls.Add(this.tabControl1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Details"; + this.Text = "Details"; + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.Button m_bnOk; + private System.Windows.Forms.ListView m_listViewMapItem; + private System.Windows.Forms.ColumnHeader m_keyCol; + private System.Windows.Forms.ColumnHeader m_valCol; + private System.Windows.Forms.ColumnHeader m_clonedCol; + private System.Windows.Forms.ColumnHeader m_primCol; + private System.Windows.Forms.ColumnHeader m_ownerCol; + private System.Windows.Forms.ListView m_listViewMap; + private System.Windows.Forms.ColumnHeader m_idMapkeyCol; + private System.Windows.Forms.ColumnHeader m_idMapValCol; + private System.Windows.Forms.ColumnHeader m_objCol; + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Reactors/Forms/Details.cs b/MgdDbgLibrary/Reactors/Forms/Details.cs new file mode 100644 index 0000000..9073148 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Forms/Details.cs @@ -0,0 +1,131 @@ +// (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 System.Windows.Forms; +using AcDb = Autodesk.AutoCAD.DatabaseServices; +using MgdDbg.Utils; + +namespace MgdDbg.Reactors.Forms { + public partial class Details : Form { + private AcDb.IdMapping m_idMap; + private MgdDbg.Utils.ListViewColumnSorter m_colSorter; + + /// + /// + /// + /// + /// + public Details(string titleName, AcDb.IdMapping idMap) + { + InitializeComponent(); + this.Name = titleName; + this.Text = titleName; + m_idMap = idMap; + m_colSorter = new MgdDbg.Utils.ListViewColumnSorter(); + m_listViewMapItem.ListViewItemSorter = m_colSorter; + DisplayMapProps(); + DisplayMapItems(); + } + + /// + /// + /// + private void DisplayMapProps() + { + ListViewItem item = new ListViewItem(); + item.Text = "Destination Database"; + try { + item.SubItems.Add(AcadUi.DbToStr(m_idMap.DestinationDatabase)); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) { + item.SubItems.Add(e.Message); + } + m_listViewMap.Items.Add(item); + + ListViewItem item1 = new ListViewItem(); + item1.Text = "Original Database"; + try { + item.SubItems.Add(AcadUi.DbToStr(m_idMap.OriginalDatabase)); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) { + item.SubItems.Add(e.Message); + } + m_listViewMap.Items.Add(item1); + + ListViewItem item2 = new ListViewItem(); + item2.Text = "Deep Clone Context"; + item2.SubItems.Add(m_idMap.DeepCloneContext.ToString()); + m_listViewMap.Items.Add(item2); + + ListViewItem item3 = new ListViewItem(); + item3.Text = "Duplicate Record Cloning"; + item3.SubItems.Add(m_idMap.DuplicateRecordCloning.ToString()); + m_listViewMap.Items.Add(item3); + } + + /// + /// + /// + private void DisplayMapItems() + { + System.Collections.IEnumerator iter = m_idMap.GetEnumerator(); + while (iter.MoveNext()) { + AcDb.IdPair pair = (AcDb.IdPair)iter.Current; + + try { + ListViewItem item = new ListViewItem(AcadUi.ObjToTypeAndHandleStr(pair.Key)); + item.SubItems.Add(pair.Key.ToString()); + item.SubItems.Add(pair.Value.ToString()); + item.SubItems.Add(pair.IsCloned.ToString()); + item.SubItems.Add(pair.IsPrimary.ToString()); + item.SubItems.Add(pair.IsOwnerTranslated.ToString()); + item.Tag = pair; + m_listViewMapItem.Items.Add(item); + } + catch (Autodesk.AutoCAD.Runtime.Exception e) { + MessageBox.Show("Couldn't add a pair from the map: " + e.Message); + } + } + } + + private void m_listViewMapItem_ColumnClick(object sender, ColumnClickEventArgs e) + { + // Determine if clicked column is already the column that is being sorted. + if (e.Column == m_colSorter.SortColumn) { + // Reverse the current sort direction for this column. + if (m_colSorter.Order == SortOrder.Ascending) { + m_colSorter.Order = SortOrder.Descending; + } + else { + m_colSorter.Order = SortOrder.Ascending; + } + } + else { + // Set the column number that is to be sorted; default to ascending. + m_colSorter.SortColumn = e.Column; + m_colSorter.Order = SortOrder.Ascending; + } + + // Perform the sort with these new sort options. + m_listViewMapItem.Sort(); + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Reactors/Forms/Details.resx b/MgdDbgLibrary/Reactors/Forms/Details.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/MgdDbgLibrary/Reactors/Forms/Details.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MgdDbgLibrary/Reactors/Forms/EventsForm.cs b/MgdDbgLibrary/Reactors/Forms/EventsForm.cs new file mode 100644 index 0000000..f96e758 --- /dev/null +++ b/MgdDbgLibrary/Reactors/Forms/EventsForm.cs @@ -0,0 +1,108 @@ +// +// (C) Copyright 2006 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 System; +using System.Windows.Forms; + +using AcApp = Autodesk.AutoCAD.ApplicationServices; + +namespace MgdDbg.Reactors.Forms { + + public partial class EventsForm : Form { + + public static Events.ApplicationEvents m_appEvents = new Events.ApplicationEvents(); + public static Events.DatabaseEvents m_dbEvents = new Events.DatabaseEvents(); + public static Events.DatabaseObjEvents m_dbObjEvents = new Events.DatabaseObjEvents(); + public static Events.DocumentEvents m_docEvents = new Events.DocumentEvents(); + public static Events.DocumentMgrEvents m_docMgrEvents = new Events.DocumentMgrEvents(); + public static Events.DynamicLinkerEvents m_dynLnkEvents = new Events.DynamicLinkerEvents(); + public static Events.EditorEvents m_edEvents = new Events.EditorEvents(); + public static Events.GraphicsSystemEvents m_gsEvents = new Events.GraphicsSystemEvents(); + public static Events.LayoutManagerEvents m_layoutMgrEvents = new Events.LayoutManagerEvents(); + public static Events.PlotEvents m_plotEvents = new Events.PlotEvents(); + public static Events.PublishEvents m_publishEvents = new Events.PublishEvents(); + + public + EventsForm() + { + InitializeComponent(); + + m_cbAppEventsOn.Checked = m_appEvents.AreEventsEnabled; + m_cbDbEventsOn.Checked = m_dbEvents.AreEventsEnabled; + m_cbDbObjEventsOn.Checked = m_dbObjEvents.AreEventsEnabled; + m_cbDocEventsOn.Checked = m_docEvents.AreEventsEnabled; + m_cbDocMgrEventsOn.Checked = m_docMgrEvents.AreEventsEnabled; + m_cbDynLinkerEventsOn.Checked = m_dynLnkEvents.AreEventsEnabled; + m_cbEdEventsOn.Checked = m_edEvents.AreEventsEnabled; + m_cbGsEventsOn.Checked = m_gsEvents.AreEventsEnabled; + m_cbLayoutMgrEventsOn.Checked = m_layoutMgrEvents.AreEventsEnabled; + m_cbPlotEventsOn.Checked = m_plotEvents.AreEventsEnabled; + m_cbPubEventsOn.Checked = m_publishEvents.AreEventsEnabled; + + m_cbShowDetailsDbEvents.Checked = m_dbEvents.ShowDetails; + m_cbShowDetailsDocMgrEvents.Checked = m_docMgrEvents.ShowDetails; + m_cbShowDetailsEdEvents.Checked = m_edEvents.ShowDetails; + m_cbShowDetailsGsEvents.Checked = m_gsEvents.ShowDetails; + m_cbShowDetailsLayoutMgrEvents.Checked = m_layoutMgrEvents.ShowDetails; + m_cbShowDetailsPlotEvents.Checked = m_plotEvents.ShowDetails; + m_cbShowDetailsPublishEvents.Checked = m_publishEvents.ShowDetails; + } + + private void + event_OnBnOkClick(object sender, EventArgs e) + { + SetEventsOnOff(m_appEvents, m_cbAppEventsOn.Checked, false); + SetEventsOnOff(m_dbEvents, m_cbDbEventsOn.Checked, m_cbShowDetailsDbEvents.Checked); + SetEventsOnOff(m_dbObjEvents, m_cbDbObjEventsOn.Checked, false); + SetEventsOnOff(m_docEvents, m_cbDocEventsOn.Checked, false); + SetEventsOnOff(m_docMgrEvents, m_cbDocMgrEventsOn.Checked, m_cbShowDetailsDocMgrEvents.Checked); + SetEventsOnOff(m_dynLnkEvents, m_cbDynLinkerEventsOn.Checked, false); + SetEventsOnOff(m_edEvents, m_cbEdEventsOn.Checked, m_cbShowDetailsEdEvents.Checked); + SetEventsOnOff(m_gsEvents, m_cbGsEventsOn.Checked, m_cbShowDetailsGsEvents.Checked); + SetEventsOnOff(m_layoutMgrEvents, m_cbLayoutMgrEventsOn.Checked, m_cbShowDetailsLayoutMgrEvents.Checked); + SetEventsOnOff(m_plotEvents, m_cbPlotEventsOn.Checked, m_cbShowDetailsPlotEvents.Checked); + SetEventsOnOff(m_publishEvents, m_cbPubEventsOn.Checked, m_cbShowDetailsPublishEvents.Checked); + + this.Close(); + } + + private void + SetEventsOnOff(Events.EventsBase eventGroup, bool onOff, bool showDetails) + { + if (onOff) { // on + if (eventGroup.AreEventsEnabled == false) { + eventGroup.EnableEvents(); + } + } + else { // off + if (eventGroup.AreEventsEnabled == true) { + eventGroup.DisableEvents(); + } + } + eventGroup.ShowDetails = showDetails; + } + + private void m_tabPageSys_Click(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Reactors/Forms/EventsForm.designer.cs b/MgdDbgLibrary/Reactors/Forms/EventsForm.designer.cs new file mode 100644 index 0000000..5c757df --- /dev/null +++ b/MgdDbgLibrary/Reactors/Forms/EventsForm.designer.cs @@ -0,0 +1,506 @@ +namespace MgdDbg.Reactors.Forms { + partial class EventsForm { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.m_grpAppEvents = new System.Windows.Forms.GroupBox(); + this.m_cbAppEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpDbEvents = new System.Windows.Forms.GroupBox(); + this.m_cbShowDetailsDbEvents = new System.Windows.Forms.CheckBox(); + this.m_cbDbEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpDocEvents = new System.Windows.Forms.GroupBox(); + this.m_cbDocEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpDocMgrEvents = new System.Windows.Forms.GroupBox(); + this.m_cbShowDetailsDocMgrEvents = new System.Windows.Forms.CheckBox(); + this.m_cbDocMgrEventsOn = new System.Windows.Forms.CheckBox(); + this.m_bnOk = new System.Windows.Forms.Button(); + this.m_tabCtrl = new System.Windows.Forms.TabControl(); + this.m_tabPageSys = new System.Windows.Forms.TabPage(); + this.m_grpLayoutMgrEvents = new System.Windows.Forms.GroupBox(); + this.m_cbShowDetailsLayoutMgrEvents = new System.Windows.Forms.CheckBox(); + this.m_cbLayoutMgrEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpDynLinkerEvents = new System.Windows.Forms.GroupBox(); + this.m_cbDynLinkerEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpPlotEvents = new System.Windows.Forms.GroupBox(); + this.m_cbShowDetailsPlotEvents = new System.Windows.Forms.CheckBox(); + this.m_cbPlotEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpPublishEvents = new System.Windows.Forms.GroupBox(); + this.m_cbShowDetailsPublishEvents = new System.Windows.Forms.CheckBox(); + this.m_cbPubEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpGsEvents = new System.Windows.Forms.GroupBox(); + this.m_cbShowDetailsGsEvents = new System.Windows.Forms.CheckBox(); + this.m_cbGsEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpEditorEvents = new System.Windows.Forms.GroupBox(); + this.m_cbShowDetailsEdEvents = new System.Windows.Forms.CheckBox(); + this.m_cbEdEventsOn = new System.Windows.Forms.CheckBox(); + this.m_bnCancel = new System.Windows.Forms.Button(); + this.m_grpDbObjEvents = new System.Windows.Forms.GroupBox(); + this.m_cbDbObjEventsOn = new System.Windows.Forms.CheckBox(); + this.m_grpAppEvents.SuspendLayout(); + this.m_grpDbEvents.SuspendLayout(); + this.m_grpDocEvents.SuspendLayout(); + this.m_grpDocMgrEvents.SuspendLayout(); + this.m_tabCtrl.SuspendLayout(); + this.m_tabPageSys.SuspendLayout(); + this.m_grpLayoutMgrEvents.SuspendLayout(); + this.m_grpDynLinkerEvents.SuspendLayout(); + this.m_grpPlotEvents.SuspendLayout(); + this.m_grpPublishEvents.SuspendLayout(); + this.m_grpGsEvents.SuspendLayout(); + this.m_grpEditorEvents.SuspendLayout(); + this.m_grpDbObjEvents.SuspendLayout(); + this.SuspendLayout(); + // + // m_grpAppEvents + // + this.m_grpAppEvents.Controls.Add(this.m_cbAppEventsOn); + this.m_grpAppEvents.Location = new System.Drawing.Point(201, 6); + this.m_grpAppEvents.Name = "m_grpAppEvents"; + this.m_grpAppEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpAppEvents.TabIndex = 0; + this.m_grpAppEvents.TabStop = false; + this.m_grpAppEvents.Text = "Application Events"; + // + // m_cbAppEventsOn + // + this.m_cbAppEventsOn.AutoSize = true; + this.m_cbAppEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbAppEventsOn.Name = "m_cbAppEventsOn"; + this.m_cbAppEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbAppEventsOn.TabIndex = 1; + this.m_cbAppEventsOn.Text = "On"; + this.m_cbAppEventsOn.UseVisualStyleBackColor = true; + // + // m_grpDbEvents + // + this.m_grpDbEvents.Controls.Add(this.m_cbShowDetailsDbEvents); + this.m_grpDbEvents.Controls.Add(this.m_cbDbEventsOn); + this.m_grpDbEvents.Location = new System.Drawing.Point(17, 6); + this.m_grpDbEvents.Name = "m_grpDbEvents"; + this.m_grpDbEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpDbEvents.TabIndex = 3; + this.m_grpDbEvents.TabStop = false; + this.m_grpDbEvents.Text = "Database Events"; + // + // m_cbShowDetailsDbEvents + // + this.m_cbShowDetailsDbEvents.AutoSize = true; + this.m_cbShowDetailsDbEvents.Location = new System.Drawing.Point(16, 37); + this.m_cbShowDetailsDbEvents.Name = "m_cbShowDetailsDbEvents"; + this.m_cbShowDetailsDbEvents.Size = new System.Drawing.Size(88, 17); + this.m_cbShowDetailsDbEvents.TabIndex = 2; + this.m_cbShowDetailsDbEvents.Text = "Show Details"; + this.m_cbShowDetailsDbEvents.UseVisualStyleBackColor = true; + // + // m_cbDbEventsOn + // + this.m_cbDbEventsOn.AutoSize = true; + this.m_cbDbEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbDbEventsOn.Name = "m_cbDbEventsOn"; + this.m_cbDbEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbDbEventsOn.TabIndex = 1; + this.m_cbDbEventsOn.Text = "On"; + this.m_cbDbEventsOn.UseVisualStyleBackColor = true; + // + // m_grpDocEvents + // + this.m_grpDocEvents.Controls.Add(this.m_cbDocEventsOn); + this.m_grpDocEvents.Location = new System.Drawing.Point(17, 217); + this.m_grpDocEvents.Name = "m_grpDocEvents"; + this.m_grpDocEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpDocEvents.TabIndex = 4; + this.m_grpDocEvents.TabStop = false; + this.m_grpDocEvents.Text = "Document Events"; + // + // m_cbDocEventsOn + // + this.m_cbDocEventsOn.AutoSize = true; + this.m_cbDocEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbDocEventsOn.Name = "m_cbDocEventsOn"; + this.m_cbDocEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbDocEventsOn.TabIndex = 1; + this.m_cbDocEventsOn.Text = "On"; + this.m_cbDocEventsOn.UseVisualStyleBackColor = true; + // + // m_grpDocMgrEvents + // + this.m_grpDocMgrEvents.Controls.Add(this.m_cbShowDetailsDocMgrEvents); + this.m_grpDocMgrEvents.Controls.Add(this.m_cbDocMgrEventsOn); + this.m_grpDocMgrEvents.Location = new System.Drawing.Point(17, 148); + this.m_grpDocMgrEvents.Name = "m_grpDocMgrEvents"; + this.m_grpDocMgrEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpDocMgrEvents.TabIndex = 3; + this.m_grpDocMgrEvents.TabStop = false; + this.m_grpDocMgrEvents.Text = "Document Manager Events"; + // + // m_cbShowDetailsDocMgrEvents + // + this.m_cbShowDetailsDocMgrEvents.AutoSize = true; + this.m_cbShowDetailsDocMgrEvents.Location = new System.Drawing.Point(16, 37); + this.m_cbShowDetailsDocMgrEvents.Name = "m_cbShowDetailsDocMgrEvents"; + this.m_cbShowDetailsDocMgrEvents.Size = new System.Drawing.Size(88, 17); + this.m_cbShowDetailsDocMgrEvents.TabIndex = 2; + this.m_cbShowDetailsDocMgrEvents.Text = "Show Details"; + this.m_cbShowDetailsDocMgrEvents.UseVisualStyleBackColor = true; + // + // m_cbDocMgrEventsOn + // + this.m_cbDocMgrEventsOn.AutoSize = true; + this.m_cbDocMgrEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbDocMgrEventsOn.Name = "m_cbDocMgrEventsOn"; + this.m_cbDocMgrEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbDocMgrEventsOn.TabIndex = 1; + this.m_cbDocMgrEventsOn.Text = "On"; + this.m_cbDocMgrEventsOn.UseVisualStyleBackColor = true; + // + // m_bnOk + // + this.m_bnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.m_bnOk.Location = new System.Drawing.Point(211, 373); + this.m_bnOk.Name = "m_bnOk"; + this.m_bnOk.Size = new System.Drawing.Size(75, 23); + this.m_bnOk.TabIndex = 5; + this.m_bnOk.Text = "OK"; + this.m_bnOk.UseVisualStyleBackColor = true; + this.m_bnOk.Click += new System.EventHandler(this.event_OnBnOkClick); + // + // m_tabCtrl + // + this.m_tabCtrl.Controls.Add(this.m_tabPageSys); + this.m_tabCtrl.Location = new System.Drawing.Point(12, 12); + this.m_tabCtrl.Name = "m_tabCtrl"; + this.m_tabCtrl.SelectedIndex = 0; + this.m_tabCtrl.Size = new System.Drawing.Size(558, 344); + this.m_tabCtrl.TabIndex = 6; + // + // m_tabPageSys + // + this.m_tabPageSys.Controls.Add(this.m_grpDbObjEvents); + this.m_tabPageSys.Controls.Add(this.m_grpLayoutMgrEvents); + this.m_tabPageSys.Controls.Add(this.m_grpDynLinkerEvents); + this.m_tabPageSys.Controls.Add(this.m_grpPlotEvents); + this.m_tabPageSys.Controls.Add(this.m_grpPublishEvents); + this.m_tabPageSys.Controls.Add(this.m_grpGsEvents); + this.m_tabPageSys.Controls.Add(this.m_grpEditorEvents); + this.m_tabPageSys.Controls.Add(this.m_grpAppEvents); + this.m_tabPageSys.Controls.Add(this.m_grpDbEvents); + this.m_tabPageSys.Controls.Add(this.m_grpDocMgrEvents); + this.m_tabPageSys.Controls.Add(this.m_grpDocEvents); + this.m_tabPageSys.Location = new System.Drawing.Point(4, 22); + this.m_tabPageSys.Name = "m_tabPageSys"; + this.m_tabPageSys.Padding = new System.Windows.Forms.Padding(3); + this.m_tabPageSys.Size = new System.Drawing.Size(550, 318); + this.m_tabPageSys.TabIndex = 0; + this.m_tabPageSys.Text = "System"; + this.m_tabPageSys.UseVisualStyleBackColor = true; + this.m_tabPageSys.Click += new System.EventHandler(this.m_tabPageSys_Click); + // + // m_grpLayoutMgrEvents + // + this.m_grpLayoutMgrEvents.Controls.Add(this.m_cbShowDetailsLayoutMgrEvents); + this.m_grpLayoutMgrEvents.Controls.Add(this.m_cbLayoutMgrEventsOn); + this.m_grpLayoutMgrEvents.Location = new System.Drawing.Point(201, 217); + this.m_grpLayoutMgrEvents.Name = "m_grpLayoutMgrEvents"; + this.m_grpLayoutMgrEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpLayoutMgrEvents.TabIndex = 5; + this.m_grpLayoutMgrEvents.TabStop = false; + this.m_grpLayoutMgrEvents.Text = "Layout Manager Events"; + // + // m_cbShowDetailsLayoutMgrEvents + // + this.m_cbShowDetailsLayoutMgrEvents.AutoSize = true; + this.m_cbShowDetailsLayoutMgrEvents.Location = new System.Drawing.Point(16, 35); + this.m_cbShowDetailsLayoutMgrEvents.Name = "m_cbShowDetailsLayoutMgrEvents"; + this.m_cbShowDetailsLayoutMgrEvents.Size = new System.Drawing.Size(88, 17); + this.m_cbShowDetailsLayoutMgrEvents.TabIndex = 3; + this.m_cbShowDetailsLayoutMgrEvents.Text = "Show Details"; + this.m_cbShowDetailsLayoutMgrEvents.UseVisualStyleBackColor = true; + // + // m_cbLayoutMgrEventsOn + // + this.m_cbLayoutMgrEventsOn.AutoSize = true; + this.m_cbLayoutMgrEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbLayoutMgrEventsOn.Name = "m_cbLayoutMgrEventsOn"; + this.m_cbLayoutMgrEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbLayoutMgrEventsOn.TabIndex = 1; + this.m_cbLayoutMgrEventsOn.Text = "On"; + this.m_cbLayoutMgrEventsOn.UseVisualStyleBackColor = true; + // + // m_grpDynLinkerEvents + // + this.m_grpDynLinkerEvents.Controls.Add(this.m_cbDynLinkerEventsOn); + this.m_grpDynLinkerEvents.Location = new System.Drawing.Point(377, 6); + this.m_grpDynLinkerEvents.Name = "m_grpDynLinkerEvents"; + this.m_grpDynLinkerEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpDynLinkerEvents.TabIndex = 5; + this.m_grpDynLinkerEvents.TabStop = false; + this.m_grpDynLinkerEvents.Text = "Dynamic Linker Events"; + // + // m_cbDynLinkerEventsOn + // + this.m_cbDynLinkerEventsOn.AutoSize = true; + this.m_cbDynLinkerEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbDynLinkerEventsOn.Name = "m_cbDynLinkerEventsOn"; + this.m_cbDynLinkerEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbDynLinkerEventsOn.TabIndex = 1; + this.m_cbDynLinkerEventsOn.Text = "On"; + this.m_cbDynLinkerEventsOn.UseVisualStyleBackColor = true; + // + // m_grpPlotEvents + // + this.m_grpPlotEvents.Controls.Add(this.m_cbShowDetailsPlotEvents); + this.m_grpPlotEvents.Controls.Add(this.m_cbPlotEventsOn); + this.m_grpPlotEvents.Location = new System.Drawing.Point(377, 76); + this.m_grpPlotEvents.Name = "m_grpPlotEvents"; + this.m_grpPlotEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpPlotEvents.TabIndex = 6; + this.m_grpPlotEvents.TabStop = false; + this.m_grpPlotEvents.Text = "Plot Events"; + // + // m_cbShowDetailsPlotEvents + // + this.m_cbShowDetailsPlotEvents.AutoSize = true; + this.m_cbShowDetailsPlotEvents.Location = new System.Drawing.Point(16, 37); + this.m_cbShowDetailsPlotEvents.Name = "m_cbShowDetailsPlotEvents"; + this.m_cbShowDetailsPlotEvents.Size = new System.Drawing.Size(88, 17); + this.m_cbShowDetailsPlotEvents.TabIndex = 2; + this.m_cbShowDetailsPlotEvents.Text = "Show Details"; + this.m_cbShowDetailsPlotEvents.UseVisualStyleBackColor = true; + // + // m_cbPlotEventsOn + // + this.m_cbPlotEventsOn.AutoSize = true; + this.m_cbPlotEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbPlotEventsOn.Name = "m_cbPlotEventsOn"; + this.m_cbPlotEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbPlotEventsOn.TabIndex = 1; + this.m_cbPlotEventsOn.Text = "On"; + this.m_cbPlotEventsOn.UseVisualStyleBackColor = true; + // + // m_grpPublishEvents + // + this.m_grpPublishEvents.Controls.Add(this.m_cbShowDetailsPublishEvents); + this.m_grpPublishEvents.Controls.Add(this.m_cbPubEventsOn); + this.m_grpPublishEvents.Location = new System.Drawing.Point(377, 148); + this.m_grpPublishEvents.Name = "m_grpPublishEvents"; + this.m_grpPublishEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpPublishEvents.TabIndex = 8; + this.m_grpPublishEvents.TabStop = false; + this.m_grpPublishEvents.Text = "Publish Events"; + // + // m_cbShowDetailsPublishEvents + // + this.m_cbShowDetailsPublishEvents.AutoSize = true; + this.m_cbShowDetailsPublishEvents.Location = new System.Drawing.Point(16, 37); + this.m_cbShowDetailsPublishEvents.Name = "m_cbShowDetailsPublishEvents"; + this.m_cbShowDetailsPublishEvents.Size = new System.Drawing.Size(88, 17); + this.m_cbShowDetailsPublishEvents.TabIndex = 2; + this.m_cbShowDetailsPublishEvents.Text = "Show Details"; + this.m_cbShowDetailsPublishEvents.UseVisualStyleBackColor = true; + // + // m_cbPubEventsOn + // + this.m_cbPubEventsOn.AutoSize = true; + this.m_cbPubEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbPubEventsOn.Name = "m_cbPubEventsOn"; + this.m_cbPubEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbPubEventsOn.TabIndex = 1; + this.m_cbPubEventsOn.Text = "On"; + this.m_cbPubEventsOn.UseVisualStyleBackColor = true; + // + // m_grpGsEvents + // + this.m_grpGsEvents.Controls.Add(this.m_cbShowDetailsGsEvents); + this.m_grpGsEvents.Controls.Add(this.m_cbGsEventsOn); + this.m_grpGsEvents.Location = new System.Drawing.Point(201, 148); + this.m_grpGsEvents.Name = "m_grpGsEvents"; + this.m_grpGsEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpGsEvents.TabIndex = 6; + this.m_grpGsEvents.TabStop = false; + this.m_grpGsEvents.Text = "Graphics System Events"; + // + // m_cbShowDetailsGsEvents + // + this.m_cbShowDetailsGsEvents.AutoSize = true; + this.m_cbShowDetailsGsEvents.Location = new System.Drawing.Point(16, 37); + this.m_cbShowDetailsGsEvents.Name = "m_cbShowDetailsGsEvents"; + this.m_cbShowDetailsGsEvents.Size = new System.Drawing.Size(88, 17); + this.m_cbShowDetailsGsEvents.TabIndex = 3; + this.m_cbShowDetailsGsEvents.Text = "Show Details"; + this.m_cbShowDetailsGsEvents.UseVisualStyleBackColor = true; + // + // m_cbGsEventsOn + // + this.m_cbGsEventsOn.AutoSize = true; + this.m_cbGsEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbGsEventsOn.Name = "m_cbGsEventsOn"; + this.m_cbGsEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbGsEventsOn.TabIndex = 1; + this.m_cbGsEventsOn.Text = "On"; + this.m_cbGsEventsOn.UseVisualStyleBackColor = true; + // + // m_grpEditorEvents + // + this.m_grpEditorEvents.Controls.Add(this.m_cbShowDetailsEdEvents); + this.m_grpEditorEvents.Controls.Add(this.m_cbEdEventsOn); + this.m_grpEditorEvents.Location = new System.Drawing.Point(201, 76); + this.m_grpEditorEvents.Name = "m_grpEditorEvents"; + this.m_grpEditorEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpEditorEvents.TabIndex = 8; + this.m_grpEditorEvents.TabStop = false; + this.m_grpEditorEvents.Text = "Editor Events"; + // + // m_cbShowDetailsEdEvents + // + this.m_cbShowDetailsEdEvents.AutoSize = true; + this.m_cbShowDetailsEdEvents.Location = new System.Drawing.Point(16, 37); + this.m_cbShowDetailsEdEvents.Name = "m_cbShowDetailsEdEvents"; + this.m_cbShowDetailsEdEvents.Size = new System.Drawing.Size(88, 17); + this.m_cbShowDetailsEdEvents.TabIndex = 2; + this.m_cbShowDetailsEdEvents.Text = "Show Details"; + this.m_cbShowDetailsEdEvents.UseVisualStyleBackColor = true; + // + // m_cbEdEventsOn + // + this.m_cbEdEventsOn.AutoSize = true; + this.m_cbEdEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbEdEventsOn.Name = "m_cbEdEventsOn"; + this.m_cbEdEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbEdEventsOn.TabIndex = 1; + this.m_cbEdEventsOn.Text = "On"; + this.m_cbEdEventsOn.UseVisualStyleBackColor = true; + // + // m_bnCancel + // + this.m_bnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.m_bnCancel.Location = new System.Drawing.Point(294, 373); + this.m_bnCancel.Name = "m_bnCancel"; + this.m_bnCancel.Size = new System.Drawing.Size(75, 23); + this.m_bnCancel.TabIndex = 7; + this.m_bnCancel.Text = "Cancel"; + this.m_bnCancel.UseVisualStyleBackColor = true; + // + // m_grpDbObjEvents + // + this.m_grpDbObjEvents.Controls.Add(this.m_cbDbObjEventsOn); + this.m_grpDbObjEvents.Location = new System.Drawing.Point(17, 76); + this.m_grpDbObjEvents.Name = "m_grpDbObjEvents"; + this.m_grpDbObjEvents.Size = new System.Drawing.Size(158, 63); + this.m_grpDbObjEvents.TabIndex = 9; + this.m_grpDbObjEvents.TabStop = false; + this.m_grpDbObjEvents.Text = "Database Obj Events"; + // + // m_cbDbObjEventsOn + // + this.m_cbDbObjEventsOn.AutoSize = true; + this.m_cbDbObjEventsOn.Location = new System.Drawing.Point(16, 19); + this.m_cbDbObjEventsOn.Name = "m_cbDbObjEventsOn"; + this.m_cbDbObjEventsOn.Size = new System.Drawing.Size(40, 17); + this.m_cbDbObjEventsOn.TabIndex = 0; + this.m_cbDbObjEventsOn.Text = "On"; + this.m_cbDbObjEventsOn.UseVisualStyleBackColor = true; + // + // EventsForm + // + this.AcceptButton = this.m_bnOk; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.m_bnCancel; + this.ClientSize = new System.Drawing.Size(581, 405); + this.Controls.Add(this.m_bnCancel); + this.Controls.Add(this.m_tabCtrl); + this.Controls.Add(this.m_bnOk); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "EventsForm"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Events"; + this.m_grpAppEvents.ResumeLayout(false); + this.m_grpAppEvents.PerformLayout(); + this.m_grpDbEvents.ResumeLayout(false); + this.m_grpDbEvents.PerformLayout(); + this.m_grpDocEvents.ResumeLayout(false); + this.m_grpDocEvents.PerformLayout(); + this.m_grpDocMgrEvents.ResumeLayout(false); + this.m_grpDocMgrEvents.PerformLayout(); + this.m_tabCtrl.ResumeLayout(false); + this.m_tabPageSys.ResumeLayout(false); + this.m_grpLayoutMgrEvents.ResumeLayout(false); + this.m_grpLayoutMgrEvents.PerformLayout(); + this.m_grpDynLinkerEvents.ResumeLayout(false); + this.m_grpDynLinkerEvents.PerformLayout(); + this.m_grpPlotEvents.ResumeLayout(false); + this.m_grpPlotEvents.PerformLayout(); + this.m_grpPublishEvents.ResumeLayout(false); + this.m_grpPublishEvents.PerformLayout(); + this.m_grpGsEvents.ResumeLayout(false); + this.m_grpGsEvents.PerformLayout(); + this.m_grpEditorEvents.ResumeLayout(false); + this.m_grpEditorEvents.PerformLayout(); + this.m_grpDbObjEvents.ResumeLayout(false); + this.m_grpDbObjEvents.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox m_grpAppEvents; + private System.Windows.Forms.CheckBox m_cbAppEventsOn; + private System.Windows.Forms.GroupBox m_grpDbEvents; + private System.Windows.Forms.CheckBox m_cbShowDetailsDbEvents; + private System.Windows.Forms.CheckBox m_cbDbEventsOn; + private System.Windows.Forms.GroupBox m_grpDocEvents; + private System.Windows.Forms.GroupBox m_grpDocMgrEvents; + private System.Windows.Forms.CheckBox m_cbShowDetailsDocMgrEvents; + private System.Windows.Forms.CheckBox m_cbDocMgrEventsOn; + private System.Windows.Forms.Button m_bnOk; + private System.Windows.Forms.TabControl m_tabCtrl; + private System.Windows.Forms.TabPage m_tabPageSys; + private System.Windows.Forms.GroupBox m_grpLayoutMgrEvents; + private System.Windows.Forms.CheckBox m_cbLayoutMgrEventsOn; + private System.Windows.Forms.GroupBox m_grpDynLinkerEvents; + private System.Windows.Forms.CheckBox m_cbDynLinkerEventsOn; + private System.Windows.Forms.GroupBox m_grpPlotEvents; + private System.Windows.Forms.CheckBox m_cbShowDetailsPlotEvents; + private System.Windows.Forms.GroupBox m_grpPublishEvents; + private System.Windows.Forms.CheckBox m_cbShowDetailsPublishEvents; + private System.Windows.Forms.CheckBox m_cbPubEventsOn; + private System.Windows.Forms.GroupBox m_grpGsEvents; + private System.Windows.Forms.GroupBox m_grpEditorEvents; + private System.Windows.Forms.CheckBox m_cbShowDetailsEdEvents; + private System.Windows.Forms.CheckBox m_cbShowDetailsGsEvents; + private System.Windows.Forms.CheckBox m_cbShowDetailsLayoutMgrEvents; + private System.Windows.Forms.CheckBox m_cbPlotEventsOn; + private System.Windows.Forms.CheckBox m_cbGsEventsOn; + private System.Windows.Forms.CheckBox m_cbEdEventsOn; + private System.Windows.Forms.CheckBox m_cbDocEventsOn; + private System.Windows.Forms.Button m_bnCancel; + private System.Windows.Forms.GroupBox m_grpDbObjEvents; + private System.Windows.Forms.CheckBox m_cbDbObjEventsOn; + } +} \ No newline at end of file diff --git a/MgdDbgLibrary/Reactors/Forms/EventsForm.resx b/MgdDbgLibrary/Reactors/Forms/EventsForm.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/MgdDbgLibrary/Reactors/Forms/EventsForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MgdDbgLibrary/ReportBrowser/ObjCountReport.html b/MgdDbgLibrary/ReportBrowser/ObjCountReport.html new file mode 100644 index 0000000..20fd80b --- /dev/null +++ b/MgdDbgLibrary/ReportBrowser/ObjCountReport.html @@ -0,0 +1,36 @@ + + + DWG Stats Report + + + + + + + + + Sorry, this page needs Frames on in order to display + + diff --git a/MgdDbgLibrary/ReportBrowser/css/ReportList.css b/MgdDbgLibrary/ReportBrowser/css/ReportList.css new file mode 100644 index 0000000..2008742 --- /dev/null +++ b/MgdDbgLibrary/ReportBrowser/css/ReportList.css @@ -0,0 +1,14 @@ + + +a:link { color: Darkgreen; } +a:active { color: Darkgreen; } +a:visited { color: Darkgreen; } + + +BODY +{ + font-family:Arial, helvetica, sans-serif; font-size:12pt; + background-color:linen; +} + + diff --git a/MgdDbgLibrary/ReportBrowser/css/Reports.css b/MgdDbgLibrary/ReportBrowser/css/Reports.css new file mode 100644 index 0000000..c5418b9 --- /dev/null +++ b/MgdDbgLibrary/ReportBrowser/css/Reports.css @@ -0,0 +1,20 @@ + + +a:link { color: #0000CC; } +a:active { color: #0000CC; } +a:visited { color: #990099; } + + +body { font-family:Arial, helvetica, sans-serif; font-size:12pt; } + +table.small { font-family:Arial, helvetica, sans-serif; font-size:10pt; } + +td.label { font-weight: bold } + +tr.aecobject { background-color: DarkSeaGreen; } +tr.nonaecobject { background-color: Whitesmoke; } +tr.drawing { background-color: Lightgoldenrodyellow; } +tr.styleheader { background-color: Skyblue; } + +p.reportDesc { font-style: italic; } + diff --git a/MgdDbgLibrary/ReportBrowser/js/ReportUtils_DwgStat.js b/MgdDbgLibrary/ReportBrowser/js/ReportUtils_DwgStat.js new file mode 100644 index 0000000..79ab9a5 --- /dev/null +++ b/MgdDbgLibrary/ReportBrowser/js/ReportUtils_DwgStat.js @@ -0,0 +1,307 @@ + +////////////////////////////////////////////////////////////////////////// +// +// Functions to help implement various reports +// +// Jim Awe +// Autodesk, Inc. +// +////////////////////////////////////////////////////////////////////////// + + +/************************************************************************* +** +** createXmlDom +** do the repetative work of loading a DOM tree with all the right +** arguments. I'm not currently sure these are all the right settings, +** but it will do for now. +** +** **jma +** +*********************************/ + +function createXmlDom() +{ + var xmlDom = new ActiveXObject("MSXML2.DOMDocument"); + if (xmlDom == null) + return null; + + xmlDom.async = false; + xmlDom.setProperty("SelectionLanguage", "XPath"); + + return xmlDom; +} + +/************************************************************************* +** +** createFreeThreadedXmlDom +** do the repetative work of loading a DOM tree with all the right +** arguments. I'm not currently sure these are all the right settings, +** but it will do for now. +** +** **jma +** +*********************************/ + +function createFreeThreadedXmlDom() +{ + var xmlDom = new ActiveXObject("MSXML2.FreeThreadedDOMDocument"); + if (xmlDom == null) + return null; + + xmlDom.async = false; + xmlDom.setProperty("SelectionLanguage", "XPath"); + + return xmlDom; +} + +/************************************************************************* +** +** createXmlDomAndLoad +** do the repetative work of loading a DOM tree with all the right +** arguments. I'm not currently sure these are all the right settings, +** but it will do for now. +** +** **jma +** +*********************************/ + +function createXmlDomAndLoad(url) +{ + var xmlDom = new ActiveXObject("MSXML2.DOMDocument"); + if (xmlDom == null) + return null; + + xmlDom.async = false; + xmlDom.setProperty("SelectionLanguage", "XPath"); + + if (!xmlDom.load(url)) { + var msg = "Could not load file: " + url + "\n" + xmlDom.parseError.reason; + alert(msg); + return null; + } + else + return xmlDom; +} + +/************************************************************************* +** +** createFreeThreadedXmlDomAndLoad +** do the repetative work of loading a DOM tree with all the right +** arguments. I'm not currently sure these are all the right settings, +** but it will do for now. +** +** **jma +** +*********************************/ + +function createFreeThreadedXmlDomAndLoad(url) +{ + var xmlDom = new ActiveXObject("MSXML2.FreeThreadedDOMDocument"); + if (xmlDom == null) + return null; + + xmlDom.async = false; + xmlDom.setProperty("SelectionLanguage", "XPath"); + + if (!xmlDom.load(url)) { + var msg = "Could not load file: " + url + "\n" + xmlDom.parseError.reason; + alert(msg); + return null; + } + else + return xmlDom; +} + +/************************************************************************* +** +** createXslTemplateAndLoad +** +** **jma +** +*********************************/ + +function createXslTemplateAndLoad(url) +{ + var template = new ActiveXObject("MSXML2.XSLTemplate.3.0"); + template.stylesheet = createFreeThreadedXmlDomAndLoad(url); + return template; +} + +/************************************************************************* +** +** xformByXsl +** +** **jma +** +*********************************/ + +function xformByXsl(xmlDataSrcObj, xslUrl) +{ + var xslXform = createXmlDomAndLoad(xslUrl); + if (xslXform == null) { + window.status = "Could not load XSL transform!"; + return; + } + + if (xmlDataSrcObj != null) { + xslTarget.innerHTML = xmlDataSrcObj.transformNode(xslXform.documentElement); + } + else { + alert("No XML data source is loaded."); + document.write("No XML data source loaded."); + } +} + +/************************************************************************* +** +** writeDomElement +** +** **jma +** +*********************************/ + +function writeDomElement(xmlDoc, curNode, tagName) +{ + var newNode = xmlDoc.createElement(tagName); + + if (curNode == null) { + // not sure why this has to be special cased, but I couldn't + // get it to work any other way??? + var rootNode = xmlDoc.selectSingleNode("/"); + rootNode.appendChild(newNode); + } + else { + curNode.appendChild(newNode); + } + + return newNode; +} + +/************************************************************************* +** +** writeDomAttribute +** +** **jma +** +*********************************/ + +function writeDomAttribute(curNode, attName, attValue) +{ + //alert("about to add att: " + attName); + + curNode.setAttribute(attName, attValue); +} + +/************************************************************************* +** +** arrayHas +** see if this item exists in a string array already +** +** **jma +** +*********************************/ + +function arrayHas(strArray, strVal) +{ + for (var i=0;i + + Block Data + + + + + + This report shows a count of the object types that appear in + the selected drawing files on a per-block basis. It is sorted by Count. + + +
This report shows a count of the object types that appear in + the selected drawing files on a per-block basis. It is sorted by Count.