hytos / DTI_PID / SPPIDConverter / Wrapper / SPPIDConverterWrapper.cs @ d19ae675
이력 | 보기 | 이력해설 | 다운로드 (11.7 KB)
1 |
/*---------------------------------------------------------------------+\ |
---|---|
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 |
namespace Converter.SPPID.Wrapper |
28 |
{ |
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 |
public partial class SPPIDConverterWrapper : System.Windows.Forms.Form |
47 |
{ |
48 |
const string DialogBarName = "Auto Converter"; |
49 |
public static string autoModelingDllPath = string.Empty; |
50 |
|
51 |
/// <summary> |
52 |
/// Constructor for the form. |
53 |
/// </summary> |
54 |
public SPPIDConverterWrapper() |
55 |
{ |
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 |
|
123 |
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 |
autoModelingDllPath = ID2.GetValue("path") + @"Converter\SPPIDConverter.dll"; |
134 |
#if DEBUG |
135 |
autoModelingDllPath = @"Z:\HanKyouHo\Source\DTIPID\DTI_PID\SPPIDConverterDll\SPPIDConverter.dll"; |
136 |
#endif |
137 |
|
138 |
#region Set ToolBar and Menu |
139 |
ToolBars toolBars = application.ToolBars; |
140 |
//application.ActiveDocument.SelectSet.GetEnumerator(); |
141 |
bool find = true; |
142 |
while (find) |
143 |
{ |
144 |
find = false; |
145 |
foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
146 |
{ |
147 |
if (toolBar.Name == "Main") |
148 |
{ |
149 |
foreach (ToolbarControl item in toolBars["Main"].Controls) |
150 |
{ |
151 |
if (item.DLLName.Contains("SPPIDConverter.dll")) |
152 |
{ |
153 |
item.Delete(); |
154 |
find = true; |
155 |
break; |
156 |
} |
157 |
} |
158 |
break; |
159 |
} |
160 |
} |
161 |
|
162 |
} |
163 |
foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
164 |
{ |
165 |
if (toolBar.Name == "Main") |
166 |
{ |
167 |
ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(autoModelingDllPath); |
168 |
toolBarControl.ToolTipText = GetTooltip; |
169 |
toolBarControl.Picture = ToolbarImage; |
170 |
break; |
171 |
} |
172 |
} |
173 |
|
174 |
Menus menus = application.Menus; |
175 |
find = true; |
176 |
while (find) |
177 |
{ |
178 |
find = false; |
179 |
foreach (Ingr.RAD2D.Menu menu in menus) |
180 |
{ |
181 |
if (menu.Name == "&Tools") |
182 |
{ |
183 |
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 |
break; |
193 |
} |
194 |
} |
195 |
} |
196 |
foreach (Ingr.RAD2D.Menu menu in menus) |
197 |
{ |
198 |
if (menu.Name == "&Tools") |
199 |
{ |
200 |
MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(GetTooltip, autoModelingDllPath); |
201 |
menuControl.ToolTipText = GetTooltip; |
202 |
} |
203 |
} |
204 |
|
205 |
#endregion |
206 |
|
207 |
#region Add Docking |
208 |
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 |
DialogbarControl dialogBarControl_UserControl = dlgBar.Controls.AddManaged(autoModelingDllPath, "Converter.SPPID.Wrapper.ConverterDocking", 150, 300); |
225 |
} |
226 |
} |
227 |
catch (Exception ex) |
228 |
{ |
229 |
MessageBox.Show("Fail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
230 |
} |
231 |
|
232 |
#endregion |
233 |
} |
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 |
finally |
245 |
{ |
246 |
Close(); |
247 |
} |
248 |
|
249 |
} |
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 |
} |