프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Symbol.xaml.cs @ 036650a0

이력 | 보기 | 이력해설 | 다운로드 (41.3 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
        MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
45

    
46
        public Symbol()
47
        {
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
            ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
99
            var symbol_Private = client.GetSymbolList(App.ViewInfo.UserID);
100
            foreach (var item in symbol_Private)
101
            {
102
                Custom.Name = item.NAME;
103
                Custom.ImageUri = item.IMAGE_URL;
104
                Custom.ID = item.ID;
105
                Custom_List.Add(Custom);
106
                Custom = new Symbol_Custom();
107
            }
108
            lstSymbolPrivate.ItemsSource = Custom_List;
109

    
110
            Custom = new Symbol_Custom();
111
            Custom_List = new List<Symbol_Custom>();
112

    
113
            deptlist.ItemsSource = client.GetPublicSymbolDeptList();
114

    
115
            List<SYMBOL_PUBLIC> symbol_Public;
116

    
117

    
118
            if (deptlist.SelectedValue != null)
119
            {
120
                symbol_Public = client.GetPublicSymbolList(deptlist.SelectedValue.ToString());
121
            }
122
            else
123
            {
124
                symbol_Public = client.GetPublicSymbolList(null);
125
            }
126
            foreach (var item in symbol_Public)
127
            {
128
                Custom.Name = item.NAME;
129
                Custom.ImageUri = item.IMAGE_URL;
130
                Custom.ID = item.ID;
131
                Custom_List.Add(Custom);
132
                Custom = new Symbol_Custom();
133
            }
134
            lstSymbolPublic.ItemsSource = Custom_List;
135
            client.Close();
136
        }
137

    
138
        public PngBitmapEncoder symImage(string data)
139
        {
140

    
141
            Canvas _canvas = new Canvas();
142
            _canvas.Background = Brushes.White;
143
            _canvas.Width = finalItem.BorderSize.Width;
144
            _canvas.Height = finalItem.BorderSize.Height;
145
            layer.markupParse(data, _canvas, "#FFFF0000", "");
146

    
147
            BitmapEncoder encoder = new PngBitmapEncoder();
148

    
149

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

    
152
            DrawingVisual dv = new DrawingVisual();
153

    
154
            _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50));
155
            //_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)));
156
            _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)));
157

    
158
            using (DrawingContext ctx = dv.RenderOpen())
159
            {
160
                VisualBrush vb = new VisualBrush(_canvas);
161
                //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)));
162
                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)));
163
            }
164

    
165
            try
166
            {
167
                renderBitmap.Render(dv);
168

    
169
                GC.Collect();
170
                GC.WaitForPendingFinalizers();
171
                GC.Collect();
172
                //bitmap.Render(controlToConvert);
173
                // encode png data
174
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
175
                // puch rendered bitmap into it
176
                pngEncoder.Interlace = PngInterlaceOption.Off;
177
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
178
                return pngEncoder;
179

    
180
            }
181
            catch //(Exception ex)
182
            {
183
                return null;
184
            }
185

    
186
        }
187

    
188
        public void DialogMessage_Alert(string content, string header)
189
        {
190
            var box = new TextBlock();
191
            box.MinWidth = 400;
192
            box.FontSize = 11;
193
            //box.FontSize = 12;
194
            box.Text = content;
195
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
196

    
197
            DialogParameters parameters = new DialogParameters()
198
            {
199
                Owner = Application.Current.MainWindow,
200
                Content = box,
201
                Header = header,
202
                Theme = new VisualStudio2013Theme(),
203
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
204
            };
205
            RadWindow.Alert(parameters);
206
        }
207

    
208
        #region Event
209

    
210
        #region Private Symbol Add Event
211
        private void Create_Symbol(object sender, RoutedEventArgs e)
