hytos / DTI_PID / Dwg2Igr / Launcher.cs @ e835aef5
이력 | 보기 | 이력해설 | 다운로드 (2.17 KB)
1 | 2a2d2a97 | Denny | using Ingr.RAD2D; |
---|---|---|---|
2 | using System; |
||
3 | using System.Collections.Generic; |
||
4 | using System.ComponentModel; |
||
5 | using System.Data; |
||
6 | using System.Drawing; |
||
7 | using System.IO; |
||
8 | using System.Linq; |
||
9 | using System.Text; |
||
10 | using System.Threading; |
||
11 | using System.Threading.Tasks; |
||
12 | using System.Windows.Forms; |
||
13 | |||
14 | namespace Dwg2Igr |
||
15 | { |
||
16 | public partial class Launcher : Form |
||
17 | { |
||
18 | private string dwgFilePath; |
||
19 | public int ResultCode; |
||
20 | public Launcher(string filePath) |
||
21 | { |
||
22 | this.dwgFilePath = filePath.Replace("^", " "); |
||
23 | |||
24 | InitializeComponent(); |
||
25 | |||
26 | this.Enabled = false; |
||
27 | this.Visible = false; |
||
28 | this.Hide(); |
||
29 | |||
30 | Initialize(); |
||
31 | } |
||
32 | |||
33 | private void Initialize() |
||
34 | { |
||
35 | try |
||
36 | { |
||
37 | string igrFilePath = dwgFilePath.Replace(".dwg", ".igr"); |
||
38 | Ingr.RAD2D.Application radApp = null; |
||
39 | Ingr.RAD2D.WrapperApplication wApp = null; |
||
40 | |||
41 | string appName = "SmartSketch"; |
||
42 | string appPath = @"c:\Program Files (x86)\SmartSketch\Program\"; |
||
43 | string appResourceName = "SmartSketch.drx"; |
||
44 | string appStartUpDllClsid = "{AF7DB05C-6427-11D5-868F-00A0C9D8948D}"; |
||
45 | string appDispatchObjectClsid = "{9099087E-A96B-11D1-91A8-08003643CA02}"; |
||
46 | string appEnvironmentName = "Sketch"; |
||
47 | |||
48 | wApp = (Ingr.RAD2D.WrapperApplication)Ingr.RAD2D.Initialize.RADApplicationStarter.Instance.InitializeRADApplication(appName, appPath, appResourceName, appStartUpDllClsid, appDispatchObjectClsid, appEnvironmentName); |
||
49 | radApp = wApp.RADApplication; |
||
50 | Documents radDocs = radApp.Documents; |
||
51 | Document openDoc = radDocs.Open(dwgFilePath); |
||
52 | radApp.Visible = false; |
||
53 | |||
54 | radApp.ActiveDocument.SaveAs(igrFilePath); |
||
55 | ResultCode = 1; |
||
56 | radApp.ActiveDocument.Close(false); |
||
57 | radDocs.Close(); |
||
58 | Ingr.RAD2D.Initialize.RADApplicationStarter.Instance.ExitRADApplication(); |
||
59 | } |
||
60 | catch (Exception ex) |
||
61 | { |
||
62 | ResultCode = 0; |
||
63 | } |
||
64 | this.Close(); |
||
65 | } |
||
66 | } |
||
67 | } |