프로젝트

일반

사용자정보

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

markus / KCOM / Extensions / MarkupVisitHelper.cs @ e1c892f7

이력 | 보기 | 이력해설 | 다운로드 (7.26 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
                //하단 그리드의 markup list에서 commentid가 포함된 markupinfo를 선택되게 한다.
32
                #region markup list grid select items
33

    
34
                var infoItem = instance._markupInfoList.Where(x => x.MarkupList != null).Where(f => f.MarkupList.Count(y => y == commentList.First()) > 0);
35

    
36
                if (infoItem.Count() > 0)
37
                {
38

    
39
                    var gridMarkup = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewMarkup;
40
                    gridMarkup.SelectedItems.Clear();
41
                    gridMarkup.SelectedItems.Add(infoItem.First());
42
                }
43

    
44
                #endregion
45

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

    
48
                if (pageNavigator.CurrentPage.PageNumber == commentList.First().PageNumber)
49
                {
50
                    GotoSelectedMarkup(CommentIdList);
51
                }
52
                else
53
                {
54
                    EventHandler<EventArgs> handler = null;
55

    
56
                    handler = (snd, evt) =>
57
                    {
58
                        GotoSelectedMarkup(CommentIdList);
59
                        ViewerDataModel.Instance.PageLoaded -= handler;
60
                    };
61

    
62
                    ViewerDataModel.Instance.PageLoaded += handler;
63

    
64
                    pageNavigator.GotoPage(commentList.First().PageNumber);
65
                }
66
            }
67
        }
68

    
69
        private static void GotoSelectedMarkup(IEnumerable<string> CommentIdList)
70
        {
71
            var instance = Common.ViewerDataModel.Instance;
72

    
73
            var selectOrderComments = instance.MarkupControls.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
74
            var commentUserInfo = instance.MarkupControls_USER.Where(x => CommentIdList.Count(y => y == x.CommentID) > 0).ToList();
75

    
76
            if (commentUserInfo.Count() > 0 || selectOrderComments.Count() > 0)
77
            {
78
                commentUserInfo.ForEach(x => x.IsSelected = true);
79
                commentUserInfo.AddRange(selectOrderComments);
80

    
81
                if (commentUserInfo?.Count() > 0)
82
                {
83
                    var main = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
84

    
85
                    try
86
                    {
87
                        if (Common.ViewerDataModel.Instance.Angle != 0)
88
                        {
89
                            for (int i = 0; i < (Common.ViewerDataModel.Instance.Angle / 90); i++)
90
                            {
91
                                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.drawingPannelRotate(true);
92
                            }
93

    
94
                            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = 0;
95
                            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.X = 0;
96
                            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.translate.Y = 0;
97
                        }
98

    
99
                        Rect rect = commentUserInfo.First().ItemRect;
100

    
101
                        foreach (var UserInfo in commentUserInfo)
102
                        {
103
                            rect = Rect.Union(rect, UserInfo.ItemRect);
104
                            UserInfo.OnMouseHover();
105
                        }
106

    
107
                        SelectionSet.Instance.SelectItemByRect(rect, main);
108

    
109
                        var center = new Vector(Common.ViewerDataModel.Instance.ImageViewWidth / 2, Common.ViewerDataModel.Instance.ImageViewHeight / 2);
110
                        //var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
111
                        //rect.Transform(matrix);
112

    
113
                        double scaleX = Common.ViewerDataModel.Instance.ImageViewWidth / rect.Width;
114
                        double scaleY = Common.ViewerDataModel.Instance.ImageViewHeight / rect.Height;
115
                        double newScale = main.zoomAndPanControl.ContentScale * Math.Min(scaleX, scaleY);
116
                        double positionX = 0;
117
                        double positionY = 0;
118

    
119
                        if (Common.ViewerDataModel.Instance.Angle == 90)
120
                        {
121
                            positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X;
122
                            positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y;
123
                        }
124
                        //else if (Common.ViewerDataModel.Instance.Angle == 270)
125
                        //{
126
                        //    positionX = Common.ViewerDataModel.Instance.ImageViewHeight + rect.X *4;
127
                        //    positionY = Common.ViewerDataModel.Instance.ImageViewWidth + rect.Y * 4;
128
                        //}
129

    
130
                        main.zoomAndPanControl.ContentScale = newScale;
131
                        main.zoomAndPanControl.ContentOffsetX = positionX;
132
                        main.zoomAndPanControl.ContentOffsetY = positionY;
133

    
134

    
135
                        var pageSize = new Size(main.pageNavigator.CurrentPage.Width, main.pageNavigator.CurrentPage.Height);
136

    
137
                        double pageAngle = Common.ViewerDataModel.Instance.Angle;
138

    
139
                        if (pageAngle == 90)
140
                        {
141
                            pageAngle = 270;
142
                        }
143
                        else
144
                        {
145
                            pageAngle = 90;
146
                        }
147

    
148
                        if ((rect.Size.Width + rect.Size.Height) > (pageSize.Width + pageSize.Height))
149
                        {
150
                            var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
151
                            rect.Transform(matrix);
152
                            
153
                            main.zoomAndPanControl.ZoomTo(rect);
154
                        }
155
                        else
156
                        {
157
                            rect.Inflate(rect.Width * 3, rect.Height * 3);
158

    
159
                            var matrix = MatrixHelper.Rotation(Common.ViewerDataModel.Instance.Angle);
160
                            rect.Transform(matrix);
161

    
162

    
163
                            main.zoomAndPanControl.ZoomTo(rect);
164
                        }
165
                    }
166
                    catch (Exception ex)
167
                    {
168
                        main.DialogMessage_Alert(ex.Message, "Error");
169
                    }
170
                }
171
            }
172
        }
173

    
174
    }
175
}
클립보드 이미지 추가 (최대 크기: 500 MB)