프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ c4a8d205

이력 | 보기 | 이력해설 | 다운로드 (22.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 38d69491 taeseongkim
using MarkupToPDF.Controls.Text;
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 68302e9d taeseongkim
    public partial class MainWindow : KCOM.Controls.CustomizedWindow.CustomWindow
22 787a4489 KangIngu
    {
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 5a65e058 taeseongkim
                    //강인구 추가
34 787a4489 KangIngu
                #region 단축키 선택
35
36 872b94b9 taeseongkim
                case Key.I:
37 5a65e058 taeseongkim
                    {
38
                        if (ViewerDataModel.Instance.IsPressCtrl && ViewerDataModel.Instance.IsPressShift)
39
                        {
40 c206d293 taeseongkim
                                if (!ViewerDataModel.Instance.IsAdmin)
41 872b94b9 taeseongkim
                                {
42 c206d293 taeseongkim
                                    EventHandler<WindowClosedEventArgs> closeEventHandler = (snd, evt) =>
43
                                    {
44
                                        if (evt.PromptResult == "markus01#")
45
                                        {
46
                                            ViewerDataModel.Instance.IsAdmin = true;
47
                                        }
48
                                    };
49
50
                                    var parameters = new DialogParameters()
51
                                    {
52
                                        ContentStyle = (Style)this.FindResource("RadPasswordPromptStyle"),
53
                                        Content = "Enter password: ",
54
                                        Closed = closeEventHandler
55
                                    };
56
57
                                    RadWindow.Prompt(parameters);
58 872b94b9 taeseongkim
                                }
59
                                else
60
                                {
61
                                    ViewerDataModel.Instance.IsAdmin = false;
62
                                }
63
                            }
64 5a65e058 taeseongkim
                    }
65
                    break;
66
67
                    #region 전체 선택(Ctrl + A)
68 787a4489 KangIngu
                case Key.A:
69
                    {
70 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
71 787a4489 KangIngu
                        {
72 f959ea6f humkyung
                            this.dzMainMenu.ConvertInkControlToPolygon();
73 787a4489 KangIngu
74
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
75
                            {
76 92c9cab8 taeseongkim
                                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
77
                                if (text_item_ != null)
78
                                {
79 2a2e72c2 swate0609
                                    //2024-04-25 IRON
80
                                    //TextBox가 편집중일 때 Control + A (전체 선택) 하면 전체 텍스트가 선택되도록 수정. 
81
                                    return;
82 92c9cab8 taeseongkim
                                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
83
                                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
84 2a2e72c2 swate0609
                                    //(text_item_ as TextControl).UnEditingMode();
85 92c9cab8 taeseongkim
86 2a2e72c2 swate0609
                                    //SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
87
88
89
                                    //return;
90 92c9cab8 taeseongkim
                                }
91
92
                                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
93 c4a8d205 swate0609
                                //if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
94
                                if(Arrowtext_item_ != null)
95 92c9cab8 taeseongkim
                                {
96 8e924295 swate0609
                                    //2024-04-25 IRON
97
                                    //TextBox가 편집중일 때 Control + A (전체 선택) 하면 전체 텍스트가 선택되도록 수정. 
98
                                    return;
99
                                    //(Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
100
                                    //(Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
101
                                    //(Arrowtext_item_ as ArrowTextControl).UnEditingMode();
102 92c9cab8 taeseongkim
103 8e924295 swate0609
                                    //SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
104 92c9cab8 taeseongkim
                                }
105
106
                                    /// 전체 선택 시 선택된 토글 해제
107 787a4489 KangIngu
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
108
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
109
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
110
111 92c9cab8 taeseongkim
                                if (text_item_ == null && Arrowtext_item_ == null)
112
                                {
113
                                    /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
114
                                    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
115
                                }
116
117 787a4489 KangIngu
                                this.dzMainMenu.currentControl = null;
118
119
                                foreach (var tog in TogList)
120
                                {
121
                                    tog.IsChecked = false;
122
                                }
123 077896be humkyung
124 b37ef4b3 humkyung
                                SelectionSet.Instance.SelectAll();
125 787a4489 KangIngu
                            }
126
                        }
127
                    }
128
                    break;
129
                #endregion
130
131
                #region 복사하기(Ctrl + C)
132
                case Key.C:
133
                    {
134 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
135 787a4489 KangIngu
                    }
136
                    break;
137
                #endregion
138
139
                #region 잘라내기(Ctrl + X)
140
                case Key.X:
141
                    {
142 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
143 787a4489 KangIngu
                    }
144
                    break;
145
                #endregion
146
147
                #region 붙여넣기(Ctrl + V)
148
                case Key.V:
149
                    {
150 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
151 787a4489 KangIngu
                        {
152 b37ef4b3 humkyung
                            PasteCommand.Instance.Execute();
153 37b65344 humkyung
                        }
154 787a4489 KangIngu
                    }
155
                    break;
156
                #endregion
157
158
                #region 저장하기(Ctrl + S)
159
                case Key.S:
160
                    {
161 37b65344 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
162 787a4489 KangIngu
                        {
163 38d69491 taeseongkim
                            var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
164
                            if (text_item_ != null)
165
                            {
166
                                (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
167
                                (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
168
                                (text_item_ as TextControl).UnEditingMode();
169
170
                                SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
171
                            }
172
173
                            var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
174
                            if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
175
                            {
176
                                (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
177
                                (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
178
                                (Arrowtext_item_ as ArrowTextControl).UnEditingMode();
179
180
                                SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
181
                            }
182
183
                            if (text_item_ == null && Arrowtext_item_ == null)
184
                            {                                 //컨트롤을 그리는 도중일 경우 컨트롤 삭제
185
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
186
                            }
187
188 787a4489 KangIngu
                            this.dzMainMenu.currentControl = null;
189
190 316d0f5c KangIngu
                            //this.dzTopMenu.SaveEvent(null, null);
191 65eb8dd6 ljiyeon
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
192
                            {
193 5ba8f2d5 taeseongkim
                                ViewerDataModel.Instance.IsMarkupUpdate = true;
194 cb5c7f06 humkyung
                                this.dzTopMenu.SaveEventCallback(new object(), null);
195 65eb8dd6 ljiyeon
                            }
196 6707a5c7 ljiyeon
197
                            //저장완료후 임시파일 삭제
198 2b1f30fe taeseongkim
                            //TempFile.Remove();
199 37b65344 humkyung
                        }
200 787a4489 KangIngu
                    }
201
                    break;
202
                #endregion
203
204
                #region 프린트하기(Ctrl + P)
205
                case Key.P:
206
                    {
207
                        if (ViewerDataModel.Instance.IsPressCtrl)
208
                        {
209
                            this.dzTopMenu.Print_Start("Print");
210
                        }
211
                    }
212
                    break;
213
                #endregion
214
215
                #region Undo(Ctrl + Z)
216
                case Key.Z:
217
                    {
218 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
219 787a4489 KangIngu
                    }
220
                    break;
221
                #endregion
222
223
                #region Redo(Ctrl + Y)
224
                case Key.Y:
225
                    {
226 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
227 787a4489 KangIngu
                    }
228
                    break;
229
                #endregion
230
231
                #region 삭제하기(Delete)
232
                case Key.Delete:
233
                    {
234 8e6884a5 taeseongkim
                        List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems;
235
                        SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
236 f816dd63 humkyung
                        this.dzMainMenu.SelectLayer.Children.Clear();
237 8e6884a5 taeseongkim
238
                        DeleteCommand.Instance.Execute(selectItems);
239 787a4489 KangIngu
                    }
240
                    break;
241
                #endregion
242
243
                #region 선택된 컨트롤 모두 해제 하기(ESC)
244
                case Key.Escape:
245
                    {
246
                        //캡쳐모드 일 경우 초기화
247 37b65344 humkyung
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
248 787a4489 KangIngu
                        {
249
                            //dzMainMenu.PN_Navi.IsEnabled = true;
250
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
251
                            ViewerDataModel.Instance.Capture_Opacity = 0;
252
                        }
253
254 b74a9c91 taeseongkim
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
255
                                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
256 787a4489 KangIngu
                        {
257
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
258
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
259
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
260
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
261
                            foreach (var tog in TogList)
262
                            {
263
                                tog.IsChecked = false;
264
                            }
265
                        }
266
267 077896be humkyung
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
268 787a4489 KangIngu
269
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
270 49b217ad humkyung
                        if (this.dzMainMenu.currentControl != null)
271
                        {
272
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
273
                            this.dzMainMenu.currentControl = null;
274
                        }
275 787a4489 KangIngu
276 2eac4f76 KangIngu
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
277
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
278
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
279
280
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
281
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
282
283 17a22987 KangIngu
                        foreach (var item in toggleList)
284
                        {
285
                            if (item.Name == "btnSelection")
286 2eac4f76 KangIngu
                            {
287
                                item.IsChecked = true;
288
                            }
289 17a22987 KangIngu
                            else
290 2eac4f76 KangIngu
                            {
291
                                item.IsChecked = false;
292
                            }
293 17a22987 KangIngu
                        }
294 9f473fb7 KangIngu
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
295 b643fcca taeseongkim
                            //foreach (var item in toggleList2)
296
                            //{
297
                            //    item.IsChecked = false;
298
                            //}
299
                            ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
300 787a4489 KangIngu
                    }
301
                    break;
302 992a98b4 KangIngu
                #endregion
303
304
                #region FIND(Ctrl + F)
305
                case Key.F:
306
                    {
307 469b2bbf KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl)
308 992a98b4 KangIngu
                        {
309 469b2bbf KangIngu
                            if (!this.dzMainMenu.searchPane.IsPinned)
310 992a98b4 KangIngu
                            {
311 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = true;
312
                                if (ViewerDataModel.Instance.searchPDF != null)
313
                                {
314 8bd25583 taeseongkim
                                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
315
                                    {
316
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true;
317
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
318
                                        Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch);
319
                                    }), System.Windows.Threading.DispatcherPriority.Render);
320 469b2bbf KangIngu
                                }
321
                                else
322
                                {
323
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
324
                                }
325 992a98b4 KangIngu
                            }
326
                            else
327
                            {
328 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = false;
329
                                this.dzMainMenu.searchPane.IsActive = false;
330
                                //this.dzMainMenu.searchPane.IsHidden = true;
331 992a98b4 KangIngu
                            }
332
                        }
333
                    }
334
                    break;
335
                #endregion
336 787a4489 KangIngu
337
                #endregion
338
339
                //강인구 추가
340
                #region Control Move
341 1edefbdf taeseongkim
                //case Key.NumPad4:
342
                //case Key.NumPad5:
343
                //case Key.NumPad6:
344
                //case Key.NumPad8:
345 d543f923 ljiyeon
                case Key.Right:
346
                case Key.Left:
347
                case Key.Up:
348
                case Key.Down:
349
                    {
350 d60f94ee taeseongkim
						if(System.Windows.Input.Keyboard.FocusedElement is System.Windows.Controls.TextBox)
351
						{
352
							return;
353
						}
354
						
355 91e84544 taeseongkim
                        if(sender is UIElement)
356
                        {
357
                            (sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false);
358
                        }
359
360 f87dfb18 taeseongkim
                        Point? MovePoint = null;
361
                        if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
362 d543f923 ljiyeon
                        {
363 f87dfb18 taeseongkim
                            MovePoint = new Point(0, 5);
364
                        }
365
                        else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
366
                        {
367
                            MovePoint = new Point(0, -5);
368
                        }
369
                        else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
370
                        {
371
                            MovePoint = new Point(-5, 0);
372
                        }
373
                        else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
374
                        {
375
                            MovePoint = new Point(5, 0);
376
                        }
377
378
                        if (MovePoint != null && MovePoint.HasValue)
379
                        {
380
                            if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift)
381 37b65344 humkyung
                            {
382 f87dfb18 taeseongkim
383
                                this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
384 37b65344 humkyung
                            }
385 f87dfb18 taeseongkim
                            else
386 37b65344 humkyung
                            {
387 91e84544 taeseongkim
                                //if (ViewerDataModel.Instance.IsPressCtrl)
388
                                //{
389 f87dfb18 taeseongkim
                                    bool IsMovePossibility = false;
390
391
                                    var instance = ViewerDataModel.Instance;
392
393
                                    if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
394
                                    {
395 f06cce07 taeseongkim
                                        if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
396 f87dfb18 taeseongkim
                                        {
397
                                            IsMovePossibility = true;
398
                                        }
399
                                    }
400
                                    else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
401
                                    {
402
                                        if (0 < instance.ContentOffsetY)
403
                                        {
404
                                            IsMovePossibility = true;
405
                                        }
406
                                    }
407
                                    else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
408
                                    {
409
                                        if (0 < instance.ContentOffsetX)
410
                                        {
411
                                            IsMovePossibility = true;
412
                                        }
413
                                    }
414
                                    else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
415
                                    {
416 f06cce07 taeseongkim
                                        if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth)
417 f87dfb18 taeseongkim
                                        {
418
                                            IsMovePossibility = true;
419
                                        }
420
                                    }
421
422
                                    if (IsMovePossibility)
423
                                    {
424
                                        Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10);
425
426
                                        this.dzMainMenu.MoveZoomAndPanControl(dragOffset);
427
428
                                        this.dzMainMenu.MainDocumentPanel.Focus();
429
430
                                        System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX);
431
                                    }
432 91e84544 taeseongkim
                                //}
433 37b65344 humkyung
                            }
