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