프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Controls / Symbol.xaml.cs @ 1c7f408a

이력 | 보기 | 이력해설 | 다운로드 (42.1 KB)

1
using IKCOM;
2
using KCOM.Common;
3
using KCOM.Events;
4
using KCOMDataModel.Common;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using MarkupToPDF.Controls.Parsing;
8
using Svg2Xaml;
9
using System;
10
using System.Collections.Generic;
11
using System.ComponentModel;
12
using System.Linq;
13
using System.Text;
14
using System.Windows;
15
using System.Windows.Controls;
16
using System.Windows.Data;
17
using System.Windows.Documents;
18
using System.Windows.Input;
19
using System.Windows.Media;
20
using System.Windows.Media.Imaging;
21
using System.Windows.Navigation;
22
using System.Windows.Shapes;
23
using Telerik.Windows.Controls;
24
using Telerik.Windows.Controls.DragDrop;
25

    
26
namespace KCOM.Controls
27
{
28
    public class Symbol_Custom
29
    {
30
        public string ID { get; set; }
31
        public string Name { get; set; }
32
        public string ImageUri { get; set; }
33
    }
34

    
35
    /// <summary>
36
    /// Symbol.xaml에 대한 상호 작용 논리
37
    /// </summary>
38
    public partial class Symbol : UserControl
39
    {
40
        AdornerFinal finalItem;
41
        bool IsMouseDown = false;
42
        string moveItem_id = "";
43
        public string filename { get; set; }
44

    
45
        public Symbol()
46
        {
47
            App.splashString(ISplashMessage.SYMBOL);
48
            InitializeComponent();
49

    
50
            //RadDragAndDropManager.AddDragInfoHandler(lstSymbolPrivate, OnDragPrivateInfo);
51
            //RadDragAndDropManager.AddDragQueryHandler(lstSymbolPrivate, OnDragPrivateQuery);
52
            //RadDragAndDropManager.SetAllowDrag(lstSymbolPrivate, true);
53

    
54
            DataBind();
55
        }
56

    
57
        private void OnDragPrivateInfo(object sender, DragDropEventArgs e)
58
        {
59
        }
60

    
61
        private void OnDragPrivateQuery(object sender, DragDropQueryEventArgs e)
62
        {
63
            if (e.Options.Status == DragStatus.DragQuery)
64
            {
65
                //var draggedListBoxItem = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem;
66
                //BitmapImage im = new BitmapImage(new Uri((draggedListBoxItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate).ImageUri));
67
                //ImageSource _source = im;
68
                //Image img = new Image();
69
                //img.Source = _source;
70

    
71
                //e.Options.Payload = im;
72
                //var dragCue = new Image();
73
                //dragCue.Source = img.Source;
74
                //dragCue.Width = 0;
75
                //dragCue.Height = 0;
76
                //e.Options.DragCue = dragCue;
77

    
78

    
79
                //PayLoadAdorner = new AdornerFinal();
80
                //DeepView.ServiceDeepView_Symbol.SymbolPrivate tempDragableControl = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate;
81
                //var xamldata = tempDragableControl.Data;
82
                ////this.DeepLayer.markupParse(xamldata, this.DeepLayer._TempLayer, "복사된 데이터_이름으로 수정해야함");
83
                //PayLoadAdorner = this.DeepLayer.markupParseToAdorner(xamldata, this.DeepLayer._SelectLayer, "");
84
                //this.DeepLayer._SelectLayer.Children.Add(PayLoadAdorner);
85
            }
86

    
87
            e.QueryResult = true;
88
            e.Handled = true;
89
        }
90

    
91
        private void DataBind()
92
        {
93
            //lstSymbolPrivate.ItemsSource = null;
94
            //lstSymbolPublic.ItemsSource = null;
95

    
96
            Symbol_Custom Custom = new Symbol_Custom();
97
            List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
98

    
99
            var mainwindow = (RadWindowManager.Current.GetWindows().Find(x => x is MainWindow) as MainWindow);
100

    
101
            if (mainwindow.dzMainMenu.BaseClient != null)
102
            {
103
                var symbol_Private = mainwindow.dzMainMenu.BaseClient.GetSymbolList(App.ViewInfo.UserID);
104

    
105
                foreach (var item in symbol_Private)
106
                {
107
                    Custom.Name = item.NAME;
108
                    Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL, App.isExternal);
109
                    Custom.ID = item.ID;
110
                    Custom_List.Add(Custom);
111
                    Custom = new Symbol_Custom();
112
                }
113
                lstSymbolPrivate.ItemsSource = Custom_List;
114

    
115
                Custom = new Symbol_Custom();
116
                Custom_List = new List<Symbol_Custom>();
117

    
118
                deptlist.ItemsSource = ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetPublicSymbolDeptList();
119

    
120
                List<SYMBOL_PUBLIC> symbol_Public;
121

    
122

    
123
                if (deptlist.SelectedValue != null)
124
                {
125
                    symbol_Public = ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetPublicSymbolList(deptlist.SelectedValue.ToString());
126
                }
127
                else
128
                {
129
                    symbol_Public = ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetPublicSymbolList(null);
130
                }
131
                foreach (var item in symbol_Public)
132
                {
133
                    Custom.Name = item.NAME;
134
                    Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL, App.isExternal);
135
                    Custom.ID = item.ID;
136
                    Custom_List.Add(Custom);
137
                    Custom = new Symbol_Custom();
138
                }
139
                lstSymbolPublic.ItemsSource = Custom_List;
140
            }
141
        }
