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