프로젝트

일반

사용자정보

개정판 eefebdb7

IDeefebdb7189d76d9fefe919980d4de488547683e
상위 8578883b
하위 8763aa9f

김태성이(가) 약 5년 전에 추가함

test

Change-Id: I3b054f5538543dfe147f62f672c758aafae9b738

차이점 보기:

KCOM/Views/MainMenu.xaml.cs
5522 5522
        public string Title { get; set; }
5523 5523
    }
5524 5524
}
5525

  
5526
using MarkupToPDF.Controls.Common;
5527
using MarkupToPDF.Controls.Line;
5528
using MarkupToPDF.Controls.Polygon;
5529
using MarkupToPDF.Controls.Shape;
5530
using MarkupToPDF.Controls.Text;
5531
using MarkupToPDF.Controls.Etc;
5532
using System;
5533
using System.Collections.Generic;
5534
using System.Linq;
5535
using System.Text;
5536
using System.Windows;
5537
using System.Windows.Controls;
5538
using System.Windows.Data;
5539
using System.Windows.Documents;
5540
using System.Windows.Input;
5541
using System.Windows.Media;
5542
using System.Windows.Media.Imaging;
5543
using System.Windows.Navigation;
5544
using System.Windows.Shapes;
5545
using KCOM.Common;
5546
using IKCOM;
5547
using System.Windows.Ink;
5548
using System.Collections.ObjectModel;
5549
using Telerik.Windows.Controls;
5550
using KCOM.Events;
5551
using System.Reflection;
5552
using MarkupToPDF.Common;
5553
using KCOM.Controls;
5554
using KCOMDataModel.DataModel;
5555
using System.Xml;
5556
using static KCOM.TempFile;
5557
using System.Windows.Threading;
5558
using System.Diagnostics;
5559
using System.Threading;
5560
using System.Windows.Resources;
5561
using Svg2Xaml;
5562
using System.Runtime.InteropServices;
5563
using System.Windows.Media.Effects;
5564
using MarkupToPDF.Controls.Cad;
5565
using MarkupToPDF.Controls.Parsing;
5566
using Telerik.Windows.Data;
5567
using System.ComponentModel;
5568
using static KCOM.Controls.Sample;
5569
using System.Web;
5570
using System.Threading.Tasks;
5571

  
5572
namespace KCOM.Views
5573
{
5574
    public static class ControlExtensions
5575
    {
5576
        public static T Clone<T>(this T controlToClone)
5577
            where T : System.Windows.Controls.Control
5578
        {
5579
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
5580

  
5581
            T instance = Activator.CreateInstance<T>();
5582

  
5583
            foreach (PropertyInfo propInfo in controlProperties)
5584
            {
5585
                if (propInfo.CanWrite)
5586
                {
5587
                    if (propInfo.Name != "WindowTarget")
5588
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
5589
                }
5590
            }
5591
            return instance;
5592
        }
5593
    }
5594

  
5595
    public class MyConsole
5596
    {
5597
        private readonly System.Threading.ManualResetEvent _readLineSignal;
5598
        private string _lastLine;
5599
        public MyConsole()
5600
        {
5601
            _readLineSignal = new System.Threading.ManualResetEvent(false);
5602
            Gui = new TextBox();
5603
            Gui.AcceptsReturn = true;
5604
            Gui.KeyUp += OnKeyUp;
5605
        }
5606

  
5607
        private void OnKeyUp(object sender, KeyEventArgs e)
5608
        {
5609
            // this is always fired on UI thread
5610
            if (e.Key == Key.Enter)
5611
            {
5612
                // quick and dirty, but that is not relevant to your question
5613
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
5614
                // now, when you detected that user typed a line, set signal
5615
                _readLineSignal.Set();
5616
            }
5617
        }
5618

  
5619
        public TextBox Gui { get; private set; }
5620

  
5621
        public string ReadLine()
5622
        {
5623
            // that should always be called from non-ui thread
5624
            if (Gui.Dispatcher.CheckAccess())
5625
                throw new Exception("Cannot be called on UI thread");
5626
            // reset signal
5627
            _readLineSignal.Reset();
5628
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
5629
            _readLineSignal.WaitOne();
5630
            // we got signalled - return line user typed.
5631
            return _lastLine;
5632
        }
5633

  
5634
        public void WriteLine(string line)
5635
        {
5636
            if (!Gui.Dispatcher.CheckAccess())
5637
            {
5638
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
5639
                return;
5640
            }
5641

  
5642
            Gui.Text += line + Environment.NewLine;
5643
        }
5644
    }
5645

  
5646
    /// <summary>
5647
    /// MainMenu.xaml에 대한 상호 작용 논리
5648
    /// </summary>
5649
    public partial class MainMenu : UserControl
5650
    {
5651
        #region 프로퍼티
5652
        public CommentUserInfo currentControl { get; set; }
5653
        public ControlType controlType { get; set; }
5654
        private Move move = new Move();
5655
        private double[] rotateValue = { 0, 90, 180, 270 };
5656
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
5657
        private static readonly double DragThreshold = 5;
5658
        private System.Windows.Input.Cursor cursor { get; set; }
5659

  
5660
        /// <summary>
5661
        ///  문서의 마우스 위치
5662
        /// </summary>
5663
        public Point CanvasDrawingMouseDownPoint;
5664

  
5665
        public string filename { get; set; }
5666
        private Point canvasZoomPanningMouseDownPoint;
5667
        public Point getCurrentPoint;
5668
        private Point canvasZoommovingMouseDownPoint;
5669
        List<object> ControlList = new List<object>();
5670
        private ListBox listBox = new ListBox();
5671
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
5672
        private bool isDraggingSelectionRect = false;
5673
        DrawingAttributes inkDA = new DrawingAttributes();
5674
        private VPRevision CurrentRev { get; set; }
5675
        public RadRibbonButton btnConsolidate { get; set; }
5676
        public RadRibbonButton btnFinalPDF { get; set; }
5677
        public RadRibbonButton btnTeamConsolidate { get; set; }
5678
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
5679

  
5680
        public string Filename_ { get; set; }
5681
        public double L_Size = 0;
5682
        public AdornerFinal adorner_;
5683
        public Multi_Undo_data multi_Undo_Data;
5684
        public string Symbol_ID = "";
5685
        /// <summary>
5686
        /// Set to 'true' when the left mouse-button is down.
5687
        /// </summary>
5688
        public bool isLeftMouseButtonDownOnWindow = false;
5689

  
5690
        public InkPresenter _InkBoard = null;
5691
        Stroke stroke;
5692
        Boolean IsDrawing = false;
5693
        StylusPointCollection strokePoints;
5694
        //StylusPointCollection erasePoints;
5695
        RenderTargetBitmap canvasImage;
5696
        Point Sync_Offset_Point;
5697

  
5698
        //강인구 테스트
5699
        private Path _SelectionPath { get; set; }
5700
        public Path SelectionPath
5701
        {
5702
            get
5703
            {
5704
                return _SelectionPath;
5705
            }
5706
            set
5707
            {
5708
                if (_SelectionPath != value)
5709
                {
5710
                    _SelectionPath = value;
5711
                    RaisePropertyChanged("SelectionPath");
5712

  
5713
                }
5714
            }
5715
        }
5716

  
5717
        private System.Windows.Controls.Image _imageViewer { get; set; }
5718
        public System.Windows.Controls.Image imageViewer
5719
        {
5720
            get
5721
            {
5722
                if (_imageViewer == null)
5723
                {
5724
                    _imageViewer = new System.Windows.Controls.Image();
5725
                    return _imageViewer;
5726
                }
5727
                else
5728
                {
5729
                    return _imageViewer;
5730
                }
5731
            }
5732
            set
5733
            {
5734
                if (_imageViewer != value)
5735
                {
5736
                    _imageViewer = value;
5737
                }
5738
            }
5739
        }
5740

  
5741
        public bool IsSyncPDFMode { get; set; }
5742

  
5743
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
5744
        public System.Windows.Controls.Image imageViewer_Compare
5745
        {
5746
            get
5747
            {
5748
                if (_imageViewer_Compare == null)
5749
                {
5750
                    _imageViewer_Compare = new System.Windows.Controls.Image();
5751
                    return _imageViewer_Compare;
5752
                }
5753
                else
5754
                {
5755
                    return _imageViewer_Compare;
5756
                }
5757
            }
5758
            set
5759
            {
5760
                if (_imageViewer_Compare != value)
5761
                {
5762
                    _imageViewer_Compare = value;
5763
                }
5764
            }
5765
        }
5766

  
5767
        #endregion
5768

  
5769
        public MainMenu()
5770
        {
5771
            //App.splashString(ISplashMessage.MAINMENU_0);            
5772
           InitializeComponent();
5773

  
5774
            //List<testItem> testItems = new List<testItem>
5775
            //{
5776
            //    new testItem{Title = "test1"},
5777
            //    new testItem{Title = "test2"},
5778
            //    new testItem{Title = "test3"},
5779
            //    new testItem{Title = "test4"},
5780
            //};
5781

  
5782
            //lstSymbolPrivate.ItemsSource = testItems;
5783

  
5784
            this.Loaded += MainMenu_Loaded;
5785
        }
5786

  
5787
        public class TempDt
5788
        {
5789
            public int PageNumber { get; set; }
5790
            public string CommentID { get; set; }
5791
            public string ConvertData { get; set; }
5792
            public int DATA_TYPE { get; set; }
5793
            public string MarkupInfoID { get; set; }
5794
            public int IsUpdate { get; set; }
5795
        }
5796

  
5797
        List<TempDt> tempDtList = new List<TempDt>();
5798

  
5799
        private void SetCursor()
5800
        {
5801
            this.Cursor = cursor;
5802
        }
5803

  
5804
        /// <summary>
5805
        /// get image url
5806
        /// </summary>
5807
        /// <author>humkyung</author>
5808
        /// <param name="sDocumentID"></param>
5809
        /// <returns></returns>
5810
        public string GetImageURL(string sDocumentID, int iPageNo)
5811
        {
5812
            string uri = string.Empty;
5813

  
5814
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
5815
            if (userData.COMPANY != "EXT")
5816
            {
5817
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
5818
            }
5819
            else
5820
            {
5821
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
5822
            }
5823

  
5824
            return uri;
5825
        }
5826

  
5827
        /// <summary>
5828
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
5829
        /// </summary>
5830
        /// <returns></returns>
5831
        public string GetOriginalPDFURL()
5832
        {
5833
            string uri = string.Empty;
5834
            string sDocumentID = this._DocItem.DOCUMENT_ID;
5835
            string filename = string.Empty;
5836
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
5837
            {
5838
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
5839
            }
5840
            else
5841
            {
5842
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
5843
            }
5844

  
5845
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
5846
            if (userData.COMPANY != "EXT")
5847
            {
5848
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
5849
            }
5850
            else
5851
            {
5852
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
5853
            }
5854
            uri = uri.Replace(".png", "");
5855
            return uri;
5856
        }
5857

  
5858
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
5859
        {
5860
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
5861
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
5862
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
5863
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
5864
            {
5865
                return true;
5866
            }
5867

  
5868
            return false;
5869
        }
5870

  
5871
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
5872
        {
5873
            if (rotate.Angle == 90 || rotate.Angle == 270)
5874
            {
5875
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
5876
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
5877
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
5878
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
5879
                {
5880
                    return true;
5881
                }
5882
            }
5883
            else
5884
            {
5885
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
5886
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
5887
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
5888
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
5889
                {
5890
                    return true;
5891
                }
5892
            }
5893

  
5894
            return false;
5895
        }
5896

  
5897
        public void DeleteItem(MarkupInfoItem item)
5898
        {
5899
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
5900
            {
5901
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;           }
5902

  
5903
            
5904
            ViewerDataModel.Instance._markupInfoList.Remove(item);
5905

  
5906
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
5907
            {
5908
                ViewerDataModel.Instance.MarkupControls.Remove(a);
5909
            });
5910

  
5911
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
5912
            {
5913
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
5914
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
5915
                null, Event_Type.Delete, a.CommentID, null);
5916
            });
