프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Common / CommentUserInfo.cs @ a6272c57

이력 | 보기 | 이력해설 | 다운로드 (5.63 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
    }
18

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

    
25
        public string Memo { get; set; }
26
        public string MarkupInfoID { get; set; }
27
        public bool IsMouseOver { get; set; }
28
        public bool IsNew { get; set; }
29
        public string CommentID { get; set; }
30
        public string SymbolID { get; set; }
31
        public long GroupID { get; set; }
32

    
33
        private SolidColorBrush _TempBorderBrush { get; set; }
34
        private SolidColorBrush _HoverBorderBrush = new SolidColorBrush(Color.FromRgb(255, 0, 255));
35

    
36
        public CommentUserInfo()
37
        {
38
            this.BorderThickness = new System.Windows.Thickness(20.0);
39
            this.MouseEnter += CommentUserInfo_MouseEnter;
40
            this.MouseLeave += CommentUserInfo_MouseLeave;
41
        }
42

    
43
        protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
44
        {
45
            var temp = base.HitTestCore(hitTestParameters);
46
            return temp;
47
        }
48

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

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

    
70
        public virtual void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) { }
71

    
72
        /// <summary>
73
        /// subclass has to override this property
74
        /// </summary>
75
        public virtual bool IsSelected { get; set; }
76

    
77
        /// <summary>
78
        /// subclass has to override this property
79
        /// </summary>
80
        public virtual ControlType ControlType { get; set; }
81

    
82
        public virtual SolidColorBrush StrokeColor { get; set; }
83

    
84
        /// <summary>
85
        /// translate commeny by given dx, dy
86
        /// </summary>
87
        /// <param name="dx"></param>
88
        /// <param name="dy"></param>
89
        public virtual void Move(double dx, double dy) { }
90

    
91
        /// <summary>
92
        /// 
93
        /// </summary>
94
        public virtual void ApplyOverViewData() { }
95

    
96
        /// <summary>
97
        /// subclass has to override this method
98
        /// </summary>
99
        /// <returns>serialized string</returns>
100
        public virtual string Serialize() { return string.Empty; }
101

    
102
        /// <summary>
103
        /// return MARKUP_DATA
104
        /// </summary>
105
        /// <param name="sUserID"></param>
106
        /// <param name="iPageNo"></param>
107
        /// <returns></returns>
108
        public virtual MARKUP_DATA GetMarkupData(string sUserID, int iPageNo, string sMarkupVersionID)
109
        {
110
            var root = MarkupParser.MarkupToString(this, sUserID);
111
            return new MARKUP_DATA
112
            {
113
                ID = this.CommentID,
114
                DATA = root.ConvertData,
115
                DATA_TYPE = root.DATA_TYPE,
116
                PAGENUMBER = iPageNo,
117
                MARKUPINFO_VERSION_ID = sMarkupVersionID,
118
                SYMBOL_ID = this.SymbolID,
119
                //GROUP_ID = this.GroupID
120
            };
121
        }
122

    
123
        /// <summary>
124
        /// return item's area
125
        /// </summary>
126
        public virtual Rect ItemRect
127
        {
128
            get;
129
        }
130

    
131
        /// <summary>
132
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
133
        /// </summary>
134
        /// <param name="StartP">StartPoint</param>
135
        /// <param name="EndP">EndPoint</param>
136
        /// <returns>Return_EndPoint</returns>
137
        public Point GetSquareEndPoint(Point StartP, Point EndP)
138
        {
139
            Point? res = null;
140

    
141
            double dx = EndP.X - StartP.X;
142
            double dy = EndP.Y - StartP.Y;
143
            double length;
144

    
145
            switch (this.ControlType)
146
            {
147
                case ControlType.Triangle:
148
                    {
149
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
150
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
151
                        res = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
152
                    }
153
                    break;
154
                default:
155
                    {
156
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
157
                        res = new Point((dx > 0) ? StartP.X + length : StartP.X - length, (dy > 0) ? StartP.Y + length : StartP.Y - length);
158
                    }
159
                    break;
160
            }
161

    
162
            return res.Value;
163
        }
164
    }
165
}
클립보드 이미지 추가 (최대 크기: 500 MB)