프로젝트

일반

사용자정보

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

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

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

1 53880c83 ljiyeon
using IKCOM;
2
using KCOM.Common;
3 787a4489 KangIngu
using KCOM.Events;
4 5ce56a3a KangIngu
using KCOMDataModel.Common;
5
using KCOMDataModel.DataModel;
6 34c8d43a ljiyeon
using MarkupToPDF.Common;
7 036650a0 humkyung
using MarkupToPDF.Controls.Parsing;
8 53880c83 ljiyeon
using Svg2Xaml;
9 787a4489 KangIngu
using System;
10
using System.Collections.Generic;
11 53880c83 ljiyeon
using System.ComponentModel;
12 787a4489 KangIngu
using System.Linq;
13
using System.Text;
14 f65e6c02 taeseongkim
using System.Threading.Tasks;
15 787a4489 KangIngu
using System.Windows;
16
using System.Windows.Controls;
17
using System.Windows.Data;
18
using System.Windows.Documents;
19
using System.Windows.Input;
20
using System.Windows.Media;
21
using System.Windows.Media.Imaging;
22
using System.Windows.Navigation;
23
using System.Windows.Shapes;
24
using Telerik.Windows.Controls;
25 5ce56a3a KangIngu
using Telerik.Windows.Controls.DragDrop;
26 787a4489 KangIngu
27
namespace KCOM.Controls
28
{
29
    public class Symbol_Custom
30
    {
31 5ce56a3a KangIngu
        public string ID { get; set; }
32 787a4489 KangIngu
        public string Name { get; set; }
33
        public string ImageUri { get; set; }
34
    }
35
36
    /// <summary>
37
    /// Symbol.xaml에 대한 상호 작용 논리
38
    /// </summary>
39
    public partial class Symbol : UserControl
40
    {
41
        AdornerFinal finalItem;
42 5ce56a3a KangIngu
        bool IsMouseDown = false;
43
        string moveItem_id = "";
44 787a4489 KangIngu
        public string filename { get; set; }
45 f65e6c02 taeseongkim
        bool _Initialize = false;
46 787a4489 KangIngu
47
        public Symbol()
48
        {
49 f65e6c02 taeseongkim
            //App.splashString(ISplashMessage.SYMBOL);
50 787a4489 KangIngu
            InitializeComponent();
51 53880c83 ljiyeon
52
            //RadDragAndDropManager.AddDragInfoHandler(lstSymbolPrivate, OnDragPrivateInfo);
53
            //RadDragAndDropManager.AddDragQueryHandler(lstSymbolPrivate, OnDragPrivateQuery);
54
            //RadDragAndDropManager.SetAllowDrag(lstSymbolPrivate, true);
55 f65e6c02 taeseongkim
            this.Loaded += Symbol_Loaded;
56
 
57
        }
58
59
        
60 787a4489 KangIngu
61 f65e6c02 taeseongkim
        private async void Symbol_Loaded(object sender, RoutedEventArgs e)
62
        {
63 8fb54282 taeseongkim
            if (!App.IsDesignMode)
64 f65e6c02 taeseongkim
            {
65 8fb54282 taeseongkim
                if (!_Initialize)
66
                {
67
                    _Initialize = true;
68
                    await DataBindAsync();
69 f65e6c02 taeseongkim
70 8fb54282 taeseongkim
                }
71 f65e6c02 taeseongkim
            }
72 787a4489 KangIngu
        }
73
74 5ce56a3a KangIngu
        private void OnDragPrivateInfo(object sender, DragDropEventArgs e)
75
        {
76
        }
77
78
        private void OnDragPrivateQuery(object sender, DragDropQueryEventArgs e)
79
        {
80
            if (e.Options.Status == DragStatus.DragQuery)
81
            {
82
                //var draggedListBoxItem = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem;
83
                //BitmapImage im = new BitmapImage(new Uri((draggedListBoxItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate).ImageUri));
84
                //ImageSource _source = im;
85
                //Image img = new Image();
86
                //img.Source = _source;
87
88
                //e.Options.Payload = im;
89
                //var dragCue = new Image();
90
                //dragCue.Source = img.Source;
91
                //dragCue.Width = 0;
92
                //dragCue.Height = 0;
93
                //e.Options.DragCue = dragCue;
94
95
96
                //PayLoadAdorner = new AdornerFinal();
97
                //DeepView.ServiceDeepView_Symbol.SymbolPrivate tempDragableControl = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate;
98
                //var xamldata = tempDragableControl.Data;
99
                ////this.DeepLayer.markupParse(xamldata, this.DeepLayer._TempLayer, "복사된 데이터_이름으로 수정해야함");
100
                //PayLoadAdorner = this.DeepLayer.markupParseToAdorner(xamldata, this.DeepLayer._SelectLayer, "");
101
                //this.DeepLayer._SelectLayer.Children.Add(PayLoadAdorner);
102
            }
103
104
            e.QueryResult = true;
105
            e.Handled = true;
106
        }
107
108 f65e6c02 taeseongkim
        private async Task DataBindAsync()
109 787a4489 KangIngu
        {
110 5ce56a3a KangIngu
            //lstSymbolPrivate.ItemsSource = null;
111
            //lstSymbolPublic.ItemsSource = null;
112 787a4489 KangIngu
113
            Symbol_Custom Custom = new Symbol_Custom();
114 ff01c725 humkyung
            List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
115
116
            try
117
            {
118
119 f65e6c02 taeseongkim
                var symbol_Private = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetSymbolListAsync(App.ViewInfo.UserID);
120 ff01c725 humkyung
121
                foreach (var item in symbol_Private)
122
                {
123
                    Custom.Name = item.NAME;
124
                    Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL, App.isExternal);
125
                    Custom.ID = item.ID;
126
                    Custom_List.Add(Custom);
127
                    Custom = new Symbol_Custom();
128
                }
129
                lstSymbolPrivate.ItemsSource = Custom_List;
130
            }
131
            catch (Exception ex)
132 5ce56a3a KangIngu
            {
133 ff01c725 humkyung
                System.Diagnostics.Debug.WriteLine(ex.ToString());
134 6c781c0c djkim
            }
135 5ce56a3a KangIngu
136 6c781c0c djkim
            Custom = new Symbol_Custom();
137
            Custom_List = new List<Symbol_Custom>();
138 5ce56a3a KangIngu
139 f65e6c02 taeseongkim
            deptlist.ItemsSource = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolDeptListAsync();
140 5ce56a3a KangIngu
141 6c781c0c djkim
            List<SYMBOL_PUBLIC> symbol_Public;
142 5ce56a3a KangIngu
143 53880c83 ljiyeon
144 6c781c0c djkim
            if (deptlist.SelectedValue != null)
145
            {
146 f65e6c02 taeseongkim
                symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(deptlist.SelectedValue.ToString());
147 6c781c0c djkim
            }
148
            else
149
            {
150 f65e6c02 taeseongkim
                symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(null);
151 5ce56a3a KangIngu
            }
152 223975f7 taeseongkim
        
153 6c781c0c djkim
            foreach (var item in symbol_Public)
154
            {
155
                Custom.Name = item.NAME;
156 19391ad3 djkim
                Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL, App.isExternal);
157 6c781c0c djkim
                Custom.ID = item.ID;
158
                Custom_List.Add(Custom);
159
                Custom = new Symbol_Custom();
160
            }
161 f65e6c02 taeseongkim
162 223975f7 taeseongkim
            lstSymbolPublic.ItemsSource = Custom_List;
163 5ce56a3a KangIngu
        }
