프로젝트

일반

사용자정보

개정판 7fa95b67

ID7fa95b67b2188294dfc9d6c9ea6ab79f3fae90cb
상위 5a223b60
하위 26c9c3bf

백흠경이(가) 5달 전에 추가함

Fix: 이미지 심볼 배치 오류 수정

Change-Id: Ice2ccb7ab56cedc7adc7c535d95c410d01001cd3

차이점 보기:

KCOM/Views/MainMenu.xaml.cs
5511 5511
            }
5512 5512
        }
5513 5513

  
5514
        private void Create_Symbol(object sender, RoutedEventArgs e)
5515
        {
5516
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5514
        public int symbolselectindex = 0;
5517 5515

  
5518
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5519
            {
5520
                DialogMessage_Alert("Please Select Controls", "Alert");
5521
            }
5522
            else //선택된 것이 있으면
5516
        /// <summary>
5517
        /// 심볼을 저장한다.
5518
        /// </summary>
5519
        /// <param name="Img_byte"></param>
5520
        /// <param name="data"></param>
5521
        /// <param name="args"></param>
5522
        private void SymbolMarkupNamePromptClose(SymbolPrompt prompt, byte[] Img_byte, string data, WindowClosedEventArgs args)
5523
        {
5524
            try
5523 5525
            {
5524
                string MarkupData = "";
5525
                adorner_ = new AdornerFinal();
5526
                string svgfilename = null;
5527
                if (string.IsNullOrEmpty(prompt.SymbolName)) return;
5526 5528

  
5527
                foreach (var item in SelectLayer.Children)
5529
                kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5530
                string guid = Commons.ShortGuid();
5531

  
5532
                fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5533
                fileUploader.RunCompleted += (ex, arg) =>
5528 5534
                {
5529
                    if (item.GetType().Name == "AdornerFinal")
5535
                    filename = arg.Result;
5536
                    if (prompt.IsPng)
5530 5537
                    {
5531
                        adorner_ = (item as Controls.AdornerFinal);
5532
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5538
                        if (!string.IsNullOrEmpty(filename))
5533 5539
                        {
5534
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5540
                            if (symbolselectindex == 0)
5535 5541
                            {
5536
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5537
                                MarkupData += markupReturn.ConvertData;
5542
                                SavePrivateSymbol(prompt.SymbolName, filename, data);
5543
                            }
5544
                            else
5545
                            {
5546
                                SavePublicSymbol(prompt.SymbolName, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5538 5547
                            }
5539 5548
                        }
5540 5549
                    }
5541
                }
5542
                DialogParameters parameters = new DialogParameters()
5543
                {
5544
                    Owner = Application.Current.MainWindow,
5545
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5546
                    DefaultPromptResultValue = "Custom State",
5547
                    Content = "Name :",
5548
                    Header = "Insert Custom Symbol Name",
5549
                    Theme = new VisualStudio2013Theme(),
5550
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5551
                };
5552
                RadWindow.Prompt(parameters);
5553
            }
5554
        }
5555

  
5556
        public int symbolselectindex = 0;
5557

  
5558
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5559
        {
5560
            //Save save = new Save();
5561
            try
5562
            {
5563
                string svgfilename = null;
5564
                if (symbolname != null)
5565
                {
5566
                    if (symbolpng == true || symbolsvg == true)
5550
                    else if (prompt.IsSvg)
5567 5551
                    {
5568
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5569
                        string guid = Commons.ShortGuid();
5570

  
5571
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5572
                        //Check_Uri.UriCheck();
5573
                        fileUploader.RunCompleted += (ex, arg) =>
5552
                        try
5574 5553
                        {
5575
                            filename = arg.Result;
5576
                            if (symbolpng == true)
5577
                            {
5578
                                if (filename != null)
5579
                                {
5580
                                    if (symbolselectindex == 0)
5581
                                    {
5582
                                        SymbolSave(symbolname, filename, data);
5583
                                    }
5584
                                    else
5585
                                    {
5586
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5587
                                    }
5588
                                    DataBind();
5589
                                }
5590
                            }
5554
                            var defaultBitmapImage = new BitmapImage();
5555
                            defaultBitmapImage.BeginInit();
5556
                            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5557
                            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5558
                            Check_Uri.UriCheck(filename);
5559
                            defaultBitmapImage.UriSource = new Uri(filename);
5560
                            defaultBitmapImage.EndInit();
5561

  
5562
                            System.Drawing.Bitmap image;
5591 5563

  
5592
                            if (symbolsvg == true)
5564
                            if (defaultBitmapImage.IsDownloading)
5593 5565
                            {
5594
                                try
5566
                                defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5595 5567
                                {
5596
                                    var defaultBitmapImage = new BitmapImage();
5597
                                    defaultBitmapImage.BeginInit();
5598
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5599
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5600
                                    Check_Uri.UriCheck(filename);
5601
                                    defaultBitmapImage.UriSource = new Uri(filename);
5602
                                    defaultBitmapImage.EndInit();
5568
                                    defaultBitmapImage.Freeze();
5569
                                    image = GetBitmap(defaultBitmapImage);
5570
                                    image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5571
                                    Process potrace = new Process
5572
                                    {
5573
                                        StartInfo = new ProcessStartInfo
5574
                                        {
5575
                                            FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5576
                                            Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5577
                                            RedirectStandardInput = true,
5578
                                            RedirectStandardOutput = true,
5579
                                            RedirectStandardError = true,
5580
                                            UseShellExecute = false,
5581
                                            CreateNoWindow = true,
5582
                                            WindowStyle = ProcessWindowStyle.Hidden
5583
                                        },
5584
                                    };
5603 5585

  
5604
                                    System.Drawing.Bitmap image;
5586
                                    StringBuilder svgBuilder = new StringBuilder();
5587
                                    potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5588
                                    {
5589
                                        svgBuilder.AppendLine(e2.Data);
5590
                                    };
5605 5591

  
5606
                                    if (defaultBitmapImage.IsDownloading)
5592
                                    potrace.EnableRaisingEvents = true;
5593
                                    potrace.Start();
5594
                                    potrace.Exited += (sender, e) =>
5607 5595
                                    {
5608
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5596
                                        byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5597
                                        svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5598
                                        Check_Uri.UriCheck(svgfilename);
5599
                                        if (symbolselectindex == 0)
5609 5600
                                        {
5610
                                            defaultBitmapImage.Freeze();
5611
                                            image = GetBitmap(defaultBitmapImage);
5612
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5613
                                            Process potrace = new Process
5614
                                            {
5615
                                                StartInfo = new ProcessStartInfo
5616
                                                {
5617
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5618
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5619
                                                    RedirectStandardInput = true,
5620
                                                    RedirectStandardOutput = true,
5621
                                                    RedirectStandardError = true,
5622
                                                    UseShellExecute = false,
5623
                                                    CreateNoWindow = true,
5624
                                                    WindowStyle = ProcessWindowStyle.Hidden
5625
                                                },
5626
                                            };
5627

  
5628
                                            StringBuilder svgBuilder = new StringBuilder();
5629
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5630
                                            {
5631
                                                svgBuilder.AppendLine(e2.Data);
5632
                                            };
5633

  
5634
                                            potrace.EnableRaisingEvents = true;
5635
                                            potrace.Start();
5636
                                            potrace.Exited += (sender, e) =>
5637
                                            {
5638
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5639
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5640
                                                Check_Uri.UriCheck(svgfilename);
5641
                                                if (symbolselectindex == 0)
5642
                                                {
5643
                                                    SymbolSave(symbolname, svgfilename, data);
5644
                                                }
5645
                                                else
5646
                                                {
5647
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5648
                                                }
5649

  
5650
                                                DataBind();
5651
                                            };
5652
                                            potrace.WaitForExit();
5653
                                        };
5654
                                    }
5655
                                    else
5656
                                    {
5657
                                        //GC.Collect();
5658
                                    }
5659
                                }
5660
                                catch (Exception ee)
5661
                                {
5662
                                    DialogMessage_Alert("" + ee, "Alert");
5663
                                }
5601
                                            SavePrivateSymbol(prompt.SymbolName, svgfilename, data);
5602
                                        }
5603
                                        else
5604
                                        {
5605
                                            SavePublicSymbol(prompt.SymbolName, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5606
                                        }
5607
                                    };
5608
                                    potrace.WaitForExit();
5609
                                };
5664 5610
                            }
5665
                        };
5611
                            else
5612
                            {
5613
                                //GC.Collect();
5614
                            }
5615
                        }
5616
                        catch (Exception ee)
5617
                        {
5618
                            DialogMessage_Alert("" + ee, "Alert");
5619
                        }
5666 5620
                    }
5667
                }
5621
                };