5917

  
5918
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
5919
            {
5920
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
5921
                //임시파일에서도 삭제
5922
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());                
5923
            });
5924

  
5925
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
5926

  
5927
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
5928
            {
5929
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
5930
                {
5931
                    var infoId = Commons.shortGuid();
5932
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
5933
                    {
5934
                        CreateTime = DateTime.Now,
5935
                        Depatment = userData.DEPARTMENT,
5936
                        UpdateTime = DateTime.Now,
5937
                        DisplayColor = "#FFFF0000",
5938
                        UserID = userData.ID,
5939
                        UserName = userData.NAME,
5940
                        PageCount = 1,
5941
                        Description = "",
5942
                        MarkupInfoID = infoId,
5943
                        MarkupList = null,
5944
                        MarkupVersionID = Commons.shortGuid(),
5945
                        Consolidate = 0,
5946
                        PartConsolidate = 0,
5947
                        userDelete = true,
5948
                        AvoidConsolidate = 0,
5949
                        IsPreviewUser = true
5950
                    };
5951
                    App.Custom_ViewInfoId = infoId;
5952
                }
5953
            }
5954
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
5955
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);    
5956
        }
5957

  
5958
        /// <summary>
5959
        /// delete selected comments
5960
        /// </summary>
5961
        /// <param name="sender"></param>
