프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Common / CommentUserInfo.cs @ 91e84544

이력 | 보기 | 이력해설 | 다운로드 (7.58 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, bool bShiftKeyPressed);
17
        void OnMoveCtrlPoint(Point pt, double dx, double dy);
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 IsMouseOver { 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
            this.SetValue(Telerik.Windows.Controls.TabNavigationExtensions.IsTabStopProperty, false);
42
               this.BorderThickness = new System.Windows.Thickness(20.0);
43
            this.MouseEnter += CommentUserInfo_MouseEnter;
44
            this.MouseLeave += CommentUserInfo_MouseLeave;
45
        }
46

    
47
        protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
48
        {
49
            var temp = base.HitTestCore(hitTestParameters);
50
            return temp;
51
        }
52

    
53
        private void CommentUserInfo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
54
        {
55
            this.IsMouseOver = false;
56
            if (this.StrokeColor != null)
57
            {
58
                this.StrokeColor = this._TempBorderBrush;
59
                this.UpdateLayout();
60
            }
61
        }
62

    
63
        private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
64
        {
65
            this.IsMouseOver = true;
66
            if (this.StrokeColor != null)
67
            {
68
                this._TempBorderBrush = this.StrokeColor;
69
                this.StrokeColor = this._HoverBorderBrush;
70
                this.UpdateLayout();
71
            }
72
        }
73

    
74
        public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) { }
75
        public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy) { }
76

    
77
        /// <summary>
78
        /// translate control along given dx,dy
79
        /// </summary>
80
        /// <param name="dx"></param>
81
        /// <param name="dy"></param>
82
        public virtual void OnTranslate(double dx, double dy)
83
        {
84
            var path = (this as IPath);
85
            for (int i = 0; i < path.PointSet.Count; ++i)
86
            {
87
                path.PointSet[i] = new Point(path.PointSet[i].X + dx, path.PointSet[i].Y + dy);
88
            }
89
            this.UpdateControl();
90
        }
91

    
92
        /// <summary>
93
        /// update control
94
        /// </summary>
95
        public virtual void UpdateControl() { }
96

    
97
        /// <summary>
98
        /// subclass has to override this property
99
        /// </summary>
100
        public virtual bool IsSelected { get; set; }
101

    
102
        /// <summary>
103
        /// subclass has to override this property
104
        /// </summary>
105
        public virtual ControlType ControlType { get; set; }
106

    
107
        private double _CommentAngle;
108

    
109
        /// <summary>
110
        /// 컨트롤의 ANGLE
111
        /// </summary>
112
        public virtual double CommentAngle
113
        {
114
            get { return _CommentAngle; }
115
            set
116
            {
117
                _CommentAngle = value;
118
                System.Diagnostics.Debug.WriteLine($"CommentInfo CommentAngle {value}");
119
            }
120
        }
121

    
122
        private double _PageAngle;
123

    
124
        /// <summary>
125
        /// 실제 저장된 Page의 ANGLE
126
        /// DB에 저장됨
127
        /// </summary>
128
        public virtual double PageAngle
129
        {
130
            get { return _PageAngle; }
131
            set
132
            {
133
                _PageAngle = value;
134
                System.Diagnostics.Debug.WriteLine($"CommentInfo PageAngle {value}");
135
            }
136
        }
137

    
138
        private double _VisualPageAngle;
139

    
140
        /// <summary>
141
        /// Display되는 Page의 ANGLE
142
        /// PageAngle에서 변형됨
143
        /// </summary>
144
        public virtual double VisualPageAngle
145
        {
146
            get { return _VisualPageAngle; }
147
            set
148
            {
149
                _VisualPageAngle = value;
150
                //System.Diagnostics.Debug.WriteLine($"CommentInfo VisualPageAngle {value}");
151
            }
152
        }
153

    
154
        public virtual SolidColorBrush StrokeColor { get; set; }
155

    
156
        /// <summary>
157
        /// 
158
        /// </summary>
159
        public virtual void ApplyOverViewData() { }
160

    
161
        /// <summary>
162
        /// subclass has to override this method
163
        /// </summary>
164
        /// <returns>serialized string</returns>
165
        public virtual string Serialize() { return string.Empty; }
166

    
167
        /// <summary>
168
        /// return MARKUP_DATA
169
        /// </summary>
170
        /// <param name="sUserID"></param>
171
        /// <param name="iPageNo"></param>
172
        /// <returns></returns>
173
        public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID)
174
        {
175
            var root = MarkupParser.MarkupToString(this, sUserID);
176
            return new MARKUP_DATA
177
            {
178
                ID = this.CommentID,
179
                DATA = root.ConvertData,
180
                DATA_TYPE = root.DATA_TYPE,
181
                PAGENUMBER = iPageNo,
182
                MARKUPINFO_VERSION_ID = sMarkupVersionID,
183
                SYMBOL_ID = this.SymbolID,
184
                //GROUP_ID = this.GroupID
185
            };
186
        }
187

    
188
        /// <summary>
189
        /// return item's area
190
        /// </summary>
191
        public virtual Rect ItemRect
192
        {
193
            get;
194
        }
195

    
196
        /// <summary>
197
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
198
        /// </summary>
199
        /// <param name="StartP">StartPoint</param>
200
        /// <param name="EndP">EndPoint</param>
201
        /// <returns>Return_EndPoint</returns>
202
        public Point GetSquareEndPoint(Point StartP, Point EndP)
203
        {
204
            Point? res = null;
205

    
206
            double dx = EndP.X - StartP.X;
207
            double dy = EndP.Y - StartP.Y;
208
            double length;
209

    
210
            switch (this.ControlType)
211
            {
212
                case ControlType.Triangle:
213
                    {
214
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
215
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
216
                        res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
217
                    }
218
                    break;
219
                default:
220
                    {
221
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
222
                        res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length);
223
                    }
224
                    break;
225
            }
226

    
227
            return res.Value;
228
        }
229
    }
230
}
클립보드 이미지 추가 (최대 크기: 500 MB)