프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Common / CommentUserInfo.cs @ b2d0f316

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

1
using KCOMDataModel.DataModel;
2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Parsing;
4
using System;
5
using System.Collections.Generic;
6
using System.ComponentModel;
7
using System.Linq;
8
using System.Text;
9
using System.Windows;
10
using System.Windows.Input;
11
using System.Windows.Media;
12

    
13
namespace MarkupToPDF.Common
14
{
15
    public interface ICommentUserInfo
16
    {
17
        void OnCreatingMouseMove(Point pt, bool bAxisLocked);
18
        void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false);
19
        void OnTranslate(double dx, double dy);
20
        void UpdateControl();
21
    }
22

    
23
    public class CommentUserInfo : System.Windows.Controls.Control, ICommentUserInfo
24
    {
25
        public static readonly string[] delimiterChars = { "|DZ|" };
26
        public static readonly string[] delimiterChars2 = { "|" };
27
        public static readonly SolidColorBrush DefaultColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse(""));
28

    
29
        public string Memo { get; set; }
30
        public string MarkupInfoID { get; set; }
31
        public bool IsMouseEnter { get; set; }
32
        public bool IsNew { get; set; }
33
        public string CommentID { get; set; }
34
        public string SymbolID { get; set; }
35
        public long GroupID { get; set; }
36

    
37
        [Description("ZIndex 값이 높을 수록 앞쪽으로 배치된다.")]
38
        public int ZIndex { get; set; } = 0;
39

    
40
        private SolidColorBrush _TempBorderBrush { get; set; }
41
        private SolidColorBrush _HoverBorderBrush { get; } = new SolidColorBrush(Color.FromRgb(255, 0, 255));
42

    
43
        public CommentUserInfo()
44
        {
45
            Load();
46
        }
47

    
48
        public virtual void Copy(CommentUserInfo lhs) { throw new NotImplementedException("Must implement Copy()"); }
49
        public virtual CommentUserInfo Clone() { throw new NotImplementedException("Must implement Clone()"); }
50

    
51
        public void Load()
52
        {
53
            this.IsHitTestVisible = true;
54

    
55
            this.SetValue(Telerik.Windows.Controls.TabNavigationExtensions.IsTabStopProperty, false);
56
               this.BorderThickness = new System.Windows.Thickness(20.0);
57
            this.MouseEnter += CommentUserInfo_MouseEnter;
58
            this.MouseLeave += CommentUserInfo_MouseLeave;
59
        }
60

    
61
        protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
62
        {
63
            var temp = base.HitTestCore(hitTestParameters);
64
            return temp;
65
        }
66

    
67
        private void CommentUserInfo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
68
        {
69
            System.Diagnostics.Debug.WriteLine("Is Mouse Leave."); 
70

    
71
            this.IsMouseEnter = false;
72
            if (this.StrokeColor != this._TempBorderBrush)
73
            {
74
                this.StrokeColor = this._TempBorderBrush;
75
                this.UpdateLayout();
76
            }
77
        }
78

    
79
        private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
80
        {
81
            this.IsMouseEnter = true;
82
            System.Diagnostics.Debug.WriteLine("Is Mouse Enter.");
83
            OnMouseHover();
84
        }
85

    
86
        public void OnMouseHover()
87
        {
88
            if (this.StrokeColor != this._HoverBorderBrush)
89
            {
90
                this._TempBorderBrush = this.StrokeColor;
91
                this.StrokeColor = this._HoverBorderBrush;
92
                this.UpdateLayout();
93
            }
94
        }
95

    
96
        public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked) { }
97
        public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) { }
98

    
99
        /// <summary>
100
        /// translate control along given dx,dy
101
        /// </summary>
102
        /// <param name="dx"></param>
103
        /// <param name="dy"></param>
104
        public virtual void OnTranslate(double dx, double dy)
105
        {
106
            var path = (this as IPath);
107
            for (int i = 0; i < path.PointSet.Count; ++i)
108
            {
109
                path.PointSet[i] = new Point(path.PointSet[i].X + dx, path.PointSet[i].Y + dy);
110
            }
111
            this.UpdateControl();
112
        }