164
165
        public PngBitmapEncoder symImage(string data)
166
        {
167
168
            Canvas _canvas = new Canvas();
169
            _canvas.Background = Brushes.White;
170
            _canvas.Width = finalItem.BorderSize.Width;
171
            _canvas.Height = finalItem.BorderSize.Height;
172 5529d2a2 humkyung
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
173 5ce56a3a KangIngu
174
            BitmapEncoder encoder = new PngBitmapEncoder();
175
176
177
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
178
179
            DrawingVisual dv = new DrawingVisual();
180
181
            _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50));
182
            //_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)));
183
            _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)));
184
185
            using (DrawingContext ctx = dv.RenderOpen())
186
            {
187
                VisualBrush vb = new VisualBrush(_canvas);
188
                //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)));
189
                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)));
190
            }
191
192
            try
193
            {
194
                renderBitmap.Render(dv);
195
196
                GC.Collect();
197
                GC.WaitForPendingFinalizers();
198
                GC.Collect();
199
                //bitmap.Render(controlToConvert);
200
                // encode png data
201
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
202
                // puch rendered bitmap into it
203
                pngEncoder.Interlace = PngInterlaceOption.Off;
204
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
205
                return pngEncoder;
206
207
            }
208 53880c83 ljiyeon
            catch //(Exception ex)
209 5ce56a3a KangIngu
            {
210
                return null;
211
            }
212 787a4489 KangIngu
213
        }
214
215 5ce56a3a KangIngu
        public void DialogMessage_Alert(string content, string header)
