프로젝트

일반

사용자정보

개정판 53880c83

ID53880c83defd8cc6468fd4130469156a289f4e62
상위 6472f348
하위 97e8ad04

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

issue #886: Symbol legend 생성 작업 중....

차이점 보기:

KCOM/Views/MainMenu.xaml.cs
34 34
using System.Diagnostics;
35 35
using System.Threading;
36 36
using System.Windows.Resources;
37
using Svg2Xaml;
38
using System.Runtime.InteropServices;
39
using System.Windows.Media.Effects;
37 40

  
38 41
namespace KCOM.Views
39 42
{
......
154 157
        Stroke stroke;
155 158
        Boolean IsDrawing = false;
156 159
        StylusPointCollection strokePoints;
157
        StylusPointCollection erasePoints;
160
        //StylusPointCollection erasePoints;
158 161
        RenderTargetBitmap canvasImage;
159 162
        Point Sync_Offset_Point;
160 163

  
......
232 235
        public MainMenu()
233 236
        {
234 237
            //InitializeComponent();    
235
            this.Loaded += MainMenu_Loaded;
238
            this.Loaded += MainMenu_Loaded;            
236 239
        }
237 240

  
238 241
        public class TempDt
......
389 392
                    this.SymbolPane.Visibility = Visibility.Collapsed;
390 393
                    this.FavoritePane.Visibility = Visibility.Collapsed;
391 394
                    this.drawingRotateCanvas.IsHitTestVisible = false;
392
                }
395
                }                
393 396
            }
394 397
            timer = new Timer(timercallback, null, 0, InitInterval * 60000); 
395 398
        }
......
662 665
                                    MarkupInfoID = App.Custom_ViewInfoId,
663 666
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
664 667
                                    Symbol_ID = control.SymbolID,
668
                                    Group_ID = control.GroupID,
665 669
                                });
666 670
                                ComingNewBieEnd = false;
667 671
                            }
......
733 737
            {
734 738
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
735 739
            }
736

  
740
            
737 741
            var defaultBitmapImage = new BitmapImage();
738 742
            defaultBitmapImage.BeginInit();
739 743
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
......
1315 1319
        {
1316 1320
            //Control_Init(e.Source);
1317 1321
        }
1322
        private Window _dragdropWindow = null;
1323
        private bool symbolMouse = false;
1324

  
1325
        [DllImport("user32.dll")]
1326
        [return: MarshalAs(UnmanagedType.Bool)]
1327
        internal static extern bool GetCursorPos(ref Win32Point pt);
1328

  
1329
        [StructLayout(LayoutKind.Sequential)]
1330
        internal struct Win32Point
1331
        {
1332
            public Int32 X;
1333
            public Int32 Y;
1334
        };
1335
        public string symbol_id = null;
1336
        public long symbol_group_id;
1337
        public int symbol_SelectedIndex;
1338
        public ImageSource symbol_img;
1339
        public string symbol_Data = null;
1340
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1341
        {
1342
            if (this._dragdropWindow != null)
1343
            {
1344
                this._dragdropWindow.Close();
1345
                this._dragdropWindow = null;
1346
            }
1347

  
1348
            symbol_id = id;
1349
            symbol_group_id = group_id;
1350
            symbol_SelectedIndex = SelectedIndex;
1351
            symbol_Data = Data_;
1352
            symbol_img = img;
1353

  
1354
      
1355
            CreateDragDropWindow2(img);
1356
        }
1357

  
1358
        private void CreateDragDropWindow2(ImageSource image)
1359
        {
1360
            this._dragdropWindow = new Window();
1361
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1362
            _dragdropWindow.WindowStyle = WindowStyle.None;
1363
            _dragdropWindow.AllowsTransparency = true;           
1364
            _dragdropWindow.AllowDrop = false;
1365
            _dragdropWindow.Background = null;
1366
            _dragdropWindow.IsHitTestVisible = false;
1367
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1368
            _dragdropWindow.Topmost = true;
1369
            _dragdropWindow.ShowInTaskbar = false;
1370
            
1371
            Rectangle r = new Rectangle();
1372
            r.Width = image.Width;
1373
            r.Height = image.Height;
1374
            r.Opacity = 0.5;            
1375
            r.Fill = new ImageBrush(image);
1376
            this._dragdropWindow.Content = r;
1377

  
1378
            Win32Point w32Mouse = new Win32Point();
1379
            GetCursorPos(ref w32Mouse);
1380

  
1381
            //w32Mouse.X = getCurrentPoint.X;
1382
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1383
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1384
            this._dragdropWindow.Show();
1385
        }