212
        {
213
            if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
214
            {
215
                DialogMessage_Alert("Please Select Controls", "Alert");
216
            }
217
            else //선택된 것이 있으면
218
            {
219
                string MarkupData = "";
220
                finalItem = new AdornerFinal();
221

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

    
250
        }
251
        #endregion
252

    
253
        #region Symbol Add Close Event 
254
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
255
        {
256
            if (args.PromptResult != null)
257
            {
258
                if (args.DialogResult.Value)
259
                {
260
                    PngBitmapEncoder _Encoder = symImage(data);
261

    
262
                    System.IO.MemoryStream fs = new System.IO.MemoryStream();
263
                    _Encoder.Save(fs);
264
                    System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
265

    
266
                    byte[] Img_byte = fs.ToArray();
267

    
268
                    kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
269
                    filename = fileUploader.Run(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Save.shortGuid() + ".png", Img_byte);
270

    
271
                    if (RadTab.SelectedIndex == 0)
272
                    {
273
                        SymbolSave(args.PromptResult, filename, data);
274
                    }
275
                    else
276
                    {
277
                        SymbolSave_Public(args.PromptResult, filename, data, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
278
                    }
279

    
280
                    DataBind();
281
                }
282
            }
283
        }
284
        #endregion
285

    
286
        public void SymbolSave(string Name, string Url, string Data)
287
        {
288
            try
289
            {
290
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
291
                {
292
                    ID = Events.Save.shortGuid(),
293
                    MEMBER_USER_ID = App.ViewInfo.UserID,
294
                    NAME = Name,
295
                    IMAGE_URL = Url,
296
                    DATA = Data
297
                };
298

    
299
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
300
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
301
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
302
            }
303
            catch (Exception)
304
            {
305
                throw;
306
            }
307
        }
308

    
309
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
310
        {
311
            try
312
            {
313
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
314
                {
315
                    ID = Events.Save.shortGuid(),
316
                    DEPARTMENT = Department,
317
                    NAME = Name,
318
                    IMAGE_URL = Url,
319
                    DATA = Data
320
                };
321
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
322
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
323
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
324
            }
325
            catch (Exception)
326
            {
327
                throw;
328
            }
329
        }
330

    
331
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
332
        {
333
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
334
            DataBind();
335
        }
336

    
337
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
338
        {
339
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
340
            DataBind();
341
        }
342

    
343
        #region Private Symbol Delete Event
344
        private void Remove_Symbol(object sender, RoutedEventArgs e)
345
        {
346
            if (lstSymbolPrivate.SelectedItem == null)
347
            {
348
                DialogMessage_Alert("Please Select Symbol", "Alert");
349
                return;
350
            }
351
            string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
352

    
353
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
354
            Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
355
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
356
        }
357
        #endregion
358
        #region Public Symbol Delete Event
359
        private void Remove_Symbol_Public(object sender, RoutedEventArgs e)
360
        {
361
            if (lstSymbolPublic.SelectedItem == null)
362
            {
363
                DialogMessage_Alert("Please Select Symbol", "Alert");
364
                return;
365
            }
366
            string delItem_ID = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
367

    
368
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
369
            Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
370
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
371
        }
372

    
373
        private void BaseClient_DeleteSymbolCompleted(object sender, ServiceDeepView.DeleteSymbolCompletedEventArgs e)
374
        {
375
            Logger.sendResLog("DeleteSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
376
            DataBind();
377
        }
378
        #endregion
379

    
380
        public Undo_data UndoData { get; set; }
381
        /// <summary>
382
        /// place symbol which has given id to original position which is created
383
        /// </summary>
384
        /// <date>2018.06.14</date>
385
        /// <param name="id"></param>
386
        private void PlaceSymbol(string id)
387
        {
388
            string Data_ = "";
389

    
390
            try
391
            {
392
                Logger.sendReqLog("GetSymbolData: ", id + "," + RadTab.SelectedIndex, 1);
393
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolData(id, RadTab.SelectedIndex);
394
                if (Data_ != null || Data_ != "")
395
                {
396
                    Logger.sendResLog("GetSymbolData", "TRUE", 1);
397
                }
398
                else
399
                {
400
                    Logger.sendResLog("GetSymbolData", "FALSE", 1);
401
                }
402

    
403
                //MARKUP_DATA_GROUP INSERT
404
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
405
                {
406
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
407
                    STATE = 0,
408
                };
409
                long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
410
                Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
411

    
412
                if (Data_.Contains("|DZ|"))
413
                {
414
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
415

    
416
                    string[] delimiterChars = { "|DZ|" };
417
                    string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
418

    
419
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
420
                    UndoData = new Undo_data()
421
                    {
422
                        IsUndo = false,
423
                        Event = Event_Type.Create,
424
                        EventTime = DateTime.Now,
425
                        Markup_List = new List<Multi_Undo_data>()
426
                    };
427
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
428
                    {
429
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
430
                    });
431

    
432
                    foreach (string parse in data)
433
                    {
434
                        if (parse != "")
435
                        {
436
                            System.Windows.Controls.Control item = layer.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
437
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
438
                            (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = id;
439
                            (item as MarkupToPDF.Common.CommentUserInfo).GroupID = group_id;
440
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
441
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
442

    
443
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
444

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

    
447
                            UndoData.Markup_List.Add(multi_Undo_Data);
448
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
449
                        }
450
                    }
451
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
452

    
453
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
454
                }
455
                else
456
                {
457
                    PlaceImageSymbol(id, group_id);
458
                }
459
            }
460
            catch (Exception ex)
461
            {
462
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
463
            }
464
        }
465

    
466
        private void PlaceImageSymbol(string id, long group_id)
467
        {
468
           
469
            //canvasZoommovingMouseDownPoint
470
            string Data_ = "";
471

    
472
            try
473
            {
474
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + RadTab.SelectedIndex, 1);
475
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, RadTab.SelectedIndex);
476
                if (Data_ != null || Data_ != "")
477
                {
478
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
479
                }
480
                else
481
                {
482
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
483
                }
484

    
485
                //MARKUP_DATA_GROUP INSERT
486
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
487
                {
488
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
489
                    STATE = 0,
490
                };
491
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
492
                //Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
493

    
494
                if (Data_ != null)
495
                {
496
                    Image img = new Image();
497
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
498
                    if (Data_.Contains(".svg"))
499
                    {
500
                        byte[] imageData = null;
501
                        DrawingImage image = null;
502
                        using (System.Net.WebClient web = new System.Net.WebClient())
503
                        {
504
                            imageData = web.DownloadData(new Uri(Data_));
505
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
506
                            image = SvgReader.Load(stream);
507
                        }
508
                        img.Source = image;
509
                    }
510
                    else
511
                    {
512
                        img.Source = new BitmapImage(new Uri(Data_));
513
                    }
514

    
515
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
516
                    {
517
                        PointSet = new List<Point>(),
518
                        FilePath = Data_,
519
                        ImageData = img.Source,
520
                        StartPoint = new Point(0, 0),
521
                        EndPoint = new Point(img.Source.Width, img.Source.Height),
522
                        TopRightPoint = new Point(img.Source.Width, 0),
523
                        LeftBottomPoint = new Point(0, img.Source.Height)
524
                    };
525

    
526
                    currentControl.PointSet = new List<Point>
527
                                        {
528
                                            currentControl.StartPoint,
529
                                            currentControl.LeftBottomPoint,
530
                                            currentControl.EndPoint,
531
                                            currentControl.TopRightPoint,
532
                                        };
533
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
534
                    UndoData = new Undo_data()
535
                    {
536
                        IsUndo = false,
537
                        Event = Event_Type.Create,
538
                        EventTime = DateTime.Now,
539
                        Markup_List = new List<Multi_Undo_data>()
540
                    };
541
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
542
                    {
543
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
544
                    });
545

    
546
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
547
                    multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
548
                    UndoData.Markup_List.Add(multi_Undo_Data);
549
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
550

    
551
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
552
                    currentControl.CommentID = Events.Save.shortGuid();
553
                    currentControl.SymbolID = id;
554
                    currentControl.GroupID = group_id;
555
                    currentControl.ApplyTemplate();
556
                    currentControl.SetImage();
557

    
558
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
559
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
560
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
561

    
562
                    // this.ParentOfType<MainWindow>().dzMainMenu.isLeftMouseButtonDownOnWindow = true;
563
                    // final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
564
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
565
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
566
                      final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
567
                    // move.control_Select(item, dragRect);
568
                    ApplyDragSelectionRect();
569
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = MouseHandlingMode.DragSymbol;
570
                    this.ParentOfType<MainWindow>().dzMainMenu.mouseButtonDown = MouseButton.Left;
571
                    this.ParentOfType<MainWindow>().dzMainMenu.symboldata(id, group_id, RadTab.SelectedIndex, Data_, img.Source);
572
                    
573
                }
574
            }
575
            catch(Exception ex)
576
            {
577
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
578
            }
579
        }