216
        {
217
            DialogParameters parameters = new DialogParameters()
218
            {
219 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
220 0d32593b ljiyeon
                Content = new TextBlock()
221
                {
222
                    MinWidth = 400,
223
                    FontSize = 11,
224
                    Text = content,
225
                    TextWrapping = System.Windows.TextWrapping.Wrap
226
                },
227 5ce56a3a KangIngu
                Header = header,
228
                Theme = new VisualStudio2013Theme(),
229
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
230
            };
231
            RadWindow.Alert(parameters);
232
        }
233
234
        #region Event
235
236 498f0fc9 ljiyeon
        #region Private Symbol Add Event
237 787a4489 KangIngu
        private void Create_Symbol(object sender, RoutedEventArgs e)
238
        {
239 5529d2a2 humkyung
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
240 787a4489 KangIngu
241
            if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
242
            {
243
                DialogMessage_Alert("Please Select Controls", "Alert");
244
            }
245
            else //선택된 것이 있으면
246
            {
247
                string MarkupData = "";
248
                finalItem = new AdornerFinal();
249
250
                foreach (var item in Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children)
251
                {
252
                    if (item.GetType().Name == "AdornerFinal")
253
                    {
254
                        finalItem = (item as Controls.AdornerFinal);
255 4913851c humkyung
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
256 787a4489 KangIngu
                        {
257
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
258
                            {
259 5529d2a2 humkyung
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
260 787a4489 KangIngu
                                MarkupData += markupReturn.ConvertData;
261
                            }
262
                        }
263
                    }
264
                }
265
                DialogParameters parameters = new DialogParameters()
266
                {
267 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
268 53880c83 ljiyeon
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
269 787a4489 KangIngu
                    DefaultPromptResultValue = "Custom State",
270
                    Content = "Name :",
271
                    Header = "Insert Custom Symbol Name",
272
                    Theme = new VisualStudio2013Theme(),
273
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
274
                };
275
                RadWindow.Prompt(parameters);
276
            }
277
278
        }
279 5ce56a3a KangIngu
        #endregion
280 787a4489 KangIngu
281 5ce56a3a KangIngu
        #region Symbol Add Close Event 
