프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ 949d5058

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

1 787a4489 KangIngu
using KCOM.Common;
2 f816dd63 humkyung
using KCOM.Events;
3 787a4489 KangIngu
using MarkupToPDF.Common;
4 036650a0 humkyung
using MarkupToPDF.Controls.Parsing;
5 53880c83 ljiyeon
using Svg2Xaml;
6 787a4489 KangIngu
using System;
7
using System.Collections.Generic;
8
using System.ComponentModel;
9
using System.Linq;
10
using System.Text;
11
using System.Windows;
12
using System.Windows.Controls;
13
using System.Windows.Input;
14 53880c83 ljiyeon
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16 787a4489 KangIngu
using Telerik.Windows.Controls;
17 0c997b99 ljiyeon
//using static KCOM.Views.MainMenu;
18 787a4489 KangIngu
19
namespace KCOM
20
{
21
    public partial class MainWindow : Window
22
    {
23
        public double CumulativeWheel = 0;
24 036650a0 humkyung
        MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
25 da92cfb7 ljiyeon
                
26 787a4489 KangIngu
        public void KeyEventDownAction(object sender, KeyEventArgs e)
27
        {
28
            switch (e.Key)
29
            {
30
                //강인구 추가
31
                #region 단축키 선택
32
33
                #region 전체 선택(Ctrl + A)
34
                case Key.A:
35
                    {
36 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
37 787a4489 KangIngu
                        {
38 f959ea6f humkyung
                            this.dzMainMenu.ConvertInkControlToPolygon();
39 787a4489 KangIngu
40
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
41
                            {
42 b37ef4b3 humkyung
                                /// 전체 선택 시 선택된 토글 해제
43 787a4489 KangIngu
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
44
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
45
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
46
47 b37ef4b3 humkyung
                                /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
48 787a4489 KangIngu
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
49
                                this.dzMainMenu.currentControl = null;
50
51
                                foreach (var tog in TogList)
52
                                {
53
                                    tog.IsChecked = false;
54
                                }
55 077896be humkyung
56 b37ef4b3 humkyung
                                SelectionSet.Instance.SelectAll();
57 787a4489 KangIngu
                            }
58
                        }
59
                    }
60
                    break;
61
                #endregion
62
63
                #region 복사하기(Ctrl + C)
64
                case Key.C:
65
                    {
66 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
67 787a4489 KangIngu
                    }
68
                    break;
69
                #endregion
70
71
                #region 잘라내기(Ctrl + X)
72
                case Key.X:
73
                    {
74 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
75 787a4489 KangIngu
                    }
76
                    break;
77
                #endregion
78
79
                #region 붙여넣기(Ctrl + V)
80
                case Key.V:
81
                    {
82 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
83 787a4489 KangIngu
                        {
84 b37ef4b3 humkyung
                            PasteCommand.Instance.Execute();
85 37b65344 humkyung
                        }
86 787a4489 KangIngu
                    }
87
                    break;
88
                #endregion
89
90
                #region 저장하기(Ctrl + S)
91
                case Key.S:
92
                    {
93 37b65344 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
94 787a4489 KangIngu
                        {
95
                            //컨트롤을 그리는 도중일 경우 컨트롤 삭제
96
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
97
                            this.dzMainMenu.currentControl = null;
98
99 316d0f5c KangIngu
                            //this.dzTopMenu.SaveEvent(null, null);
100 65eb8dd6 ljiyeon
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
101
                            {
102 cb5c7f06 humkyung
                                this.dzTopMenu.SaveEventCallback(new object(), null);
103 65eb8dd6 ljiyeon
                            }
104 6707a5c7 ljiyeon
105
                            //저장완료후 임시파일 삭제
106 a20d338f ljiyeon
                            TempFile.Remove();
107 37b65344 humkyung
                        }
108 787a4489 KangIngu
                    }
109
                    break;
110
                #endregion
111
112
                #region 프린트하기(Ctrl + P)
113
                case Key.P:
114
                    {
115
                        if (ViewerDataModel.Instance.IsPressCtrl)
116
                        {
117
                            this.dzTopMenu.Print_Start("Print");
118
                        }
119
                    }
120
                    break;
121
                #endregion
122
123
                #region Undo(Ctrl + Z)
124
                case Key.Z:
125
                    {
126 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
127 787a4489 KangIngu
                    }
128
                    break;
129
                #endregion
130
131
                #region Redo(Ctrl + Y)
132
                case Key.Y:
133
                    {
134 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
135 787a4489 KangIngu
                    }
136
                    break;
137
                #endregion
138
139
                #region 삭제하기(Delete)
140
                case Key.Delete:
141
                    {
142 d62c0439 humkyung
                        DeleteCommand.Instance.Execute(SelectionSet.Instance.SelectedItems);
143 f816dd63 humkyung
                        this.dzMainMenu.SelectLayer.Children.Clear();
144 787a4489 KangIngu
                    }
145
                    break;
146
                #endregion
147
148
                #region 선택된 컨트롤 모두 해제 하기(ESC)
149
                case Key.Escape:
150
                    {
151
                        //캡쳐모드 일 경우 초기화
152 37b65344 humkyung
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
153 787a4489 KangIngu
                        {
154
                            //dzMainMenu.PN_Navi.IsEnabled = true;
155
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
156
                            ViewerDataModel.Instance.Capture_Opacity = 0;
157
                        }
158
159 37b65344 humkyung
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
160 787a4489 KangIngu
                        {
161
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
162
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
163
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
164
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
165
                            foreach (var tog in TogList)
166
                            {
167
                                tog.IsChecked = false;
168
                            }
169
                        }
170
171 077896be humkyung
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
172 787a4489 KangIngu
173
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
174 49b217ad humkyung
                        if (this.dzMainMenu.currentControl != null)
175
                        {
176
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
177
                            this.dzMainMenu.currentControl = null;
178
                        }
179 787a4489 KangIngu
180 2eac4f76 KangIngu
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
181
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
182
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
183
184
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
185
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
186
187 17a22987 KangIngu
                        foreach (var item in toggleList)
188
                        {
189
                            if (item.Name == "btnSelection")
190 2eac4f76 KangIngu
                            {
191
                                item.IsChecked = true;
192
                            }
193 17a22987 KangIngu
                            else
194 2eac4f76 KangIngu
                            {
195
                                item.IsChecked = false;
196
                            }
197 17a22987 KangIngu
                        }
198 9f473fb7 KangIngu
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
199 17a22987 KangIngu
                        //foreach (var item in toggleList2)
200
                        //{
201
                        //    item.IsChecked = false;
202
                        //}
203 787a4489 KangIngu
                    }
204
                    break;
205 992a98b4 KangIngu
                #endregion
206
207
                #region FIND(Ctrl + F)
208
                case Key.F:
209
                    {
210 469b2bbf KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl)
211 992a98b4 KangIngu
                        {
212 469b2bbf KangIngu
                            if (!this.dzMainMenu.searchPane.IsPinned)
213 992a98b4 KangIngu
                            {
214 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = true;
215
                                if (ViewerDataModel.Instance.searchPDF != null)
216
                                {
217
                                    this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
218
                                }
219
                                else
220
                                {
221
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
222
                                }
223 992a98b4 KangIngu
                            }
224
                            else
225
                            {
226 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = false;
227
                                this.dzMainMenu.searchPane.IsActive = false;
228
                                //this.dzMainMenu.searchPane.IsHidden = true;
229 992a98b4 KangIngu
                            }
230
                        }
231
                    }
232
                    break;
233
                #endregion
234 787a4489 KangIngu
235
                #endregion
236
237
                //강인구 추가
238
                #region Control Move
239 5cbd5c21 djkim
                case Key.NumPad4:
240
                case Key.NumPad5:
241
                case Key.NumPad6:
242 37b65344 humkyung
                case Key.NumPad8:
243 d543f923 ljiyeon
                case Key.Right:
244
                case Key.Left:
245
                case Key.Up:
246
                case Key.Down:
247
                    {
248
                        if (this.dzMainMenu.SelectLayer.Children.Count > 0)
249
                        {
250 37b65344 humkyung
                            Point? control = null;
251 e36af3a8 humkyung
                            if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad5)) || (e.Key == Key.Down))
252 d543f923 ljiyeon
                            {
253 37b65344 humkyung
                                control = new Point(0, 5);
254 d543f923 ljiyeon
                            }
255 e36af3a8 humkyung
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad8)) || (e.Key == Key.Up))
256 d543f923 ljiyeon
                            {
257 37b65344 humkyung
                                control = new Point(0, -5);
258 d543f923 ljiyeon
                            }