580

    
581
        public Multi_Undo_data multi_Undo_Data;
582
        private void ApplyDragSelectionRect()
583
        {
584
            move = new Move();
585
            multi_Undo_Data = new Multi_Undo_data();
586

    
587
            UndoData = new Undo_data()
588
            {
589
                IsUndo = false,
590
                Event = Event_Type.Select,
591
                EventTime = DateTime.Now,
592
                Markup_List = new List<Multi_Undo_data>()
593
            };
594

    
595
            this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed;
596

    
597
            double x = Canvas.GetLeft(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
598
            double y = Canvas.GetTop(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
599
            double width = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Width;
600
            double height = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Height;
601
            Rect dragRect = new Rect(x, y, width, height);
602
            Boolean Flag = false;
603
            dragRect.Inflate(width / 10, height / 10);
604
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
605
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
606

    
607
            dragRect = new Rect(x, y, width, height);
608
            dragRect.Inflate(width / 10, height / 10);
609

    
610
            //move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting;
611
            //move.
612
            foreach (var item in Items)
613
            {
614
                Flag = move.control_Select(item, dragRect);
615

    
616
                if (Flag)
617
                {
618
                    adornerSet.Add(item);
619
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
620

    
621
                    this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item);
622
                    UndoData.Markup_List.Add(multi_Undo_Data);
623
                    multi_Undo_Data = new Multi_Undo_data();
624
                    if (item.GroupID > 0)
625
                    {
626

    
627
                    }
628
                }
629
            }
630
            if (adornerSet.Count > 0)
631
            {
632
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
633
                {
634
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
635
                });
636
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
637

    
638
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
639
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
640
            }
641
        }
