프로젝트

일반

사용자정보

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

markus / KCOM / Extensions / MarkupVisitHelper.cs @ fc4e50f2

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

1 c7fde400 taeseongkim
using KCOM.Common;
2
using KCOM.Controls;
3
using System;
4
using System.Collections.Generic;
5
using System.Linq;
6
using System.Text;
7
using System.Threading.Tasks;
8
using System.Windows;
9
10
namespace KCOM
11
{
12
    /// <summary>
13
    /// Markup 이동
14
    /// </summary>
15
    public static class MarkupHelper
16
    {
17
        /// <summary>
18
        /// 선택된 마크업의 ID리스트를 받아 해당 페이지로 이동 후 GotoSelectedMarkup 호출
19
        /// </summary>
20
        /// <param name="CommentIdList"></param>
21
        public static void GotoMarkup(IEnumerable<string> CommentIdList)
22
        {
23
            var instance = Common.ViewerDataModel.Instance;
24
25
            SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
26
27
            var commentList = instance._markupInfoList.Where(x => x.MarkupList != null).SelectMany(x => x.MarkupList).Where(f => f.ID == CommentIdList.First());
28
29
            if (commentList.Count() > 0)
30
            {
31
32 1d46df43 taeseongkim
                var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
33 c7fde400 taeseongkim
34 1d46df43 taeseongkim
                /// 페이지가 틀린 경우 먼저 페이지를 변경한다.
35
                if (pageNavigator.CurrentPage.PageNumber != commentList.First().PageNumber)
36 c7fde400 taeseongkim
                {
37 1d46df43 taeseongkim
                    EventHandler<EventArgs> handler = null;
38 c7fde400 taeseongkim
39 1d46df43 taeseongkim
                    /// 페이지 변경 후 다시 호출
40
                    handler = (snd, evt) =>
41
                    {
42
                        ViewerDataModel.Instance.PageLoaded -= handler;
43 c7fde400 taeseongkim
44 1d46df43 taeseongkim
                        Task.Delay(100).ConfigureAwait(true);
45 c7fde400 taeseongkim
46 1d46df43 taeseongkim
                        GotoMarkup(CommentIdList);
47
                    };
48 c7fde400 taeseongkim
49 1d46df43 taeseongkim
                    ViewerDataModel.Instance.PageLoaded += handler;
50
51
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(commentList.First().PageNumber);
52 c7fde400 taeseongkim
                }
53
                else
54
                {
55 1d46df43 taeseongkim
                    //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
56
                    #region markup list grid select items
57 c7fde400 taeseongkim
58 1d46df43 taeseongkim
                    var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
59
60
                    if (infoItem.Count() > 0)
61 c7fde400 taeseongkim
                    {
62
63 1d46df43 taeseongkim
                        var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
64
                        gridMarkup.SelectedItems.Clear();
65
                        gridMarkup.SelectedItems.Add(infoItem.First());
66
                    }
67
68
                    #endregion
69
70
                    GotoSelectedMarkup(CommentIdList);
71 c7fde400 taeseongkim
72
                }
73
            }
74
        }
75
76 f3ab410f taeseongkim
        public static MarkupToPDF.Common.CommentUserInfo VisualCommentUserInfoFind(string id)
77
        {
78
            MarkupToPDF.Common.CommentUserInfo result = null;
79
80
            var instance = Common.ViewerDataModel.Instance;
81
82
            var selectOrderComments = instance.MarkupControls.Where(x => id == x.CommentID).ToList();
83
84
            if(selectOrderComments.Count() > 0)
85
            {
86
                result=  selectOrderComments.First();
87
            }
88
89
            var commentUserInfo = instance.MarkupControls_USER.Where(x => id == x.CommentID).ToList();
90
91
            if (commentUserInfo.Count() > 0)
92
            {
93
                result = commentUserInfo.First();
94
            }
95
96
            return result;
97
        }
98
99 c7fde400 taeseongkim
        private static void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
100
        {
101
            var instance = Common.ViewerDataModel.Instance;
102
103
            var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
104
            var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
105
106
            if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
107
            {
108
                commentUserInfo.ForEach(x => x.IsSelected = true);
109
                commentUserInfo.AddRange(selectOrderComments);
110
111
                if (commentUserInfo?.Count() > 0)
112
                {
113
                    var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
114
115
                    try
116
                    {
117 4f017ed3 taeseongkim
                        if (Common.ViewerDataModel.Instance.MarkupAngle != 0)
118 c7fde400 taeseongkim
                        {
119 4f017ed3 taeseongkim
                            for (int i = 0; i < (Common.ViewerDataModel.Instance.MarkupAngle / 90); i++)
120 c7fde400 taeseongkim
                            {
121
                                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
122
                            }
123
124
                            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
125
                            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
126
                            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
127
                        }
128
129
                        Rect rect = commentUserInfo.First().ItemRect;
130
131
                        foreach (var UserInfo in commentUserInfo)
132
                        {
133
                            rect = Rect.Union(rect, UserInfo.ItemRect);
134 f65e6c02 taeseongkim
                            UserInfo.OnMouseHover();
135 c7fde400 taeseongkim
                        }
136
137
                        SelectionSet.Instance.SelectItemByRect(rect, main);
138
139
                        var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
140
                        //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
141
                        //rect.Transform(matrix);
142
143
                        double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
144
                        double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
145
                        double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
146
                        double positionX = 0;
147
                        double positionY = 0;
148
149 4f017ed3 taeseongkim
                        if (Common.ViewerDataModel.Instance.MarkupAngle == 90)
150 c7fde400 taeseongkim
                        {
151
                            positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
152
                            positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
153
                        }
154 e1c892f7 taeseongkim
                        //else if (Common.ViewerDataModel.Instance.Angle == 270)
155
                        //{
156
                        //    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X *4;
157
                        //    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y * 4;
158
                        //}
159 c7fde400 taeseongkim
160
                        main.zoomAndPanControl.ContentScale = newScale;
161
                        main.zoomAndPanControl.ContentOffsetX = positionX;
162
                        main.zoomAndPanControl.ContentOffsetY = positionY;
163
164
165
                        var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
166
167 4f017ed3 taeseongkim
                        double pageAngle = Common.ViewerDataModel.Instance.MarkupAngle;
168 c7fde400 taeseongkim
169
                        if (pageAngle == 90)
170
                        {
171
                            pageAngle = 270;
172
                        }
173
                        else
174
                        {
175
                            pageAngle = 90;
176
                        }
177
178
                        if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
179
                        {
180 4f017ed3 taeseongkim
                            var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.MarkupAngle);
181 c7fde400 taeseongkim
                            rect.Transform(matrix);
182 e1c892f7 taeseongkim
                            
183 c7fde400 taeseongkim
                            main.zoomAndPanControl.ZoomTo(rect);
184
                        }
185
                        else
186
                        {
187
                            rect.Inflate(rect.Width * 3, rect.Height * 3);
188
189 4f017ed3 taeseongkim
                            var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.MarkupAngle);
190 c7fde400 taeseongkim
                            rect.Transform(matrix);
191
192
193
                            main.zoomAndPanControl.ZoomTo(rect);
194
                        }
195
                    }
196
                    catch (Exception ex)
197
                    {
198
                        main.DialogMessage_Alert(ex.Message, "Error");
199
                    }
200
                }
201
            }
202
        }
203
204
    }
205
}
클립보드 이미지 추가 (최대 크기: 500 MB)