프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ c206d293

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

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Parsing;
5
using Svg2Xaml;
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
                                /// 전체 선택 시 선택된 토글 해제
77
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
78
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
79
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
80

    
81
                                /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
82
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
83
                                this.dzMainMenu.currentControl = null;
84

    
85
                                foreach (var tog in TogList)
86
                                {
87
                                    tog.IsChecked = false;
88
                                }
89

    
90
                                SelectionSet.Instance.SelectAll();
91
                            }
92
                        }
93
                    }
94
                    break;
95
                #endregion
96

    
97
                #region 복사하기(Ctrl + C)
98
                case Key.C:
99
                    {
100
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
101
                    }
102
                    break;
103
                #endregion
104

    
105
                #region 잘라내기(Ctrl + X)
106
                case Key.X:
107
                    {
108
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
109
                    }
110
                    break;
111
                #endregion
112

    
113
                #region 붙여넣기(Ctrl + V)
114
                case Key.V:
115
                    {
116
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
117
                        {
118
                            PasteCommand.Instance.Execute();
119
                        }
120
                    }
121
                    break;
122
                #endregion
123

    
124
                #region 저장하기(Ctrl + S)
125
                case Key.S:
126
                    {
127
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
128
                        {
129
                            //컨트롤을 그리는 도중일 경우 컨트롤 삭제
130
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
131
                            this.dzMainMenu.currentControl = null;
132

    
133
                            //this.dzTopMenu.SaveEvent(null, null);
134
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
135
                            {
136
                                this.dzTopMenu.SaveEventCallback(new object(), null);
137
                            }
138

    
139
                            //저장완료후 임시파일 삭제
140
                            TempFile.Remove();
141
                        }
142
                    }
143
                    break;
144
                #endregion
145

    
146
                #region 프린트하기(Ctrl + P)
147
                case Key.P:
148
                    {
149
                        if (ViewerDataModel.Instance.IsPressCtrl)
150
                        {
151
                            this.dzTopMenu.Print_Start("Print");
152
                        }
153
                    }
154
                    break;
155
                #endregion
156

    
157
                #region Undo(Ctrl + Z)
158
                case Key.Z:
159
                    {
160
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
161
                    }
162
                    break;
163
                #endregion
164

    
165
                #region Redo(Ctrl + Y)
166
                case Key.Y:
167
                    {
168
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
169
                    }
170
                    break;
171
                #endregion
172

    
173
                #region 삭제하기(Delete)
174
                case Key.Delete:
175
                    {
176
                        List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems;
177
                        SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
178
                        this.dzMainMenu.SelectLayer.Children.Clear();
179

    
180
                        DeleteCommand.Instance.Execute(selectItems);
181
                    }
182
                    break;
183
                #endregion
184

    
185
                #region 선택된 컨트롤 모두 해제 하기(ESC)
186
                case Key.Escape:
187
                    {
188
                        //캡쳐모드 일 경우 초기화
189
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
190
                        {
191
                            //dzMainMenu.PN_Navi.IsEnabled = true;
192
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
193
                            ViewerDataModel.Instance.Capture_Opacity = 0;
194
                        }
195

    
196
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
197
                        {
198
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
199
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
200
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
201
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
202
                            foreach (var tog in TogList)
203
                            {
204
                                tog.IsChecked = false;
205
                            }
206
                        }
207

    
208
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
209

    
210
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
211
                        if (this.dzMainMenu.currentControl != null)
212
                        {
213
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
214
                            this.dzMainMenu.currentControl = null;
215
                        }
216

    
217
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
218
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
219
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
220

    
221
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
222
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
223

    
224
                        foreach (var item in toggleList)
225
                        {
226
                            if (item.Name == "btnSelection")
227
                            {
228
                                item.IsChecked = true;
229
                            }
230
                            else
231
                            {
232
                                item.IsChecked = false;
233
                            }
234
                        }
235
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
236
                            //foreach (var item in toggleList2)
237
                            //{
238
                            //    item.IsChecked = false;
239
                            //}
240
                            ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
241
                    }
242
                    break;
243
                #endregion
244

    
245
                #region FIND(Ctrl + F)
246
                case Key.F:
247
                    {
248
                        if (ViewerDataModel.Instance.IsPressCtrl)
249
                        {
250
                            if (!this.dzMainMenu.searchPane.IsPinned)
251
                            {
252
                                this.dzMainMenu.searchPane.IsPinned = true;
253
                                if (ViewerDataModel.Instance.searchPDF != null)
254
                                {
255
                                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
256
                                    {
257
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true;
258
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
259
                                        Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch);
260
                                    }), System.Windows.Threading.DispatcherPriority.Render);
261
                                }
262
                                else
263
                                {
264
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
265
                                }
266
                            }
267
                            else
268
                            {
269
                                this.dzMainMenu.searchPane.IsPinned = false;
270
                                this.dzMainMenu.searchPane.IsActive = false;
271
                                //this.dzMainMenu.searchPane.IsHidden = true;
272
                            }
273
                        }
274
                    }
275
                    break;
276
                #endregion
277

    
278
                #endregion
279

    
280
                //강인구 추가
281
                #region Control Move
282
                case Key.NumPad4:
283
                case Key.NumPad5:
284
                case Key.NumPad6:
285
                case Key.NumPad8:
286
                case Key.Right:
287
                case Key.Left:
288
                case Key.Up:
289
                case Key.Down:
290
                    {
291
                        if(sender is UIElement)
292
                        {
293
                            (sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false);
294
                        }
295

    
296
                        Point? MovePoint = null;
297
                        if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
298
                        {
299
                            MovePoint = new Point(0, 5);
300
                        }
301
                        else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
302
                        {
303
                            MovePoint = new Point(0, -5);
304
                        }
305
                        else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
306
                        {
307
                            MovePoint = new Point(-5, 0);
308
                        }
309
                        else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
310
                        {
311
                            MovePoint = new Point(5, 0);
312
                        }
313

    
314
                        if (MovePoint != null && MovePoint.HasValue)
315
                        {
316
                            if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift)
317
                            {
318

    
319
                                this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
320
                            }
321
                            else
322
                            {
323
                                //if (ViewerDataModel.Instance.IsPressCtrl)
324
                                //{
325
                                    bool IsMovePossibility = false;
326

    
327
                                    var instance = ViewerDataModel.Instance;
328

    
329
                                    if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
330
                                    {
331
                                        if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
332
                                        {
333
                                            IsMovePossibility = true;
334
                                        }
335
                                    }
336
                                    else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
337
                                    {
338
                                        if (0 < instance.ContentOffsetY)
339
                                        {
340
                                            IsMovePossibility = true;
341
                                        }
342
                                    }
343
                                    else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
344
                                    {
345
                                        if (0 < instance.ContentOffsetX)
346
                                        {
347
                                            IsMovePossibility = true;
348
                                        }
349
                                    }
350
                                    else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
351
                                    {
352
                                        if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth)
353
                                        {
354
                                            IsMovePossibility = true;
355
                                        }
356
                                    }
357

    
358
                                    if (IsMovePossibility)
359
                                    {
360
                                        Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10);
361

    
362
                                        this.dzMainMenu.MoveZoomAndPanControl(dragOffset);
363

    
364
                                        this.dzMainMenu.MainDocumentPanel.Focus();
365

    
366
                                        System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX);
367
                                    }
368
                                //}
369
                            }
370
                        }
371
                    }
372
                    break;
373
                #endregion
374
                case Key.PageUp:
375
                    
376
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
377
                    break;
378
                case Key.PageDown:
379
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
380
                    break;
381
            }
382
            });
383
        }
384

    
385

    
386
        /// <summary>
387
        /// translate or rotate items by given pt and angle
388
        /// </summary>
389
        /// <author>humkyung</author>
390
        /// <date>2019.07.03</date>
391
        /// <param name="pt">control point</param>
392
        /// <param name="dAngle">angle in degree</param>
393
        private void TranslateOrRotateItems(Point pt, double dAngle)
394
        {
395
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
396
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
397
            {
398
                if (item.GetType().Name == "AdornerFinal")
399
                {
400
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
401
                    {
402
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
403
                    }
404
                    else
405
                    {
406
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
407
                    }
408

    
409
                }
410
            }
411
        }
412
    }
413
}
클립보드 이미지 추가 (최대 크기: 500 MB)