282 f65e6c02 taeseongkim
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
283 787a4489 KangIngu
        {
284 c73426a9 ljiyeon
            try
285 787a4489 KangIngu
            {
286 c73426a9 ljiyeon
                if (args.PromptResult != null)
287 53880c83 ljiyeon
                {
288 c73426a9 ljiyeon
                    if (args.DialogResult.Value)
289
                    {
290
                        PngBitmapEncoder _Encoder = symImage(data);
291 787a4489 KangIngu
292 c73426a9 ljiyeon
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
293
                        _Encoder.Save(fs);
294
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
295 787a4489 KangIngu
296 c73426a9 ljiyeon
                        byte[] Img_byte = fs.ToArray();
297 787a4489 KangIngu
298 c73426a9 ljiyeon
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
299 24678e06 humkyung
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
300 c73426a9 ljiyeon
                        Check_Uri.UriCheck(filename);
301
                        if (RadTab.SelectedIndex == 0)
302
                        {
303
                            SymbolSave(args.PromptResult, filename, data);
304
                        }
305
                        else
306
                        {
307
                            SymbolSave_Public(args.PromptResult, filename, data, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
308
                        }
309 53880c83 ljiyeon
310 f65e6c02 taeseongkim
                        await DataBindAsync();
311 53880c83 ljiyeon
                    }
312 498f0fc9 ljiyeon
                }
313 53880c83 ljiyeon
            }
314 c73426a9 ljiyeon
            catch(Exception ex)
315
            {
316
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("" + ex, "Alert");
317
            }
318 53880c83 ljiyeon
        }
319
        #endregion
320
321
        public void SymbolSave(string Name, string Url, string Data)
322
        {
323
            try
324
            {
325
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
326 498f0fc9 ljiyeon
                {
327 24678e06 humkyung
                    ID = Commons.shortGuid(),
328 53880c83 ljiyeon
                    MEMBER_USER_ID = App.ViewInfo.UserID,
329
                    NAME = Name,
330
                    IMAGE_URL = Url,
331
                    DATA = Data
332
                };
333 5ce56a3a KangIngu
334 53880c83 ljiyeon
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
335
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
336
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
337
            }
338
            catch (Exception)
339
            {
340
                throw;
341 787a4489 KangIngu
            }
342
        }
343 53880c83 ljiyeon
344
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
345
        {
346
            try
347
            {
348
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
349
                {
350 24678e06 humkyung
                    ID = Commons.shortGuid(),
351 53880c83 ljiyeon
                    DEPARTMENT = Department,
352
                    NAME = Name,
353
                    IMAGE_URL = Url,
354
                    DATA = Data
355
                };
356
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
357
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
358
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
359
            }
360
            catch (Exception)
361
            {
362
                throw;
363
            }
364
        }
365
366 f65e6c02 taeseongkim
        private async void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
367 53880c83 ljiyeon
        {
368
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
369 f65e6c02 taeseongkim
            await DataBindAsync();
370 53880c83 ljiyeon
        }
371
372 f65e6c02 taeseongkim
        private async void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
373 53880c83 ljiyeon
        {
374
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
375 f65e6c02 taeseongkim
            await DataBindAsync();
376 53880c83 ljiyeon
        }
377 787a4489 KangIngu
378 498f0fc9 ljiyeon
        #region Private Symbol Delete Event
379 5ce56a3a KangIngu
        private void Remove_Symbol(object sender, RoutedEventArgs e)
380 787a4489 KangIngu
        {
381 5ce56a3a KangIngu
            if (lstSymbolPrivate.SelectedItem == null)
382
            {
383
                DialogMessage_Alert("Please Select Symbol", "Alert");
384
                return;
385
            }
386 6c781c0c djkim
            string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
387 0f065e57 ljiyeon
388 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
389 0f065e57 ljiyeon
            Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
390 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
391 498f0fc9 ljiyeon
        }
392
        #endregion
393
        #region Public Symbol Delete Event
394
        private void Remove_Symbol_Public(object sender, RoutedEventArgs e)
395
        {
396
            if (lstSymbolPublic.SelectedItem == null)
397
            {
398
                DialogMessage_Alert("Please Select Symbol", "Alert");
399
                return;
400
            }
401
            string delItem_ID = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
402
403
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
404
            Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
405
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
406 6c781c0c djkim
        }
407 787a4489 KangIngu
408 f65e6c02 taeseongkim
        private async void BaseClient_DeleteSymbolCompleted(object sender, ServiceDeepView.DeleteSymbolCompletedEventArgs e)
409 6c781c0c djkim
        {
410 0f065e57 ljiyeon
            Logger.sendResLog("DeleteSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
411 f65e6c02 taeseongkim
             await DataBindAsync();
412 5ce56a3a KangIngu
        }
413
        #endregion
414 787a4489 KangIngu
415 34c8d43a ljiyeon
        public Undo_data UndoData { get; set; }
416 702abd98 humkyung
        /// <summary>
417
        /// place symbol which has given id to original position which is created
418
        /// </summary>
419
        /// <date>2018.06.14</date>
420
        /// <param name="id"></param>
421 c7fde400 taeseongkim
        private void PlaceSymbol(string id,Point CurrentMousePoint)
422 5ce56a3a KangIngu
        {
423 702abd98 humkyung
            string Data_ = "";
424 787a4489 KangIngu
425 c7fde400 taeseongkim
            var systemMain = Common.ViewerDataModel.Instance.SystemMain;
426
            var mainMenu = systemMain.dzMainMenu;
427
            
428
            SelectionSet.Instance.UnSelect(mainMenu);  /// unselect alreay selected items
429
430 702abd98 humkyung
            try
431 5ce56a3a KangIngu
            {
432 0f065e57 ljiyeon
                Logger.sendReqLog("GetSymbolData: ", id + "," + RadTab.SelectedIndex, 1);
433 c7fde400 taeseongkim
                Data_ = mainMenu.BaseClient.GetSymbolData(id, RadTab.SelectedIndex);
434
435 0f065e57 ljiyeon
                if (Data_ != null || Data_ != "")
436
                {
437
                    Logger.sendResLog("GetSymbolData", "TRUE", 1);
438
                }
439
                else
440
                {
441
                    Logger.sendResLog("GetSymbolData", "FALSE", 1);
442
                }
443 787a4489 KangIngu
444 53880c83 ljiyeon
                //MARKUP_DATA_GROUP INSERT
445 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
446
                //{
447
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
448
                //    STATE = 0,
449
                //};
450
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
451
                //Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
452 53880c83 ljiyeon
453 5ce56a3a KangIngu
                if (Data_.Contains("|DZ|"))
454
                {
455
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
456
457
                    string[] delimiterChars = { "|DZ|" };
458
                    string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
459
460 34c8d43a ljiyeon
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
461
                    UndoData = new Undo_data()
462
                    {
463
                        IsUndo = false,
464
                        Event = Event_Type.Create,
465
                        EventTime = DateTime.Now,
466
                        Markup_List = new List<Multi_Undo_data>()
467
                    };
468
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
469
                    {
470
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
471
                    });
472
473
                    foreach (string parse in data)
474 5ce56a3a KangIngu
                    {
475
                        if (parse != "")
476
                        {
477 5529d2a2 humkyung
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
478 24678e06 humkyung
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
479 c8e9b3e4 ljiyeon
                            (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = id;
480 c0977e97 djkim
                            //(item as MarkupToPDF.Common.CommentUserInfo).GroupID = group_id;
481 c7fde400 taeseongkim
482 5ce56a3a KangIngu
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
483
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
484 53880c83 ljiyeon
485 5ce56a3a KangIngu
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
486 34c8d43a ljiyeon
487
                            multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
488
489
                            UndoData.Markup_List.Add(multi_Undo_Data);
490
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
491 5ce56a3a KangIngu
                        }
492
                    }
493 c7fde400 taeseongkim
494 5ce56a3a KangIngu
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
495
496 c7fde400 taeseongkim
                    // 마우스 클릭된 페이지 위치
497
498
                    var pageWidth = mainMenu.pageNavigator.CurrentPage.Width;
499
                    var pageHeight = mainMenu.pageNavigator.CurrentPage.Height;
500
                    var angle = Common.ViewerDataModel.Instance.Angle;
501
502
                    Point pagePoint = new Point(pageWidth/2, pageHeight/2);
503
504
                    var rotatePoint = Rotate(mainMenu.CanvasDrawingMouseDownPoint,pagePoint,angle);
505
506
                    var diff = Point.Subtract(rotatePoint, final.Centeroid);
507 6b6e937c taeseongkim
                    final.TranslateItems(diff.X, diff.Y);
508 c7fde400 taeseongkim
509
                    mainMenu.SelectLayer.Children.Add(final);
510
                    //var finalPosition = new Point(Canvas.GetLeft(final), Canvas.GetTop(final));
511
                    //Rect rect = new Rect(finalPosition, Point.Add(finalPosition,new Vector(final.Width,final.Height)));
512
513
                    //SelectionSet.Instance.SelectItemByRect(final.getAdornerSize(), mainMenu);
514
515 5ce56a3a KangIngu
                }
516 53880c83 ljiyeon
                else
517
                {
518 c0977e97 djkim
                    PlaceImageSymbol(id, 0);
519 53880c83 ljiyeon
                }
520
            }
521
            catch (Exception ex)
522
            {
523
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
524
            }
525
        }
526
527 c7fde400 taeseongkim
528
        //출처: https://icodebroker.tistory.com/3189 [ICODEBROKER]
529
        public Point Rotate(Point sourcePoint, Point centerPoint, double rotateAngle)
530
        {
531
            Point targetPoint = new Point();
532
533
            double radian = rotateAngle / 180 * Math.PI;
534
535
            targetPoint.X = Math.Cos(radian) * (sourcePoint.X - centerPoint.X) - Math.Sin(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.X;
536
            targetPoint.Y = Math.Sin(radian) * (sourcePoint.X - centerPoint.X) + Math.Cos(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.Y;
537
538
            return targetPoint;
539
        }
540
541
542
543 53880c83 ljiyeon
        private void PlaceImageSymbol(string id, long group_id)
544
        {
545
           
546
            //canvasZoommovingMouseDownPoint
547
            string Data_ = "";
548
549
            try
550
            {
551
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + RadTab.SelectedIndex, 1);
552
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, RadTab.SelectedIndex);
553
                if (Data_ != null || Data_ != "")
554
                {
555
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
556
                }
557
                else
558
                {
559
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
560
                }
561
562
                //MARKUP_DATA_GROUP INSERT
563 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
564
                //{
565
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
566
                //    STATE = 0,
567
                //};
568 53880c83 ljiyeon
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
569
                //Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
570
571
                if (Data_ != null)
572
                {
573
                    Image img = new Image();
574
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
575
                    if (Data_.Contains(".svg"))
576
                    {
577
                        byte[] imageData = null;
578
                        DrawingImage image = null;
579
                        using (System.Net.WebClient web = new System.Net.WebClient())
580
                        {
581
                            imageData = web.DownloadData(new Uri(Data_));
582
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
583
                            image = SvgReader.Load(stream);
584
                        }
585
                        img.Source = image;
586
                    }
587
                    else
588
                    {
589
                        img.Source = new BitmapImage(new Uri(Data_));
590
                    }
591
592
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
593
                    {
594
                        PointSet = new List<Point>(),
595
                        FilePath = Data_,
596
                        ImageData = img.Source,
597
                        StartPoint = new Point(0, 0),
598
                        EndPoint = new Point(img.Source.Width, img.Source.Height),
599
                        TopRightPoint = new Point(img.Source.Width, 0),
600
                        LeftBottomPoint = new Point(0, img.Source.Height)
601
                    };
602
603
                    currentControl.PointSet = new List<Point>
604
                                        {
605
                                            currentControl.StartPoint,
606
                                            currentControl.LeftBottomPoint,
607
                                            currentControl.EndPoint,
608
                                            currentControl.TopRightPoint,
609
                                        };
610
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
611
                    UndoData = new Undo_data()
612
                    {
613
                        IsUndo = false,
614
                        Event = Event_Type.Create,
615
                        EventTime = DateTime.Now,
616
                        Markup_List = new List<Multi_Undo_data>()
617
                    };
618
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
619
                    {
620
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
621
                    });
622
623
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
624
                    multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
625
                    UndoData.Markup_List.Add(multi_Undo_Data);
626
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
627
628
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
629 24678e06 humkyung
                    currentControl.CommentID = Commons.shortGuid();
630 53880c83 ljiyeon
                    currentControl.SymbolID = id;
631
                    currentControl.GroupID = group_id;
632
                    currentControl.ApplyTemplate();
633
                    currentControl.SetImage();
634
635
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
636
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
637
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
638
639 7211e0c2 ljiyeon
                    /*
640 53880c83 ljiyeon
                    // this.ParentOfType<MainWindow>().dzMainMenu.isLeftMouseButtonDownOnWindow = true;
641
                    // final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
642
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
643
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
644 0d00f9c8 humkyung
                      final.TranslateItems(realPointX, realPointY);
645 53880c83 ljiyeon
                    // move.control_Select(item, dragRect);
646
                    ApplyDragSelectionRect();
647 7211e0c2 ljiyeon
                    //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = MouseHandlingMode.DragSymbol;
648 e6a9ddaf humkyung
                    ///this.ParentOfType<MainWindow>().dzMainMenu.mouseButtonDown = MouseButton.Left;
649 7211e0c2 ljiyeon
                    //this.ParentOfType<MainWindow>().dzMainMenu.symboldata(id, group_id, RadTab.SelectedIndex, Data_, img.Source);*/
650 53880c83 ljiyeon
                    
651
                }
652 5ce56a3a KangIngu
            }
653 702abd98 humkyung
            catch(Exception ex)
654
            {
655 53880c83 ljiyeon
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
656
            }
657
        }
658
659
        public Multi_Undo_data multi_Undo_Data;
660
        private void ApplyDragSelectionRect()
661
        {
662
            multi_Undo_Data = new Multi_Undo_data();
663
664
            UndoData = new Undo_data()
665
            {
666
                IsUndo = false,
667
                Event = Event_Type.Select,
668
                EventTime = DateTime.Now,
669
                Markup_List = new List<Multi_Undo_data>()
670
            };
671
672
            this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed;
673
674
            double x = Canvas.GetLeft(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
675
            double y = Canvas.GetTop(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
676
            double width = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Width;
677
            double height = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Height;
678
            Rect dragRect = new Rect(x, y, width, height);
679
            Boolean Flag = false;
680
            dragRect.Inflate(width / 10, height / 10);
681
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
682
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
683
684
            dragRect = new Rect(x, y, width, height);
685
            dragRect.Inflate(width / 10, height / 10);
686
687
            //move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting;
688
            //move.
689
            foreach (var item in Items)
690
            {
691 91efe37a humkyung
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
692 53880c83 ljiyeon
693
                if (Flag)
694
                {
695
                    adornerSet.Add(item);
696
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
697
698
                    this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item);
699
                    UndoData.Markup_List.Add(multi_Undo_Data);
700
                    multi_Undo_Data = new Multi_Undo_data();
701
                    if (item.GroupID > 0)
702
                    {
703
704
                    }
705
                }
706
            }
707
            if (adornerSet.Count > 0)
708
            {
709
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
710
                {
711
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
712
                });
713
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
714
715
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
716
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
717 702abd98 humkyung
            }
718
        }
719
720 f816dd63 humkyung
        ///private Move move;
721 702abd98 humkyung
        #region Symbol DoubleClick Event
722
        private void Move_Symbol(object sender, MouseButtonEventArgs e)
723
        {
724 16d13764 djkim
            try
725 702abd98 humkyung
            {
726 16d13764 djkim
                Type type = e.OriginalSource.GetType();
727
                string id = string.Empty;
728 be31927d djkim
                Logger.sendResLog("Move_Symbol", type.Name, 0);
729 16d13764 djkim
                if (type.Name == "Image")
730
                {
731
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
732
                }
733
                else if (type.Name == "Border")
734
                {
735
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
736
                }
737 53880c83 ljiyeon
                else if (type.Name == "TextBox")
738 be31927d djkim
                {
739 53880c83 ljiyeon
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
740 be31927d djkim
                }
741 16d13764 djkim
742
                IsMouseDown = true;
743 53880c83 ljiyeon
744 16d13764 djkim
                if (e.ClickCount > 1)
745
                {
746 c7fde400 taeseongkim
                    this.PlaceSymbol(id,ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
747 16d13764 djkim
                }
748 702abd98 humkyung
            }
749 16d13764 djkim
            catch(Exception ex)
750
            {
751
                Logger.sendResLog("Move_Symbol", ex.Message, 0);
752 53880c83 ljiyeon
            }
753 5ce56a3a KangIngu
        }
754
        #endregion
755
756 498f0fc9 ljiyeon
        #region Private Symbol Rename Event
757 5ce56a3a KangIngu
        private void Rename_Symbol(object sender, RoutedEventArgs e)
758
        {
759
            if (lstSymbolPrivate.SelectedItem == null)
760 787a4489 KangIngu
            {
761 5ce56a3a KangIngu
                DialogMessage_Alert("Please Select Symbol", "Alert");
762
                return;
763 787a4489 KangIngu
            }
764
765 5ce56a3a KangIngu
            DialogParameters parameters = new DialogParameters()
766 787a4489 KangIngu
            {
767 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
768 5ce56a3a KangIngu
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
769
                //DefaultPromptResultValue = "Custom State",
770
                DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name,
771
                Content = "Name :",
772
                Header = "Update Custom Symbol Name",
773
                Theme = new VisualStudio2013Theme(),
774
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
775
            };
776
            RadWindow.Prompt(parameters);
777 787a4489 KangIngu
778 5ce56a3a KangIngu
        }
779
        #endregion
780 787a4489 KangIngu
781 498f0fc9 ljiyeon
        #region Public Symbol Rename Event
782
        private void Rename_Symbol_Public(object sender, RoutedEventArgs e)
783
        {
784
            if (lstSymbolPublic.SelectedItem == null)
785
            {
786
                DialogMessage_Alert("Please Select Symbol", "Alert");
787
                return;
788
            }
789
790
            DialogParameters parameters = new DialogParameters()
791
            {
792 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
793 498f0fc9 ljiyeon
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
794
                //DefaultPromptResultValue = "Custom State",
795
                DefaultPromptResultValue = (lstSymbolPublic.SelectedItem as Symbol_Custom).Name,
796
                Content = "Name :",
797
                Header = "Update Custom Symbol Name",
798
                Theme = new VisualStudio2013Theme(),
799
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
800
            };
801
            RadWindow.Prompt(parameters);
802
803
        }
804
        #endregion
805 5ce56a3a KangIngu
        #region Symbol Rename Close Event
806
        private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args)
807
        {
808
            if (args.DialogResult != null && args.DialogResult.Value)
809
            {
810 498f0fc9 ljiyeon
                if(RadTab.SelectedIndex == 0)
811
                {
812
                    string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
813
                    string _name = args.PromptResult;
814
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
815
                    Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
816
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
817
                }
818
                else
819
                {
820
                    string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
821
                    string _name = args.PromptResult;
822
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
823
                    Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
824
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
825 53880c83 ljiyeon
                }
826 787a4489 KangIngu
            }
827 5ce56a3a KangIngu
        }
828 6c781c0c djkim
829 f65e6c02 taeseongkim
        private async void BaseClient_RenameSymbolCompleted(object sender, ServiceDeepView.RenameSymbolCompletedEventArgs e)
830 6c781c0c djkim
        {
831 0f065e57 ljiyeon
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
832 f65e6c02 taeseongkim
            await DataBindAsync();
833 6c781c0c djkim
        }
834 5ce56a3a KangIngu
        #endregion
835
836
        #region Wheel Event
837
        private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
838
        {
839
            ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2));