142

    
143
        public PngBitmapEncoder symImage(string data)
144
        {
145

    
146
            Canvas _canvas = new Canvas();
147
            _canvas.Background = Brushes.White;
148
            _canvas.Width = finalItem.BorderSize.Width;
149
            _canvas.Height = finalItem.BorderSize.Height;
150
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
151

    
152
            BitmapEncoder encoder = new PngBitmapEncoder();
153

    
154

    
155
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
156

    
157
            DrawingVisual dv = new DrawingVisual();
158

    
159
            _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50));
160
            //_canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 50, Y = -finalItem.BorderSize.Y - 50 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
161
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
162

    
163
            using (DrawingContext ctx = dv.RenderOpen())
164
            {
165
                VisualBrush vb = new VisualBrush(_canvas);
166
                //ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
167
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X, Y = -finalItem.BorderSize.Y }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
168
            }
169

    
170
            try
171
            {
172
                renderBitmap.Render(dv);
173

    
174
                GC.Collect();
175
                GC.WaitForPendingFinalizers();
176
                GC.Collect();
177
                //bitmap.Render(controlToConvert);
178
                // encode png data
179
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
180
                // puch rendered bitmap into it
181
                pngEncoder.Interlace = PngInterlaceOption.Off;
182
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
183
                return pngEncoder;
184

    
185
            }
186
            catch //(Exception ex)
187
            {
188
                return null;
189
            }
190

    
191
        }
192

    
193
        public void DialogMessage_Alert(string content, string header)
194
        {
195
            DialogParameters parameters = new DialogParameters()
196
            {
197
                Owner = Application.Current.MainWindow,
198
                Content = new TextBlock()
199
                {
200
                    MinWidth = 400,
201
                    FontSize = 11,
202
                    Text = content,
203
                    TextWrapping = System.Windows.TextWrapping.Wrap
204
                },
205
                Header = header,
206
                Theme = new VisualStudio2013Theme(),
207
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
208
            };
209
            RadWindow.Alert(parameters);
210
        }
211

    
212
        #region Event
213

    
214
        #region Private Symbol Add Event
215
        private void Create_Symbol(object sender, RoutedEventArgs e)