1318 1386

  
1319 1387
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1320 1388
        {
......
1418 1486
            }
1419 1487

  
1420 1488
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1421

  
1489
            #region 주석
1422 1490
            //if (mouseButtonDown == MouseButton.Middle)
1423 1491
            //{
1424 1492
            //    SetCursor();
......
1441 1509
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1442 1510
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1443 1511
            //}
1512
            #endregion
1513

  
1444 1514
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1445 1515
            {
1446 1516
                SetCursor();
......
1458 1528
                }
1459 1529
            }
1460 1530

  
1461

  
1462 1531
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1463 1532
            {
1464 1533
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
......
2387 2456

  
2388 2457
                                    if (control.StartPoint == control.EndPoint)
2389 2458
                                    {
2390
                                        string appovalData = "";
2459
                                        //string appovalData = "";
2391 2460

  
2392 2461
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2393 2462
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
......
2547 2616
                    e.Handled = true;
2548 2617
                }
2549 2618
            }
2619
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2620
            { //symbol      
2621
                if(_dragdropWindow != null)
2622
                {
2623
                    Win32Point w32Mouse = new Win32Point();
2624
                    GetCursorPos(ref w32Mouse);
2625

  
2626
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2627
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2628
                }                
2629
            }
2550 2630
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2551 2631
            {
2552 2632
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
......
2558 2638
                else
2559 2639
                {
2560 2640
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2561
                   
2641

  
2562 2642
                    SetCursor();
2563 2643
                }
2564 2644
            }
......
2666 2746

  
2667 2747
                        if (isDraggingSelectionRect)
2668 2748
                        {
2669
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2749
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2750
                            {
2751
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2752
                                mouseHandlingMode = MouseHandlingMode.None;
2753
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2754
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2755
                                Set_Symbol_Capture(endPoint);
2756
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2757
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2758
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2759
                            }
2760
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2670 2761
                            {
2671 2762
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2672 2763
                                mouseHandlingMode = MouseHandlingMode.None;
......
2732 2823
            //controlType = ControlType.SingleLine;
2733 2824
        }
2734 2825

  
2826
        public void Set_Symbol_Capture(Point endPoint)
2827
        {       
2828
            double x = canvasDrawingMouseDownPoint.X;
2829
            double y = canvasDrawingMouseDownPoint.Y;
2830
            if(x > endPoint.X)
2831
            {
2832
                x = endPoint.X;
2833
                y = endPoint.Y;
2834
            }
2835

  
2836
            double width = dragCaptureBorder.Width;
2837
            double height = dragCaptureBorder.Height;
2838

  
2839
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2840

  
2841
            if (x < 0)
2842
            {
2843
                width += x;
2844
                x = 0;
2845
            }
2846
            if (y < 0)
2847
            {
2848
                height += y;
2849
                y = 0;
2850

  
2851
                width = (int)canvasImage.PixelWidth - x;
2852
            }
2853
            if (x + width > canvasImage.PixelWidth)
2854
            {
2855
                width = (int)canvasImage.PixelWidth - x;
2856
            }
2857
            if (y + height > canvasImage.PixelHeight)
2858
            {
2859
                height = (int)canvasImage.PixelHeight - y;
2860
            }
2861
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2862

  
2863
            string uri = "";
2864
            if (userData.COMPANY != "EXT")
2865
            {
2866
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO,
2867
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2868
            }
2869
            else
2870
            {
2871
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
2872
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2873
            }
2874

  
2875
            var defaultBitmapImage = new BitmapImage();
2876
            defaultBitmapImage.BeginInit();
2877
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2878
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2879
            defaultBitmapImage.UriSource = new Uri(uri);
2880
            defaultBitmapImage.EndInit();
2881

  
2882
            GC.Collect();
2883

  
2884
            if (defaultBitmapImage.IsDownloading)
2885
            {
2886
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2887
                {
2888
                    defaultBitmapImage.Freeze();
2889
                    GC.Collect();
2890
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2891
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2892
                };
2893
            }
2894
        }
2895

  
2735 2896
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2736 2897
        {
2737 2898
            mouseButtonDown = MouseButton.Left;
......
2740 2901
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2741 2902
        {
2742 2903
            mouseButtonDown = MouseButton.Left;
2743
            this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2904
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2744 2905
        }
2745 2906

  
2746 2907
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
......
2848 3009
                    Control_Style(item);
2849 3010
                    UndoData.Markup_List.Add(multi_Undo_Data);
2850 3011
                    multi_Undo_Data = new Multi_Undo_data();
3012
                    if (item.GroupID > 0)
3013
                    {
3014

  
3015
                    }
2851 3016
                }
2852 3017
            }