840
        }
841
        private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
842
        {
843
            ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2));
844
        }
845
        #endregion
846
847
        #region Tab Selection Event
848
        private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e)
849
        {
850
            foreach (var item in (e.OriginalSource as RadTabControl).Items)
851 787a4489 KangIngu
            {
852 5ce56a3a KangIngu
                (item as RadTabItem).FontWeight = FontWeights.Normal;
853 787a4489 KangIngu
            }
854 5ce56a3a KangIngu
            ((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold;
855
        }
856
        #endregion
857 787a4489 KangIngu
858 5ce56a3a KangIngu
        #region Department Selection Event
859 f65e6c02 taeseongkim
        private async void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
860 5ce56a3a KangIngu
        {
861 f65e6c02 taeseongkim
            await DataBindAsync();
862 787a4489 KangIngu
        }
863 5ce56a3a KangIngu
        #endregion
864 787a4489 KangIngu
865 5ce56a3a KangIngu
        #endregion
866 29010418 ljiyeon
867 5ce56a3a KangIngu
        private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
868
        {
869
870
        }
871
872
        private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e)
873
        {
874
875
        }
876
877
        private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e)
878 787a4489 KangIngu
        {
879
880
        }
881 29010418 ljiyeon
882 5ce56a3a KangIngu
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
883 787a4489 KangIngu
        {
884 5ce56a3a KangIngu
            if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed)