216
        {
217
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
218

    
219
            if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
220
            {
221
                DialogMessage_Alert("Please Select Controls", "Alert");
222
            }
223
            else //선택된 것이 있으면
224
            {
225
                string MarkupData = "";
226
                finalItem = new AdornerFinal();
227

    
228
                foreach (var item in Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children)
229
                {
230
                    if (item.GetType().Name == "AdornerFinal")
231
                    {
232
                        finalItem = (item as Controls.AdornerFinal);
233
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
234
                        {
235
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
236
                            {
237
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
238
                                MarkupData += markupReturn.ConvertData;
239
                            }
240
                        }
241
                    }
242
                }
243
                DialogParameters parameters = new DialogParameters()
244
                {
245
                    Owner = Application.Current.MainWindow,
246
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
247
                    DefaultPromptResultValue = "Custom State",
248
                    Content = "Name :",
249
                    Header = "Insert Custom Symbol Name",
250
                    Theme = new VisualStudio2013Theme(),
251
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
252
                };
253
                RadWindow.Prompt(parameters);
254
            }
255

    
256
        }
257
        #endregion
258

    
259
        #region Symbol Add Close Event 
260
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
261
        {
262
            try
263
            {
264
                if (args.PromptResult != null)
265
                {
266
                    if (args.DialogResult.Value)
267
                    {
268
                        PngBitmapEncoder _Encoder = symImage(data);
269

    
270
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
271
                        _Encoder.Save(fs);
272
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
273

    
274
                        byte[] Img_byte = fs.ToArray();
275

    
276
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
277
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
278
                        Check_Uri.UriCheck(filename);
279
                        if (RadTab.SelectedIndex == 0)
280
                        {
281
                            SymbolSave(args.PromptResult, filename, data);
282
                        }
283
                        else
284
                        {
285
                            SymbolSave_Public(args.PromptResult, filename, data, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
286
                        }
287

    
288
                        DataBind();
289
                    }
290
                }
291
            }
292
            catch(Exception ex)
293
            {
294
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("" + ex, "Alert");
295
            }
296
        }
297
        #endregion
298

    
299
        public void SymbolSave(string Name, string Url, string Data)
300
        {
301
            try
302
            {
303
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
304
                {
305
                    ID = Commons.shortGuid(),
306
                    MEMBER_USER_ID = App.ViewInfo.UserID,
307
                    NAME = Name,
308
                    IMAGE_URL = Url,
309
                    DATA = Data
310
                };
311

    
312
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
313
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
314
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
315
            }
316
            catch (Exception)
317
            {
318
                throw;
319
            }
320
        }
321

    
322
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
323
        {
324
            try
325
            {
326
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
327
                {
328
                    ID = Commons.shortGuid(),
329
                    DEPARTMENT = Department,
330
                    NAME = Name,
331
                    IMAGE_URL = Url,
332
                    DATA = Data
333
                };
334
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
335
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
336
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
337
            }
338
            catch (Exception)
339
            {
340
                throw;
341
            }
342
        }
343

    
344
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
345
        {
346
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
347
            DataBind();
348
        }
349

    
350
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
351
        {
352
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
353
            DataBind();
354
        }
355

    
356
        #region Private Symbol Delete Event
357
        private void Remove_Symbol(object sender, RoutedEventArgs e)
358
        {
359
            if (lstSymbolPrivate.SelectedItem == null)
360
            {
361
                DialogMessage_Alert("Please Select Symbol", "Alert");
362
                return;
363
            }
364
            string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
365

    
366
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
367
            Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
368
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
369
        }
370
        #endregion
371
        #region Public Symbol Delete Event
372
        private void Remove_Symbol_Public(object sender, RoutedEventArgs e)
373
        {
374
            if (lstSymbolPublic.SelectedItem == null)
375
            {
376
                DialogMessage_Alert("Please Select Symbol", "Alert");
377
                return;
378
            }
379
            string delItem_ID = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
380

    
381
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
382
            Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
383
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
384
        }
385

    
386
        private void BaseClient_DeleteSymbolCompleted(object sender, ServiceDeepView.DeleteSymbolCompletedEventArgs e)
387
        {
388
            Logger.sendResLog("DeleteSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
389
            DataBind();
390
        }
391
        #endregion
392

    
393
        public Undo_data UndoData { get; set; }
394
        /// <summary>
395
        /// place symbol which has given id to original position which is created
396
        /// </summary>
397
        /// <date>2018.06.14</date>
398
        /// <param name="id"></param>
399
        private void PlaceSymbol(string id)
400
        {
401
            string Data_ = "";
402

    
403
            try
404
            {
405
                Logger.sendReqLog("GetSymbolData: ", id + "," + RadTab.SelectedIndex, 1);
406
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolData(id, RadTab.SelectedIndex);
407
                if (Data_ != null || Data_ != "")
408
                {
409
                    Logger.sendResLog("GetSymbolData", "TRUE", 1);
410
                }
411
                else
412
                {
413
                    Logger.sendResLog("GetSymbolData", "FALSE", 1);
414
                }
415

    
416
                //MARKUP_DATA_GROUP INSERT
417
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
418
                //{
419
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
420
                //    STATE = 0,
421
                //};
422
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
423
                //Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
424

    
425
                if (Data_.Contains("|DZ|"))
426
                {
427
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
428

    
429
                    string[] delimiterChars = { "|DZ|" };
430
                    string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
431

    
432
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
433
                    UndoData = new Undo_data()
434
                    {
435
                        IsUndo = false,
436
                        Event = Event_Type.Create,
437
                        EventTime = DateTime.Now,
438
                        Markup_List = new List<Multi_Undo_data>()
439
                    };
440
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
441
                    {
442
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
443
                    });
444

    
445
                    foreach (string parse in data)
446
                    {
447
                        if (parse != "")
448
                        {
449
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
450
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
451
                            (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = id;
452
                            //(item as MarkupToPDF.Common.CommentUserInfo).GroupID = group_id;
453
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
454
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
455

    
456
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
457

    
458
                            multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
459

    
460
                            UndoData.Markup_List.Add(multi_Undo_Data);
461
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
462
                        }
463
                    }
464
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
465

    
466
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
467
                }
468
                else
469
                {
470
                    PlaceImageSymbol(id, 0);
471
                }
472
            }
473
            catch (Exception ex)
474
            {
475
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
476
            }
477
        }
478

    
479
        private void PlaceImageSymbol(string id, long group_id)
480
        {
481
           
482
            //canvasZoommovingMouseDownPoint
483
            string Data_ = "";
484

    
485
            try
486
            {
487
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + RadTab.SelectedIndex, 1);
488
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, RadTab.SelectedIndex);
489
                if (Data_ != null || Data_ != "")
490
                {
491
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
492
                }
493
                else
494
                {
495
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
496
                }
497

    
498
                //MARKUP_DATA_GROUP INSERT
499
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
500
                //{
501
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
502
                //    STATE = 0,
503
                //};
504
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
505
                //Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
506

    
507
                if (Data_ != null)
508
                {
509
                    Image img = new Image();
510
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
511
                    if (Data_.Contains(".svg"))
512
                    {
513
                        byte[] imageData = null;
514
                        DrawingImage image = null;
515
                        using (System.Net.WebClient web = new System.Net.WebClient())
516
                        {
517
                            imageData = web.DownloadData(new Uri(Data_));
518
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
519
                            image = SvgReader.Load(stream);
520
                        }
521
                        img.Source = image;
522
                    }
523
                    else
524
                    {
525
                        img.Source = new BitmapImage(new Uri(Data_));
526
                    }
527

    
528
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
529
                    {
530
                        PointSet = new List<Point>(),
531
                        FilePath = Data_,
532
                        ImageData = img.Source,
533
                        StartPoint = new Point(0, 0),
534
                        EndPoint = new Point(img.Source.Width, img.Source.Height),
535
                        TopRightPoint = new Point(img.Source.Width, 0),
536
                        LeftBottomPoint = new Point(0, img.Source.Height)
537
                    };
538

    
539
                    currentControl.PointSet = new List<Point>
540
                                        {
541
                                            currentControl.StartPoint,
542
                                            currentControl.LeftBottomPoint,
543
                                            currentControl.EndPoint,
544
                                            currentControl.TopRightPoint,
545
                                        };
546
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
547
                    UndoData = new Undo_data()
548
                    {
549
                        IsUndo = false,
550
                        Event = Event_Type.Create,
551
                        EventTime = DateTime.Now,
552
                        Markup_List = new List<Multi_Undo_data>()
553
                    };
554
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
555
                    {
556
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
557
                    });
558

    
559
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
560
                    multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
561
                    UndoData.Markup_List.Add(multi_Undo_Data);
562
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
563

    
564
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
565
                    currentControl.CommentID = Commons.shortGuid();
566
                    currentControl.SymbolID = id;
567
                    currentControl.GroupID = group_id;
568
                    currentControl.ApplyTemplate();
569
                    currentControl.SetImage();
570

    
571
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
572
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
573
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
574

    
575
                    /*
576
                    // this.ParentOfType<MainWindow>().dzMainMenu.isLeftMouseButtonDownOnWindow = true;
577
                    // final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
578
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
579
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
580
                      final.TranslateItems(realPointX, realPointY);
581
                    // move.control_Select(item, dragRect);
582
                    ApplyDragSelectionRect();
583
                    //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = MouseHandlingMode.DragSymbol;
584
                    ///this.ParentOfType<MainWindow>().dzMainMenu.mouseButtonDown = MouseButton.Left;
585
                    //this.ParentOfType<MainWindow>().dzMainMenu.symboldata(id, group_id, RadTab.SelectedIndex, Data_, img.Source);*/
586
                    
587
                }
588
            }
