hytos / DTI_PID / SPPIDConverter_DialogBarWrapper / SPPIDConverterDialogBarWrapper.cs @ 007e6e3b
이력 | 보기 | 이력해설 | 다운로드 (11.9 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 SPPIDConverter_DialogBarWrapper |
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 SPPIDConverterDialogBarWrapper : Form |
47 |
{ |
48 |
const string DialogBarName = "Auto Converter"; |
49 |
|
50 |
/// <summary> |
51 |
/// Constructor for the form. |
52 |
/// </summary> |
53 |
public SPPIDConverterDialogBarWrapper() |
54 |
{ |
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 |
|
122 |
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 |
//string wrapperDllPath = ID2.GetValue("Path").ToString() + @"Converter\SPPIDConverter_DialogBarWrapper.dll"; |
133 |
//string dialogBarDllPath = ID2.GetValue("Path").ToString() + @"Converter\SPPIDConverter_AutoModeling.dll"; |
134 |
|
135 |
string wrapperDllPath = @"Z:\HanKyouHo\Source\DTIPID\DTI_PID\SPPIDConverter_AutoModeling\bin\Debug\SPPIDConverter_AutoModeling.dll"; |
136 |
string dialogBarDllPath = @"Z:\HanKyouHo\Source\DTIPID\DTI_PID\SPPIDConverter_DialogBarWrapper\bin\Debug\SPPIDConverter_DialogBarWrapper.dll"; |
137 |
|
138 |
#region DialogBar Setting |
139 |
try |
140 |
{ |
141 |
bool bExist = false; |
142 |
foreach (DialogBar dialogBar in application.DialogBars) |
143 |
{ |
144 |
if (dialogBar.Name == DialogBarName) |
145 |
{ |
146 |
bExist = true; |
147 |
dialogBar.Delete(); |
148 |
break; |
149 |
} |
150 |
} |
151 |
if (!bExist) |
152 |
{ |
153 |
DialogBar dlgBar = application.DialogBars.Add(DialogBarName, DockingFlagsConstants.igDockableOnLeft, DockingLocationConstants.igDockOnLeft, DialogBarStyleConstants.igDialogBarStyleShowCaption | DialogBarStyleConstants.igDialogBarStyleStretchToFitHorizontal | DialogBarStyleConstants.igDialogBarStyleStretchToFitVertical | DialogBarStyleConstants.igDialogBarStyleResizeable, 0, 0); |
154 |
DialogbarControl dialogBarControl_UserControl = dlgBar.Controls.AddManaged(wrapperDllPath, "SPPIDConverter_AutoModeling.MainControl", 735, 900); |
155 |
} |
156 |
} |
157 |
catch (Exception ex) |
158 |
{ |
159 |
|
160 |
} |
161 |
#endregion |
162 |
|
163 |
#region Set ToolBar and Menu |
164 |
ToolBars toolBars = application.ToolBars; |
165 |
|
166 |
bool find = true; |
167 |
while (find) |
168 |
{ |
169 |
find = false; |
170 |
foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
171 |
{ |
172 |
if (toolBar.Name == "Main") |
173 |
{ |
174 |
foreach (ToolbarControl item in toolBars["Main"].Controls) |
175 |
{ |
176 |
if (item.DLLName.Contains("SPPIDConverter_DialogBarWrapper.dll")) |
177 |
{ |
178 |
item.Delete(); |
179 |
find = true; |
180 |
break; |
181 |
} |
182 |
} |
183 |
break; |
184 |
} |
185 |
} |
186 |
|
187 |
} |
188 |
foreach (Ingr.RAD2D.ToolBar toolBar in toolBars) |
189 |
{ |
190 |
if (toolBar.Name == "Main") |
191 |
{ |
192 |
ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dialogBarDllPath); |
193 |
toolBarControl.ToolTipText = GetTooltip; |
194 |
toolBarControl.Picture = ToolbarImage; |
195 |
break; |
196 |
} |
197 |
} |
198 |
|
199 |
Menus menus = application.Menus; |
200 |
find = true; |
201 |
while (find) |
202 |
{ |
203 |
find = false; |
204 |
foreach (Ingr.RAD2D.Menu menu in menus) |
205 |
{ |
206 |
if (menu.Name == "&Tools") |
207 |
{ |
208 |
foreach (MenuControl item in menus["&Tools"].Controls) |
209 |
{ |
210 |
if (item.Caption == GetTooltip) |
211 |
{ |
212 |
item.Delete(); |
213 |
find = true; |
214 |
break; |
215 |
} |
216 |
} |
217 |
break; |
218 |
} |
219 |
} |
220 |
|
221 |
} |
222 |
foreach (Ingr.RAD2D.Menu menu in menus) |
223 |
{ |
224 |
if (menu.Name == "&Tools") |
225 |
{ |
226 |
MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(GetTooltip, dialogBarDllPath); |
227 |
menuControl.ToolTipText = GetTooltip; |
228 |
} |
229 |
} |
230 |
|
231 |
#endregion |
232 |
} |
233 |
} |
234 |
else |
235 |
{ |
236 |
MessageBox.Show("Please SetUp ID2", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); |
237 |
} |
238 |
} |
239 |
catch (Exception ex) |
240 |
{ |
241 |
MessageBox.Show(ex.Message); |
242 |
} |
243 |
finally |
244 |
{ |
245 |
commandControl.Application.RADApplication.Interactive = true; |
246 |
this.Hide(); |
247 |
commandControl.Done = true; |
248 |
} |
249 |
|
250 |
} |
251 |
|
252 |
/// <summary> |
253 |
/// The Terminate event is where the command can clean up any command |
254 |
/// specific allocated resources. |
255 |
/// </summary> |
256 |
/// <param name="sender">The sender of the event</param> |
257 |
/// <param name="e">The event's arguments</param> |
258 |
public void commandControl_Terminate(object sender, EventArgs e) |
259 |
{ |
260 |
|
261 |
} |
262 |
|
263 |
/// <summary> |
264 |
/// The primary form should not simply be unloaded. You should set |
265 |
/// the Intergraph Command Control Done property to True when you |
266 |
/// want the form to be unloaded. Then unload the form in the |
267 |
/// dispose method. |
268 |
/// </summary> |
269 |
/// <param name="sender">The sender of the event</param> |
270 |
/// <param name="e">The event's arguments</param> |
271 |
private void SPPIDConverterDialogBarWrapper_FormClosing(object sender, FormClosingEventArgs e) |
272 |
{ |
273 |
commandControl.Application.RADApplication.Interactive = true; |
274 |
commandControl.Done = true; |
275 |
} |
276 |
|
277 |
} |
278 |
} |