5962
        /// <param name="e"></param>
5963
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
5964
        {
5965
            //정말 삭제 하시겠습니까?
5966
            DialogParameters parameters = new DialogParameters()
5967
            {
5968
                Owner = Application.Current.MainWindow,
5969
                Content = new TextBlock()
5970
                { 
5971
                    MinWidth = 400,
5972
                    FontSize = 11,
5973
                    Text = "Are you sure you want to delete?",
5974
                    TextWrapping = System.Windows.TextWrapping.Wrap
5975
                },
5976
                Header = "Confirm",
5977
                Theme = new VisualStudio2013Theme(),
5978
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5979
                OkButtonContent = "Yes",
5980
                CancelButtonContent = "No",
5981
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
5982
                {
5983
                    if(wc.DialogResult == true)
5984
                    {
5985
                        //선택된 어도너가 있을시 삭제가 되지 않음
5986
                        SelectionSet.Instance.UnSelect(this);
5987

  
5988
                        Button content = (sender as Button);
5989
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
5990

  
5991
                        DeleteItem(item);
5992
                    }
5993
                }
5994
            };
5995
            RadWindow.Confirm(parameters);
5996
        }
5997

  
5998
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
5999

  
6000
        private static Timer timer;
6001
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
6002
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
6003
        {
6004
            //InitializeComponent();            
6005
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
6006

  
6007
            if (App.ParameterMode)
6008
            {
6009
                App.splashString(ISplashMessage.MAINMENU_1);
6010
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
6011
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
6012
                imageViewer_Compare = new Image();
6013
                ViewerDataModel.Instance.Capture_Opacity = 0;
6014
                da.From = 0.8;
6015
                da.To = 0;
6016
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
6017
                da.AutoReverse = true;
6018
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
6019

  
6020
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
6021
                {
6022
                    this.SymbolPane.Visibility = Visibility.Collapsed;
6023
                    this.FavoritePane.Visibility = Visibility.Collapsed;
6024
                    this.drawingRotateCanvas.IsHitTestVisible = false;
6025
                }
6026
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
6027
            }
6028

  
6029
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
6030

  
6031
        }