589
            catch(Exception ex)
590
            {
591
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
592
            }
593
        }
594

    
595
        public Multi_Undo_data multi_Undo_Data;
596
        private void ApplyDragSelectionRect()
597
        {
598
            multi_Undo_Data = new Multi_Undo_data();
599

    
600
            UndoData = new Undo_data()
601
            {
602
                IsUndo = false,
603
                Event = Event_Type.Select,
604
                EventTime = DateTime.Now,
605
                Markup_List = new List<Multi_Undo_data>()
606
            };
607

    
608
            this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed;
609

    
610
            double x = Canvas.GetLeft(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
611
            double y = Canvas.GetTop(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
612
            double width = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Width;
613
            double height = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Height;
614
            Rect dragRect = new Rect(x, y, width, height);
615
            Boolean Flag = false;
616
            dragRect.Inflate(width / 10, height / 10);
617
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
618
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
619

    
620
            dragRect = new Rect(x, y, width, height);
621
            dragRect.Inflate(width / 10, height / 10);
622

    
623
            //move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting;
624
            //move.
625
            foreach (var item in Items)
626
            {
627
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
628

    
629
                if (Flag)
630
                {
631
                    adornerSet.Add(item);
632
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
633

    
634
                    this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item);
635
                    UndoData.Markup_List.Add(multi_Undo_Data);
636
                    multi_Undo_Data = new Multi_Undo_data();
637
                    if (item.GroupID > 0)
638
                    {
639

    
640
                    }
641
                }
642
            }
643
            if (adornerSet.Count > 0)
644
            {
645
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
646
                {
647
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
648
                });
649
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
650

    
651
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
652
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
653
            }
654
        }
