프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (13 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 : Window
22
    {
23
        public double CumulativeWheel = 0;
24
        MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
25
                
26
        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
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
37
                        {
38
                            this.dzMainMenu.ConvertInkControlToPolygon();
39

    
40
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
41
                            {
42
                                /// 전체 선택 시 선택된 토글 해제
43
                                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
                                /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
48
                                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

    
56
                                SelectionSet.Instance.SelectAll();
57
                            }
58
                        }
59
                    }
60
                    break;
61
                #endregion
62

    
63
                #region 복사하기(Ctrl + C)
64
                case Key.C:
65
                    {
66
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
67
                    }
68
                    break;
69
                #endregion
70

    
71
                #region 잘라내기(Ctrl + X)
72
                case Key.X:
73
                    {
74
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
75
                    }
76
                    break;
77
                #endregion
78

    
79
                #region 붙여넣기(Ctrl + V)
80
                case Key.V:
81
                    {
82
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
83
                        {
84
                            PasteCommand.Instance.Execute();
85
                        }
86
                    }
87
                    break;
88
                #endregion
89

    
90
                #region 저장하기(Ctrl + S)
91
                case Key.S:
92
                    {
93
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
94
                        {
95
                            //컨트롤을 그리는 도중일 경우 컨트롤 삭제
96
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
97
                            this.dzMainMenu.currentControl = null;
98

    
99
                            //this.dzTopMenu.SaveEvent(null, null);
100
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
101
                            {
102
                                this.dzTopMenu.SaveEventCallback(new object(), null);
103
                            }
104

    
105
                            //저장완료후 임시파일 삭제
106
                            TempFile.Remove();
107
                        }
108
                    }
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
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
127
                    }
128
                    break;
129
                #endregion
130

    
131
                #region Redo(Ctrl + Y)
132
                case Key.Y:
133
                    {
134
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
135
                    }
136
                    break;
137
                #endregion
138

    
139
                #region 삭제하기(Delete)
140
                case Key.Delete:
141
                    {
142
                        DeleteCommand.Instance.Execute(SelectionSet.Instance.SelectedItems);
143
                        this.dzMainMenu.SelectLayer.Children.Clear();
144
                    }
145
                    break;
146
                #endregion
147

    
148
                #region 선택된 컨트롤 모두 해제 하기(ESC)
149
                case Key.Escape:
150
                    {
151
                        //캡쳐모드 일 경우 초기화
152
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
153
                        {
154
                            //dzMainMenu.PN_Navi.IsEnabled = true;
155
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
156
                            ViewerDataModel.Instance.Capture_Opacity = 0;
157
                        }
158

    
159
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
160
                        {
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
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
172

    
173
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
174
                        if (this.dzMainMenu.currentControl != null)
175
                        {
176
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
177
                            this.dzMainMenu.currentControl = null;
178
                        }
179

    
180
                        //모든 컨트롤 초기화 하고 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
                        foreach (var item in toggleList)
188
                        {
189
                            if (item.Name == "btnSelection")
190
                            {
191
                                item.IsChecked = true;
192
                            }
193
                            else
194
                            {
195
                                item.IsChecked = false;
196
                            }
197
                        }
198
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
199
                        //foreach (var item in toggleList2)
200
                        //{
201
                        //    item.IsChecked = false;
202
                        //}
203
                    }
204
                    break;
205
                #endregion
206

    
207
                #region FIND(Ctrl + F)
208
                case Key.F:
209
                    {
210
                        if (ViewerDataModel.Instance.IsPressCtrl)
211
                        {
212
                            if (!this.dzMainMenu.searchPane.IsPinned)
213
                            {
214
                                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
                            }
224
                            else
225
                            {
226
                                this.dzMainMenu.searchPane.IsPinned = false;
227
                                this.dzMainMenu.searchPane.IsActive = false;
228
                                //this.dzMainMenu.searchPane.IsHidden = true;
229
                            }
230
                        }
231
                    }
232
                    break;
233
                #endregion
234

    
235
                #endregion
236

    
237
                //강인구 추가
238
                #region Control Move
239
                case Key.NumPad4:
240
                case Key.NumPad5:
241
                case Key.NumPad6:
242
                case Key.NumPad8:
243
                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
                            Point? control = null;
251
                            if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad5)) || (e.Key == Key.Down))
252
                            {
253
                                control = new Point(0, 5);
254
                            }
255
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad8)) || (e.Key == Key.Up))
256
                            {
257
                                control = new Point(0, -5);
258
                            }
259
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad4)) || (e.Key == Key.Left))
260
                            {
261
                                control = new Point(-5, 0);
262
                            }
263
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad6)) || (e.Key == Key.Right))
264
                            {
265
                                control = new Point(5, 0);
266
                            }
267
                            if(control != null && control.HasValue) this.TranslateOrRotateItems(control.Value, this.dzMainMenu.rotate.Angle);
268
                        }
269
                    }
270
                    break;
271
                #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
            }
279
        }
280

    
281
        /// <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
    }
308
}
클립보드 이미지 추가 (최대 크기: 500 MB)