2853 3018
            if (adornerSet.Count > 0)
......
3014 3179
            ViewerDataModel.Instance.Angle = rotate.Angle;
3015 3180
        }
3016 3181

  
3017
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3182
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
3018 3183
        {
3184
            string Data_ = "";
3185

  
3186
            try
3187
            {
3188
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
3189
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
3190
                if (Data_ != null || Data_ != "")
3191
                {
3192
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
3193
                }
3194
                else
3195
                {
3196
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
3197
                }
3198

  
3199
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
3200
                {
3201
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
3202
                    STATE = 0,
3203
                };
3204
                if (Data_ != null)
3205
                {
3206
                    Image img = new Image();
3207
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
3208
                    if (Data_.Contains(".svg"))
3209
                    {
3210
                        byte[] imageData = null;
3211
                        DrawingImage image = null;
3212
                        using (System.Net.WebClient web = new System.Net.WebClient())
3213
                        {
3214
                            imageData = web.DownloadData(new Uri(Data_));
3215
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3216
                            image = SvgReader.Load(stream);
3217
                        }
3218
                        img.Source = image;
3219
                    }
3220
                    else
3221
                    {
3222
                        img.Source = new BitmapImage(new Uri(Data_));
3223
                    }
3224

  
3225
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3226
                    {
3227
                        PointSet = new List<Point>(),
3228
                        FilePath = Data_,
3229
                        ImageData = img.Source,
3230
                        StartPoint = canvasZoomPanningMouseDownPoint,
3231
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3232
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3233
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3234
                        canvasZoomPanningMouseDownPoint.Y),
3235
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3236
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3237
                    };
3238

  
3239
                    currentControl.PointSet = new List<Point>
3240
                                        {
3241
                                            currentControl.StartPoint,
3242
                                            currentControl.LeftBottomPoint,
3243
                                            currentControl.EndPoint,
3244
                                            currentControl.TopRightPoint,
3245
                                        };
3246
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3247
                    UndoData = new Undo_data()
3248
                    {
3249
                        IsUndo = false,
3250
                        Event = Event_Type.Create,
3251
                        EventTime = DateTime.Now,
3252
                        Markup_List = new List<Multi_Undo_data>()
3253
                    };
3254
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3255
                    {
3256
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3257
                    });
3258

  
3259
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3260
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3261
                    UndoData.Markup_List.Add(multi_Undo_Data);
3262
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3263

  
3264
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3265
                    currentControl.CommentID = Events.Save.shortGuid();
3266
                    currentControl.SymbolID = id;
3267
                    currentControl.GroupID = group_id;
3268
                    currentControl.ApplyTemplate();
3269
                    currentControl.SetImage();
3270

  
3271
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3272
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3273
                    SelectLayer.Children.Add(final);
3274
                }
3275
            }
3276
            catch (Exception ex)
3277
            {
3278
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3279
            }
3280
        }