655

    
656
        ///private Move move;
657
        #region Symbol DoubleClick Event
658
        private void Move_Symbol(object sender, MouseButtonEventArgs e)
659
        {
660
            try
661
            {
662
                Type type = e.OriginalSource.GetType();
663
                string id = string.Empty;
664
                Logger.sendResLog("Move_Symbol", type.Name, 0);
665
                if (type.Name == "Image")
666
                {
667
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
668
                }
669
                else if (type.Name == "Border")
670
                {
671
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
672
                }
673
                else if (type.Name == "TextBox")
674
                {
675
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
676
                }
677

    
678
                IsMouseDown = true;
679

    
680
                if (e.ClickCount > 1)
681
                {
682
                    this.PlaceSymbol(id);
683
                }
684
            }
685
            catch(Exception ex)
686
            {
687
                Logger.sendResLog("Move_Symbol", ex.Message, 0);
688
            }
689
        }
690
        #endregion
691

    
692
        #region Private Symbol Rename Event
693
        private void Rename_Symbol(object sender, RoutedEventArgs e)
694
        {
695
            if (lstSymbolPrivate.SelectedItem == null)
696
            {
697
                DialogMessage_Alert("Please Select Symbol", "Alert");
698
                return;
699
            }
700

    
701
            DialogParameters parameters = new DialogParameters()
702
            {
703
                Owner = Application.Current.MainWindow,
704
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
705
                //DefaultPromptResultValue = "Custom State",
706
                DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name,
707
                Content = "Name :",
708
                Header = "Update Custom Symbol Name",
709
                Theme = new VisualStudio2013Theme(),
710
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
711
            };
712
            RadWindow.Prompt(parameters);
713

    
714
        }
