개정판 4582b1d2
dev issue #728: add registry path
DTI_PID/SPPIDConverter_CustomCommand/ConverterForm.cs | ||
---|---|---|
28 | 28 |
using SPPID.Utill; |
29 | 29 |
using SPPID.Model; |
30 | 30 |
using System.Threading; |
31 |
using Microsoft.Win32; |
|
31 | 32 |
|
32 | 33 |
namespace CustomCommand |
33 | 34 |
{ |
... | ... | |
53 | 54 |
#region Default CustomCommand |
54 | 55 |
readonly string menuControlName = "ID2 to SPPID Converter"; |
55 | 56 |
readonly string toolTipText = "ID2 to SPPID Converter"; |
56 |
readonly string dllPath = System.Environment.CurrentDirectory + @"\SPPIDConverter_CustomCommand.dll"; |
|
57 | 57 |
readonly Image image = (Image)Properties.Resources.ResourceManager.GetObject("ToolbarImage"); //Image.FromFile(@".\Close.png"); |
58 | 58 |
/// <summary> |
59 | 59 |
/// Constructs and initializes the form. |
... | ... | |
109 | 109 |
{ |
110 | 110 |
try |
111 | 111 |
{ |
112 |
SPPIDUtill.LoadMapping(mapping); |
|
113 |
|
|
114 |
Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
|
115 |
|
|
116 |
ToolBars toolBars = application.ToolBars; |
|
117 |
bool find = true; |
|
118 |
while (find) |
|
112 |
RegistryKey key = Registry.LocalMachine; |
|
113 |
RegistryKey software = key.OpenSubKey("SOFTWARE"); |
|
114 |
RegistryKey DOFTECH = software.OpenSubKey("DOFTECH"); |
|
115 |
if (DOFTECH != null) |
|
119 | 116 |
{ |
120 |
find = false;
|
|
121 |
foreach (ToolbarControl item in toolBars["Main"].Controls)
|
|
117 |
RegistryKey ID2 = DOFTECH.OpenSubKey("ID2");
|
|
118 |
if (ID2 != null)
|
|
122 | 119 |
{ |
123 |
if (item.DLLName.Contains("SPPIDConverter_CustomCommand.dll")) |
|
120 |
SPPIDUtill.defaultPath = ID2.GetValue("Path").ToString(); |
|
121 |
|
|
122 |
Log.logPath = SPPIDUtill.defaultPath + @"Converter\SPPID Converter.log"; |
|
123 |
SPPIDUtill.mappingFilePath = SPPIDUtill.defaultPath + @"Converter\mapping.xml"; |
|
124 |
string dllPath = SPPIDUtill.defaultPath + @"Converter\SPPIDConverter_CustomCommand.dll"; |
|
125 |
|
|
126 |
SPPIDUtill.LoadMapping(mapping); |
|
127 |
Ingr.RAD2D.Application application = commandControl.Application.RADApplication; |
|
128 |
|
|
129 |
ToolBars toolBars = application.ToolBars; |
|
130 |
bool find = true; |
|
131 |
while (find) |
|
124 | 132 |
{ |
125 |
item.Delete(); |
|
126 |
find = true; |
|
127 |
break; |
|
133 |
find = false; |
|
134 |
foreach (ToolbarControl item in toolBars["Main"].Controls) |
|
135 |
{ |
|
136 |
if (item.DLLName.Contains("SPPIDConverter_CustomCommand.dll")) |
|
137 |
{ |
|
138 |
item.Delete(); |
|
139 |
find = true; |
|
140 |
break; |
|
141 |
} |
|
142 |
} |
|
128 | 143 |
} |
129 |
} |
|
130 |
} |
|
131 | 144 |
|
132 |
ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dllPath); |
|
133 |
toolBarControl.ToolTipText = toolTipText; |
|
134 |
//toolBarControl.Picture = image; |
|
145 |
ToolbarControl toolBarControl = toolBars["Main"].Controls.AppendMacroCommand(dllPath);
|
|
146 |
toolBarControl.ToolTipText = toolTipText;
|
|
147 |
//toolBarControl.Picture = image;
|
|
135 | 148 |
|
136 |
Menus menu = application.Menus; |
|
137 |
find = true; |
|
138 |
while (find) |
|
139 |
{ |
|
140 |
find = false; |
|
141 |
foreach (MenuControl item in menu["&Tools"].Controls) |
|
142 |
{ |
|
143 |
if (item.Caption == menuControlName) |
|
149 |
Menus menu = application.Menus; |
|
150 |
find = true; |
|
151 |
while (find) |
|
144 | 152 |
{ |
145 |
item.Delete(); |
|
146 |
find = true; |
|
147 |
break; |
|
153 |
find = false; |
|
154 |
foreach (MenuControl item in menu["&Tools"].Controls) |
|
155 |
{ |
|
156 |
if (item.Caption == menuControlName) |
|
157 |
{ |
|
158 |
item.Delete(); |
|
159 |
find = true; |
|
160 |
break; |
|
161 |
} |
|
162 |
} |
|
148 | 163 |
} |
164 |
MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(menuControlName, dllPath); |
|
165 |
menuControl.ToolTipText = toolTipText; |
|
149 | 166 |
} |
150 | 167 |
} |
151 |
MenuControl menuControl = application.Menus["&Tools"].Controls.AppendMacroCommand(menuControlName, dllPath); |
|
152 |
menuControl.ToolTipText = toolTipText; |
|
153 | 168 |
} |
154 | 169 |
catch (Exception ex) |
155 | 170 |
{ |
내보내기 Unified diff