3281

  
3282
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3283
        {            
3019 3284
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3020 3285
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3021 3286
            {
......
3076 3341
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3077 3342
            }
3078 3343

  
3344
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3345
            {                
3346
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3347
                //SetCursor();
3348

  
3349
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3350
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3351
                if(symbol_id != null)
3352
                {
3353
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3354
                }                
3355
            }
3356

  
3357
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3358
            {
3359
                if (this._dragdropWindow != null)
3360
                {
3361
                    this._dragdropWindow.Close();
3362
                    this._dragdropWindow = null;
3363
                    symbol_id = null;
3364
                }
3365
            }
3366

  
3079 3367
            if (mouseButtonDown == MouseButton.Left)
3080 3368
            {
3081 3369
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
......
3980 4268

  
3981 4269
                                        CreateControl();
3982 4270
                                        (currentControl as ImgControl).ApplyOverViewData();
3983

  
4271
                                        controlType = ControlType.ImgControl;
3984 4272
                                        currentControl = null;
3985 4273
                                    }
3986 4274
                                    else
3987 4275
                                    {
3988 4276
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3989
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
4277
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3990 4278
                                        {
3991 4279
                                            Image img = new Image();
3992
                                            img.Source = new BitmapImage(new Uri(filename));
4280
                                            //img.Source = new BitmapImage(new Uri(filename));
4281
                                            if (filename.Contains(".svg"))
4282
                                            {
4283
                                                byte[] imageData = null;
4284
                                                DrawingImage image = null;
4285
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4286
                                                {
4287
                                                    imageData = web.DownloadData(new Uri(filename));
4288
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4289
                                                    image = SvgReader.Load(stream);
4290
                                                }
4291
                                                img.Source = image;
4292
                                            }
4293
                                            else
4294
                                            {
4295
                                                img.Source = new BitmapImage(new Uri(filename));
4296
                                            }
3993 4297

  
3994 4298
                                            currentControl = new ImgControl
3995 4299
                                            {
3996
                                                Background = new SolidColorBrush(Colors.Black),
3997
                                                PointSet = new List<Point>(),
3998
                                                FilePath = filename,
3999
                                                ImageData = img.Source,
4000
                                                StartPoint = canvasDrawingMouseDownPoint,
4001
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4002
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4003
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
4004
                                            };
4005

  
4006
                                            currentControl.CommentID = Save.shortGuid();
4007
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4008
                                            currentControl.IsNew = true;
4009
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4010

  
4011
                                            //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4012
                                            (currentControl as ImgControl).Angle -= rotate.Angle;
4013
                                    }
4300
                                                    Background = new SolidColorBrush(Colors.Black),
4301
                                                    PointSet = new List<Point>(),
4302
                                                    FilePath = filename,
4303
                                                    ImageData = img.Source,
4304
                                                    StartPoint = canvasDrawingMouseDownPoint,
4305
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4306
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4307
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4308
                                                    ControlType = ControlType.ImgControl
4309
                                                };
4310

  
4311
                                        
4312
                                                currentControl.CommentID = Save.shortGuid();                                            
4313
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4314
                                                currentControl.IsNew = true;
4315
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4316

  
4317
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4318
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4319
                                        }
4014 4320
                                    }
4015 4321
                                //}
4016 4322
                            }
......
5496 5802
            }
5497 5803

  
5498 5804
        }
5805
        public int symbolselectindex = 0;
5806
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5807
        {
5808
            //Save save = new Save();
5809
            try
5810
            {
5811
                string svgfilename = null;
5812
                if (symbolname != null)
5813
                {
5814
                    if (symbolpng == true || symbolsvg == true)
5815
                    {
5816
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5817
                        string guid = Save.shortGuid();
5818

  
5819
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5820
                        fileUploader.RunCompleted += (ex, arg) =>
5821
                        {
5822
                            filename = arg.Result;
5823
                            if (symbolpng == true)
5824
                            {
5825
                                if (filename != null)
5826
                                { 
5827
                                    if (symbolselectindex == 0)
5828
                                    {
5829
                                        SymbolSave(symbolname, filename, data);
5830
                                    }
5831
                                    else
5832
                                    {
5833
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5834
                                    }
5835
                                    DataBind();
5836
                                }                                
5837
                            }
5838

  
5839

  
5840

  
5841
                            if (symbolsvg == true)
5842
                            {
5843
                                //Common.Converter.SvgConverter svgConverter = new Common.Converter.SvgConverter();
5844
                                var defaultBitmapImage = new BitmapImage();
5845
                                defaultBitmapImage.BeginInit();
5846
                                defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5847
                                defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5848
                                defaultBitmapImage.UriSource = new Uri(filename);
5849
                                defaultBitmapImage.EndInit();
5850

  
5851
                                GC.Collect();
5852
                                System.Drawing.Bitmap image;
5853

  
5854
                                if (defaultBitmapImage.IsDownloading)
5855
                                {
5856
                                    defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5857
                                    {
5858
                                        defaultBitmapImage.Freeze();
5859
                                        GC.Collect();
5860

  
5861
                                        image = GetBitmap(defaultBitmapImage);
5862

  
5863
                                        image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5864

  
5865
                                        Process potrace = new Process
5866
                                        {
5867
                                            StartInfo = new ProcessStartInfo
5868
                                            {
5869
                                                //FileName = @"http://cloud.devdoftech.co.kr:5977/UserData/"+ "potrace.exe",
5870
                                                FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5871
                                                //Arguments = "-s -u 1", //SVG
5872
                                                //Arguments = "- -o- --svg",
5873
                                                //Arguments = filename2 + "  --backend svg",
5874
                                                //Arguments = @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp" + "  --backend svg -i",
5875
                                                //Arguments = "-b svg -i " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5876
                                                Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5877
                                                RedirectStandardInput = true,
5878
                                                RedirectStandardOutput = true,
5879
                                                //RedirectStandardError = Program.IsDebug,
5880
                                                RedirectStandardError = true,
5881
                                                UseShellExecute = false,
5882
                                                CreateNoWindow = true,
5883
                                                WindowStyle = ProcessWindowStyle.Hidden
5884
                                            },
5885
                                            //EnableRaisingEvents = false
5886
                                        };
5887

  
5888
                                        StringBuilder svgBuilder = new StringBuilder();
5889
                                        potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) => {
5890
                                            svgBuilder.AppendLine(e2.Data);
5891
                                        };
5892

  
5893

  
5894
                                        //potrace.WaitForExit();
5895

  
5896
                                        potrace.EnableRaisingEvents = true;
5897
                                        potrace.Start();
5898
                                        potrace.Exited += (sender, e) => {
5899
                                            byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5900
                                            //kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5901
                                            svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5902
                                            if (symbolselectindex == 0)
5903
                                            {
5904
                                                SymbolSave(symbolname, svgfilename, data);
5905
                                            }
5906
                                            else
5907
                                            {
5908
                                                SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5909
                                            }
5910

  
5911
                                            DataBind();
5912
                                        };
5913
                                        potrace.WaitForExit();
5914
                                        //potrace.WaitForExit();
5915
                                    };
5916
                                }
5917
                            }
5918
                        };                                             
5919
                    }
5920
                }
5921
            }
