프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Symbol.xaml.cs @ ff01c725

이력 | 보기 | 이력해설 | 다운로드 (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
            try
100
            {
101

    
102
                var symbol_Private = ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolList(App.ViewInfo.UserID);
103

    
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
            catch (Exception ex)
116
            {
117
                System.Diagnostics.Debug.WriteLine(ex.ToString());
118
            }
119

    
120
            Custom = new Symbol_Custom();
121
            Custom_List = new List<Symbol_Custom>();
122

    
123
            deptlist.ItemsSource = ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetPublicSymbolDeptList();
124

    
125
            List<SYMBOL_PUBLIC> symbol_Public;
126

    
127

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

    
147
        public PngBitmapEncoder symImage(string data)
148
        {
149

    
150
            Canvas _canvas = new Canvas();
151
            _canvas.Background = Brushes.White;
152
            _canvas.Width = finalItem.BorderSize.Width;
153
            _canvas.Height = finalItem.BorderSize.Height;
154
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
155

    
156
            BitmapEncoder encoder = new PngBitmapEncoder();
157

    
158

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

    
161
            DrawingVisual dv = new DrawingVisual();
162

    
163
            _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50));
164
            //_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)));
165
            _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)));
166

    
167
            using (DrawingContext ctx = dv.RenderOpen())
168
            {
169
                VisualBrush vb = new VisualBrush(_canvas);
170
                //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)));
171
                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)));
172
            }
173

    
174
            try
175
            {
176
                renderBitmap.Render(dv);
177

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

    
189
            }
190
            catch //(Exception ex)
191
            {
192
                return null;
193
            }
194

    
195
        }
196

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

    
216
        #region Event
217

    
218
        #region Private Symbol Add Event
219
        private void Create_Symbol(object sender, RoutedEventArgs e)
220
        {
221
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
222

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

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

    
260
        }
261
        #endregion
262

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

    
274
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
275
                        _Encoder.Save(fs);
276
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
277

    
278
                        byte[] Img_byte = fs.ToArray();
279

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

    
292
                        DataBind();
293
                    }
294
                }
295
            }
296
            catch(Exception ex)
297
            {
298
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("" + ex, "Alert");
299
            }
300
        }
301
        #endregion
302

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

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

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

    
348
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
349
        {
350
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
351
            DataBind();
352
        }
353

    
354
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
355
        {
356
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
357
            DataBind();
358
        }
359

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

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

    
385
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
386
            Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
387
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
388
        }
389

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

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

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

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

    
429
                if (Data_.Contains("|DZ|"))
430
                {
431
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
432

    
433
                    string[] delimiterChars = { "|DZ|" };
434
                    string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
435

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

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

    
460
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
461

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

    
464
                            UndoData.Markup_List.Add(multi_Undo_Data);
465
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
466
                        }
467
                    }
468
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
469

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

    
483
        private void PlaceImageSymbol(string id, long group_id)
484
        {
485
           
486
            //canvasZoommovingMouseDownPoint
487
            string Data_ = "";
488

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

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

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

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

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

    
563
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
564
                    multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
565
                    UndoData.Markup_List.Add(multi_Undo_Data);
566
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
567

    
568
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
569
                    currentControl.CommentID = Commons.shortGuid();
570
                    currentControl.SymbolID = id;
571
                    currentControl.GroupID = group_id;
572
                    currentControl.ApplyTemplate();
573
                    currentControl.SetImage();
574

    
575
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
576
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
577
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
578

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

    
599
        public Multi_Undo_data multi_Undo_Data;
600
        private void ApplyDragSelectionRect()
601
        {
602
            multi_Undo_Data = new Multi_Undo_data();
603

    
604
            UndoData = new Undo_data()
605
            {
606
                IsUndo = false,
607
                Event = Event_Type.Select,
608
                EventTime = DateTime.Now,
609
                Markup_List = new List<Multi_Undo_data>()
610
            };
611

    
612
            this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed;
613

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

    
624
            dragRect = new Rect(x, y, width, height);
625
            dragRect.Inflate(width / 10, height / 10);
626

    
627
            //move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting;
628
            //move.
629
            foreach (var item in Items)
630
            {
631
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
632

    
633
                if (Flag)
634
                {
635
                    adornerSet.Add(item);
636
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
637

    
638
                    this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item);
639
                    UndoData.Markup_List.Add(multi_Undo_Data);
640
                    multi_Undo_Data = new Multi_Undo_data();
641
                    if (item.GroupID > 0)
642
                    {
643

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

    
655
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
656
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
657
            }
658
        }
659

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

    
682
                IsMouseDown = true;
683

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

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

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

    
718
        }
719
        #endregion
720

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

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

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

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

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

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

    
798
        #region Department Selection Event
799
        private void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
800
        {
801
            DataBind();
802
        }
803
        #endregion
804

    
805
        #endregion
806

    
807
        private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
808
        {
809

    
810
        }
811

    
812
        private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e)
813
        {
814

    
815
        }
816

    
817
        private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e)
818
        {
819

    
820
        }
821

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

    
834
        private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
835
        {
836
            IsMouseDown = false;
837
        }
838

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

    
854
            string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
855
            this.PlaceSymbol(id);
856
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
857
        }
858

    
859
        private void Place_Symbol_Public(object sender, RoutedEventArgs e)
860
        {
861
            if (lstSymbolPublic.SelectedItem == null)
862
            {
863
                DialogMessage_Alert("Please Select Symbol", "Alert");
864
                return;
865
            }
866

    
867
            string id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
868
            this.PlaceSymbol(id);
869
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
870
        }
871

    
872
        private void Image_Place_Register(object sender, RoutedEventArgs e)
873
        {
874
            SyncInit();
875
            ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
876
            //캡쳐 하기 전에 코멘트 저장
877
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
878
            {
879
                var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
880
                SelectionSet.Instance.UnSelect(menu);
881
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
882
                {
883
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null);
884
                }
885
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
886
                {
887

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

    
899

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

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

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

    
936
            }
937
        }
938

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

    
959
                //((System.Windows.Controls.TextBox)sender).Text;
960

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