113

    
114
        /// <summary>
115
        /// update control
116
        /// </summary>
117
        public virtual void UpdateControl() { }
118

    
119
        /// <summary>
120
        /// subclass has to override this property
121
        /// </summary>
122
        public virtual bool IsSelected { get; set; }
123

    
124
        /// <summary>
125
        /// subclass has to override this property
126
        /// </summary>
127
        public virtual ControlType ControlType { get; set; }
128

    
129
        private double _CommentAngle;
130

    
131
        /// <summary>
132
        /// 컨트롤의 ANGLE
133
        /// </summary>
134
        public virtual double CommentAngle
135
        {
136
            get { return _CommentAngle; }
137
            set
138
            {
139
                _CommentAngle = value;
140
                System.Diagnostics.Debug.WriteLine($"CommentInfo CommentAngle {value}");
141
            }
142
        }
143

    
144
        private double _PageAngle;
145

    
146
        /// <summary>
147
        /// 실제 저장된 Page의 ANGLE
148
        /// DB에 저장됨
149
        /// </summary>
150
        public virtual double PageAngle
151
        {
152
            get { return _PageAngle; }
153
            set
154
            {
155
                _PageAngle = value;
156
                System.Diagnostics.Debug.WriteLine($"CommentInfo PageAngle {value}");
157
            }
158
        }
159

    
160
        private double _VisualPageAngle;
161

    
162
        /// <summary>
163
        /// Display되는 Page의 ANGLE
164
        /// PageAngle에서 변형됨
165
        /// </summary>
166
        public virtual double VisualPageAngle
167
        {
168
            get { return _VisualPageAngle; }
169
            set
170
            {
171
                _VisualPageAngle = value;
172
                //System.Diagnostics.Debug.WriteLine($"CommentInfo VisualPageAngle {value}");
173
            }
174
        }
175

    
176
        public virtual SolidColorBrush StrokeColor { get; set; }
177

    
178
        /// <summary>
179
        /// 
180
        /// </summary>
181
        public virtual void ApplyOverViewData() { }
182

    
183
        /// <summary>
184
        /// subclass has to override this method
185
        /// </summary>
186
        /// <returns>serialized string</returns>
187
        public virtual string Serialize() { return string.Empty; }
188

    
189
        /// <summary>
190
        /// return MARKUP_DATA
191
        /// </summary>
192
        /// <param name="sUserID"></param>
193
        /// <param name="iPageNo"></param>
194
        /// <returns></returns>
195
        public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID)
196
        {
197
            var root = MarkupParser.MarkupToString(this, sUserID);
198
            return new MARKUP_DATA
199
            {
200
                ID = this.CommentID,
201
                DATA = root.ConvertData,
202
                DATA_TYPE = root.DATA_TYPE,
203
                PAGENUMBER = iPageNo,
204
                MARKUPINFO_VERSION_ID = sMarkupVersionID,
205
                SYMBOL_ID = this.SymbolID,
206
                //GROUP_ID = this.GroupID
207
            };
208
        }
209

    
210
        /// <summary>
211
        /// return item's area
212
        /// </summary>
213
        public virtual Rect ItemRect
214
        {
215
            get;
216
        }
217

    
218
        /// <summary>
219
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
220
        /// </summary>
221
        /// <param name="StartP">StartPoint</param>
222
        /// <param name="EndP">EndPoint</param>
223
        /// <returns>Return_EndPoint</returns>
224
        public Point GetSquareEndPoint(Point StartP, Point EndP)
225
        {
226
            Point? res = null;
227

    
228
            double dx = EndP.X - StartP.X;
229
            double dy = EndP.Y - StartP.Y;
230
            double length;
231

    
232
            switch (this.ControlType)
233
            {
234
                case ControlType.Triangle:
235
                    {
236
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
237
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
238
                        res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
239
                    }
240
                    break;
241
                default:
242
                    {
243
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
244
                        res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length);
245
                    }
246
                    break;
247
            }
248

    
249
            return res.Value;
250
        }
251
    }
252
}
클립보드 이미지 추가 (최대 크기: 500 MB)