259 e36af3a8 humkyung
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad4)) || (e.Key == Key.Left))
260 37b65344 humkyung
                            {
261
                                control = new Point(-5, 0);
262
                            }
263 e36af3a8 humkyung
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad6)) || (e.Key == Key.Right))
264 37b65344 humkyung
                            {
265
                                control = new Point(5, 0);
266
                            }
267
                            if(control != null && control.HasValue) this.TranslateOrRotateItems(control.Value, this.dzMainMenu.rotate.Angle);
268 d543f923 ljiyeon
                        }
269
                    }
270
                    break;
271 da92cfb7 ljiyeon
                #endregion
272
                case Key.PageUp:
273
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
274
                    break;
275
                case Key.PageDown:
276
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
277
                    break;
278 787a4489 KangIngu
            }
279
        }
280
281 37b65344 humkyung
        /// <summary>
282
        /// translate or rotate items by given pt and angle
283
        /// </summary>
284
        /// <author>humkyung</author>
285
        /// <date>2019.07.03</date>
286
        /// <param name="pt">control point</param>
287
        /// <param name="dAngle">angle in degree</param>
288
        private void TranslateOrRotateItems(Point pt, double dAngle)
289
        {
290
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
291
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
292
            {
293
                if (item.GetType().Name == "AdornerFinal")
294
                {
295
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
296
                    {
297
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
298
                    }
299
                    else
300
                    {
301
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
302
                    }
303
304
                }
305
            }
306
        }
307 787a4489 KangIngu
    }
308
}
클립보드 이미지 추가 (최대 크기: 500 MB)