6032

  
6033
        private async Task DownloadOriginalFileAsync()
6034
        {
6035
            try
6036
            {
6037
                using (System.Net.WebClient client = new System.Net.WebClient())
6038
                {
6039
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
6040
                    string downloadurl = GetOriginalPDFURL();
6041
                    
6042
                    // canceltoken을 위해서 상위에 선언
6043
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
6044

  
6045
                    client.DownloadProgressChanged += (snd, evt) =>
6046
                    {
6047
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
6048

  
6049
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
6050
                    };
6051

  
6052
                    await task;
6053

  
6054
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
6055
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
6056
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
6057
                }
6058
            }
6059
            catch (Exception ex)
6060
            {
6061
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
6062
            }
6063
        }
6064

  
6065
        private void timercallback(Object o)
6066
        {
6067
            Stopwatch sw = new Stopwatch();
6068
            sw.Start();
6069
            TempFile.TempFileAdd();
6070
            sw.Stop();
6071

  
6072
            Dispatcher.InvokeAsync(new Action(delegate
6073
            {
6074
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
6075
                {
6076
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
6077
                }
6078
            }));
6079

  
6080
            ////GC.Collect();
6081
        }
6082
        
6083
        /// <summary>
6084
        /// update my markuplist
6085
        ///  - update existing markup data if already exist
6086
        ///  - add new markup data if control is new
6087
        /// </summary>
6088
        public void UpdateMyMarkupList()
6089
        {
6090
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
6091

  
6092
            /// add or update markup list
6093
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
6094
            {
6095
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
6096

  
6097
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
6098
                if (exist != null) //신규 추가 된 코멘트
6099
                {
6100
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
6101
                    {
6102
                        exist.Data = root.ConvertData;
6103
                        exist.IsUpdate = true;
6104
                    }
6105
                }
6106
                else if (root.CommentID != null)
6107
                {
6108
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
6109
                    {
6110
                        ID = control.CommentID,
6111
                        Data = root.ConvertData,
6112
                        Data_Type = root.DATA_TYPE,
6113
                        MarkupInfoID = App.Custom_ViewInfoId,
6114
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
6115
                        Symbol_ID = control.SymbolID,
6116
                        //Group_ID = control.GroupID,
6117
                    });
6118
                }
6119
            }
6120

  
6121
            /// delete markup list
6122
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
6123

  
6124
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
6125
                          where (markup.PageNumber == iPageNo) 
6126
                          && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
6127
                          select markup).ToList();
6128

  
6129
            foreach (var markup in deleted)
6130
            {
6131
                ViewerDataModel.Instance.MyMarkupList.Remove(markup);
6132
            }
6133
            /// up to here
6134

  
6135
            //if (modified)
6136
            //{
6137
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
6138
            //    {
6139
            //        ComingNewBieEnd = true;
6140
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
6141
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
6142
            //        gridViewMarkup.ItemsSource = null;
6143
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
6144
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
6145

  
6146
            //        GroupDescriptor descriptor = new GroupDescriptor();
6147
            //        descriptor.Member = "Depatment";
6148
            //        descriptor.DisplayContent = "DEPT";
6149
            //        descriptor.SortDirection = ListSortDirection.Ascending;
6150
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
6151
            //    }
6152
            //}
6153
        }
6154

  
6155
        DispatcherTimer renderTesttimer;
6156

  
6157
        /// <summary>
6158
        /// start page changing
6159
        ///  - save controls if page is modified
6160
        ///  - starting download page image
6161
        /// </summary>
6162
        /// <param name="sender"></param>
6163
        /// <param name="e"></param>
6164
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
6165
        {
6166
            //await Task.Delay(300);
6167

  
6168
            // 마크업 로드
6169
            await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
6170

  
6171
            // 페이지 이미지 변경
6172
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
6173
        }
