개정판 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 |
{ |
DTI_PID/SPPIDConverter_CustomCommand/SPPIDAutoModeling/Utill/Log.cs | ||
---|---|---|
12 | 12 |
{ |
13 | 13 |
public static class Log |
14 | 14 |
{ |
15 |
readonly static string defaultPath = Environment.CurrentDirectory + @"\SPPID Converter.log"; |
|
16 |
public static string Path = ""; |
|
15 |
public static string logPath = ""; |
|
17 | 16 |
|
18 | 17 |
public static void WriteLine(Exception ex) |
19 | 18 |
{ |
20 |
string logPath = Path; |
|
21 |
if (string.IsNullOrEmpty(Path)) |
|
22 |
{ |
|
23 |
logPath = defaultPath; |
|
24 |
} |
|
25 |
|
|
26 | 19 |
using (StreamWriter sw = new StreamWriter(logPath, true)) |
27 | 20 |
{ |
28 | 21 |
sw.WriteLine(ex.Message); |
... | ... | |
32 | 25 |
|
33 | 26 |
public static void WriteLine(string text) |
34 | 27 |
{ |
35 |
string logPath = Path; |
|
36 |
if (string.IsNullOrEmpty(Path)) |
|
37 |
{ |
|
38 |
logPath = defaultPath; |
|
39 |
} |
|
40 |
|
|
41 | 28 |
using (StreamWriter sw = new StreamWriter(logPath, true)) |
42 | 29 |
{ |
43 | 30 |
sw.WriteLine(text); |
DTI_PID/SPPIDConverter_CustomCommand/SPPIDAutoModeling/Utill/SPPIDUtill.cs | ||
---|---|---|
13 | 13 |
{ |
14 | 14 |
private static readonly double _DWG_X = 0.875; |
15 | 15 |
private static readonly double _DWG_Y = 0.617; |
16 |
private static readonly string mappingFilePath = Environment.CurrentDirectory + @"\mapping.xml"; |
|
16 |
public static string defaultPath = ""; |
|
17 |
public static string mappingFilePath = ""; |
|
17 | 18 |
|
18 | 19 |
public static void ConvertSPPIDPoint(ref double dX, ref double dY, double dDwgX, double dDwgY) |
19 | 20 |
{ |
... | ... | |
164 | 165 |
{ |
165 | 166 |
XElement mappingElement = new XElement("Mapping"); |
166 | 167 |
|
167 |
XElement symbolPath = new XElement("SymbolPath"); |
|
168 |
XElement attrPath = new XElement("Attribute"); |
|
169 |
|
|
170 | 168 |
foreach (var item in mapping) |
171 | 169 |
{ |
172 | 170 |
string name = item.Key; |
... | ... | |
176 | 174 |
element.SetAttributeValue("SPPID", SPPID_Name); |
177 | 175 |
element.Value = name; |
178 | 176 |
|
179 |
symbolPath.Add(element);
|
|
177 |
mappingElement.Add(element);
|
|
180 | 178 |
} |
181 | 179 |
|
182 | 180 |
mappingElement.Save(mappingFilePath); |
내보내기 Unified diff