434 d543f923 ljiyeon
                        }
435
                    }
436
                    break;
437 da92cfb7 ljiyeon
                #endregion
438
                case Key.PageUp:
439 2d584f1a djkim
                    
440 da92cfb7 ljiyeon
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
441
                    break;
442
                case Key.PageDown:
443
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
444
                    break;
445 787a4489 KangIngu
            }
446 91e84544 taeseongkim
            });
447 787a4489 KangIngu
        }
448
449 f87dfb18 taeseongkim
450 37b65344 humkyung
        /// <summary>
451
        /// translate or rotate items by given pt and angle
452
        /// </summary>
453
        /// <author>humkyung</author>
454
        /// <date>2019.07.03</date>
455
        /// <param name="pt">control point</param>
456
        /// <param name="dAngle">angle in degree</param>
457
        private void TranslateOrRotateItems(Point pt, double dAngle)
458
        {
459
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
460
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
461
            {
462
                if (item.GetType().Name == "AdornerFinal")
463
                {
464
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
465
                    {
466
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
467
                    }
468
                    else
469
                    {
470 6b6e937c taeseongkim
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
471 37b65344 humkyung
                    }
472
473
                }
474
            }
475
        }
476 787a4489 KangIngu
    }
477
}
클립보드 이미지 추가 (최대 크기: 500 MB)