6174

  
6175
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber)
6176
        { 
6177
            CompareMode.IsChecked = false;
6178
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
6179
           
6180
            #region 페이지가 벗어난 경우
6181

  
6182
            if (BalancePoint < 1)
6183
            {
6184
                BalancePoint = 1;
6185
                ViewerDataModel.Instance.PageBalanceNumber = 0;
6186
            }
6187

  
6188
            if (pageNavigator.PageCount < BalancePoint)
6189
            {
6190
                BalancePoint = pageNavigator.PageCount;
6191
                ViewerDataModel.Instance.PageBalanceNumber = 0;
6192
            }
6193

  
6194
            #endregion
6195

  
6196
            ViewerDataModel.Instance.PageNumber = BalancePoint;
6197

  
6198
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
6199
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
6200
            var contentScale = zoomAndPanControl.ContentScale;
6201

  
6202
            #region 페이지 이미지 로딩 수정
6203

  
6204
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageAsync(changePageNumber);
6205
       
6206
            ScaleImage(pageWidth, pageHeight);
6207

  
6208
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
6209
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
6210

  
6211
            zoomAndPanCanvas.Width = pageWidth;
6212
            zoomAndPanCanvas.Height = pageHeight;
6213

  
6214
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
6215
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
6216

  
6217
            inkBoard.Width = pageWidth;
6218
            inkBoard.Height = pageHeight;
6219

  
6220
            #endregion
6221

  
6222
            if (!testPanel2.IsHidden)
6223
            {
6224
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
6225
                //PDF모드일때 잠시 대기(강인구)
6226
                if (IsSyncPDFMode)
6227
                {
6228
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
6229
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
6230

  
6231
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
6232
                    if (pdfpath.IsDownloading)
6233
                    {
6234
                        pdfpath.DownloadCompleted += (ex, arg) =>
6235
                        {
6236
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
6237
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
6238
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
6239
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
6240
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
6241
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
6242
                        };
6243
                    }
6244
                    else
6245
                    {
6246
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
6247
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
6248
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
6249
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
6250

  
6251
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
6252
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
6253
                    }
6254
                }
6255
                else
6256
                {
6257
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
6258
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
6259

  
6260
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
6261
                    var defaultBitmapImage_Compare = new BitmapImage();
6262
                    defaultBitmapImage_Compare.BeginInit();
6263
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
6264
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
6265
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
6266
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
6267
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
6268
                    defaultBitmapImage_Compare.EndInit();
6269

  
6270
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
6271

  
6272
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
6273
                    zoomAndPanControl.ZoomTo(new Rect
6274
                    {
6275
                        X = 0,
6276
                        Y = 0,
6277
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
6278
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
6279
                    });
6280

  
6281
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
6282
                    if (defaultBitmapImage_Compare.IsDownloading)
6283
                    {
6284
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
6285
                        {
6286
                            defaultBitmapImage_Compare.Freeze();
6287
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6288
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6289
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6290
                            ComparePanel.UpdateLayout();
6291
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
6292
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
6293

  
6294
                            zoomAndPanControl.ZoomTo(new Rect
6295
                            {
6296
                                X = 0,
6297
                                Y = 0,
6298
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
6299
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
6300
                            });
6301

  
6302
                            //defaultBitmapImage_Compare dispose
6303
                            defaultBitmapImage_Compare = null;
6304
                            GC.Collect();
6305
                        };
6306
                    }
6307
                }
6308
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
6309
            }
6310

  
6311
            SearchFocusBorder.Visibility = Visibility.Collapsed;
6312

  
6313
            this.pageNavigator.ChangePage(changePageNumber);
6314
        }
6315

  
6316
        /// <summary>
6317
        /// called after page is changed
6318
        /// </summary>
6319
        /// <param name="sender"></param>
6320
        /// <param name="e"></param>
6321
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
6322
        {
6323
            //if (zoomAndPanCanvas.Width.IsNaN())
6324
            //{
6325

  
6326
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
6327
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
6328
                );
6329
            //}
6330

  
6331

  
6332
            var instanceMain = ViewerDataModel.Instance.SystemMain;
6333

  
6334
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
6335
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
6336

  
6337
            instanceMain.dzTopMenu.rotateOffSet = 0;
6338
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
6339
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
6340

  
6341
            /// 페이지의 모든 마크업을 로드한 후 호출
6342
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
6343
            ViewerDataModel.Instance.LoadPageMarkup();
6344
        }
6345

  
6346
        private void MarkupLoad(int pageNumber)
6347
        { 
6348
            /// 컨트롤을 새로 생성한다.
6349
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
6350
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
6351
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
6352
            { 
6353
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
6354
                if (info != null)
6355
                {
6356
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
6357
                    if (info.UserID == App.ViewInfo.UserID)
6358
                    {
6359
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
6360
                                        markup.MarkupInfoID, markup.ID);
6361
                        control.Visibility = Visibility.Hidden;
6362
                    }
6363
                    else
6364
                    {
6365
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
6366
                                                                markup.MarkupInfoID, markup.ID);
6367
                        control.Visibility = Visibility.Hidden;
6368
                    }
6369
                }
6370
            };
6371
            /// up to here
6372

  
6373
            /// fire selection event
6374
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
6375
            this.gridViewMarkup.UnselectAll();
6376
            this.gridViewMarkup.Select(gridSelectionItem);
6377

  
6378
            if (!testPanel2.IsHidden)
6379
            {
6380
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
6381
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
6382
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
6383

  
6384
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
6385
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6386

  
6387

  
6388
                foreach (var item in gridSelectionRevItem)
6389
                {
6390
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
6391
                    {
6392
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
6393
                    });
6394
                }
6395
            }
6396
            
6397
            SetCommentPages();
6398

  
6399
        }
6400

  
6401
        public void SetCommentPages()
6402
        {
6403
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
6404
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
6405
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
6406
            {
6407
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
6408
                if(item.MarkupList != null)
6409
                {
6410
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
6411
                    instance.UserName = item.UserName;
6412
                    instance.Depart = item.Depatment;
6413
                    instance.MarkupInfoID = item.MarkupInfoID;
6414
                    instance.IsSelected = true;
6415
                    instance.isConSolidation = item.Consolidate;
6416
                    instance.SetColor = item.DisplayColor;
6417
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
6418
                    {
6419
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
6420
                    }
6421
                    else
6422
                    {
6423
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
6424
                    }
6425
                    _pages.Add(instance);
6426
                }                   
6427
            }
6428
            
6429
            this.pageNavigator.SetCommentList(_pages.ToList());
6430
        }
