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