885
            {
886
                ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id;
887
            }
888
            else
889
            {
890
                IsMouseDown = false;
891
            }
892
        }
893 787a4489 KangIngu
894 5ce56a3a KangIngu
        private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
895
        {
896
            IsMouseDown = false;
897 787a4489 KangIngu
        }
898 702abd98 humkyung
899
        /// <summary>
900
        /// place symbol which user select
901
        /// </summary>
902
        /// <author>humkyung</author>
903
        /// <date>2018.06.14</date>
904
        /// <param name="sender"></param>
905
        /// <param name="e"></param>
906
        private void Place_Symbol(object sender, RoutedEventArgs e)
907
        {
908
            if (lstSymbolPrivate.SelectedItem == null)
909
            {
910
                DialogMessage_Alert("Please Select Symbol",  "Alert");
911
                return;
912
            }
913
914
            string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
915 c7fde400 taeseongkim
            this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
916 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
917 702abd98 humkyung
        }
918 ffcc8124 ljiyeon
919
        private void Place_Symbol_Public(object sender, RoutedEventArgs e)
920
        {
921
            if (lstSymbolPublic.SelectedItem == null)
922
            {
923
                DialogMessage_Alert("Please Select Symbol", "Alert");
924
                return;
925
            }
926
927
            string id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
928 c7fde400 taeseongkim
            this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
929 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
930
        }
