hytos / DTI_PID / SPPIDConverter / Wrapper / SPPIDConverterWrapper.cs @ d19ae675
이력 | 보기 | 이력해설 | 다운로드 (11.7 KB)
1 | 2cae7d1f | gaqhf | /*---------------------------------------------------------------------+\ |
---|---|---|---|
2 | | | |
||
3 | | Copyright 2016 Intergraph Corporation | |
||
4 | | All Rights Reserved | |
||
5 | | | |
||
6 | | Including software, file formats, and audio-visual displays; | |
||
7 | | may only be used pursuant to applicable software license | |
||
8 | | agreement; contains confidential and proprietary information of| |
||
9 | | Intergraph and/or third parties which is protected by copyright| |
||
10 | | and trade secret law and may not be provided or otherwise made | |
||
11 | | available without proper authorization. | |
||
12 | | | |
||
13 | | Unpublished -- rights reserved under the Copyright Laws of the | |
||
14 | | United States. | |
||
15 | | | |
||
16 | | Intergraph Corporation | |
||
17 | | Huntsville, Alabama 35894-0001 | |
||
18 | | | |
||
19 | \+---------------------------------------------------------------------*/ |
||
20 | |||
21 | using System; |
||
22 | using System.ComponentModel; |
||
23 | using System.Windows.Forms; |
||
24 | using Microsoft.Win32; |
||
25 | using Ingr.RAD2D; |
||
26 | |||
27 | 0a24b232 | gaqhf | namespace Converter.SPPID.Wrapper |
28 | 2cae7d1f | gaqhf | { |
29 | /// <summary> |
||
30 | /// This is the primary form. |
||
31 | /// This command may be built as an executable (EXE) or as a dynamic link |
||
32 | /// library (DLL). |
||
33 | /// |
||
34 | /// When you implement the code that dismisses your form, e.g., an OK |
||
35 | /// button or a Stop Processing button, you should include the following: |
||
36 | /// |
||
37 | /// Hide the form, for example |
||
38 | /// sPPIDConverterDialogBarWrapper.Hide |
||
39 | /// |
||
40 | /// Set the Application's Interactive property to True, for example |
||
41 | /// commandControl.Application.Interactive = True |
||
42 | /// |
||
43 | /// Set Intergraph Command Control Done property to True, for example |
||
44 | /// commandControl.Done = True |
||
45 | /// </summary> |
||
46 | e3e2d41f | gaqhf | public partial class SPPIDConverterWrapper : System.Windows.Forms.Form |
47 | 2cae7d1f | gaqhf | { |
48 | const string DialogBarName = "Auto Converter"; |
||
49 | e3e2d41f | gaqhf | public static string autoModelingDllPath = string.Empty; |
50 | 2cae7d1f | gaqhf | |
51 | /// <summary> |
||
52 | /// Constructor for the form. |
||
53 | /// </summary> |
||
54 | 2f0955d4 | gaqhf | public SPPIDConverterWrapper() |
55 | 2cae7d1f | gaqhf | { |
56 | InitializeComponent(); |
||
57 | } |
||
58 | |||
59 | /// <summary> |
||
60 | /// Gets the tooltip of the command. |
||
61 | /// </summary> |
||
62 | /// <value> |
||
63 | /// The tooltip of the command as assigned in the resources file. |
||
64 | /// </value> |
||
65 | public string GetTooltip |
||
66 | { |
||
67 | get |
||
68 | { |
||
69 | return Properties.Resources.ResourceManager.GetString("Tooltip", System.Globalization.CultureInfo.CurrentCulture); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | /// <summary> |
||
74 | /// Gets the toolbar image. |
||
75 | /// </summary> |
||
76 | /// <value> |
||
77 | /// The toolbar image of the command as assigned in the resources file. |
||
78 | /// </value> |
||
79 | public System.Drawing.Image ToolbarImage |
||
80 | { |
||
81 | get |
||
82 | { |
||
83 | return (System.Drawing.Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage", System.Globalization.CultureInfo.CurrentCulture); |
||
84 | } |
||
85 | } |
||
86 | |||
87 | /// <summary> |
||
88 | /// The Activate Event is where the command should show its form |
||
89 | /// if it should be displayed. |
||
90 | /// </summary> |
||
91 | /// <param name="sender">The sender of the event</param> |
||
92 | /// <param name="e">The event's arguments</param> |
||
93 | private void commandControl_Activate(object sender, EventArgs e) |
||
94 | { |
||
95 | |||
96 | } |
||
97 | |||
98 | /* The Deactivate event is where the command should hide its form if it |
||
99 | * was displayed. The command should not unload the form here. |
||
100 | * The command's form should be unloaded in the Class Module Terminate event. |
||
101 | */ |
||
102 | /// <summary> |
||
103 | /// |
||
104 | /// </summary> |
||
105 | /// <param name="sender">The sender of the event</param> |
||
106 | /// <param name="e">The event's arguments</param> |
||
107 | private void commandControl_Deactivate(object sender, EventArgs e) |
||
108 | { |
||
109 | |||
110 | } |
||
111 | |||
112 | /// <summary> |
||
113 | /// The Initialize event is where the command should perform 1 time |
||
114 | /// initialization, for example it might save a reference to the |
||
115 | /// active document in private global data. |
||
116 | /// </summary> |
||
117 | /// <param name="sender">The sender of the event</param> |
||
118 | /// <param name="e">The event's arguments</param> |
||
119 | private void commandControl_Initialize(object sender, EventArgs e) |
||
120 | { |
||
121 | Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
||
122 | b33b0d0a | gaqhf | |
123 | 2cae7d1f | gaqhf | try |
124 | { |
||
125 | RegistryKey key = Registry.LocalMachine; |
||
126 | RegistryKey software = key.OpenSubKey("SOFTWARE"); |
||
127 | RegistryKey DOFTECH = software.OpenSubKey("DOFTECH"); |
||
128 | if (DOFTECH != null) |
||
129 | { |
||
130 | RegistryKey ID2 = DOFTECH.OpenSubKey("ID2"); |
||
131 | if (ID2 != null) |
||
132 | { |
||
133 | e3e2d41f | gaqhf | autoModelingDllPath = ID2.GetValue("path") + @"Converter\SPPIDConverter.dll"; |
134 | e62fd094 | gaqhf | #if DEBUG |
135 | autoModelingDllPath = @"Z:\HanKyouHo\Source\DTIPID\DTI_PID\SPPIDConverterDll\SPPIDConverter.dll"; |
||
136 | #endif |
||
137 | |||
138 | 2cae7d1f | gaqhf | #region Set ToolBar and Menu |
139 | ToolBars toolBars = application.ToolBars; |
||
140 | 8aa6f2db | gaqhf | //application.ActiveDocument.SelectSet.GetEnumerator(); |
141 | 2cae7d1f | gaqhf | bool find = true; |
142 | while (find) |
||
143 | { |
||
144 | find = false; |
||
145 | b33b0d0a | gaqhf | foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
146 | 2cae7d1f | gaqhf | { |
147 | b33b0d0a | gaqhf | if (toolBar.Name == "Main") |
148 | 2cae7d1f | gaqhf | { |
149 | b33b0d0a | gaqhf | foreach (ToolbarControl item in toolBars["Main"].Controls) |
150 | { |
||
151 | d19ae675 | gaqhf | if (item.DLLName.Contains("SPPIDConverter.dll")) |
152 | b33b0d0a | gaqhf | { |
153 | item.Delete(); |
||
154 | find = true; |
||
155 | break; |
||
156 | } |
||
157 | } |
||
158 | 2cae7d1f | gaqhf | break; |
159 | } |
||
160 | } |
||
161 | |||
162 | b33b0d0a | gaqhf | } |
163 | foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
||
164 | { |
||
165 | if (toolBar.Name == "Main") |
||
166 | { |
||
167 | d19ae675 | gaqhf | ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(autoModelingDllPath); |
168 | b33b0d0a | gaqhf | toolBarControl.ToolTipText = GetTooltip; |
169 | toolBarControl.Picture = ToolbarImage; |
||
170 | break; |
||
171 | } |
||
172 | } |
||
173 | 2cae7d1f | gaqhf | |
174 | b33b0d0a | gaqhf | Menus menus = application.Menus; |
175 | 2cae7d1f | gaqhf | find = true; |
176 | while (find) |
||
177 | { |
||
178 | find = false; |
||
179 | b33b0d0a | gaqhf | foreach (Ingr.RAD2D.Menu menu in menus) |
180 | 2cae7d1f | gaqhf | { |
181 | b33b0d0a | gaqhf | if (menu.Name == "&Tools") |
182 | 2cae7d1f | gaqhf | { |
183 | b33b0d0a | gaqhf | foreach (MenuControl item in menus["&Tools"].Controls) |
184 | { |
||
185 | if (item.Caption == GetTooltip) |
||
186 | { |
||
187 | item.Delete(); |
||
188 | find = true; |
||
189 | break; |
||
190 | } |
||
191 | } |
||
192 | 2cae7d1f | gaqhf | break; |
193 | } |
||
194 | } |
||
195 | b33b0d0a | gaqhf | } |
196 | foreach (Ingr.RAD2D.Menu menu in menus) |
||
197 | { |
||
198 | if (menu.Name == "&Tools") |
||
199 | { |
||
200 | d19ae675 | gaqhf | MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(GetTooltip, autoModelingDllPath); |
201 | b33b0d0a | gaqhf | menuControl.ToolTipText = GetTooltip; |
202 | } |
||
203 | 2cae7d1f | gaqhf | } |
204 | |||
205 | #endregion |
||
206 | 96a2080c | gaqhf | |
207 | c4d079c4 | gaqhf | #region Add Docking |
208 | e3e2d41f | gaqhf | try |
209 | { |
||
210 | bool bExist = false; |
||
211 | foreach (DialogBar dialogBar in application.DialogBars) |
||
212 | { |
||
213 | if (dialogBar.Name == DialogBarName) |
||
214 | { |
||
215 | bExist = true; |
||
216 | dialogBar.Delete(); |
||
217 | break; |
||
218 | } |
||
219 | } |
||
220 | if (!bExist) |
||
221 | { |
||
222 | DialogBar dlgBar = application.DialogBars.Add(DialogBarName, DockingFlagsConstants.igDockableOnLeft, DockingLocationConstants.igDockOnLeft, |
||
223 | DialogBarStyleConstants.igDialogBarStyleShowCaption | DialogBarStyleConstants.igDialogBarStyleStretchToFitHorizontal | DialogBarStyleConstants.igDialogBarStyleStretchToFitVertical | DialogBarStyleConstants.igDialogBarStyleNoBorder, 0, 0); |
||
224 | d19ae675 | gaqhf | DialogbarControl dialogBarControl_UserControl = dlgBar.Controls.AddManaged(autoModelingDllPath, "Converter.SPPID.Wrapper.ConverterDocking", 150, 300); |
225 | e3e2d41f | gaqhf | } |
226 | } |
||
227 | catch (Exception ex) |
||
228 | { |
||
229 | d19ae675 | gaqhf | MessageBox.Show("Fail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
230 | e3e2d41f | gaqhf | } |
231 | c4d079c4 | gaqhf | |
232 | #endregion |
||
233 | 2cae7d1f | gaqhf | } |
234 | } |
||
235 | else |
||
236 | { |
||
237 | MessageBox.Show("Please SetUp ID2", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||
238 | } |
||
239 | } |
||
240 | catch (Exception ex) |
||
241 | { |
||
242 | MessageBox.Show(ex.Message); |
||
243 | } |
||
244 | b33b0d0a | gaqhf | finally |
245 | { |
||
246 | d19ae675 | gaqhf | Close(); |
247 | b33b0d0a | gaqhf | } |
248 | |||
249 | 2cae7d1f | gaqhf | } |
250 | |||
251 | /// <summary> |
||
252 | /// The Terminate event is where the command can clean up any command |
||
253 | /// specific allocated resources. |
||
254 | /// </summary> |
||
255 | /// <param name="sender">The sender of the event</param> |
||
256 | /// <param name="e">The event's arguments</param> |
||
257 | public void commandControl_Terminate(object sender, EventArgs e) |
||
258 | { |
||
259 | |||
260 | } |
||
261 | |||
262 | /// <summary> |
||
263 | /// The primary form should not simply be unloaded. You should set |
||
264 | /// the Intergraph Command Control Done property to True when you |
||
265 | /// want the form to be unloaded. Then unload the form in the |
||
266 | /// dispose method. |
||
267 | /// </summary> |
||
268 | /// <param name="sender">The sender of the event</param> |
||
269 | /// <param name="e">The event's arguments</param> |
||
270 | private void SPPIDConverterDialogBarWrapper_FormClosing(object sender, FormClosingEventArgs e) |
||
271 | { |
||
272 | commandControl.Application.RADApplication.Interactive = true; |
||
273 | commandControl.Done = true; |
||
274 | } |
||
275 | |||
276 | } |
||
277 | } |