715
        #endregion
716

    
717
        #region Public Symbol Rename Event
718
        private void Rename_Symbol_Public(object sender, RoutedEventArgs e)
719
        {
720
            if (lstSymbolPublic.SelectedItem == null)
721
            {
722
                DialogMessage_Alert("Please Select Symbol", "Alert");
723
                return;
724
            }
725

    
726
            DialogParameters parameters = new DialogParameters()
727
            {
728
                Owner = Application.Current.MainWindow,
729
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
730
                //DefaultPromptResultValue = "Custom State",
731
                DefaultPromptResultValue = (lstSymbolPublic.SelectedItem as Symbol_Custom).Name,
732
                Content = "Name :",
733
                Header = "Update Custom Symbol Name",
734
                Theme = new VisualStudio2013Theme(),
735
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
736
            };
737
            RadWindow.Prompt(parameters);
738

    
739
        }
740
        #endregion
741
        #region Symbol Rename Close Event
742
        private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args)
743
        {
744
            if (args.DialogResult != null && args.DialogResult.Value)
745
            {
746
                if(RadTab.SelectedIndex == 0)
747
                {
748
                    string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
749
                    string _name = args.PromptResult;
750
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
751
                    Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
752
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
753
                }
754
                else
755
                {
756
                    string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
757
                    string _name = args.PromptResult;
758
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
759
                    Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
760
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
761
                }
762
            }
763
        }
764

    
765
        private void BaseClient_RenameSymbolCompleted(object sender, ServiceDeepView.RenameSymbolCompletedEventArgs e)
766
        {
767
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
768
            DataBind();
769
        }
770
        #endregion
771

    
772
        #region Wheel Event
773
        private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
774
        {
775
            ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2));
776
        }
777
        private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
778
        {
779
            ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2));
780
        }
781
        #endregion
782

    
783
        #region Tab Selection Event
784
        private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e)
785
        {
786
            foreach (var item in (e.OriginalSource as RadTabControl).Items)
787
            {
788
                (item as RadTabItem).FontWeight = FontWeights.Normal;
789
            }
790
            ((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold;
791
        }
792
        #endregion
793

    
794
        #region Department Selection Event
795
        private void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
796
        {
797
            DataBind();
798
        }
799
        #endregion
800

    
801
        #endregion
802

    
803
        private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
804
        {
805

    
806
        }
807

    
808
        private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e)
809
        {
810

    
811
        }
812

    
813
        private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e)
814
        {
815

    
816
        }
817

    
818
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
819
        {
820
            if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed)
821
            {
822
                ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id;
823
            }
824
            else