6431

  
6432
        public void MarkupitemViewUpdate(string markupinfo_id)
6433
        {
6434
            //db에 업데이트 한 list 를 view 에 업데이트
6435
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
6436
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
6437
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
6438
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
6439
            if (dbinfo.MarkupList.Count > 0)
6440
            {
6441
                if (viewinfo.MarkupList != null)
6442
                {
6443
                    viewinfo.MarkupList.Clear();
6444
                    viewinfo.MarkupList = null;
6445
                }
6446
                viewinfo.MarkupList = new List<MarkupItem>();
6447
                foreach (var item in dbinfo.MarkupList)
6448
                {
6449
                    viewinfo.MarkupList.Add(item);
6450
                }
6451
            }
6452
        }
6453

  
6454
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
6455
        {
6456
            var instance = ViewerDataModel.Instance;
6457

  
6458
            if(instance.IsWheelPageChanage)
6459
            {
6460
                return;
6461
            }
6462

  
6463
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
6464
            {
6465
       
6466
                int changePage = 0;
6467
                
6468
                if (e.Delta > 0)
6469
                {
6470
                    if (0 < instance.ContentOffsetY)
6471
                    {
6472
                        Vector dragOffset = new Vector(0, e.Delta);
6473
                        MoveZoomAndPanControl(dragOffset);
6474
                    }
6475
                    //else
6476
                    //{
6477
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
6478
                    //    {
6479
                    //        instance.IsWheelPageChanage = true;
6480
                    //        changePage -= 1;
6481
                    //    }
6482
                    //}
6483
                }
6484
                else if(e.Delta < 0)
6485
                {
6486
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
6487
                    {
6488
                        Vector dragOffset = new Vector(0,e.Delta);
6489
                        MoveZoomAndPanControl(dragOffset);
6490
                    }
6491
                    //else
6492
                    //{
6493
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
6494
                    //    {
6495
                    //        instance.IsWheelPageChanage = true;
6496
                    //        changePage += 1;
6497
                    //    }
6498
                    //}
6499
                }
6500

  
6501
                //if (changePage != 0)
6502
                //{
6503
                //    await Task.Factory.StartNew(() =>
6504
                //    {
6505
                //        double beforeScale = instance.ContentScale;
6506

  
6507
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
6508

  
6509
                //        handler = (snd, evt) =>
6510
                //        {
6511
                //            /// 최상단으로 이전 zoomScale로 위치한다
6512
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
6513
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
6514
                //            instance.IsWheelPageChanage = false;
6515
                //            pageNavigator.PageChanged -= handler;
6516
                //        };
6517

  
6518
                //        pageNavigator.PageChanged += handler;
6519

  
6520
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
6521
                //    });
6522
                    
6523

  
6524
                //}
6525
            }
6526
            else
6527
            {
6528
                e.Handled = true;
6529
                if (e.Delta > 0)
6530
                {
6531
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
6532
                    ZoomIn(currentContentMousePoint);
6533
                }
6534
                else
6535
                {
6536
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
6537
                    ZoomOut(currentContentMousePoint);
6538
                }
6539
            }
6540
        }
6541

  
6542
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
6543
        {
6544
            e.Handled = true;
6545
            if (e.Delta > 0)
6546
            {
6547
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
6548
                ZoomIn_Sync(currentContentMousePoint);
6549
            }
6550
            else
6551
            {
6552
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
6553
                ZoomOut_Sync(currentContentMousePoint);
6554
            }
6555
        }
6556

  
6557
        #region ZoomIn & ZoomOut
6558

  
6559
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
6560
        {
6561
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
6562
                zoomAndPanControl.ContentZoomFocusY));
6563
        }
6564

  
6565
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
6566
        {
6567
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
6568
                zoomAndPanControl.ContentZoomFocusY));
6569
        }
6570

  
6571

  
6572
        //강인구 추가 (줌 인아웃 수치 변경)
6573
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
6574
        private void ZoomOut(Point contentZoomCenter)
6575
        {
6576
            if (zoomAndPanControl.ContentScale > 0.39)
6577
            {
6578
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
6579
            }
6580
            else
6581
            {
6582
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
6583
            }
6584

  
6585
            if (zoomAndPanControl2 != null && Sync.IsChecked)
6586
            {
6587
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
6588
            }
6589
        }
6590

  
6591
        private void ZoomIn(Point contentZoomCenter)
6592
        {
6593
            if (zoomAndPanControl.ContentScale > 0.19)
6594
            {
6595
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
6596
            }
6597
            else
6598
            {
6599
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
6600
            }
6601

  
6602
            if (zoomAndPanControl2 != null && Sync.IsChecked)
6603
            {
6604
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
6605
            }
6606

  
6607
        }
6608

  
6609
        private void ZoomOut_Sync(Point contentZoomCenter)
6610
        {
6611
            if (zoomAndPanControl2.ContentScale > 0.39)
6612
            {
6613
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
6614
            }
6615
            else
6616
            {
6617
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
6618
            }
6619

  
6620
            if (Sync.IsChecked)
6621
            {
6622
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
6623
            }
6624
        }
