프로젝트

일반

사용자정보

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

markus / KCOM / Controls / CustomImage1.xaml.cs @ 684ef11c

이력 | 보기 | 이력해설 | 다운로드 (4.56 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
    /// <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
            mTeighaD3DImage = new TeighaD3DImage();
101
        }
102

    
103
        public void ControlSizeChanged(Size size)
104
        {
105
            mTeighaD3DImage.OnRenderSizeChanged(size);
106
        }
107

    
108
        public override void EndInit()
109
        {
110
            base.EndInit();
111
            if (String.Empty != pFilePath)
112
            {
113
                mTeighaD3DImage.FilePath = pFilePath;
114
                renderImage.Source = mTeighaD3DImage;
115
            }
116
        }
117

    
118
        protected override void OnMouseWheel(MouseWheelEventArgs e)
119
        {
120
            startPoint = e.GetPosition(renderImage);
121
            mTeighaD3DImage.OnMouseWheel(e, startPoint);
122
            //mTeighaD3DImage.Zoom(e.Delta > 0);
123
        }
124
        public static bool mDown = false;
125
        protected override void OnMouseMove(MouseEventArgs e)
126
        {
127
            curPoint = e.GetPosition(renderImage);
128

    
129
            if (mDown)
130
            {
131
                //mTeighaD3DImage.Dolly(startPoint.X - curPoint.X, curPoint.Y - startPoint.Y, 0);
132
                mTeighaD3DImage.OnMouseDolly(e, startPoint, curPoint);
133
                startPoint = curPoint;
134
            }
135
            base.OnMouseMove(e);
136
        }
137
        protected override void OnMouseDown(MouseButtonEventArgs e)
138
        {
139
            mDown = true;
140
            //  curPoint = e.GetPosition(renderImage);
141
            curPoint = e.GetPosition(renderImage);
142
            // startPoint = e.GetPosition(renderImage);
143
            base.OnMouseDown(e);
144
        }
145
        protected override void OnMouseUp(MouseButtonEventArgs e)
146
        {
147
            mDown = false;
148
            base.OnMouseUp(e);
149
        }
150

    
151
    }
152
}
클립보드 이미지 추가 (최대 크기: 500 MB)