931
932
        private void Image_Place_Register(object sender, RoutedEventArgs e)
933
        {
934
            SyncInit();
935
            ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
936
            //캡쳐 하기 전에 코멘트 저장
937
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
938
            {
939
                var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
940 077896be humkyung
                SelectionSet.Instance.UnSelect(menu);
941 53880c83 ljiyeon
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
942
                {
943 cb5c7f06 humkyung
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null);
944 53880c83 ljiyeon
                }
945
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
946
                {
947
948
                }
949
                else
950
                {
951 cb5c7f06 humkyung
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null);
952 53880c83 ljiyeon
                }
953
            }
954
            Application.Current.MainWindow.Focus();
955
            Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
956
            (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
957
        }
958
959
960
        private void SyncInit()
961
        {
962
            try
963
            {
964
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
965
                {
966
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
967
                    ViewerDataModel.Instance.PageBalanceMode = false;
968
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
969
                    ViewerDataModel.Instance.PageNumber = 0;
970
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
971
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
972
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
973
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
974
                }
975
            }
976
            catch (Exception ex)
977
            {
978
                Logger.sendResLog("SyncInit", ex.Message, 0);
979
            }
980
        }
981
982
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
983
        {
984
            var block = sender as TextBox;
985
            block.Focusable = true;
986
               
987
        }
