프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Controls / CAD / CustomImage1.xaml.cs @ f65e6c02

이력 | 보기 | 이력해설 | 다운로드 (4.56 KB)

1 684ef11c ljiyeon
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
    /// <summary>
16
    /// CustomImage1.xaml에 대한 상호 작용 논리
17
    /// </summary>
18
    public partial class CustomImage1 : UserControl
19
    {
20
        private Point startPoint = new Point(0, 0);
21
        private Point curPoint = new Point(0, 0);
22
        private Point endPoint = new Point(0, 0);
23
        private TeighaD3DImage mTeighaD3DImage = null;
24
        public String FilePath
25
        {
26
            get
27
            {
28
                if (null == mTeighaD3DImage)
29
                {
30
                    return pFilePath;
31
                }
32
                return mTeighaD3DImage.FilePath;
33
            }
34
            set
35
            {
36
                if (null != mTeighaD3DImage)
37
                {
38
                    if (String.Empty == pFilePath)
39
                    {
40
                        renderImage.Source = mTeighaD3DImage;
41
                    }
42
                    mTeighaD3DImage.FilePath = value;
43
                }
44
                pFilePath = value;
45
            }
46
        }
47
48
        public void DeleteContext()
49
        {
50
            mTeighaD3DImage.DeleteContext();
51
        }
52
53
        public void PointClear()
54
        {
55
            startPoint = new Point(0, 0);
56
            endPoint = new Point(0, 0);
57
            mTeighaD3DImage.ClearPoint();
58
        }
59
60
        public void DrawPoint(OdGePoint3d point, DrawType drawType)
61
        {
62
            mTeighaD3DImage.DrawPoint(point, drawType);
63
        }
64
65
        public OdGePoint3d PointCheck(object sender, MouseButtonEventArgs e, DrawType drawType)
66
        {
67
            OdGePoint3d odaPoint = new OdGePoint3d(0, 0, 0);
68
            startPoint = e.GetPosition(renderImage);
69
            if (drawType == DrawType.sp)
70
            {
71
                //curPoint = e.GetPosition(renderImage);                
72
                odaPoint = mTeighaD3DImage.ScreenPointToWorld(startPoint);
73
                //odaPoint = mTeighaD3DImage.SelectionPointsByPointOnScreen(startPoint.X, startPoint.Y);
74
            }
75
            else if (drawType == DrawType.ep)
76
            {
77
                //curPoint = e.GetPosition(renderImage);
78
                odaPoint = mTeighaD3DImage.ScreenPointToWorld(startPoint);
79
                //odaPoint = mTeighaD3DImage.SelectionPointsByPointOnScreen(endPoint.X, endPoint.Y);
80
            }
81
82
            return odaPoint;
83
        }
84
85
        public OdGePoint3d[] PointLoad()
86
        {
87
            return mTeighaD3DImage.PointLoad();
88
        }
89
90
        private String pFilePath = String.Empty;
91
        public void SetInvisibleWin(Window win)
92
        {
93
            HwndSource source = PresentationSource.FromVisual(win) as HwndSource;
94
            mTeighaD3DImage.wndSource = source;
95
        }
96
97
        public CustomImage1()
98
        {
99
            InitializeComponent();
100 f65e6c02 taeseongkim
     
101 684ef11c ljiyeon
            mTeighaD3DImage = new TeighaD3DImage();
102
        }
103
104
        public void ControlSizeChanged(Size size)
105
        {
106
            mTeighaD3DImage.OnRenderSizeChanged(size);
107
        }
108
109
        public override void EndInit()
110
        {
111
            base.EndInit();
112
            if (String.Empty != pFilePath)
113
            {
114
                mTeighaD3DImage.FilePath = pFilePath;
115
                renderImage.Source = mTeighaD3DImage;
116
            }
117
        }
118
119
        protected override void OnMouseWheel(MouseWheelEventArgs e)
120
        {
121
            startPoint = e.GetPosition(renderImage);
122
            mTeighaD3DImage.OnMouseWheel(e, startPoint);
123
            //mTeighaD3DImage.Zoom(e.Delta > 0);
124
        }
125
        public static bool mDown = false;
126
        protected override void OnMouseMove(MouseEventArgs e)
127
        {
128
            curPoint = e.GetPosition(renderImage);
129
130
            if (mDown)
131
            {
132
                //mTeighaD3DImage.Dolly(startPoint.X - curPoint.X, curPoint.Y - startPoint.Y, 0);
133
                mTeighaD3DImage.OnMouseDolly(e, startPoint, curPoint);
134
                startPoint = curPoint;
135
            }
136
            base.OnMouseMove(e);
137
        }
138
        protected override void OnMouseDown(MouseButtonEventArgs e)
139
        {
140
            mDown = true;
141
            //  curPoint = e.GetPosition(renderImage);
142
            curPoint = e.GetPosition(renderImage);
143
            // startPoint = e.GetPosition(renderImage);
144
            base.OnMouseDown(e);
145
        }
146
        protected override void OnMouseUp(MouseButtonEventArgs e)
147
        {
148
            mDown = false;
149
            base.OnMouseUp(e);
150
        }
151
152
    }
153
}
클립보드 이미지 추가 (최대 크기: 500 MB)