6625

  
6626
        private void ZoomIn_Sync(Point contentZoomCenter)
6627
        {
6628
            if (zoomAndPanControl2.ContentScale > 0.19)
6629
            {
6630
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
6631
            }
6632
            else
6633
            {
6634
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
6635
            }
6636

  
6637
            if (Sync.IsChecked)
6638
            {
6639
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
6640
            }
6641
        }
6642

  
6643
        private void ZoomOut()
6644
        {
6645
            zoomAndPanControl.ContentScale -= 0.1;
6646
            //if (zoomAndPanControl2 != null)
6647
            //{
6648
            //    zoomAndPanControl2.ContentScale -= 0.1;
6649
            //}
6650
        }
6651

  
6652
        private void ZoomIn()
6653
        {
6654
            zoomAndPanControl.ContentScale += 0.1;
6655
            //if (zoomAndPanControl2 != null)
6656
            //{
6657
            //    zoomAndPanControl2.ContentScale += 0.1;
6658
            //}
6659
        }
6660

  
6661
        #endregion
6662

  
6663
        private void init()
6664
        {
6665
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
6666
            {
6667

  
6668
                ControlList.Clear();
6669
                listBox.Items.Clear();
6670
                selected_item.Clear();
6671

  
6672
                (item as IMarkupCommonData).IsSelected = false;
6673
            }
6674

  
6675
        }
6676

  
6677
        private HitTestResultBehavior MyCallback(HitTestResult result)
6678
        {
6679
            //this.cursor = Cursors.UpArrow;
6680
            var element = result.VisualHit;
6681
            while (element != null && !(element is CommentUserInfo))
6682
                element = VisualTreeHelper.GetParent(element);
6683

  
6684
            if (element == null)
6685
            {
6686
                return HitTestResultBehavior.Stop;
6687
            }
6688
            else
6689
            {
6690
                if (element is CommentUserInfo)
6691
                {
6692
                    if (!hitList.Contains(element))
6693
                    {
6694
                        hitList.Add((CommentUserInfo)element);
6695
                    }
6696
                    else
6697
                    {
6698
                        return HitTestResultBehavior.Stop;
6699
                    }
6700
                }
6701
            }
6702
            return HitTestResultBehavior.Continue;
6703
        }
6704

  
6705
        public void ReleaseSelectPath()
6706
        {
6707
            if (SelectionPath == null)
6708
            {
6709
                SelectionPath = new Path();
6710
                SelectionPath.Name = "";
6711
            }
6712
            if (SelectionPath.Name != "")
6713
            {
6714
                SelectionPath.Name = "None";
6715
            }
6716
            SelectionPath.Opacity = 0.01;
6717
            SelectionPath.RenderTransform = null;
6718
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
6719
        }
6720

  
6721
        #region 컨트롤 초기화 
6722
        public void Control_Init(object control)
6723
        {
6724
            if (L_Size != 0 && (control as IPath) != null)
6725
            {
6726
                (control as IPath).LineSize = L_Size;
6727
                L_Size = 0;
6728
            }
6729

  
6730
            switch (control.GetType().Name)
6731
            {
6732
                case "RectangleControl":
6733
                    {
6734
                        (control as RectangleControl).StrokeColor = Brushes.Red;
6735
                    }
6736
                    break;
6737
                case "CircleControl":
6738
                    {
6739
                        (control as CircleControl).StrokeColor = Brushes.Red;
6740
                    }
6741
                    break;
6742
                case "TriControl":
6743
                    {
6744
                        (control as TriControl).StrokeColor = Brushes.Red;
6745
                    }
6746
                    break;
6747
                case "RectCloudControl":
6748
                    {
6749
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
6750
                    }
6751
                    break;
6752
                case "CloudControl":
6753
                    {
6754
                        (control as CloudControl).StrokeColor = Brushes.Red;
6755
                    }
6756
                    break;
6757
                case "PolygonControl":
6758
                    {
6759
                        (control as PolygonControl).StrokeColor = Brushes.Red;
6760
                    }
6761
                    break;
6762
                case "ArcControl":
6763
                    {
6764
                        (control as ArcControl).StrokeColor = Brushes.Red;
6765
                    }
6766
                    break;
6767
                case "ArrowArcControl":
6768
                    {
6769
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
6770
                    }
6771
                    break;
6772
                case "LineControl":
6773
                    {
6774
                        (control as LineControl).StrokeColor = Brushes.Red;
6775
                    }
6776
                    break;
6777
                case "ArrowControl_Multi":
6778
                    {
6779
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
6780
                    }
6781
                    break;
6782
                case "TextControl":
6783
                    {
6784
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
6785
                    }
6786
                    break;
6787
                case "ArrowTextControl":
6788
                    {
6789
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
6790
                    }
6791
                    break;
6792
                case "InsideWhiteControl":
6793
                    {
6794
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
6795
                    }
6796
                    break;
6797
                case "OverlapWhiteControl":
6798
                    {
6799
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
6800
                    }
6801
                    break;
6802
                case "ClipWhiteControl":
6803
                    {
6804
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
6805
                    }
6806
                    break;
6807
                case "CoordinateControl":
6808
                    {
6809
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
6810
                    }
6811
                    break;
6812
            }
6813
        }
