markus / KCOM / Events / Event_KeyEvent.cs @ 5ba8f2d5
이력 | 보기 | 이력해설 | 다운로드 (18.4 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 |
ViewerDataModel.Instance.IsMarkupUpdate = true; |
137 |
this.dzTopMenu.SaveEventCallback(new object(), null); |
138 |
} |
139 |
|
140 |
//저장완료후 임시파일 삭제 |
141 |
TempFile.Remove(); |
142 |
} |
143 |
} |
144 |
break; |
145 |
#endregion |
146 |
|
147 |
#region 프린트하기(Ctrl + P) |
148 |
case Key.P: |
149 |
{ |
150 |
if (ViewerDataModel.Instance.IsPressCtrl) |
151 |
{ |
152 |
this.dzTopMenu.Print_Start("Print"); |
153 |
} |
154 |
} |
155 |
break; |
156 |
#endregion |
157 |
|
158 |
#region Undo(Ctrl + Z) |
159 |
case Key.Z: |
160 |
{ |
161 |
if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute(); |
162 |
} |
163 |
break; |
164 |
#endregion |
165 |
|
166 |
#region Redo(Ctrl + Y) |
167 |
case Key.Y: |
168 |
{ |
169 |
if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute(); |
170 |
} |
171 |
break; |
172 |
#endregion |
173 |
|
174 |
#region 삭제하기(Delete) |
175 |
case Key.Delete: |
176 |
{ |
177 |
List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems; |
178 |
SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
179 |
this.dzMainMenu.SelectLayer.Children.Clear(); |
180 |
|
181 |
DeleteCommand.Instance.Execute(selectItems); |
182 |
} |
183 |
break; |
184 |
#endregion |
185 |
|
186 |
#region 선택된 컨트롤 모두 해제 하기(ESC) |
187 |
case Key.Escape: |
188 |
{ |
189 |
//캡쳐모드 일 경우 초기화 |
190 |
if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture) |
191 |
{ |
192 |
//dzMainMenu.PN_Navi.IsEnabled = true; |
193 |
this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
194 |
ViewerDataModel.Instance.Capture_Opacity = 0; |
195 |
} |
196 |
|
197 |
if (Common.ViewerDataModel.Instance.SelectedControl == "Batch" |
198 |
|| Common.ViewerDataModel.Instance.SelectedControl == "MACRO") |
199 |
{ |
200 |
this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None; |
201 |
this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed; |
202 |
this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
203 |
var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>(); |
204 |
foreach (var tog in TogList) |
205 |
{ |
206 |
tog.IsChecked = false; |
207 |
} |
208 |
} |
209 |
|
210 |
SelectionSet.Instance.UnSelect(this.dzMainMenu); |
211 |
|
212 |
//코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화 |
213 |
if (this.dzMainMenu.currentControl != null) |
214 |
{ |
215 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl); |
216 |
this.dzMainMenu.currentControl = null; |
217 |
} |
218 |
|
219 |
//모든 컨트롤 초기화 하고 Selection모드로 변경 |
220 |
dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting; |
221 |
dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None; |
222 |
|
223 |
var toggleList = this.ChildrenOfType<RadToggleButton>(); |
224 |
var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>(); |
225 |
|
226 |
foreach (var item in toggleList) |
227 |
{ |
228 |
if (item.Name == "btnSelection") |
229 |
{ |
230 |
item.IsChecked = true; |
231 |
} |
232 |
else |
233 |
{ |
234 |
item.IsChecked = false; |
235 |
} |
236 |
} |
237 |
dzMainMenu.isLeftMouseButtonDownOnWindow = false; |
238 |
//foreach (var item in toggleList2) |
239 |
//{ |
240 |
// item.IsChecked = false; |
241 |
//} |
242 |
ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed); |
243 |
} |
244 |
break; |
245 |
#endregion |
246 |
|
247 |
#region FIND(Ctrl + F) |
248 |
case Key.F: |
249 |
{ |
250 |
if (ViewerDataModel.Instance.IsPressCtrl) |
251 |
{ |
252 |
if (!this.dzMainMenu.searchPane.IsPinned) |
253 |
{ |
254 |
this.dzMainMenu.searchPane.IsPinned = true; |
255 |
if (ViewerDataModel.Instance.searchPDF != null) |
256 |
{ |
257 |
Application.Current.Dispatcher.BeginInvoke(new Action(() => |
258 |
{ |
259 |
this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true; |
260 |
this.dzMainMenu.searchPanel_Instance.tbSearch.Focus(); |
261 |
Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch); |
262 |
}), System.Windows.Threading.DispatcherPriority.Render); |
263 |
} |
264 |
else |
265 |
{ |
266 |
this.dzMainMenu.searchPanel_Instance.btnSearch.Focus(); |
267 |
} |
268 |
} |
269 |
else |
270 |
{ |
271 |
this.dzMainMenu.searchPane.IsPinned = false; |
272 |
this.dzMainMenu.searchPane.IsActive = false; |
273 |
//this.dzMainMenu.searchPane.IsHidden = true; |
274 |
} |
275 |
} |
276 |
} |
277 |
break; |
278 |
#endregion |
279 |
|
280 |
#endregion |
281 |
|
282 |
//강인구 추가 |
283 |
#region Control Move |
284 |
//case Key.NumPad4: |
285 |
//case Key.NumPad5: |
286 |
//case Key.NumPad6: |
287 |
//case Key.NumPad8: |
288 |
case Key.Right: |
289 |
case Key.Left: |
290 |
case Key.Up: |
291 |
case Key.Down: |
292 |
{ |
293 |
if(System.Windows.Input.Keyboard.FocusedElement is System.Windows.Controls.TextBox) |
294 |
{ |
295 |
return; |
296 |
} |
297 |
|
298 |
if(sender is UIElement) |
299 |
{ |
300 |
(sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false); |
301 |
} |
302 |
|
303 |
Point? MovePoint = null; |
304 |
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down)) |
305 |
{ |
306 |
MovePoint = new Point(0, 5); |
307 |
} |
308 |
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up)) |
309 |
{ |
310 |
MovePoint = new Point(0, -5); |
311 |
} |
312 |
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left)) |
313 |
{ |
314 |
MovePoint = new Point(-5, 0); |
315 |
} |
316 |
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right)) |
317 |
{ |
318 |
MovePoint = new Point(5, 0); |
319 |
} |
320 |
|
321 |
if (MovePoint != null && MovePoint.HasValue) |
322 |
{ |
323 |
if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift) |
324 |
{ |
325 |
|
326 |
this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle); |
327 |
} |
328 |
else |
329 |
{ |
330 |
//if (ViewerDataModel.Instance.IsPressCtrl) |
331 |
//{ |
332 |
bool IsMovePossibility = false; |
333 |
|
334 |
var instance = ViewerDataModel.Instance; |
335 |
|
336 |
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down)) |
337 |
{ |
338 |
if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight) |
339 |
{ |
340 |
IsMovePossibility = true; |
341 |
} |
342 |
} |
343 |
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up)) |
344 |
{ |
345 |
if (0 < instance.ContentOffsetY) |
346 |
{ |
347 |
IsMovePossibility = true; |
348 |
} |
349 |
} |
350 |
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left)) |
351 |
{ |
352 |
if (0 < instance.ContentOffsetX) |
353 |
{ |
354 |
IsMovePossibility = true; |
355 |
} |
356 |
} |
357 |
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right)) |
358 |
{ |
359 |
if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth) |
360 |
{ |
361 |
IsMovePossibility = true; |
362 |
} |
363 |
} |
364 |
|
365 |
if (IsMovePossibility) |
366 |
{ |
367 |
Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10); |
368 |
|
369 |
this.dzMainMenu.MoveZoomAndPanControl(dragOffset); |
370 |
|
371 |
this.dzMainMenu.MainDocumentPanel.Focus(); |
372 |
|
373 |
System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX); |
374 |
} |
375 |
//} |
376 |
} |
377 |
} |
378 |
} |
379 |
break; |
380 |
#endregion |
381 |
case Key.PageUp: |
382 |
|
383 |
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1); |
384 |
break; |
385 |
case Key.PageDown: |
386 |
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1); |
387 |
break; |
388 |
} |
389 |
}); |
390 |
} |
391 |
|
392 |
|
393 |
/// <summary> |
394 |
/// translate or rotate items by given pt and angle |
395 |
/// </summary> |
396 |
/// <author>humkyung</author> |
397 |
/// <date>2019.07.03</date> |
398 |
/// <param name="pt">control point</param> |
399 |
/// <param name="dAngle">angle in degree</param> |
400 |
private void TranslateOrRotateItems(Point pt, double dAngle) |
401 |
{ |
402 |
Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle); |
403 |
foreach (var item in this.dzMainMenu.SelectLayer.Children) |
404 |
{ |
405 |
if (item.GetType().Name == "AdornerFinal") |
406 |
{ |
407 |
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) |
408 |
{ |
409 |
(item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2)); |
410 |
} |
411 |
else |
412 |
{ |
413 |
(item as Controls.AdornerFinal).TranslateItems(control.X, control.Y); |
414 |
} |
415 |
|
416 |
} |
417 |
} |
418 |
} |
419 |
} |
420 |
} |