642

    
643
        private Move move;
644
        #region Symbol DoubleClick Event
645
        private void Move_Symbol(object sender, MouseButtonEventArgs e)
646
        {
647
            try
648
            {
649
                Type type = e.OriginalSource.GetType();
650
                string id = string.Empty;
651
                Logger.sendResLog("Move_Symbol", type.Name, 0);
652
                if (type.Name == "Image")
653
                {
654
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
655
                }
656
                else if (type.Name == "Border")
657
                {
658
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
659
                }
660
                else if (type.Name == "TextBox")
661
                {
662
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
663
                }
664

    
665
                IsMouseDown = true;
666

    
667
                if (e.ClickCount > 1)
668
                {
669
                    this.PlaceSymbol(id);
670
                }
671
            }
672
            catch(Exception ex)
673
            {
674
                Logger.sendResLog("Move_Symbol", ex.Message, 0);
675
            }
676
        }
677
        #endregion
678

    
679
        #region Private Symbol Rename Event
680
        private void Rename_Symbol(object sender, RoutedEventArgs e)
681
        {
682
            if (lstSymbolPrivate.SelectedItem == null)
683
            {
684
                DialogMessage_Alert("Please Select Symbol", "Alert");
685
                return;
686
            }
687

    
688
            DialogParameters parameters = new DialogParameters()
689
            {
690
                Owner = Application.Current.MainWindow,
691
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
692
                //DefaultPromptResultValue = "Custom State",
693
                DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name,
694
                Content = "Name :",
695
                Header = "Update Custom Symbol Name",
696
                Theme = new VisualStudio2013Theme(),
697
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
698
            };
699
            RadWindow.Prompt(parameters);
700

    
701
        }
702
        #endregion
703

    
704
        #region Public Symbol Rename Event
705
        private void Rename_Symbol_Public(object sender, RoutedEventArgs e)
706
        {
707
            if (lstSymbolPublic.SelectedItem == null)
708
            {
709
                DialogMessage_Alert("Please Select Symbol", "Alert");
710
                return;
711
            }
712

    
713
            DialogParameters parameters = new DialogParameters()
714
            {
715
                Owner = Application.Current.MainWindow,
716
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
717
                //DefaultPromptResultValue = "Custom State",
718
                DefaultPromptResultValue = (lstSymbolPublic.SelectedItem as Symbol_Custom).Name,
719
                Content = "Name :",
720
                Header = "Update Custom Symbol Name",
721
                Theme = new VisualStudio2013Theme(),
722
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
723
            };
724
            RadWindow.Prompt(parameters);
725

    
726
        }
727
        #endregion
728
        #region Symbol Rename Close Event
729
        private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args)
730
        {
731
            if (args.DialogResult != null && args.DialogResult.Value)
732
            {
733
                if(RadTab.SelectedIndex == 0)
734
                {
735
                    string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
736
                    string _name = args.PromptResult;
737
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
738
                    Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
739
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
740
                }
741
                else
742
                {
743
                    string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
744
                    string _name = args.PromptResult;
745
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
746
                    Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
747
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
748
                }
749
            }
750
        }
751

    
752
        private void BaseClient_RenameSymbolCompleted(object sender, ServiceDeepView.RenameSymbolCompletedEventArgs e)
753
        {
754
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
755
            DataBind();
756
        }