5922
            catch (Exception e)
5923
            {
5924
                //DialogMessage_Alert(e + "", "Alert");
5925
            }            
5926
        }
5927

  
5928
        public void SymbolSave(string Name, string Url, string Data)
5929
        {
5930
            try
5931
            {
5932
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5933
                {
5934
                    ID = Events.Save.shortGuid(),
5935
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5936
                    NAME = Name,
5937
                    IMAGE_URL = Url,
5938
                    DATA = Data
5939
                };
5940

  
5941
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5942
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5943
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5944
            }
5945
            catch (Exception)
5946
            {
5947
                throw;
5948
            }
5949
        }
5950

  
5951
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5952
        {
5953
            try
5954
            {
5955
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5956
                {
5957
                    ID = Events.Save.shortGuid(),
5958
                    DEPARTMENT = Department,
5959
                    NAME = Name,
5960
                    IMAGE_URL = Url,
5961
                    DATA = Data
5962
                };
5963
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5964
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5965
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5966
            }
5967
            catch (Exception)
5968
            {
5969
                throw;
5970
            }
5971
        }
5972

  
5973
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5974
        {           
5975
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5976
            DataBind();
5977
        }
5978

  
5979
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5980
        {
5981
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5982
            DataBind();
5983
        }
5984
        private void DataBind()
5985
        {
5986
            try
5987
            {
5988
                Symbol_Custom Custom = new Symbol_Custom();
5989
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5990
                ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
5991
                var symbol_Private = client.GetSymbolList(App.ViewInfo.UserID);
5992
                foreach (var item in symbol_Private)
5993
                {
5994
                    Custom.Name = item.NAME;
5995
                    Custom.ImageUri = item.IMAGE_URL;
5996
                    Custom.ID = item.ID;
5997
                    Custom_List.Add(Custom);
5998
                    Custom = new Symbol_Custom();
5999
                }
6000
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
6001
                
6002
                Custom = new Symbol_Custom();
6003
                Custom_List = new List<Symbol_Custom>();
6004

  
6005
                symbolPanel_Instance.deptlist.ItemsSource = client.GetPublicSymbolDeptList();
6006

  
6007
                List<SYMBOL_PUBLIC> symbol_Public;
5499 6008

  
6009

  
6010
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
6011
                {
6012
                    symbol_Public = client.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
6013
                }
6014
                else
6015
                {
6016
                    symbol_Public = client.GetPublicSymbolList(null);
6017
                }
6018
                foreach (var item in symbol_Public)
6019
                {
6020
                    Custom.Name = item.NAME;
6021
                    Custom.ImageUri = item.IMAGE_URL;
6022
                    Custom.ID = item.ID;
6023
                    Custom_List.Add(Custom);
6024
                    Custom = new Symbol_Custom();
6025
                }
6026
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
6027
                client.Close();                
6028
            }
6029
            catch(Exception e)
6030
            {
6031
                //DialogMessage_Alert("DataBind", "Alert");
6032
            }
6033
            
6034
        }
