프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Common / CommentUserInfo.cs @ baacbc36

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

1 cb33ad14 humkyung
using KCOMDataModel.DataModel;
2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Parsing;
4 036650a0 humkyung
using System;
5 787a4489 KangIngu
using System.Collections.Generic;
6
using System.Linq;
7
using System.Text;
8 91efe37a humkyung
using System.Windows;
9 a6272c57 humkyung
using System.Windows.Input;
10 787a4489 KangIngu
using System.Windows.Media;
11
12
namespace MarkupToPDF.Common
13
{
14 a6272c57 humkyung
    public interface ICommentUserInfo
15
    {
16
        void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed);
17 d2114d3b humkyung
        void OnMoveCtrlPoint(Point pt, double dx, double dy);
18 0d00f9c8 humkyung
        void OnTranslate(double dx, double dy);
19
        void UpdateControl();
20 a6272c57 humkyung
    }
21
22
    public class CommentUserInfo : System.Windows.Controls.Control, ICommentUserInfo
23 787a4489 KangIngu
    {
24 661b7416 humkyung
        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 787a4489 KangIngu
        public string Memo { get; set; }
29
        public string MarkupInfoID { get; set; }
30 05009a0e ljiyeon
        public bool IsMouseOver { get; set; }
31 787a4489 KangIngu
        public bool IsNew { get; set; }
32
        public string CommentID { get; set; }
33 c8e9b3e4 ljiyeon
        public string SymbolID { get; set; }
34 53880c83 ljiyeon
        public long GroupID { get; set; }
35 787a4489 KangIngu
36 4913851c humkyung
        private SolidColorBrush _TempBorderBrush { get; set; }
37
        private SolidColorBrush _HoverBorderBrush = new SolidColorBrush(Color.FromRgb(255, 0, 255));
38 787a4489 KangIngu
39
        public CommentUserInfo()
40
        {
41
            this.BorderThickness = new System.Windows.Thickness(20.0);
42
            this.MouseEnter += CommentUserInfo_MouseEnter;
43
            this.MouseLeave += CommentUserInfo_MouseLeave;
44
        }
45
46
        protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
47
        {
48
            var temp = base.HitTestCore(hitTestParameters);
49
            return temp;
50
        }
51
52
        private void CommentUserInfo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
53
        {
54 05009a0e ljiyeon
            this.IsMouseOver = false;
55 4913851c humkyung
            if (this.StrokeColor != null)
56
            {
57
                this.StrokeColor = this._TempBorderBrush;
58
                this.UpdateLayout();
59
            }
60 787a4489 KangIngu
        }
61
62
        private void CommentUserInfo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
63
        {
64 05009a0e ljiyeon
            this.IsMouseOver = true;
65 4913851c humkyung
            if (this.StrokeColor != null)
66
            {
67
                this._TempBorderBrush = this.StrokeColor;
68
                this.StrokeColor = this._HoverBorderBrush;
69
                this.UpdateLayout();
70
            }
71 787a4489 KangIngu
        }
72 036650a0 humkyung
73 a6272c57 humkyung
        public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) { }
74 d2114d3b humkyung
        public virtual void OnMoveCtrlPoint(Point pt, double dx, double dy) { }
75 a6272c57 humkyung
76 036650a0 humkyung
        /// <summary>
77 0d00f9c8 humkyung
        /// translate control along given dx,dy
78
        /// </summary>
79
        /// <param name="dx"></param>
80
        /// <param name="dy"></param>
81
        public virtual void OnTranslate(double dx, double dy)
82
        {
83
            var path = (this as IPath);
84 8771edc4 humkyung
            for(int i=0; i < path.PointSet.Count;++i)
85 0d00f9c8 humkyung
            {
86
                path.PointSet[i] = new Point(path.PointSet[i].X + dx, path.PointSet[i].Y + dy);
87
            }
88
            this.UpdateControl();
89
        }
90
91
        /// <summary>
92
        /// update control
93
        /// </summary>
94
        public virtual void UpdateControl() { }
95
96
        /// <summary>
97 036650a0 humkyung
        /// subclass has to override this property
98
        /// </summary>
99 91efe37a humkyung
        public virtual bool IsSelected { get; set; }
100 959b3ef2 humkyung
101
        /// <summary>
102
        /// subclass has to override this property
103
        /// </summary>
104
        public virtual ControlType ControlType { get; set; }
105 036650a0 humkyung
106 4913851c humkyung
        public virtual SolidColorBrush StrokeColor { get; set; }
107
108 036650a0 humkyung
        /// <summary>
109 f513c215 humkyung
        /// 
110
        /// </summary>
111
        public virtual void ApplyOverViewData() { }
112
113
        /// <summary>
114 036650a0 humkyung
        /// subclass has to override this method
115
        /// </summary>
116
        /// <returns>serialized string</returns>
117
        public virtual string Serialize() { return string.Empty; }
118 cb33ad14 humkyung
119
        /// <summary>
120
        /// return MARKUP_DATA
121
        /// </summary>
122
        /// <param name="sUserID"></param>
123
        /// <param name="iPageNo"></param>
124
        /// <returns></returns>
125
        public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID)
126
        {
127
            var root = MarkupParser.MarkupToString(this, sUserID);
128
            return new MARKUP_DATA
129
            {
130
                ID = this.CommentID,
131
                DATA = root.ConvertData,
132
                DATA_TYPE = root.DATA_TYPE,
133
                PAGENUMBER = iPageNo,
134
                MARKUPINFO_VERSION_ID = sMarkupVersionID,
135
                SYMBOL_ID = this.SymbolID,
136 c0977e97 djkim
                //GROUP_ID = this.GroupID
137 cb33ad14 humkyung
            };
138
        }
139 91efe37a humkyung
140
        /// <summary>
141
        /// return item's area
142
        /// </summary>
143
        public virtual Rect ItemRect
144
        {
145
            get;
146
        }
147 a6272c57 humkyung
148
        /// <summary>
149
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
150
        /// </summary>
151
        /// <param name="StartP">StartPoint</param>
152
        /// <param name="EndP">EndPoint</param>
153
        /// <returns>Return_EndPoint</returns>
154
        public Point GetSquareEndPoint(Point StartP, Point EndP)
155
        {
156
            Point? res = null;
157
158
            double dx = EndP.X - StartP.X;
159
            double dy = EndP.Y - StartP.Y;
160
            double length;
161
162
            switch (this.ControlType)
163
            {
164
                case ControlType.Triangle:
165
                    {
166
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
167
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
168
                        res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
169
                    }
170
                    break;
171
                default:
172
                    {
173
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
174
                        res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length);
175
                    }
176
                    break;
177
            }
178
179
            return res.Value;
180
        }
181 787a4489 KangIngu
    }
182
}
클립보드 이미지 추가 (최대 크기: 500 MB)