프로젝트

일반

사용자정보

개정판 b0fb3ad7

IDb0fb3ad72eea3fdc4809aa787c1b8543159ad88b
상위 6c12fd2e
하위 97e8ad04

이지연이(가) 5년 이상 전에 추가함

issue #979 Text Control 에 커서가 있는 상태에서 Paste시 Control Data가 Text로 들어가는 현상

차이점 보기:

KCOM/MainWindow.xaml.cs
1 1
using KCOM.Common;
2
using KCOM.Controls;
2 3
using KCOMDataModel;
3 4
using KCOMDataModel.DataModel;
5
using MarkupToPDF.Common;
6
using MarkupToPDF.Controls.Common;
7
using MarkupToPDF.Controls.Text;
8
using MarkupToPDF.Serialize.Core;
9
using MarkupToPDF.Serialize.S_Control;
4 10
using System;
5 11
using System.Collections.Generic;
6 12
using System.IO;
......
359 365
            {
360 366
                case 0x0024:
361 367
                    WmGetMinMaxInfo(hwnd, lParam);
362
                    handled = true;                      
368
                    handled = true;
363 369
                    break;
364 370
            }
365 371
            return (System.IntPtr)0;
......
409 415

  
410 416
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
411 417
        public class MONITORINFO
412
        {         
413
            public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));          
414
            public RECT rcMonitor = new RECT();      
415
            public RECT rcWork = new RECT();      
418
        {
419
            public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
420
            public RECT rcMonitor = new RECT();
421
            public RECT rcWork = new RECT();
416 422
            public int dwFlags = 0;
417 423
        }
418 424

  
......
421 427
        {
422 428
            public int left;
423 429
            public int top;
424
            public int right; 
430
            public int right;
425 431
            public int bottom;
426 432

  
427 433
            public static readonly RECT Empty = new RECT();
......
487 493
        internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
488 494
        [DllImport("User32")]
489 495
        internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
496

  
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
        }
490 685
    }
491 686
}

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)