825
            {
826
                IsMouseDown = false;
827
            }
828
        }
829

    
830
        private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
831
        {
832
            IsMouseDown = false;
833
        }
834

    
835
        /// <summary>
836
        /// place symbol which user select
837
        /// </summary>
838
        /// <author>humkyung</author>
839
        /// <date>2018.06.14</date>
840
        /// <param name="sender"></param>
841
        /// <param name="e"></param>
842
        private void Place_Symbol(object sender, RoutedEventArgs e)
843
        {
844
            if (lstSymbolPrivate.SelectedItem == null)
845
            {
846
                DialogMessage_Alert("Please Select Symbol",  "Alert");
847
                return;
848
            }
849

    
850
            string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
851
            this.PlaceSymbol(id);
852
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
853
        }
854

    
855
        private void Place_Symbol_Public(object sender, RoutedEventArgs e)
856
        {
857
            if (lstSymbolPublic.SelectedItem == null)
858
            {
859
                DialogMessage_Alert("Please Select Symbol", "Alert");
860
                return;
861
            }
862

    
863
            string id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
864
            this.PlaceSymbol(id);
865
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
866
        }
867

    
868
        private void Image_Place_Register(object sender, RoutedEventArgs e)
869
        {
870
            SyncInit();
871
            ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
872
            //캡쳐 하기 전에 코멘트 저장
873
            var mainwindow = (RadWindowManager.Current.GetWindows().Find(x => x is MainWindow) as MainWindow);
874

    
875
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || mainwindow.dzMainMenu.SelectLayer.Children.Count > 0)
876
            {
877
                var menu = mainwindow.dzMainMenu;
878
                SelectionSet.Instance.UnSelect(menu);
879
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
880
                {
881
                    mainwindow.dzTopMenu.SaveEventCallback(null, null);
882
                }
883
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
884
                {
885

    
886
                }
887
                else
888
                {
889
                    mainwindow.dzTopMenu.SaveEventCallback(null, null);
890
                }
891
            }
892
            Application.Current.MainWindow.Focus();
893
            Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
894
            mainwindow.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
895
        }
896

    
897

    
898
        private void SyncInit()
899
        {
900
            try
901
            {
902
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
903
                {
904
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
905
                    ViewerDataModel.Instance.PageBalanceMode = false;
906
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
907
                    ViewerDataModel.Instance.PageNumber = 0;
908
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
909
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
910
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
911
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
912
                }
913
            }
914
            catch (Exception ex)
915
            {
916
                Logger.sendResLog("SyncInit", ex.Message, 0);
917
            }
918
        }
919

    
920
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
921
        {
922
            var block = sender as TextBox;
923
            block.Focusable = true;
924
               
925
        }
926

    
927
        private void TextBlock_MouseEnter(object sender, MouseEventArgs e)
928
        {
929
            var block = sender as TextBox;
930
            if (block != null)
931
            {
932
                //block.Text = "Enter";
933

    
934
            }
935
        }
936

    
937
        private void OnKeyDownHandler(object sender, KeyEventArgs e)
938
        {
939
            if (e.Key == Key.Return)
940
            {
941
                Type type = e.OriginalSource.GetType();
942
                string id = string.Empty;
943
                Logger.sendResLog("Move_Symbol", type.Name, 0);
944
                if (type.Name == "Image")
945
                {
946
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
947
                }
948
                else if (type.Name == "Border")
949
                {
950
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
951
                }
952
                else if (type.Name == "TextBox")
953
                {
954
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
955
                }
956

    
957
                //((System.Windows.Controls.TextBox)sender).Text;
958

    
959
                if (RadTab.SelectedIndex == 0)
960
                {
961
                    //string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
962
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
963
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
964
                    Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
965
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
966
                }
967
                else
968
                {
969
                    //string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
970
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
971
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
972
                    Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
973
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
974
                }
975
                
976
            }
977
        }
978
    }
979
}
클립보드 이미지 추가 (최대 크기: 500 MB)