markus / KCOM / Controls / CadResultViewer.xaml.cs @ 122914ba
이력 | 보기 | 이력해설 | 다운로드 (5.29 KB)
1 | 684ef11c | ljiyeon | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Windows; |
||
6 | using System.Windows.Controls; |
||
7 | using System.Windows.Data; |
||
8 | using System.Windows.Documents; |
||
9 | using System.Windows.Input; |
||
10 | using System.Windows.Media; |
||
11 | using System.Windows.Media.Imaging; |
||
12 | using System.Windows.Navigation; |
||
13 | using System.Windows.Shapes; |
||
14 | using Teigha.Core; |
||
15 | using Teigha.TD; |
||
16 | using System.Windows.Interop; |
||
17 | using System.Windows.Forms; |
||
18 | using System.Reflection; |
||
19 | using System.Windows.Markup; |
||
20 | |||
21 | namespace KCOM.Controls |
||
22 | { |
||
23 | public partial class CadResultViewer : Window |
||
24 | { |
||
25 | private static Window win = null; |
||
26 | SaveFileDialog SaveDig = new SaveFileDialog(); //파일 세이브 다이얼로그 |
||
27 | public static DrawType drawType; |
||
28 | |||
29 | public CadResultViewer() |
||
30 | { |
||
31 | drawType = DrawType.nothing; |
||
32 | this.Loaded += CadResultViewer_Loaded; |
||
33 | } |
||
34 | |||
35 | private void CadResultViewer_Loaded(object sender, RoutedEventArgs e) |
||
36 | { |
||
37 | InitializeComponent(); |
||
38 | dwgControl.DeleteContext(); |
||
39 | |||
40 | win = new Window(); |
||
41 | win.Owner = (Window)this; |
||
42 | win.Visibility = System.Windows.Visibility.Hidden; |
||
43 | win.WindowStyle = System.Windows.WindowStyle.None; |
||
44 | win.ShowInTaskbar = false; |
||
45 | win.Background = Brushes.Transparent; |
||
46 | win.AllowsTransparency = true; |
||
47 | win.Show(); |
||
48 | win.Hide(); |
||
49 | dwgControl.SetInvisibleWin(win); |
||
50 | |||
51 | if (this.Title == "Result") |
||
52 | { |
||
53 | // filename = this.cadPanel_Instance.setResultPath(); |
||
54 | dwgControl.FilePath = filename; |
||
55 | filepath.Text = filename; |
||
56 | grid3.Visibility = System.Windows.Visibility.Collapsed; |
||
57 | } |
||
58 | else |
||
59 | { |
||
60 | Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); |
||
61 | dlg.DefaultExt = ".dwg"; |
||
62 | dlg.Filter = "DWG files (.dwg)|*.dwg"; |
||
63 | OdGePoint3d[] aa = new OdGePoint3d[4]; |
||
64 | Nullable<bool> result = dlg.ShowDialog(); |
||
65 | if (result == true) |
||
66 | { |
||
67 | filename = dlg.FileName; |
||
68 | //mTeighaD3DImage.FilePath = filename; |
||
69 | dwgControl.FilePath = filename; |
||
70 | filepath.Text = filename; |
||
71 | } |
||
72 | } |
||
73 | win.Closed += Win_Closed; |
||
74 | //this.dwgControl.MouseDown += DwgControl_MouseDown; |
||
75 | } |
||
76 | |||
77 | public string filename = null; |
||
78 | |||
79 | private void button1_Click(object sender, RoutedEventArgs e) |
||
80 | { |
||
81 | |||
82 | win = new Window(); |
||
83 | // win.Owner = cadViewer; |
||
84 | win.Visibility = System.Windows.Visibility.Hidden; |
||
85 | win.WindowStyle = System.Windows.WindowStyle.None; |
||
86 | win.ShowInTaskbar = false; |
||
87 | win.Background = Brushes.Transparent; |
||
88 | win.AllowsTransparency = true; |
||
89 | win.Show(); |
||
90 | win.Hide(); |
||
91 | dwgControl.SetInvisibleWin(win); |
||
92 | // } |
||
93 | // Create OpenFileDialog |
||
94 | Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); |
||
95 | |||
96 | dlg.DefaultExt = ".dwg"; |
||
97 | dlg.Filter = "DWG files (.dwg)|*.dwg"; |
||
98 | |||
99 | Nullable<bool> result = dlg.ShowDialog(); |
||
100 | |||
101 | if (result == true) |
||
102 | { |
||
103 | dwgControl.DeleteContext(); |
||
104 | CadResultViewer cadResultViewer = new CadResultViewer(); |
||
105 | filename = dlg.FileName; |
||
106 | //mTeighaD3DImage.FilePath = filename; |
||
107 | dwgControl.FilePath = filename; |
||
108 | filepath.Text = filename; |
||
109 | } |
||
110 | win.Closed += Win_Closed; |
||
111 | } |
||
112 | |||
113 | private void Win_Closed(object sender, EventArgs e) |
||
114 | { |
||
115 | dwgControl.DeleteContext(); |
||
116 | } |
||
117 | |||
118 | protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) |
||
119 | { |
||
120 | base.OnRenderSizeChanged(sizeInfo); |
||
121 | } |
||
122 | |||
123 | private void dwgControl_SizeChanged(object sender, SizeChangedEventArgs e) |
||
124 | { |
||
125 | if (e.NewSize != e.PreviousSize) |
||
126 | { |
||
127 | dwgControl.ControlSizeChanged(e.NewSize); |
||
128 | } |
||
129 | } |
||
130 | |||
131 | |||
132 | |||
133 | private void DwgControl_MouseDown(object sender, MouseButtonEventArgs e) |
||
134 | { |
||
135 | //OdGsDCPoint[] pts = dwgControl.SelectionPointsByPointOnScreen(e.X, e.Y); |
||
136 | OdGePoint3d point = dwgControl.PointCheck(sender, e, drawType); |
||
137 | if (drawType == DrawType.sp) |
||
138 | { |
||
139 | // this.cadPanel_Instance.spLabel.Text = "(" + point.x + ", " + point.y + ")"; |
||
140 | // this.cadPanel_Instance.startPoint = new Point(point.x, point.y); |
||
141 | dwgControl.DrawPoint(point, drawType); |
||
142 | drawType = DrawType.nothing; |
||
143 | CustomImage2.mDown = false; |
||
144 | } |
||
145 | else if (drawType == DrawType.ep) |
||
146 | { |
||
147 | // this.cadPanel_Instance.epLabel.Text = "(" + point.x + ", " + point.y + ")"; |
||
148 | // this.cadPanel_Instance.endPoint = new Point(point.x, point.y); |
||
149 | dwgControl.DrawPoint(point, drawType); |
||
150 | drawType = DrawType.nothing; |
||
151 | CustomImage2.mDown = false; |
||
152 | } |
||
153 | else |
||
154 | { |
||
155 | CustomImage2.mDown = true; |
||
156 | } |
||
157 | } |
||
158 | } |
||
159 | } |