프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ c4a8d205

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

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Parsing;
5
using MarkupToPDF.Controls.Text;
6
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
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16
using Telerik.Windows.Controls;
17
//using static KCOM.Views.MainMenu;
18

    
19
namespace KCOM
20
{
21
    public partial class MainWindow : KCOM.Controls.CustomizedWindow.CustomWindow
22
    {
23
        public double CumulativeWheel = 0;
24
        MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
25
                
26
        public async void KeyEventDownAction(object sender, KeyEventArgs e)
27
        {
28
            //if (e.IsRepeat && !ViewerDataModel.Instance.IsPressCtrl && !ViewerDataModel.Instance.IsPressShift)
29
            //    return;
30
            await this.Dispatcher.InvokeAsync(() => {
31
            switch (e.Key)
32
            {
33
                    //강인구 추가
34
                #region 단축키 선택
35

    
36
                case Key.I:
37
                    {
38
                        if (ViewerDataModel.Instance.IsPressCtrl && ViewerDataModel.Instance.IsPressShift)
39
                        {
40
                                if (!ViewerDataModel.Instance.IsAdmin)
41
                                {
42
                                    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
                                }
59
                                else
60
                                {
61
                                    ViewerDataModel.Instance.IsAdmin = false;
62
                                }
63
                            }
64
                    }
65
                    break;
66

    
67
                    #region 전체 선택(Ctrl + A)
68
                case Key.A:
69
                    {
70
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
71
                        {
72
                            this.dzMainMenu.ConvertInkControlToPolygon();
73

    
74
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
75
                            {
76
                                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
                                    //2024-04-25 IRON
80
                                    //TextBox가 편집중일 때 Control + A (전체 선택) 하면 전체 텍스트가 선택되도록 수정. 
81
                                    return;
82
                                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
83
                                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
84
                                    //(text_item_ as TextControl).UnEditingMode();
85

    
86
                                    //SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
87

    
88

    
89
                                    //return;
90
                                }
91

    
92
                                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
93
                                //if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
94
                                if(Arrowtext_item_ != null)
95
                                {
96
                                    //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

    
103
                                    //SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
104
                                }
105

    
106
                                    /// 전체 선택 시 선택된 토글 해제
107
                                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
                                if (text_item_ == null && Arrowtext_item_ == null)
112
                                {
113
                                    /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
114
                                    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
115
                                }
116

    
117
                                this.dzMainMenu.currentControl = null;
118

    
119
                                foreach (var tog in TogList)
120
                                {
121
                                    tog.IsChecked = false;
122
                                }
123

    
124
                                SelectionSet.Instance.SelectAll();
125
                            }
126
                        }
127
                    }
128
                    break;
129
                #endregion
130

    
131
                #region 복사하기(Ctrl + C)
132
                case Key.C:
133
                    {
134
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
135
                    }
136
                    break;
137
                #endregion
138

    
139
                #region 잘라내기(Ctrl + X)
140
                case Key.X:
141
                    {
142
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
143
                    }
144
                    break;
145
                #endregion
146

    
147
                #region 붙여넣기(Ctrl + V)
148
                case Key.V:
149
                    {
150
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
151
                        {
152
                            PasteCommand.Instance.Execute();
153
                        }
154
                    }
155
                    break;
156
                #endregion
157

    
158
                #region 저장하기(Ctrl + S)
159
                case Key.S:
160
                    {
161
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
162
                        {
163
                            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
                            this.dzMainMenu.currentControl = null;
189

    
190
                            //this.dzTopMenu.SaveEvent(null, null);
191
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
192
                            {
193
                                ViewerDataModel.Instance.IsMarkupUpdate = true;
194
                                this.dzTopMenu.SaveEventCallback(new object(), null);
195
                            }
196

    
197
                            //저장완료후 임시파일 삭제
198
                            //TempFile.Remove();
199
                        }
200
                    }
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
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
219
                    }
220
                    break;
221
                #endregion
222

    
223
                #region Redo(Ctrl + Y)
224
                case Key.Y:
225
                    {
226
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
227
                    }
228
                    break;
229
                #endregion
230

    
231
                #region 삭제하기(Delete)
232
                case Key.Delete:
233
                    {
234
                        List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems;
235
                        SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
236
                        this.dzMainMenu.SelectLayer.Children.Clear();
237

    
238
                        DeleteCommand.Instance.Execute(selectItems);
239
                    }
240
                    break;
241
                #endregion
242

    
243
                #region 선택된 컨트롤 모두 해제 하기(ESC)
244
                case Key.Escape:
245
                    {
246
                        //캡쳐모드 일 경우 초기화
247
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
248
                        {
249
                            //dzMainMenu.PN_Navi.IsEnabled = true;
250
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
251
                            ViewerDataModel.Instance.Capture_Opacity = 0;
252
                        }
253

    
254
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
255
                                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
256
                        {
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
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
268

    
269
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
270
                        if (this.dzMainMenu.currentControl != null)
271
                        {
272
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
273
                            this.dzMainMenu.currentControl = null;
274
                        }
275

    
276
                        //모든 컨트롤 초기화 하고 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
                        foreach (var item in toggleList)
284
                        {
285
                            if (item.Name == "btnSelection")
286
                            {
287
                                item.IsChecked = true;
288
                            }
289
                            else
290
                            {
291
                                item.IsChecked = false;
292
                            }
293
                        }
294
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
295
                            //foreach (var item in toggleList2)
296
                            //{
297
                            //    item.IsChecked = false;
298
                            //}
299
                            ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
300
                    }
301
                    break;
302
                #endregion
303

    
304
                #region FIND(Ctrl + F)
305
                case Key.F:
306
                    {
307
                        if (ViewerDataModel.Instance.IsPressCtrl)
308
                        {
309
                            if (!this.dzMainMenu.searchPane.IsPinned)
310
                            {
311
                                this.dzMainMenu.searchPane.IsPinned = true;
312
                                if (ViewerDataModel.Instance.searchPDF != null)
313
                                {
314
                                    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
                                }
321
                                else
322
                                {
323
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
324
                                }
325
                            }
326
                            else
327
                            {
328
                                this.dzMainMenu.searchPane.IsPinned = false;
329
                                this.dzMainMenu.searchPane.IsActive = false;
330
                                //this.dzMainMenu.searchPane.IsHidden = true;
331
                            }
332
                        }
333
                    }
334
                    break;
335
                #endregion
336

    
337
                #endregion
338

    
339
                //강인구 추가
340
                #region Control Move
341
                //case Key.NumPad4:
342
                //case Key.NumPad5:
343
                //case Key.NumPad6:
344
                //case Key.NumPad8:
345
                case Key.Right:
346
                case Key.Left:
347
                case Key.Up:
348
                case Key.Down:
349
                    {
350
						if(System.Windows.Input.Keyboard.FocusedElement is System.Windows.Controls.TextBox)
351
						{
352
							return;
353
						}
354
						
355
                        if(sender is UIElement)
356
                        {
357
                            (sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false);
358
                        }
359

    
360
                        Point? MovePoint = null;
361
                        if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
362
                        {
363
                            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
                            {
382

    
383
                                this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
384
                            }
385
                            else
386
                            {
387
                                //if (ViewerDataModel.Instance.IsPressCtrl)
388
                                //{
389
                                    bool IsMovePossibility = false;
390

    
391
                                    var instance = ViewerDataModel.Instance;
392

    
393
                                    if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
394
                                    {
395
                                        if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
396
                                        {
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
                                        if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth)
417
                                        {
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
                                //}
433
                            }
434
                        }
435
                    }
436
                    break;
437
                #endregion
438
                case Key.PageUp:
439
                    
440
                    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
            }
446
            });
447
        }
448

    
449

    
450
        /// <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
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
471
                    }
472

    
473
                }
474
            }
475
        }
476
    }
477
}
클립보드 이미지 추가 (최대 크기: 500 MB)