6814
        #endregion
6815

  
6816
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
6817
        {
6818
            //Control_Init(e.Source);
6819
        }
6820
        //private Window _dragdropWindow = null;
6821

  
6822
        [DllImport("user32.dll")]
6823
        [return: MarshalAs(UnmanagedType.Bool)]
6824
        internal static extern bool GetCursorPos(ref Win32Point pt);
6825

  
6826
        [StructLayout(LayoutKind.Sequential)]
6827
        internal struct Win32Point
6828
        {
6829
            public Int32 X;
6830
            public Int32 Y;
6831
        };
6832
        /*
6833
       public string symbol_id = null;
6834
       public long symbol_group_id;
6835
       public int symbol_SelectedIndex;
6836
       public ImageSource symbol_img;
6837
       public string symbol_Data = null;
6838
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
6839
       {
6840
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
6841
               zoomAndPanCanvas.ActualHeight / 2));
6842

  
6843

  
6844
               if (this._dragdropWindow != null)
6845
               {
6846
                   this._dragdropWindow.Close();
6847
                   this._dragdropWindow = null;
6848
               }
6849

  
6850
               symbol_id = id;
6851
               symbol_group_id = group_id;
6852
               symbol_SelectedIndex = SelectedIndex;
6853
               symbol_Data = Data_;
6854
               symbol_img = img;
6855

  
6856

  
6857
               CreateDragDropWindow2(img);
6858
              
6859
    }
6860

  
6861
    private void CreateDragDropWindow2(ImageSource image)
6862
        {
6863
            this._dragdropWindow = new Window();
6864
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
6865
            _dragdropWindow.WindowStyle = WindowStyle.None;
6866
            _dragdropWindow.AllowsTransparency = true;           
6867
            _dragdropWindow.AllowDrop = false;
6868
            _dragdropWindow.Background = null;
6869
            _dragdropWindow.IsHitTestVisible = false;
6870
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
6871
            _dragdropWindow.Topmost = true;
6872
            _dragdropWindow.ShowInTaskbar = false;
6873
            
6874
            Rectangle r = new Rectangle();
6875
            r.Width = image.Width;
6876
            r.Height = image.Height;
6877
            r.Opacity = 0.5;            
6878
            r.Fill = new ImageBrush(image);
6879
            this._dragdropWindow.Content = r;
6880

  
6881
            Win32Point w32Mouse = new Win32Point();
6882
            GetCursorPos(ref w32Mouse);
6883

  
6884
            //w32Mouse.X = getCurrentPoint.X;
6885
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
6886
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
6887
            this._dragdropWindow.Show();
6888
        }
6889

  
6890
        
6891

  
6892
         */
6893

  
6894
        public void MoveZoomAndPanControl(Vector dragOffset)
6895
        {
6896
   
6897
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
6898
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
6899

  
6900
            if (Sync.IsChecked)
6901
            {
6902
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
6903
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
6904
            }
6905
        }
6906

  
6907
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
6908
        {
6909
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
6910
            {
6911
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
6912

  
6913
                Point currentPos = e.GetPosition(rect);
6914

  
6915
                floatingTip.HorizontalOffset = currentPos.X + 20;
6916
                floatingTip.VerticalOffset = currentPos.Y;
6917
            }
6918

  
6919
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6920
            
6921
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
6922
            {
6923
                SetCursor();
6924
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
6925
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
6926

  
6927
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
6928

  
6929
                MoveZoomAndPanControl(dragOffset);
6930
            }
6931

  
6932
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
6933
            {
6934
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
6935
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
6936
                SetCursor();
6937

  
6938
                if (currentControl != null)
6939
                {
6940
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
6941
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
6942
                    //강인구 추가
6943
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
6944

  
6945
                    if ((currentControl as IPath) != null)
6946
                    {
6947
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
6948
                    }
6949
                    if ((currentControl as LineControl) != null)
6950
                    {
6951
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
6952
                    }
6953

  
6954
                    if ((currentControl as IShapeControl) != null)
6955
                    {
6956
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
6957
                    }
6958
                    if ((currentControl as TextControl) != null)
6959
                    {
6960
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
6961
                        {
6962
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
6963
                        }
6964
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
6965
                        {
6966
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
6967
                        }
6968
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
6969
                        {
6970
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
6971
                        }
6972
                    }
6973
                    else if ((currentControl as ArrowTextControl) != null)
6974
                    {
6975
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
6976
                        {
6977
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
6978
                        }
6979
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
6980
                        {
6981
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
6982
                        }
6983
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
6984
                        {
6985
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
6986
                        }
6987
                    }
6988
                    else if ((currentControl as RectCloudControl) != null)
6989
                    {
6990
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
6991
                    }
6992
                    else if ((currentControl as CloudControl) != null)
6993
                    {
6994
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
6995
                    }
6996

  
6997

  
6998
                    #region // 모든 컨트롤의 공통기능 제어
6999
                    if (controlType != ControlType.PenControl)
7000
                    {
7001
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
7002
                    }
7003

  
7004

  
7005
                    #endregion
7006

  
7007
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
7008

  
7009
                    switch (controlType)
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

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