프로젝트

일반

사용자정보

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

markus / KCOM / Extensions / MarkupVisitHelper.cs @ f3ab410f

이력 | 보기 | 이력해설 | 다운로드 (8.28 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
            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
                var pageNavigator = instance.SystemMain.dzMainMenu.pageNavigator;
33

    
34
                /// 페이지가 틀린 경우 먼저 페이지를 변경한다.
35
                if (pageNavigator.CurrentPage.PageNumber != commentList.First().PageNumber)
36
                {
37
                    EventHandler<EventArgs> handler = null;
38

    
39
                    /// 페이지 변경 후 다시 호출
40
                    handler = (snd, evt) =>
41
                    {
42
                        ViewerDataModel.Instance.PageLoaded -= handler;
43

    
44
                        Task.Delay(100).ConfigureAwait(true);
45

    
46
                        GotoMarkup(CommentIdList);
47
                    };
48

    
49
                    ViewerDataModel.Instance.PageLoaded += handler;
50

    
51
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(commentList.First().PageNumber);
52
                }
53
                else
54
                {
55
                    //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
56
                    #region markup list grid select items
57

    
58
                    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
                    {
62

    
63
                        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

    
72
                }
73
            }
74
        }
75

    
76
        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
        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
                        if (Common.ViewerDataModel.Instance.MarkupAngle != 0)
118
                        {
119
                            for (int i = 0; i < (Common.ViewerDataModel.Instance.MarkupAngle / 90); i++)
120
                            {
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
                            UserInfo.OnMouseHover();
135
                        }
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
                        if (Common.ViewerDataModel.Instance.MarkupAngle == 90)
150
                        {
151
                            positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
152
                            positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
153
                        }
154
                        //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

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

    
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
                            var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.MarkupAngle);
181
                            rect.Transform(matrix);
182
                            
183
                            main.zoomAndPanControl.ZoomTo(rect);
184
                        }
185
                        else
186
                        {
187
                            rect.Inflate(rect.Width * 3, rect.Height * 3);
188

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