hytos / DTI_PID / SPPIDConverter_DialogBarWrapper / SPPIDConverterWrapper.cs @ dbf4904d
이력 | 보기 | 이력해설 | 다운로드 (12.3 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 | 2f0955d4 | gaqhf | public partial class SPPIDConverterWrapper : Form |
47 | 2cae7d1f | gaqhf | { |
48 | const string DialogBarName = "Auto Converter"; |
||
49 | |||
50 | /// <summary> |
||
51 | /// Constructor for the form. |
||
52 | /// </summary> |
||
53 | 2f0955d4 | gaqhf | public SPPIDConverterWrapper() |
54 | 2cae7d1f | gaqhf | { |
55 | InitializeComponent(); |
||
56 | } |
||
57 | |||
58 | /// <summary> |
||
59 | /// Gets the tooltip of the command. |
||
60 | /// </summary> |
||
61 | /// <value> |
||
62 | /// The tooltip of the command as assigned in the resources file. |
||
63 | /// </value> |
||
64 | public string GetTooltip |
||
65 | { |
||
66 | get |
||
67 | { |
||
68 | return Properties.Resources.ResourceManager.GetString("Tooltip", System.Globalization.CultureInfo.CurrentCulture); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | /// <summary> |
||
73 | /// Gets the toolbar image. |
||
74 | /// </summary> |
||
75 | /// <value> |
||
76 | /// The toolbar image of the command as assigned in the resources file. |
||
77 | /// </value> |
||
78 | public System.Drawing.Image ToolbarImage |
||
79 | { |
||
80 | get |
||
81 | { |
||
82 | return (System.Drawing.Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage", System.Globalization.CultureInfo.CurrentCulture); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | /// <summary> |
||
87 | /// The Activate Event is where the command should show its form |
||
88 | /// if it should be displayed. |
||
89 | /// </summary> |
||
90 | /// <param name="sender">The sender of the event</param> |
||
91 | /// <param name="e">The event's arguments</param> |
||
92 | private void commandControl_Activate(object sender, EventArgs e) |
||
93 | { |
||
94 | |||
95 | } |
||
96 | |||
97 | /* The Deactivate event is where the command should hide its form if it |
||
98 | * was displayed. The command should not unload the form here. |
||
99 | * The command's form should be unloaded in the Class Module Terminate event. |
||
100 | */ |
||
101 | /// <summary> |
||
102 | /// |
||
103 | /// </summary> |
||
104 | /// <param name="sender">The sender of the event</param> |
||
105 | /// <param name="e">The event's arguments</param> |
||
106 | private void commandControl_Deactivate(object sender, EventArgs e) |
||
107 | { |
||
108 | |||
109 | } |
||
110 | |||
111 | /// <summary> |
||
112 | /// The Initialize event is where the command should perform 1 time |
||
113 | /// initialization, for example it might save a reference to the |
||
114 | /// active document in private global data. |
||
115 | /// </summary> |
||
116 | /// <param name="sender">The sender of the event</param> |
||
117 | /// <param name="e">The event's arguments</param> |
||
118 | private void commandControl_Initialize(object sender, EventArgs e) |
||
119 | { |
||
120 | Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
||
121 | b33b0d0a | gaqhf | |
122 | 2cae7d1f | gaqhf | try |
123 | { |
||
124 | RegistryKey key = Registry.LocalMachine; |
||
125 | RegistryKey software = key.OpenSubKey("SOFTWARE"); |
||
126 | RegistryKey DOFTECH = software.OpenSubKey("DOFTECH"); |
||
127 | if (DOFTECH != null) |
||
128 | { |
||
129 | RegistryKey ID2 = DOFTECH.OpenSubKey("ID2"); |
||
130 | if (ID2 != null) |
||
131 | { |
||
132 | 0a24b232 | gaqhf | //string wrapperDllPath = ID2.GetValue("Path").ToString() + @"Converter\SPPIDConverter_Wrapper.dll"; |
133 | //string wrapperDllPath = System.Reflection.Assembly.GetExecutingAssembly().Location; |
||
134 | string wrapperDllPath = @"Z:\HanKyouHo\Source\DTIPID\DTI_PID\SPPIDConverterDll\SPPIDConverter_Wrapper.dll"; |
||
135 | b8e2644e | gaqhf | string autoModelingDllPath = @"Z:\HanKyouHo\Source\DTIPID\DTI_PID\SPPIDConverterDll\SPPIDConverter.dll"; |
136 | e9718eec | gaqhf | |
137 | 2cae7d1f | gaqhf | #region Set ToolBar and Menu |
138 | ToolBars toolBars = application.ToolBars; |
||
139 | 8aa6f2db | gaqhf | //application.ActiveDocument.SelectSet.GetEnumerator(); |
140 | 2cae7d1f | gaqhf | bool find = true; |
141 | while (find) |
||
142 | { |
||
143 | find = false; |
||
144 | b33b0d0a | gaqhf | foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
145 | 2cae7d1f | gaqhf | { |
146 | b33b0d0a | gaqhf | if (toolBar.Name == "Main") |
147 | 2cae7d1f | gaqhf | { |
148 | b33b0d0a | gaqhf | foreach (ToolbarControl item in toolBars["Main"].Controls) |
149 | { |
||
150 | aadf6821 | gaqhf | if (item.DLLName.Contains("SPPIDConverter_Wrapper.dll")) |
151 | b33b0d0a | gaqhf | { |
152 | item.Delete(); |
||
153 | find = true; |
||
154 | break; |
||
155 | } |
||
156 | } |
||
157 | 2cae7d1f | gaqhf | break; |
158 | } |
||
159 | } |
||
160 | |||
161 | b33b0d0a | gaqhf | } |
162 | foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
||
163 | { |
||
164 | if (toolBar.Name == "Main") |
||
165 | { |
||
166 | 0a24b232 | gaqhf | ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(wrapperDllPath); |
167 | b33b0d0a | gaqhf | toolBarControl.ToolTipText = GetTooltip; |
168 | toolBarControl.Picture = ToolbarImage; |
||
169 | break; |
||
170 | } |
||
171 | } |
||
172 | 2cae7d1f | gaqhf | |
173 | b33b0d0a | gaqhf | Menus menus = application.Menus; |
174 | 2cae7d1f | gaqhf | find = true; |
175 | while (find) |
||
176 | { |
||
177 | find = false; |
||
178 | b33b0d0a | gaqhf | foreach (Ingr.RAD2D.Menu menu in menus) |
179 | 2cae7d1f | gaqhf | { |
180 | b33b0d0a | gaqhf | if (menu.Name == "&Tools") |
181 | 2cae7d1f | gaqhf | { |
182 | b33b0d0a | gaqhf | foreach (MenuControl item in menus["&Tools"].Controls) |
183 | { |
||
184 | if (item.Caption == GetTooltip) |
||
185 | { |
||
186 | item.Delete(); |
||
187 | find = true; |
||
188 | break; |
||
189 | } |
||
190 | } |
||
191 | 2cae7d1f | gaqhf | break; |
192 | } |
||
193 | } |
||
194 | b33b0d0a | gaqhf | |
195 | } |
||
196 | foreach (Ingr.RAD2D.Menu menu in menus) |
||
197 | { |
||
198 | if (menu.Name == "&Tools") |
||
199 | { |
||
200 | 0a24b232 | gaqhf | MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(GetTooltip, wrapperDllPath); |
201 | b33b0d0a | gaqhf | menuControl.ToolTipText = GetTooltip; |
202 | } |
||
203 | 2cae7d1f | gaqhf | } |
204 | |||
205 | #endregion |
||
206 | 96a2080c | gaqhf | |
207 | f1232880 | gaqhf | |
208 | commandControl.Application.RADApplication.RunManagedMacro(@"Z:\HanKyouHo\Source\DTIPID\DTI_PID\SPPIDConverterDll\SPPIDConverter.dll", "Converter.SPPID.SPPIDConverter_AutoModeling"); |
||
209 | return; |
||
210 | |||
211 | 96a2080c | gaqhf | #region DialogBar Setting |
212 | try |
||
213 | { |
||
214 | foreach (DialogBar dialogBar in application.DialogBars) |
||
215 | { |
||
216 | if (dialogBar.Name == DialogBarName) |
||
217 | { |
||
218 | dialogBar.Delete(); |
||
219 | break; |
||
220 | } |
||
221 | } |
||
222 | DialogBar dlgBar = application.DialogBars.Add(DialogBarName, DockingFlagsConstants.igDockableOnLeft, DockingLocationConstants.igDockOnLeft, |
||
223 | DialogBarStyleConstants.igDialogBarStyleShowCaption | DialogBarStyleConstants.igDialogBarStyleStretchToFitHorizontal | DialogBarStyleConstants.igDialogBarStyleStretchToFitVertical | DialogBarStyleConstants.igDialogBarStyleNoBorder, 0, 0); |
||
224 | //DialogbarControl dialogBarControl_UserControl = dlgBar.Controls.AddManaged(wrapperDllPath, "SPPIDConverter_AutoModeling.MainControl", 733, 900); |
||
225 | aadf6821 | gaqhf | DialogbarControl dialogBarControl_UserControl = dlgBar.Controls.AddManaged(autoModelingDllPath, "Converter.SPPID.MainWrapper", 0, 0); |
226 | 96a2080c | gaqhf | dynamic userControl = dialogBarControl_UserControl.ControlDispatch; |
227 | userControl.ShowDialog(); |
||
228 | //Control control = userControl as Control; |
||
229 | } |
||
230 | catch (Exception ex) |
||
231 | { |
||
232 | |||
233 | } |
||
234 | #endregion |
||
235 | |||
236 | |||
237 | 2cae7d1f | gaqhf | } |
238 | } |
||
239 | else |
||
240 | { |
||
241 | MessageBox.Show("Please SetUp ID2", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||
242 | } |
||
243 | } |
||
244 | catch (Exception ex) |
||
245 | { |
||
246 | MessageBox.Show(ex.Message); |
||
247 | } |
||
248 | b33b0d0a | gaqhf | finally |
249 | { |
||
250 | commandControl.Application.RADApplication.Interactive = true; |
||
251 | commandControl.Done = true; |
||
252 | } |
||
253 | |||
254 | 2cae7d1f | gaqhf | } |
255 | |||
256 | /// <summary> |
||
257 | /// The Terminate event is where the command can clean up any command |
||
258 | /// specific allocated resources. |
||
259 | /// </summary> |
||
260 | /// <param name="sender">The sender of the event</param> |
||
261 | /// <param name="e">The event's arguments</param> |
||
262 | public void commandControl_Terminate(object sender, EventArgs e) |
||
263 | { |
||
264 | |||
265 | } |
||
266 | |||
267 | /// <summary> |
||
268 | /// The primary form should not simply be unloaded. You should set |
||
269 | /// the Intergraph Command Control Done property to True when you |
||
270 | /// want the form to be unloaded. Then unload the form in the |
||
271 | /// dispose method. |
||
272 | /// </summary> |
||
273 | /// <param name="sender">The sender of the event</param> |
||
274 | /// <param name="e">The event's arguments</param> |
||
275 | private void SPPIDConverterDialogBarWrapper_FormClosing(object sender, FormClosingEventArgs e) |
||
276 | { |
||
277 | commandControl.Application.RADApplication.Interactive = true; |
||
278 | commandControl.Done = true; |
||
279 | } |
||
280 | |||
281 | } |
||
282 | } |