프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Common / CommentUserInfo.cs @ 873011c4

이력 | 보기 | 이력해설 | 다운로드 (8.17 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.Linq;
7
using System.Text;
8
using System.Windows;
9
using System.Windows.Input;
10
using System.Windows.Media;
11

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

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

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

    
36
        private SolidColorBrush _TempBorderBrush { get; set; }
37
        private SolidColorBrush _HoverBorderBrush = new SolidColorBrush(Color.FromRgb(255, 0, 255));
38

    
39
        public CommentUserInfo()
40
        {
41
            Load();
42
        }
43

    
44
        public virtual void Copy(CommentUserInfo lhs) { throw new NotImplementedException("Must implement Copy()"); }
45
        public virtual CommentUserInfo Clone() { throw new NotImplementedException("Must implement Clone()"); }
46

    
47
        public void Load()
48
        {
49
            this.IsHitTestVisible = true;
50

    
51
            this.SetValue(Telerik.Windows.Controls.TabNavigationExtensions.IsTabStopProperty, false);
52
               this.BorderThickness = new System.Windows.Thickness(20.0);
53
            this.MouseEnter += CommentUserInfo_MouseEnter;
54
            this.MouseLeave += CommentUserInfo_MouseLeave;
55
        }
56

    
57
        protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
58
        {
59
            var temp = base.HitTestCore(hitTestParameters);
60
            return temp;
61
        }
62

    
63
        private void CommentUserInfo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
64
        {
65
            System.Diagnostics.Debug.WriteLine("Is Mouse Leave."); 
66

    
67
            this.IsMouseEnter = false;
68
            if (this.StrokeColor != this._TempBorderBrush)
69
            {
70
                this.StrokeColor = this._TempBorderBrush;
71
                this.UpdateLayout();
72
            }
73
        }
74

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

    
82
        public void OnMouseHover()
83
        {
84
            if (this.StrokeColor != this._HoverBorderBrush)
85
            {
86
                this._TempBorderBrush = this.StrokeColor;
87
                this.StrokeColor = this._HoverBorderBrush;
88
                this.UpdateLayout();
89
            }
90
        }
91

    
92
        public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked) { }
93
        public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) { }
94

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

    
110
        /// <summary>
111
        /// update control
112
        /// </summary>
113
        public virtual void UpdateControl() { }
114

    
115
        /// <summary>
116
        /// subclass has to override this property
117
        /// </summary>
118
        public virtual bool IsSelected { get; set; }
119

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

    
125
        private double _CommentAngle;
126

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

    
140
        private double _PageAngle;
141

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

    
156
        private double _VisualPageAngle;
157

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

    
172
        public virtual SolidColorBrush StrokeColor { get; set; }
173

    
174
        /// <summary>
175
        /// 
176
        /// </summary>
177
        public virtual void ApplyOverViewData() { }
178

    
179
        /// <summary>
180
        /// subclass has to override this method
181
        /// </summary>
182
        /// <returns>serialized string</returns>
183
        public virtual string Serialize() { return string.Empty; }
184

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

    
206
        /// <summary>
207
        /// return item's area
208
        /// </summary>
209
        public virtual Rect ItemRect
210
        {
211
            get;
212
        }
213

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

    
224
            double dx = EndP.X - StartP.X;
225
            double dy = EndP.Y - StartP.Y;
226
            double length;
227

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

    
245
            return res.Value;
246
        }
247
    }
248
}
클립보드 이미지 추가 (최대 크기: 500 MB)