5668 5622
            }
5669 5623
            catch (Exception e)
5670 5624
            {
5671
                //DialogMessage_Alert(e + "", "Alert");
5625
                throw new InvalidOperationException(e.Message);
5672 5626
            }
5673 5627
        }
5674 5628

  
5675
        public void SymbolSave(string Name, string Url, string Data)
5629
        public void SavePrivateSymbol(string Name, string Url, string Data)
5676 5630
        {
5677 5631
            try
5678 5632
            {
......
5686 5640
                };
5687 5641

  
5688 5642
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5689
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5690 5643
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5691 5644
            }
5692 5645
            catch (Exception)
......
5695 5648
            }
5696 5649
        }
5697 5650

  
5698
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5651
        public void SavePublicSymbol(string Name, string Url, string Data, string Department)
5699 5652
        {
5700 5653
            try
5701 5654
            {
......
5719 5672

  
5720 5673
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5721 5674
        {
5722
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5723
            DataBind();
5675
            BindSymbolData();
5724 5676
        }
5725 5677

  
5726 5678
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5727 5679
        {
5728
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5729
            DataBind();
5680
            BindSymbolData();
5730 5681
        }
5731 5682

  
5732
        private void DataBind()
5683
        /// <summary>
5684
        /// Symbol 데이터를 화면에 표시한다.
5685
        /// </summary>
5686
        private void BindSymbolData()
5733 5687
        {
5734 5688
            try
5735 5689
            {
......
5779 5733
            }
5780 5734
        }
5781 5735

  
5782
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5783
        {
5784
            try
5785
            {
5786
                if (args.PromptResult != null)
5787
                {
5788
                    if (args.DialogResult.Value)
5789
                    {
5790
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5791

  
5792
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5793
                        _Encoder.Save(fs);
5794
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5795

  
5796
                        byte[] Img_byte = fs.ToArray();
5797

  
5798
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5799
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.ShortGuid() + ".png", Img_byte);
5800
                        Check_Uri.UriCheck(filename);
5801
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5802
                        {
5803
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5804
                        }
5805
                        else
5806
                        {
5807
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5808
                        }
5809
                        DataBind();
5810
                    }
5811
                }
5812
            }
5813
            catch (Exception ex)
5814
            {
5815
                DialogMessage_Alert("" + ex, "Alert");
5816
            }
5817
        }
5818

  
5819 5736
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5820 5737
        {
5821 5738
            Canvas _canvas = new Canvas();
......
5954 5871
            return bmp;
5955 5872
        }
5956 5873

  
5957
        public string symbolname = null;
5958
        public bool symbolsvg = true;
5959
        public bool symbolpng = true;
5960

  
5961 5874
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5962 5875
        {
5963 5876
            System.Drawing.Bitmap image = GetBitmap(source);
......
5991 5904
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5992 5905
                IsTopmost = true,
5993 5906
            };
5994
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5907
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(symbolPrompt, imageBytes, "", args);
5995 5908
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5996 5909
            CheckPop.ShowDialog();
5997 5910

  

내보내기 Unified diff

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