markus / KCOM / MainWindow.xaml.cs @ bab93260
이력 | 보기 | 이력해설 | 다운로드 (27.8 KB)
1 | 787a4489 | KangIngu | using KCOM.Common; |
---|---|---|---|
2 | b0fb3ad7 | ljiyeon | using KCOM.Controls; |
3 | 787a4489 | KangIngu | using KCOMDataModel; |
4 | using KCOMDataModel.DataModel; |
||
5 | b0fb3ad7 | ljiyeon | using MarkupToPDF.Common; |
6 | using MarkupToPDF.Controls.Common; |
||
7 | using MarkupToPDF.Controls.Text; |
||
8 | using MarkupToPDF.Serialize.Core; |
||
9 | using MarkupToPDF.Serialize.S_Control; |
||
10 | 787a4489 | KangIngu | using System; |
11 | using System.Collections.Generic; |
||
12 | 6707a5c7 | ljiyeon | using System.IO; |
13 | 787a4489 | KangIngu | using System.Linq; |
14 | 71bfd53e | ljiyeon | using System.Runtime.InteropServices; |
15 | 787a4489 | KangIngu | using System.Text; |
16 | using System.Windows; |
||
17 | using System.Windows.Controls; |
||
18 | using System.Windows.Data; |
||
19 | using System.Windows.Documents; |
||
20 | using System.Windows.Input; |
||
21 | using System.Windows.Media; |
||
22 | using System.Windows.Media.Imaging; |
||
23 | using System.Windows.Navigation; |
||
24 | using System.Windows.Shapes; |
||
25 | 6707a5c7 | ljiyeon | using System.Xml; |
26 | 992a98b4 | KangIngu | using Telerik.Windows.Controls; |
27 | 7e2d29a0 | ljiyeon | using WinInterop = System.Windows.Interop; |
28 | 787a4489 | KangIngu | |
29 | namespace KCOM |
||
30 | { |
||
31 | /// <summary> |
||
32 | /// MainWindow.xaml에 대한 상호 작용 논리 |
||
33 | /// </summary> |
||
34 | public partial class MainWindow : Window |
||
35 | { |
||
36 | public MainWindow() |
||
37 | { |
||
38 | 0c997b99 | ljiyeon | //InitializeComponent(); |
39 | 787a4489 | KangIngu | this.Loaded += MainWindow_Loaded; |
40 | this.KeyDown += new KeyEventHandler(KeyEventDownAction); |
||
41 | this.KeyUp += new KeyEventHandler(KeyEventUpAction); |
||
42 | 7e2d29a0 | ljiyeon | this.SourceInitialized += new EventHandler(win_SourceInitialized); |
43 | 787a4489 | KangIngu | } |
44 | ca16abb2 | ljiyeon | |
45 | public static BitmapImage CursorChange() |
||
46 | { |
||
47 | BitmapImage bmp = new BitmapImage(); |
||
48 | bmp.BeginInit(); |
||
49 | bmp.StreamSource = System.Windows.Application.GetResourceStream(new Uri("/KCOM;Component/Resources/Cursor/customCursor2.cur", UriKind.Relative)).Stream; |
||
50 | return bmp; |
||
51 | } |
||
52 | |||
53 | 787a4489 | KangIngu | public void DialogMessage_Alert(string content, string header) |
54 | { |
||
55 | var box = new TextBlock(); |
||
56 | box.MinWidth = 400; |
||
57 | box.FontSize = 12; |
||
58 | box.Text = content; |
||
59 | box.TextWrapping = System.Windows.TextWrapping.Wrap; |
||
60 | |||
61 | Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters() |
||
62 | { |
||
63 | b9b01f8e | ljiyeon | Owner = Application.Current.MainWindow, |
64 | 787a4489 | KangIngu | Content = box, |
65 | Header = header, |
||
66 | Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(), |
||
67 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
68 | }; |
||
69 | Telerik.Windows.Controls.RadWindow.Alert(parameters); |
||
70 | } |
||
71 | 7e2d29a0 | ljiyeon | |
72 | 787a4489 | KangIngu | private void MainWindow_Loaded(object sender, RoutedEventArgs e) |
73 | { |
||
74 | 0c997b99 | ljiyeon | InitializeComponent(); |
75 | ca16abb2 | ljiyeon | |
76 | //cursor change |
||
77 | this.Cursor = new Cursor(CursorChange().StreamSource); |
||
78 | |||
79 | 787a4489 | KangIngu | double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; |
80 | double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight; |
||
81 | 9f473fb7 | KangIngu | //this.Width += 40; |
82 | 787a4489 | KangIngu | double windowWidth = this.Width; |
83 | double windowHeight = this.Height; |
||
84 | this.Left = (screenWidth / 2) - (windowWidth / 2); |
||
85 | this.Top = (screenHeight / 2) - (windowHeight / 2); |
||
86 | |||
87 | 3933072f | ljiyeon | |
88 | 787a4489 | KangIngu | ViewerDataModel.Instance.SystemMain = this; |
89 | |||
90 | if (!App.ParameterMode) |
||
91 | { |
||
92 | //App.ViewInfo = new IKCOM.ViewInfo |
||
93 | //{ |
||
94 | // DocumentItemID = "11111112", |
||
95 | // //DocumentItemID = "10001", |
||
96 | // bPartner = false, |
||
97 | // CreateFinalPDFPermission = true, |
||
98 | // NewCommentPermission = true, |
||
99 | // ProjectNO = "000000", |
||
100 | // UserID = "H2011357", |
||
101 | // //UserID = "H2009115", |
||
102 | // //Mode = 0 , 1 , 2 |
||
103 | //}; |
||
104 | //DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내"); |
||
105 | |||
106 | 7e2d29a0 | ljiyeon | //#if DEBUG |
107 | // App.ViewInfo = new IKCOM.ViewInfo |
||
108 | // { |
||
109 | // DocumentItemID = "11111112", |
||
110 | // //DocumentItemID = "10001", |
||
111 | // bPartner = false, |
||
112 | // CreateFinalPDFPermission = true, |
||
113 | // NewCommentPermission = true, |
||
114 | // ProjectNO = "000000", |
||
115 | // UserID = "H2011357", |
||
116 | // //UserID = "H2009115", |
||
117 | // //Mode = 0 , 1 , 2 |
||
118 | // }; |
||
119 | // App.ParameterMode = true; |
||
120 | // this.dzMainMenu.ServiceOn(); |
||
121 | // this.dzMainMenu.SetView(App.ViewInfo); |
||
122 | //#else |
||
123 | 787a4489 | KangIngu | |
124 | DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내"); |
||
125 | this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed; |
||
126 | this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed; |
||
127 | this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed; |
||
128 | this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed; |
||
129 | this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed; |
||
130 | 7e2d29a0 | ljiyeon | //#endif |
131 | 787a4489 | KangIngu | } |
132 | else |
||
133 | { |
||
134 | this.dzMainMenu.ServiceOn(); |
||
135 | 992a98b4 | KangIngu | |
136 | if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission) |
||
137 | { |
||
138 | this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed; |
||
139 | var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList(); |
||
140 | list.ForEach(item => item.Visibility = Visibility.Collapsed); |
||
141 | this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible; |
||
142 | this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly; |
||
143 | e0204db0 | djkim | //this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed; |
144 | //this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed; |
||
145 | //this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false; |
||
146 | 992a98b4 | KangIngu | } |
147 | 787a4489 | KangIngu | this.dzMainMenu.SetView(App.ViewInfo); |
148 | 7e2d29a0 | ljiyeon | this.dzMainMenu.HubSet(); |
149 | 787a4489 | KangIngu | } |
150 | 6707a5c7 | ljiyeon | |
151 | 787a4489 | KangIngu | //App.ViewInfo = new IKCOM.ViewInfo |
152 | //{ |
||
153 | // DocumentItemID = "11111112", |
||
154 | // //DocumentItemID = "10001", |
||
155 | // bPartner = false, |
||
156 | // CreateFinalPDFPermission = true, |
||
157 | // NewCommentPermission = true, |
||
158 | // ProjectNO = "000000", |
||
159 | // UserID = "H2011357", |
||
160 | // //UserID = "H2009115", |
||
161 | // //Mode = 0 , 1 , 2 |
||
162 | //}; |
||
163 | |||
164 | //this.dzMainMenu.ServiceOn(); |
||
165 | //this.dzMainMenu.SetView(App.ViewInfo); |
||
166 | } |
||
167 | 6707a5c7 | ljiyeon | |
168 | 71bfd53e | ljiyeon | |
169 | 7e2d29a0 | ljiyeon | bool restoreIfMove = false; |
170 | 71bfd53e | ljiyeon | |
171 | 787a4489 | KangIngu | private void WindowDragEvent(object sender, MouseButtonEventArgs e) |
172 | { |
||
173 | 71bfd53e | ljiyeon | if (e.ClickCount == 2) |
174 | 787a4489 | KangIngu | { |
175 | 71bfd53e | ljiyeon | if ((ResizeMode == ResizeMode.CanResize) || |
176 | (ResizeMode == ResizeMode.CanResizeWithGrip)) |
||
177 | 787a4489 | KangIngu | { |
178 | 71bfd53e | ljiyeon | SwitchState(); |
179 | 787a4489 | KangIngu | } |
180 | } |
||
181 | else |
||
182 | { |
||
183 | 71bfd53e | ljiyeon | if (WindowState == WindowState.Maximized) |
184 | { |
||
185 | restoreIfMove = true; |
||
186 | } |
||
187 | 3933072f | ljiyeon | |
188 | 787a4489 | KangIngu | this.DragMove(); |
189 | } |
||
190 | } |
||
191 | |||
192 | 71bfd53e | ljiyeon | private void WindowDragEventUp(object sender, MouseButtonEventArgs e) |
193 | { |
||
194 | restoreIfMove = false; |
||
195 | } |
||
196 | |||
197 | private void WindowDragEventMove(object sender, MouseEventArgs e) |
||
198 | { |
||
199 | if (restoreIfMove) |
||
200 | { |
||
201 | if (Mouse.LeftButton == MouseButtonState.Pressed) |
||
202 | { |
||
203 | 3933072f | ljiyeon | //this.WindowState = WindowState.Normal; |
204 | |||
205 | 71bfd53e | ljiyeon | restoreIfMove = false; |
206 | |||
207 | double percentHorizontal = e.GetPosition(this).X / ActualWidth; |
||
208 | double targetHorizontal = RestoreBounds.Width * percentHorizontal; |
||
209 | |||
210 | double percentVertical = e.GetPosition(this).Y / ActualHeight; |
||
211 | double targetVertical = RestoreBounds.Height * percentVertical; |
||
212 | |||
213 | POINT lMousePosition; |
||
214 | 7e2d29a0 | ljiyeon | GetCursorPos(out lMousePosition); |
215 | 71bfd53e | ljiyeon | |
216 | Left = lMousePosition.X - targetHorizontal; |
||
217 | 7e2d29a0 | ljiyeon | double top = lMousePosition.Y - targetVertical; |
218 | if(top < 10) |
||
219 | { |
||
220 | top = 10; |
||
221 | } |
||
222 | Top = lMousePosition.Y; |
||
223 | 71bfd53e | ljiyeon | |
224 | 3933072f | ljiyeon | |
225 | 71bfd53e | ljiyeon | WindowState = WindowState.Normal; |
226 | |||
227 | this.DragMove(); |
||
228 | } |
||
229 | } |
||
230 | } |
||
231 | |||
232 | [DllImport("user32.dll")] |
||
233 | [return: MarshalAs(UnmanagedType.Bool)] |
||
234 | static extern bool GetCursorPos(out POINT lpPoint); |
||
235 | |||
236 | [StructLayout(LayoutKind.Sequential)] |
||
237 | public struct POINT |
||
238 | { |
||
239 | public int X; |
||
240 | public int Y; |
||
241 | |||
242 | public POINT(int x, int y) |
||
243 | { |
||
244 | this.X = x; |
||
245 | this.Y = y; |
||
246 | } |
||
247 | } |
||
248 | |||
249 | private void SwitchState() |
||
250 | { |
||
251 | switch (WindowState) |
||
252 | { |
||
253 | case WindowState.Normal: |
||
254 | { |
||
255 | WindowState = WindowState.Maximized; |
||
256 | break; |
||
257 | } |
||
258 | case WindowState.Maximized: |
||
259 | { |
||
260 | WindowState = WindowState.Normal; |
||
261 | break; |
||
262 | } |
||
263 | } |
||
264 | } |
||
265 | |||
266 | 787a4489 | KangIngu | private void RadButton_Click(object sender, RoutedEventArgs e) |
267 | { |
||
268 | Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton; |
||
269 | |||
270 | switch (button.CommandParameter.ToString()) |
||
271 | { |
||
272 | case ("Min"): |
||
273 | { |
||
274 | WindowState = WindowState.Minimized; |
||
275 | } |
||
276 | break; |
||
277 | case ("Max"): |
||
278 | { |
||
279 | WindowState = WindowState.Maximized; |
||
280 | } |
||
281 | break; |
||
282 | case ("Exit"): |
||
283 | { |
||
284 | |||
285 | } |
||
286 | break; |
||
287 | } |
||
288 | } |
||
289 | |||
290 | private void WinState(object sender, MouseButtonEventArgs e) |
||
291 | { |
||
292 | af177ca1 | djkim | switch ((e.Source as Image).Name) |
293 | 787a4489 | KangIngu | { |
294 | af177ca1 | djkim | case ("Win_min"): |
295 | 787a4489 | KangIngu | { |
296 | WindowState = WindowState.Minimized; |
||
297 | } |
||
298 | break; |
||
299 | af177ca1 | djkim | case ("Win_max"): |
300 | 787a4489 | KangIngu | { |
301 | af177ca1 | djkim | if (WindowState == WindowState.Maximized) |
302 | { |
||
303 | 787a4489 | KangIngu | WindowState = WindowState.Normal; |
304 | af177ca1 | djkim | } |
305 | 787a4489 | KangIngu | else |
306 | af177ca1 | djkim | { |
307 | 787a4489 | KangIngu | WindowState = WindowState.Maximized; |
308 | af177ca1 | djkim | } |
309 | 787a4489 | KangIngu | } |
310 | break; |
||
311 | af177ca1 | djkim | case ("Win_Close"): |
312 | 787a4489 | KangIngu | { |
313 | 316d0f5c | KangIngu | if (ViewerDataModel.Instance.UndoDataList.Count > 0) |
314 | 69ef0800 | KangIngu | { |
315 | 316d0f5c | KangIngu | DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime; |
316 | d2cd1e16 | djkim | DateTime updatetime = DateTime.Now.AddDays(-1); |
317 | if (ViewerDataModel.Instance._markupInfoList.Count > 0) |
||
318 | { |
||
319 | updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime; |
||
320 | } |
||
321 | 6707a5c7 | ljiyeon | |
322 | 316d0f5c | KangIngu | if (undoTime > updatetime) |
323 | { |
||
324 | 69ef0800 | KangIngu | var box = new TextBlock(); |
325 | box.MinWidth = 400; |
||
326 | box.FontSize = 11; |
||
327 | box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?"; |
||
328 | box.TextWrapping = System.Windows.TextWrapping.Wrap; |
||
329 | |||
330 | DialogParameters parameters = new DialogParameters() |
||
331 | { |
||
332 | b9b01f8e | ljiyeon | Owner = Application.Current.MainWindow, |
333 | 69ef0800 | KangIngu | Content = box, |
334 | Header = "Confirm", |
||
335 | Theme = new VisualStudio2013Theme(), |
||
336 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
337 | Closed = Onclose, |
||
338 | }; |
||
339 | RadWindow.Confirm(parameters); |
||
340 | } |
||
341 | 316d0f5c | KangIngu | } |
342 | 787a4489 | KangIngu | this.Close(); |
343 | } |
||
344 | break; |
||
345 | } |
||
346 | } |
||
347 | |||
348 | 69ef0800 | KangIngu | private void Onclose(object sender, WindowClosedEventArgs e) |
349 | { |
||
350 | if (e.DialogResult == true) |
||
351 | { |
||
352 | dzTopMenu.SaveEvent(null, null); |
||
353 | } |
||
354 | } |
||
355 | 7e2d29a0 | ljiyeon | |
356 | void win_SourceInitialized(object sender, EventArgs e) |
||
357 | { |
||
358 | System.IntPtr handle = (new WinInterop.WindowInteropHelper(this)).Handle; |
||
359 | WinInterop.HwndSource.FromHwnd(handle).AddHook(new WinInterop.HwndSourceHook(WindowProc)); |
||
360 | } |
||
361 | |||
362 | private static System.IntPtr WindowProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) |
||
363 | { |
||
364 | switch (msg) |
||
365 | { |
||
366 | case 0x0024: |
||
367 | WmGetMinMaxInfo(hwnd, lParam); |
||
368 | b0fb3ad7 | ljiyeon | handled = true; |
369 | 7e2d29a0 | ljiyeon | break; |
370 | } |
||
371 | return (System.IntPtr)0; |
||
372 | } |
||
373 | |||
374 | private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam) |
||
375 | { |
||
376 | MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO)); |
||
377 | int MONITOR_DEFAULTTONEAREST = 0x00000002; |
||
378 | System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); |
||
379 | |||
380 | if (monitor != System.IntPtr.Zero) |
||
381 | { |
||
382 | MONITORINFO monitorInfo = new MONITORINFO(); |
||
383 | GetMonitorInfo(monitor, monitorInfo); |
||
384 | RECT rcWorkArea = monitorInfo.rcWork; |
||
385 | RECT rcMonitorArea = monitorInfo.rcMonitor; |
||
386 | mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left); |
||
387 | mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top); |
||
388 | mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left); |
||
389 | mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top); |
||
390 | } |
||
391 | Marshal.StructureToPtr(mmi, lParam, true); |
||
392 | } |
||
393 | |||
394 | [StructLayout(LayoutKind.Sequential)] |
||
395 | public struct POINT2 |
||
396 | { |
||
397 | public int x; |
||
398 | public int y; |
||
399 | public POINT2(int x, int y) |
||
400 | { |
||
401 | this.x = x; |
||
402 | this.y = y; |
||
403 | } |
||
404 | } |
||
405 | |||
406 | [StructLayout(LayoutKind.Sequential)] |
||
407 | public struct MINMAXINFO |
||
408 | { |
||
409 | public POINT2 ptReserved; |
||
410 | public POINT2 ptMaxSize; |
||
411 | public POINT2 ptMaxPosition; |
||
412 | public POINT2 ptMinTrackSize; |
||
413 | public POINT2 ptMaxTrackSize; |
||
414 | }; |
||
415 | |||
416 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] |
||
417 | public class MONITORINFO |
||
418 | b0fb3ad7 | ljiyeon | { |
419 | public int cbSize = Marshal.SizeOf(typeof(MONITORINFO)); |
||
420 | public RECT rcMonitor = new RECT(); |
||
421 | public RECT rcWork = new RECT(); |
||
422 | 7e2d29a0 | ljiyeon | public int dwFlags = 0; |
423 | } |
||
424 | |||
425 | [StructLayout(LayoutKind.Sequential, Pack = 0)] |
||
426 | public struct RECT |
||
427 | { |
||
428 | public int left; |
||
429 | public int top; |
||
430 | b0fb3ad7 | ljiyeon | public int right; |
431 | 7e2d29a0 | ljiyeon | public int bottom; |
432 | |||
433 | public static readonly RECT Empty = new RECT(); |
||
434 | |||
435 | public int Width |
||
436 | { |
||
437 | get { return Math.Abs(right - left); } // Abs needed for BIDI OS |
||
438 | } |
||
439 | |||
440 | public int Height |
||
441 | { |
||
442 | get { return bottom - top; } |
||
443 | } |
||
444 | |||
445 | public RECT(int left, int top, int right, int bottom) |
||
446 | { |
||
447 | this.left = left; |
||
448 | this.top = top; |
||
449 | this.right = right; |
||
450 | this.bottom = bottom; |
||
451 | } |
||
452 | |||
453 | public RECT(RECT rcSrc) |
||
454 | { |
||
455 | this.left = rcSrc.left; |
||
456 | this.top = rcSrc.top; |
||
457 | this.right = rcSrc.right; |
||
458 | this.bottom = rcSrc.bottom; |
||
459 | } |
||
460 | |||
461 | public bool IsEmpty |
||
462 | { |
||
463 | get |
||
464 | { |
||
465 | // BUGBUG : On Bidi OS (hebrew arabic) left > right |
||
466 | return left >= right || top >= bottom; |
||
467 | } |
||
468 | } |
||
469 | |||
470 | public override bool Equals(object obj) |
||
471 | { |
||
472 | if (!(obj is Rect)) { return false; } |
||
473 | return (this == (RECT)obj); |
||
474 | } |
||
475 | |||
476 | public override int GetHashCode() |
||
477 | { |
||
478 | return left.GetHashCode() + top.GetHashCode() + right.GetHashCode() + bottom.GetHashCode(); |
||
479 | } |
||
480 | |||
481 | public static bool operator ==(RECT rect1, RECT rect2) |
||
482 | { |
||
483 | return (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom); |
||
484 | } |
||
485 | |||
486 | public static bool operator !=(RECT rect1, RECT rect2) |
||
487 | { |
||
488 | return !(rect1 == rect2); |
||
489 | } |
||
490 | } |
||
491 | |||
492 | [DllImport("user32")] |
||
493 | internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi); |
||
494 | [DllImport("User32")] |
||
495 | internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags); |
||
496 | b0fb3ad7 | ljiyeon | |
497 | private void WindowKeyDown(object sender, KeyEventArgs e) |
||
498 | { |
||
499 | if (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control) //Ctrl + V |
||
500 | { |
||
501 | if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
||
502 | { |
||
503 | if (Clipboard.GetText().Contains("|OR||DZ|")) |
||
504 | { |
||
505 | TextBox_Paste_Start(); |
||
506 | } |
||
507 | |||
508 | } |
||
509 | } |
||
510 | } |
||
511 | |||
512 | public void TextBox_Paste_Start() |
||
513 | { |
||
514 | if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
||
515 | { |
||
516 | if (Clipboard.GetText().Contains("|OR||DZ|")) |
||
517 | { |
||
518 | List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
||
519 | |||
520 | string[] delimiterChars = { "|OR|" }; |
||
521 | string[] delimiterChars2 = { "|OR|", "|SymbolID|" }; |
||
522 | string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
||
523 | |||
524 | this.dzMainMenu.ReleaseAdorner(); |
||
525 | |||
526 | Multi_Undo_data multi_Undo_Data = new Multi_Undo_data(); |
||
527 | |||
528 | UndoData = new Undo_data() |
||
529 | { |
||
530 | IsUndo = false, |
||
531 | Event = Event_Type.Create, |
||
532 | EventTime = DateTime.Now, |
||
533 | Markup_List = new List<Multi_Undo_data>() |
||
534 | }; |
||
535 | |||
536 | ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i => |
||
537 | { |
||
538 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
539 | }); |
||
540 | |||
541 | foreach (string parse in data) |
||
542 | { |
||
543 | if (parse != "") |
||
544 | { |
||
545 | string[] data2 = new string[2]; |
||
546 | data2 = parse.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
547 | |||
548 | System.Windows.Controls.Control item = layer.markupParse_Paste(data2[0], ViewerDataModel.Instance.MarkupControls_USER); |
||
549 | |||
550 | var controldata = JsonSerializerHelper.UnCompressString(data2[0]); |
||
551 | var unkownControl = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(controldata); //복호화작업 |
||
552 | if (unkownControl.Name == "TextControl" || unkownControl.Name == "ArrowTextControl") |
||
553 | { |
||
554 | ViewerDataModel.Instance.IsPressCtrl = false; |
||
555 | |||
556 | (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid(); |
||
557 | if (data2.Length >= 2) |
||
558 | { |
||
559 | (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = data2[1]; |
||
560 | } |
||
561 | |||
562 | ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo); |
||
563 | ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo); |
||
564 | |||
565 | adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo); |
||
566 | |||
567 | multi_Undo_Data = dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
||
568 | |||
569 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
570 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
571 | } |
||
572 | } |
||
573 | } |
||
574 | |||
575 | Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
||
576 | |||
577 | double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2); |
||
578 | double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2); |
||
579 | final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY)); |
||
580 | |||
581 | if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null) |
||
582 | { |
||
583 | final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); |
||
584 | } |
||
585 | |||
586 | this.dzMainMenu.SelectLayer.Children.Add(final); |
||
587 | |||
588 | } |
||
589 | else if (Clipboard.GetImage() != null) //외부 이미지 붙여넣기 |
||
590 | { |
||
591 | Multi_Undo_data multi_Undo_Data = new Multi_Undo_data(); |
||
592 | |||
593 | //Undo/Redo 보류 |
||
594 | UndoData = new Undo_data() |
||
595 | { |
||
596 | IsUndo = false, |
||
597 | Event = Event_Type.Create, |
||
598 | EventTime = DateTime.Now, |
||
599 | Markup_List = new List<Multi_Undo_data>() |
||
600 | }; |
||
601 | |||
602 | string temppath = System.IO.Path.GetTempPath(); |
||
603 | //string filename = KCOM.Events.Save.shortCommentKey(); |
||
604 | string filename = KCOM.Events.Save.shortFileKey(); |
||
605 | |||
606 | System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage(); |
||
607 | clipboardImage.Save(temppath + "\\" + filename); |
||
608 | |||
609 | System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath + "\\" + filename); |
||
610 | String strFile = System.IO.Path.GetFileName(fileInfo.FullName); |
||
611 | long numByte = fileInfo.Length; |
||
612 | double dLen = Convert.ToDouble(fileInfo.Length / 1000000); |
||
613 | kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload(); |
||
614 | |||
615 | if (dLen < 4) |
||
616 | { |
||
617 | System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName, |
||
618 | System.IO.FileMode.Open, System.IO.FileAccess.Read); |
||
619 | System.IO.BinaryReader br = new System.IO.BinaryReader(fStream); |
||
620 | byte[] data = br.ReadBytes((int)numByte); |
||
621 | |||
622 | filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data); |
||
623 | br.Close(); |
||
624 | fStream.Close(); |
||
625 | fStream.Dispose(); |
||
626 | } |
||
627 | else |
||
628 | { |
||
629 | dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert"); |
||
630 | return; |
||
631 | } |
||
632 | |||
633 | fileInfo.Delete(); |
||
634 | |||
635 | //System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage(); |
||
636 | System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage); |
||
637 | IntPtr hBitmap = bmp.GetHbitmap(); |
||
638 | System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); |
||
639 | Image img = new Image(); |
||
640 | img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(filename)); |
||
641 | |||
642 | var currentControl = new MarkupToPDF.Controls.Etc.ImgControl |
||
643 | { |
||
644 | PointSet = new List<Point>(), |
||
645 | FilePath = img.Source.ToString(), |
||
646 | ImageData = img.Source, |
||
647 | StartPoint = new Point(100, 100), |
||
648 | EndPoint = new Point(200, 200), |
||
649 | TopRightPoint = new Point(100, 200), |
||
650 | LeftBottomPoint = new Point(200, 100) |
||
651 | }; |
||
652 | |||
653 | currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y); |
||
654 | currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height); |
||
655 | currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height); |
||
656 | |||
657 | currentControl.PointSet = new List<Point> |
||
658 | { |
||
659 | currentControl.StartPoint, |
||
660 | currentControl.LeftBottomPoint, |
||
661 | currentControl.EndPoint, |
||
662 | currentControl.TopRightPoint, |
||
663 | }; |
||
664 | |||
665 | multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
666 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
667 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
668 | |||
669 | ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
670 | currentControl.CommentID = Events.Save.shortGuid(); |
||
671 | |||
672 | currentControl.ApplyTemplate(); |
||
673 | currentControl.SetImage(); |
||
674 | |||
675 | ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
676 | Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
677 | this.dzMainMenu.SelectLayer.Children.Add(final); |
||
678 | |||
679 | double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2); |
||
680 | double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2); |
||
681 | final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY)); |
||
682 | } |
||
683 | } |
||
684 | } |
||
685 | 787a4489 | KangIngu | } |
686 | } |