markus / KCOM / Controls / CAD / CustomImage2.xaml.cs @ f324a940
이력 | 보기 | 이력해설 | 다운로드 (4.61 KB)
1 |
using System; |
---|---|
2 |
using System.Windows; |
3 |
using System.Windows.Controls; |
4 |
using System.Windows.Input; |
5 |
using System.Windows.Media; |
6 |
using System.Windows.Shapes; |
7 |
using System.Windows.Interop; |
8 |
using Teigha.Core; |
9 |
using System.IO; |
10 |
using System.Reflection; |
11 |
using Teigha.TD; |
12 |
|
13 |
namespace KCOM.Controls |
14 |
{ |
15 |
public partial class CustomImage2 : UserControl |
16 |
{ |
17 |
private Point startPoint = new Point(0, 0); |
18 |
private Point curPoint = new Point(0, 0); |
19 |
private Point endPoint = new Point(0, 0); |
20 |
private TeighaD3DImageResult mTeighaD3DImageResult = null; |
21 |
public String FilePath |
22 |
{ |
23 |
get |
24 |
{ |
25 |
if (null == mTeighaD3DImageResult) |
26 |
{ |
27 |
return pFilePath; |
28 |
} |
29 |
return mTeighaD3DImageResult.FilePath; |
30 |
} |
31 |
set |
32 |
{ |
33 |
if (null != mTeighaD3DImageResult) |
34 |
{ |
35 |
if (String.Empty == pFilePath) |
36 |
{ |
37 |
renderImage.Source = mTeighaD3DImageResult; |
38 |
} |
39 |
mTeighaD3DImageResult.FilePath = value; |
40 |
} |
41 |
pFilePath = value; |
42 |
} |
43 |
} |
44 |
|
45 |
public void DeleteContext() |
46 |
{ |
47 |
mTeighaD3DImageResult.DeleteContext(); |
48 |
} |
49 |
|
50 |
public void PointClear() |
51 |
{ |
52 |
startPoint = new Point(0, 0); |
53 |
endPoint = new Point(0, 0); |
54 |
mTeighaD3DImageResult.ClearPoint(); |
55 |
} |
56 |
|
57 |
public void DrawPoint(OdGePoint3d point, DrawType drawType) |
58 |
{ |
59 |
mTeighaD3DImageResult.DrawPoint(point, drawType); |
60 |
} |
61 |
|
62 |
public OdGePoint3d PointCheck(object sender, MouseButtonEventArgs e, DrawType drawType) |
63 |
{ |
64 |
OdGePoint3d odaPoint = new OdGePoint3d(0, 0, 0); |
65 |
startPoint = e.GetPosition(renderImage); |
66 |
if (drawType == DrawType.sp) |
67 |
{ |
68 |
//curPoint = e.GetPosition(renderImage); |
69 |
odaPoint = mTeighaD3DImageResult.ScreenPointToWorld(startPoint); |
70 |
//odaPoint = mTeighaD3DImageResult.SelectionPointsByPointOnScreen(startPoint.X, startPoint.Y); |
71 |
} |
72 |
else if (drawType == DrawType.ep) |
73 |
{ |
74 |
//curPoint = e.GetPosition(renderImage); |
75 |
odaPoint = mTeighaD3DImageResult.ScreenPointToWorld(startPoint); |
76 |
//odaPoint = mTeighaD3DImageResult.SelectionPointsByPointOnScreen(endPoint.X, endPoint.Y); |
77 |
} |
78 |
|
79 |
return odaPoint; |
80 |
} |
81 |
|
82 |
public OdGePoint3d[] PointLoad() |
83 |
{ |
84 |
return mTeighaD3DImageResult.PointLoad(); |
85 |
} |
86 |
|
87 |
private String pFilePath = String.Empty; |
88 |
public void SetInvisibleWin(Window win) |
89 |
{ |
90 |
HwndSource source = PresentationSource.FromVisual(win) as HwndSource; |
91 |
mTeighaD3DImageResult.wndSource = source; |
92 |
} |
93 |
|
94 |
public CustomImage2() |
95 |
{ |
96 |
InitializeComponent(); |
97 |
mTeighaD3DImageResult = new TeighaD3DImageResult(); |
98 |
} |
99 |
|
100 |
public void ControlSizeChanged(Size size) |
101 |
{ |
102 |
mTeighaD3DImageResult.OnRenderSizeChanged(size); |
103 |
} |
104 |
|
105 |
public override void EndInit() |
106 |
{ |
107 |
base.EndInit(); |
108 |
if (String.Empty != pFilePath) |
109 |
{ |
110 |
mTeighaD3DImageResult.FilePath = pFilePath; |
111 |
renderImage.Source = mTeighaD3DImageResult; |
112 |
} |
113 |
} |
114 |
|
115 |
protected override void OnMouseWheel(MouseWheelEventArgs e) |
116 |
{ |
117 |
startPoint = e.GetPosition(renderImage); |
118 |
mTeighaD3DImageResult.OnMouseWheel(e, startPoint); |
119 |
//mTeighaD3DImageResult.Zoom(e.Delta > 0); |
120 |
} |
121 |
public static bool mDown = false; |
122 |
protected override void OnMouseMove(MouseEventArgs e) |
123 |
{ |
124 |
curPoint = e.GetPosition(renderImage); |
125 |
|
126 |
if (mDown) |
127 |
{ |
128 |
//mTeighaD3DImageResult.Dolly(startPoint.X - curPoint.X, curPoint.Y - startPoint.Y, 0); |
129 |
mTeighaD3DImageResult.OnMouseDolly(e, startPoint, curPoint); |
130 |
startPoint = curPoint; |
131 |
} |
132 |
base.OnMouseMove(e); |
133 |
} |
134 |
protected override void OnMouseDown(MouseButtonEventArgs e) |
135 |
{ |
136 |
mDown = true; |
137 |
// curPoint = e.GetPosition(renderImage); |
138 |
curPoint = e.GetPosition(renderImage); |
139 |
// startPoint = e.GetPosition(renderImage); |
140 |
base.OnMouseDown(e); |
141 |
} |
142 |
protected override void OnMouseUp(MouseButtonEventArgs e) |
143 |
{ |
144 |
mDown = false; |
145 |
base.OnMouseUp(e); |
146 |
} |
147 |
|
148 |
} |
149 |
} |