프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Symbol.xaml.cs @ 223975f7

이력 | 보기 | 이력해설 | 다운로드 (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
        
137
            foreach (var item in symbol_Public)
138
            {
139
                Custom.Name = item.NAME;
140
                Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL, App.isExternal);
141
                Custom.ID = item.ID;
142
                Custom_List.Add(Custom);
143
                Custom = new Symbol_Custom();
144
            }
145
            lstSymbolPublic.ItemsSource = Custom_List;
146
        }
147

    
148
        public PngBitmapEncoder symImage(string data)
149
        {
150

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

    
157
            BitmapEncoder encoder = new PngBitmapEncoder();
158

    
159

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

    
162
            DrawingVisual dv = new DrawingVisual();
163

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

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

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

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

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

    
196
        }
197

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

    
217
        #region Event
218

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

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

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

    
261
        }
262
        #endregion
263

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
683
                IsMouseDown = true;
684

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

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

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

    
719
        }
720
        #endregion
721

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

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

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

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

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

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

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

    
806
        #endregion
807

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

    
811
        }
812

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

    
816
        }
817

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

    
821
        }
822

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

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

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

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

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

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

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

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

    
900

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

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

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

    
937
            }
938
        }
939

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

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

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