프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ 1e901a8d

이력 | 보기 | 이력해설 | 다운로드 (16.3 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 91e84544 taeseongkim
        public async void KeyEventDownAction(object sender, KeyEventArgs e)
27 787a4489 KangIngu
        {
28 91e84544 taeseongkim
            //if (e.IsRepeat && !ViewerDataModel.Instance.IsPressCtrl && !ViewerDataModel.Instance.IsPressShift)
29
            //    return;
30
            await this.Dispatcher.InvokeAsync(() => {
31 787a4489 KangIngu
            switch (e.Key)
32
            {
33
                //강인구 추가
34
                #region 단축키 선택
35
36
                #region 전체 선택(Ctrl + A)
37
                case Key.A:
38
                    {
39 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
40 787a4489 KangIngu
                        {
41 f959ea6f humkyung
                            this.dzMainMenu.ConvertInkControlToPolygon();
42 787a4489 KangIngu
43
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
44
                            {
45 b37ef4b3 humkyung
                                /// 전체 선택 시 선택된 토글 해제
46 787a4489 KangIngu
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
47
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
48
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
49
50 b37ef4b3 humkyung
                                /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
51 787a4489 KangIngu
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
52
                                this.dzMainMenu.currentControl = null;
53
54
                                foreach (var tog in TogList)
55
                                {
56
                                    tog.IsChecked = false;
57
                                }
58 077896be humkyung
59 b37ef4b3 humkyung
                                SelectionSet.Instance.SelectAll();
60 787a4489 KangIngu
                            }
61
                        }
62
                    }
63
                    break;
64
                #endregion
65
66
                #region 복사하기(Ctrl + C)
67
                case Key.C:
68
                    {
69 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
70 787a4489 KangIngu
                    }
71
                    break;
72
                #endregion
73
74
                #region 잘라내기(Ctrl + X)
75
                case Key.X:
76
                    {
77 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
78 787a4489 KangIngu
                    }
79
                    break;
80
                #endregion
81
82
                #region 붙여넣기(Ctrl + V)
83
                case Key.V:
84
                    {
85 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
86 787a4489 KangIngu
                        {
87 b37ef4b3 humkyung
                            PasteCommand.Instance.Execute();
88 37b65344 humkyung
                        }
89 787a4489 KangIngu
                    }
90
                    break;
91
                #endregion
92
93
                #region 저장하기(Ctrl + S)
94
                case Key.S:
95
                    {
96 37b65344 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
97 787a4489 KangIngu
                        {
98
                            //컨트롤을 그리는 도중일 경우 컨트롤 삭제
99
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
100
                            this.dzMainMenu.currentControl = null;
101
102 316d0f5c KangIngu
                            //this.dzTopMenu.SaveEvent(null, null);
103 65eb8dd6 ljiyeon
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
104
                            {
105 cb5c7f06 humkyung
                                this.dzTopMenu.SaveEventCallback(new object(), null);
106 65eb8dd6 ljiyeon
                            }
107 6707a5c7 ljiyeon
108
                            //저장완료후 임시파일 삭제
109 a20d338f ljiyeon
                            TempFile.Remove();
110 37b65344 humkyung
                        }
111 787a4489 KangIngu
                    }
112
                    break;
113
                #endregion
114
115
                #region 프린트하기(Ctrl + P)
116
                case Key.P:
117
                    {
118
                        if (ViewerDataModel.Instance.IsPressCtrl)
119
                        {
120
                            this.dzTopMenu.Print_Start("Print");
121
                        }
122
                    }
123
                    break;
124
                #endregion
125
126
                #region Undo(Ctrl + Z)
127
                case Key.Z:
128
                    {
129 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
130 787a4489 KangIngu
                    }
131
                    break;
132
                #endregion
133
134
                #region Redo(Ctrl + Y)
135
                case Key.Y:
136
                    {
137 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
138 787a4489 KangIngu
                    }
139
                    break;
140
                #endregion
141
142
                #region 삭제하기(Delete)
143
                case Key.Delete:
144
                    {
145 d62c0439 humkyung
                        DeleteCommand.Instance.Execute(SelectionSet.Instance.SelectedItems);
146 f816dd63 humkyung
                        this.dzMainMenu.SelectLayer.Children.Clear();
147 787a4489 KangIngu
                    }
148
                    break;
149
                #endregion
150
151
                #region 선택된 컨트롤 모두 해제 하기(ESC)
152
                case Key.Escape:
153
                    {
154
                        //캡쳐모드 일 경우 초기화
155 37b65344 humkyung
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
156 787a4489 KangIngu
                        {
157
                            //dzMainMenu.PN_Navi.IsEnabled = true;
158
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
159
                            ViewerDataModel.Instance.Capture_Opacity = 0;
160
                        }
161
162 37b65344 humkyung
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
163 787a4489 KangIngu
                        {
164
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
165
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
166
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
167
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
168
                            foreach (var tog in TogList)
169
                            {
170
                                tog.IsChecked = false;
171
                            }
172
                        }
173
174 077896be humkyung
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
175 787a4489 KangIngu
176
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
177 49b217ad humkyung
                        if (this.dzMainMenu.currentControl != null)
178
                        {
179
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
180
                            this.dzMainMenu.currentControl = null;
181
                        }
182 787a4489 KangIngu
183 2eac4f76 KangIngu
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
184
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
185
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
186
187
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
188
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
189
190 17a22987 KangIngu
                        foreach (var item in toggleList)
191
                        {
192
                            if (item.Name == "btnSelection")
193 2eac4f76 KangIngu
                            {
194
                                item.IsChecked = true;
195
                            }
196 17a22987 KangIngu
                            else
197 2eac4f76 KangIngu
                            {
198
                                item.IsChecked = false;
199
                            }
200 17a22987 KangIngu
                        }
201 9f473fb7 KangIngu
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
202 17a22987 KangIngu
                        //foreach (var item in toggleList2)
203
                        //{
204
                        //    item.IsChecked = false;
205
                        //}
206 787a4489 KangIngu
                    }
207
                    break;
208 992a98b4 KangIngu
                #endregion
209
210
                #region FIND(Ctrl + F)
211
                case Key.F:
212
                    {
213 469b2bbf KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl)
214 992a98b4 KangIngu
                        {
215 469b2bbf KangIngu
                            if (!this.dzMainMenu.searchPane.IsPinned)
216 992a98b4 KangIngu
                            {
217 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = true;
218
                                if (ViewerDataModel.Instance.searchPDF != null)
219
                                {
220 8bd25583 taeseongkim
                                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
221
                                    {
222
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true;
223
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
224
                                        Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch);
225
                                    }), System.Windows.Threading.DispatcherPriority.Render);
226 469b2bbf KangIngu
                                }
227
                                else
228
                                {
229
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
230
                                }
231 992a98b4 KangIngu
                            }
232
                            else
233
                            {
234 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = false;
235
                                this.dzMainMenu.searchPane.IsActive = false;
236
                                //this.dzMainMenu.searchPane.IsHidden = true;
237 992a98b4 KangIngu
                            }
238
                        }
239
                    }
240
                    break;
241
                #endregion
242 787a4489 KangIngu
243
                #endregion
244
245
                //강인구 추가
246
                #region Control Move
247 5cbd5c21 djkim
                case Key.NumPad4:
248
                case Key.NumPad5:
249
                case Key.NumPad6:
250 37b65344 humkyung
                case Key.NumPad8:
251 d543f923 ljiyeon
                case Key.Right:
252
                case Key.Left:
253
                case Key.Up:
254
                case Key.Down:
255
                    {
256 91e84544 taeseongkim
                        if(sender is UIElement)
257
                        {
258
                            (sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false);
259
                        }
260
261 f87dfb18 taeseongkim
                        Point? MovePoint = null;
262
                        if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
263 d543f923 ljiyeon
                        {
264 f87dfb18 taeseongkim
                            MovePoint = new Point(0, 5);
265
                        }
266
                        else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
267
                        {
268
                            MovePoint = new Point(0, -5);
269
                        }
270
                        else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
271
                        {
272
                            MovePoint = new Point(-5, 0);
273
                        }
274
                        else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
275
                        {
276
                            MovePoint = new Point(5, 0);
277
                        }
278
279
                        if (MovePoint != null && MovePoint.HasValue)
280
                        {
281
                            if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift)
282 37b65344 humkyung
                            {
283 f87dfb18 taeseongkim
284
                                this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
285 37b65344 humkyung
                            }
286 f87dfb18 taeseongkim
                            else
287 37b65344 humkyung
                            {
288 91e84544 taeseongkim
                                //if (ViewerDataModel.Instance.IsPressCtrl)
289
                                //{
290 f87dfb18 taeseongkim
                                    bool IsMovePossibility = false;
291
292
                                    var instance = ViewerDataModel.Instance;
293
294
                                    if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
295
                                    {
296 f06cce07 taeseongkim
                                        if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
297 f87dfb18 taeseongkim
                                        {
298
                                            IsMovePossibility = true;
299
                                        }
300
                                    }
301
                                    else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
302
                                    {
303
                                        if (0 < instance.ContentOffsetY)
304
                                        {
305
                                            IsMovePossibility = true;
306
                                        }
307
                                    }
308
                                    else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
309
                                    {
310
                                        if (0 < instance.ContentOffsetX)
311
                                        {
312
                                            IsMovePossibility = true;
313
                                        }
314
                                    }
315
                                    else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
316
                                    {
317 f06cce07 taeseongkim
                                        if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth)
318 f87dfb18 taeseongkim
                                        {
319
                                            IsMovePossibility = true;
320
                                        }
321
                                    }
322
323
                                    if (IsMovePossibility)
324
                                    {
325
                                        Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10);
326
327
                                        this.dzMainMenu.MoveZoomAndPanControl(dragOffset);
328
329
                                        this.dzMainMenu.MainDocumentPanel.Focus();
330
331
                                        System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX);
332
                                    }