757
        #endregion
758

    
759
        #region Wheel Event
760
        private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
761
        {
762
            ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2));
763
        }
764
        private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
765
        {
766
            ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2));
767
        }
768
        #endregion
769

    
770
        #region Tab Selection Event
771
        private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e)
772
        {
773
            foreach (var item in (e.OriginalSource as RadTabControl).Items)
774
            {
775
                (item as RadTabItem).FontWeight = FontWeights.Normal;
776
            }
777
            ((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold;
778
        }
779
        #endregion
780

    
781
        #region Department Selection Event
782
        private void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
783
        {
784
            DataBind();
785
        }
786
        #endregion
787

    
788
        #endregion
789

    
790
        private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
791
        {
792

    
793
        }
794

    
795
        private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e)
796
        {
797

    
798
        }
799

    
800
        private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e)
801
        {
802

    
803
        }
804

    
805
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
806
        {
807
            if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed)
808
            {
809
                ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id;
810
            }
811
            else
812
            {
813
                IsMouseDown = false;
814
            }
815
        }
816

    
817
        private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
818
        {
819
            IsMouseDown = false;
820
        }
821

    
822
        /// <summary>
823
        /// place symbol which user select
824
        /// </summary>
825
        /// <author>humkyung</author>
826
        /// <date>2018.06.14</date>
827
        /// <param name="sender"></param>
828
        /// <param name="e"></param>
829
        private void Place_Symbol(object sender, RoutedEventArgs e)
830
        {
831
            if (lstSymbolPrivate.SelectedItem == null)
832
            {
833
                DialogMessage_Alert("Please Select Symbol",  "Alert");
834
                return;
835
            }
836

    
837
            string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
838
            this.PlaceSymbol(id);
839
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
840
        }
841

    
842
        private void Place_Symbol_Public(object sender, RoutedEventArgs e)
843
        {
844
            if (lstSymbolPublic.SelectedItem == null)
845
            {
846
                DialogMessage_Alert("Please Select Symbol", "Alert");
847
                return;
848
            }
849

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

    
855
        private void Image_Place_Register(object sender, RoutedEventArgs e)
856
        {
857
            SyncInit();
858
            ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
859
            //캡쳐 하기 전에 코멘트 저장
860
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
861
            {
862
                var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
863
                menu.ReleaseAdorner();
864
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
865
                {
866
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
867
                }
868
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
869
                {
870

    
871
                }
872
                else
873
                {
874
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.RefactoryCommentReact(menu);
875
                }
876
            }
877
            Application.Current.MainWindow.Focus();
878
            Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
879
            (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
880
        }
881

    
882

    
883
        private void SyncInit()
884
        {
885
            try
886
            {
887
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
888
                {
889
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
890
                    ViewerDataModel.Instance.PageBalanceMode = false;
891
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
892
                    ViewerDataModel.Instance.PageNumber = 0;
893
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
894
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
895
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
896
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
897
                }
898
            }
899
            catch (Exception ex)
900
            {
901
                Logger.sendResLog("SyncInit", ex.Message, 0);
902
            }
903
        }
904

    
905
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
906
        {
907
            var block = sender as TextBox;
908
            block.Focusable = true;
909
               
910
        }
911

    
912
        private void TextBlock_MouseEnter(object sender, MouseEventArgs e)
913
        {
914
            var block = sender as TextBox;
915
            if (block != null)
916
            {
917
                //block.Text = "Enter";
918

    
919
            }
920
        }
921

    
922
        private void OnKeyDownHandler(object sender, KeyEventArgs e)
923
        {
924
            if (e.Key == Key.Return)
925
            {
926
                Type type = e.OriginalSource.GetType();
927
                string id = string.Empty;
928
                Logger.sendResLog("Move_Symbol", type.Name, 0);
929
                if (type.Name == "Image")
930
                {
931
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
932
                }
933
                else if (type.Name == "Border")
934
                {
935
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
936
                }
937
                else if (type.Name == "TextBox")
938
                {
939
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
940
                }
941

    
942
                //((System.Windows.Controls.TextBox)sender).Text;
943

    
944
                if (RadTab.SelectedIndex == 0)
945
                {
946
                    //string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
947
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
948
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
949
                    Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
950
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
951
                }
952
                else
953
                {
954
                    //string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
955
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
956
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
957
                    Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
958
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
959
                }
960
                
961
            }
962
        }
963
    }
964
}
클립보드 이미지 추가 (최대 크기: 500 MB)