5500 6035
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5501 6036
        {
5502 6037
            Save save = new Save();
5503

  
5504
            if (args.DialogResult.Value)
6038
            if (args.PromptResult != null)
5505 6039
            {
5506
                PngBitmapEncoder _Encoder = symImage(data);
6040
                if (args.DialogResult.Value)
6041
                {
6042
                    PngBitmapEncoder _Encoder = symImage(data);
5507 6043

  
5508
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5509
                _Encoder.Save(fs);
5510
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6044
                    System.IO.MemoryStream fs = new System.IO.MemoryStream();
6045
                    _Encoder.Save(fs);
6046
                    System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5511 6047

  
5512
                byte[] Img_byte = fs.ToArray();
6048
                    byte[] Img_byte = fs.ToArray();
5513 6049

  
5514
                kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5515
                filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Save.shortGuid() + ".png", Img_byte);
6050
                    kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6051
                    filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Save.shortGuid() + ".png", Img_byte);
5516 6052

  
5517
                save.SymbolSave(args.PromptResult, filename, data);
6053
                    if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6054
                    {
6055
                        save.SymbolSave(args.PromptResult, filename, data);
6056
                    }
6057
                    else
6058
                    {
6059
                        save.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6060
                    }
6061
                    DataBind();
6062
                }
5518 6063
            }
5519 6064
        }
5520 6065

  
......
5558 6103
                return pngEncoder;
5559 6104

  
5560 6105
            }
5561
            catch (Exception ex)
6106
            catch //(Exception ex)
5562 6107
            {
5563 6108
                return null;
5564 6109
            }
......
5647 6192
            return target;
5648 6193
        }
5649 6194

  
6195
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6196
        {
6197
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6198
            System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6199
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6200
            bmp.UnlockBits(data);
6201
            return bmp;
6202
        }
6203
        public string symbolname = null;
6204
        public bool symbolsvg = true;
6205
        public bool symbolpng = true;
6206

  
6207
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6208
        {
6209
            System.Drawing.Bitmap image = GetBitmap(source);
6210
            //흰색 제거
6211
            //image.MakeTransparent(System.Drawing.Color.White);
6212

  
6213
            var imageStream = new System.IO.MemoryStream();
6214
            byte[] imageBytes = null;
6215
            using (imageStream)
6216
            {
6217
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6218
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6219
                imageStream.Position = 0;
6220
                imageBytes = imageStream.ToArray();
6221
            }
6222

  
6223
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6224

  
6225
            RadWindow CheckPop = new RadWindow();
6226
            //Alert check = new Alert(Msg);
6227

  
6228
            CheckPop = new RadWindow
6229
            {
6230
                MinWidth = 400,
6231
                MinHeight = 100,
6232
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6233
                Header = "Alert",
6234
                Content = symbolPrompt,
6235
                //DialogResult = 
6236
                ResizeMode = System.Windows.ResizeMode.NoResize,
6237
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6238
                IsTopmost = true,
6239
            };
6240
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6241
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6242
            CheckPop.ShowDialog();
6243

  
6244
            /*
6245
            DialogParameters parameters = new DialogParameters()
6246
            {
6247
                Owner = Application.Current.MainWindow,
6248
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6249
                DefaultPromptResultValue = "Custom State",
6250
                Content = "Name :",
6251
                Header = "Insert Custom Symbol Name",
6252
                Theme = new VisualStudio2013Theme(),
6253
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6254
            };            
6255
            RadWindow.Prompt(parameters);
6256
            */
6257
        }
6258

  
5650 6259
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5651 6260
        {
5652 6261
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
......
5720 6329
        TempFile temp = new TempFile();
5721 6330
        //MarkupInfoItem
5722 6331
        public void CreateControl()
5723
        {
5724
            
6332
        {            
5725 6333
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5726 6334
            {
5727 6335
                ViewerDataModel.Instance.UndoDataList.Remove(i);
......
6300 6908
                ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6301 6909
            }
6302 6910
        }
6303
        
6911

  
6912
        private void zoomAndPanControl_PreviewDrop(object sender, DragEventArgs e)
6913
        {
6914

  
6915
        }
6916

  
6917
        private void zoomAndPanControl_GiveFeedback(object sender, GiveFeedbackEventArgs e)
6918
        {
6919

  
6920
        }
6304 6921
    }
6305 6922
}

내보내기 Unified diff

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