프로젝트

일반

사용자정보

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

markus / KCOM / Extensions / MarkupVisitHelper.cs @ 3abe8d4e

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

1
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
            List<IKCOM.MarkupItem> commentList = new List<IKCOM.MarkupItem>();
28

    
29
            foreach (var markupInfo in instance._markupInfoList)
30
            {
31
                if (markupInfo.MarkupList != null)
32
                {
33
                    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
                }
41
            }
42

    
43
            if (commentList.Count() > 0)
44
            {
45

    
46
                var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
47

    
48
                /// 페이지가 틀린 경우 먼저 페이지를 변경한다.
49
                if (pageNavigator.CurrentPage.PageNumber != commentList.First().PageNumber)
50
                {
51
                    EventHandler<EventArgs> handler = null;
52

    
53
                    /// 페이지 변경 후 다시 호출
54
                    handler = (snd, evt) =>
55
                    {
56
                        ViewerDataModel.Instance.PageLoaded -= handler;
57

    
58
                        Task.Delay(100).ConfigureAwait(true);
59

    
60
                        GotoMarkup(CommentIdList);
61
                    };
62

    
63
                    ViewerDataModel.Instance.PageLoaded += handler;
64

    
65
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(commentList.First().PageNumber);
66
                }
67
                else
68
                {
69
                    //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
70
                    #region markup list grid select items
71
                    /// 이전에 선택하도록 수정함
72
                    //var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
73

    
74
                    //if (infoItem.Count() > 0)
75
                    //{
76

    
77
                    //    var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
78
                    //    gridMarkup.SelectedItems.Clear();
79
                    //    gridMarkup.SelectedItems.Add(infoItem.First());
80
                    //}
81

    
82
                    #endregion
83

    
84
                    GotoSelectedMarkup(CommentIdList);
85

    
86
                }
87
            }
88
        }
89

    
90
        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
        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
                        if (Common.ViewerDataModel.Instance.MarkupAngle != Common.ViewerDataModel.Instance.PageAngle)
132
                        {
133
                            for (int i = 0; i < (Math.Abs(Common.ViewerDataModel.Instance.MarkupAngle - Common.ViewerDataModel.Instance.PageAngle) / 90); i++)
134
                            {
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
                            UserInfo.OnMouseHover();
149
                        }
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
                        if (Common.ViewerDataModel.Instance.MarkupAngle == 90)
164
                        {
165
                            positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
166
                            positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
167
                        }
168
                        //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

    
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
                        double pageAngle = Common.ViewerDataModel.Instance.MarkupAngle;
182

    
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
                            var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.MarkupAngle);
195
                            rect.Transform(matrix);
196
                            
197
                            main.zoomAndPanControl.ZoomTo(rect);
198
                        }
199
                        else
200
                        {
201
                            rect.Inflate(rect.Width * 3, rect.Height * 3);
202

    
203
                            var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.MarkupAngle);
204
                            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)