333 91e84544 taeseongkim
                                //}
334 37b65344 humkyung
                            }
335 d543f923 ljiyeon
                        }
336
                    }
337
                    break;
338 da92cfb7 ljiyeon
                #endregion
339
                case Key.PageUp:
340 2d584f1a djkim
                    
341 da92cfb7 ljiyeon
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
342
                    break;
343
                case Key.PageDown:
344
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
345
                    break;
346 787a4489 KangIngu
            }
347 91e84544 taeseongkim
            });
348 787a4489 KangIngu
        }
349
350 f87dfb18 taeseongkim
351 37b65344 humkyung
        /// <summary>
352
        /// translate or rotate items by given pt and angle
353
        /// </summary>
354
        /// <author>humkyung</author>
355
        /// <date>2019.07.03</date>
356
        /// <param name="pt">control point</param>
357
        /// <param name="dAngle">angle in degree</param>
358
        private void TranslateOrRotateItems(Point pt, double dAngle)
359
        {
360
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
361
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
362
            {
363
                if (item.GetType().Name == "AdornerFinal")
364
                {
365
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
366
                    {
367
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
368
                    }
369
                    else
370
                    {
371 6b6e937c taeseongkim
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
372 37b65344 humkyung
                    }
373
374
                }
375
            }
376
        }
377 787a4489 KangIngu
    }
378
}
클립보드 이미지 추가 (최대 크기: 500 MB)