988
989
        private void TextBlock_MouseEnter(object sender, MouseEventArgs e)
990
        {
991
            var block = sender as TextBox;
992
            if (block != null)
993
            {
994
                //block.Text = "Enter";
995
996
            }
997
        }
998
999
        private void OnKeyDownHandler(object sender, KeyEventArgs e)
1000
        {
1001
            if (e.Key == Key.Return)
1002
            {
1003
                Type type = e.OriginalSource.GetType();
1004
                string id = string.Empty;
1005
                Logger.sendResLog("Move_Symbol", type.Name, 0);
1006
                if (type.Name == "Image")
1007
                {
1008
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
1009
                }
1010
                else if (type.Name == "Border")
1011
                {
1012
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
1013
                }
1014
                else if (type.Name == "TextBox")
1015
                {
1016
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
1017
                }
1018
1019
                //((System.Windows.Controls.TextBox)sender).Text;
1020
1021
                if (RadTab.SelectedIndex == 0)
1022
                {
1023
                    //string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
1024
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
1025
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
1026
                    Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
1027
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
1028
                }
1029
                else
1030
                {
1031
                    //string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
1032
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
1033
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
1034
                    Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
1035
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
1036
                }
1037
                
1038
            }
1039 ffcc8124 ljiyeon
        }
1040 8e5a4a6a taeseongkim
        
1041 787a4489 KangIngu
    }
1042
}
클립보드 이미지 추가 (최대 크기: 500 MB)