프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (41.4 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 Svg2Xaml;
8
using System;
9
using System.Collections.Generic;
10
using System.ComponentModel;
11
using System.Linq;
12
using System.Text;
13
using System.Windows;
14
using System.Windows.Controls;
15
using System.Windows.Data;
16
using System.Windows.Documents;
17
using System.Windows.Input;
18
using System.Windows.Media;
19
using System.Windows.Media.Imaging;
20
using System.Windows.Navigation;
21
using System.Windows.Shapes;
22
using Telerik.Windows.Controls;
23
using Telerik.Windows.Controls.DragDrop;
24

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

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

    
45
        public Symbol()
46
        {
47
            InitializeComponent();
48

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

    
53
            DataBind();
54
        }
55

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

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

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

    
77

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

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

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

    
95
            Symbol_Custom Custom = new Symbol_Custom();
96
            List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
97
            ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
98
            var symbol_Private = client.GetSymbolList(App.ViewInfo.UserID);
99
            foreach (var item in symbol_Private)
100
            {
101
                Custom.Name = item.NAME;
102
                Custom.ImageUri = item.IMAGE_URL;
103
                Custom.ID = item.ID;
104
                Custom_List.Add(Custom);
105
                Custom = new Symbol_Custom();
106
            }
107
            lstSymbolPrivate.ItemsSource = Custom_List;
108

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

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

    
114
            List<SYMBOL_PUBLIC> symbol_Public;
115

    
116

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

    
137
        public PngBitmapEncoder symImage(string data)
138
        {
139

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

    
146
            BitmapEncoder encoder = new PngBitmapEncoder();
147

    
148

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

    
151
            DrawingVisual dv = new DrawingVisual();
152

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

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

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

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

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

    
185
        }
186

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

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

    
207
        #region Event
208

    
209
        #region Private Symbol Add Event
210
        private void Create_Symbol(object sender, RoutedEventArgs e)
211
        {
212
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
213

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

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

    
251
        }
252
        #endregion
253

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
666
                IsMouseDown = true;
667

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

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

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

    
702
        }
703
        #endregion
704

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

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

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

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

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

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

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

    
789
        #endregion
790

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

    
794
        }
795

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

    
799
        }
800

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

    
804
        }
805

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

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

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

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

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

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

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

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

    
883

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

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

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

    
920
            }
921
        }
922

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

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

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