프로젝트

일반

사용자정보

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

markus / KCOM / Extensions / MarkupVisitHelper.cs @ 95c73392

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