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