프로젝트

일반

사용자정보

개정판 5ce56a3a

ID5ce56a3a08509844f0bed03301750089806d570e
상위 a0bab669
하위 d4b0c723

KangIngu 이(가) 약 7년 전에 추가함

Symbol 기능 추가 및 Entity 테이블 추가
상단 네비게이션 View데이터 Comment로 통합

차이점 보기:

KCOM/Controls/Symbol.xaml.cs
1 1
using KCOM.Common;
2 2
using KCOM.Events;
3
using KCOMDataModel.Common;
4
using KCOMDataModel.DataModel;
3 5
using System;
4 6
using System.Collections.Generic;
5 7
using System.Linq;
......
14 16
using System.Windows.Navigation;
15 17
using System.Windows.Shapes;
16 18
using Telerik.Windows.Controls;
19
using Telerik.Windows.Controls.DragDrop;
17 20

  
18 21
namespace KCOM.Controls
19 22
{
20 23
    public class Symbol_Custom
21 24
    {
25
        public string ID { get; set; }
22 26
        public string Name { get; set; }
23 27
        public string ImageUri { get; set; }
24 28
    }
......
29 33
    public partial class Symbol : UserControl
30 34
    {
31 35
        AdornerFinal finalItem;
36
        bool IsMouseDown = false;
37
        string moveItem_id = "";
32 38
        public string filename { get; set; }
33 39
        MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
34 40

  
35 41
        public Symbol()
36 42
        {
37 43
            InitializeComponent();
44
            
45
            RadDragAndDropManager.AddDragInfoHandler(lstSymbolPrivate, OnDragPrivateInfo);
46
            RadDragAndDropManager.AddDragQueryHandler(lstSymbolPrivate, OnDragPrivateQuery);
47
            RadDragAndDropManager.SetAllowDrag(lstSymbolPrivate, true);
38 48

  
39 49
            DataBind();
40 50
        }
41 51

  
52
        private void OnDragPrivateInfo(object sender, DragDropEventArgs e)
53
        {
54
        }
55

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

  
66
                //e.Options.Payload = im;
67
                //var dragCue = new Image();
68
                //dragCue.Source = img.Source;
69
                //dragCue.Width = 0;
70
                //dragCue.Height = 0;
71
                //e.Options.DragCue = dragCue;
72

  
73

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

  
82
            e.QueryResult = true;
83
            e.Handled = true;
84
        }
85

  
42 86
        private void DataBind()
43 87
        {
44
            lstSymbolPrivate.ItemsSource = null;
88
            //lstSymbolPrivate.ItemsSource = null;
89
            //lstSymbolPublic.ItemsSource = null;
45 90

  
46 91
            Symbol_Custom Custom = new Symbol_Custom();
47 92
            List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
48
            Custom.Name = "테스트";
49
            Custom.ImageUri = "http://cloud.devdoftech.co.kr:5977/UserData/000000/H2009115/JsInNjZNgC8d59543c6854eb4.png";
50 93

  
51
            Custom_List.Add(Custom);
52
            Custom_List.Add(Custom);
94
            using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
95
            {
96
                var symbol_Private = Entity.SYMBOL_PRIVATE.Where(data => data.MEMBER_USER_ID == App.ViewInfo.UserID).ToList();
97
                foreach(var item in symbol_Private)
98
                {
99
                    Custom.Name = item.NAME;
100
                    Custom.ImageUri = item.IMAGE_URL;
101
                    Custom.ID = item.ID;
102
                    Custom_List.Add(Custom);
103
                    Custom = new Symbol_Custom();
104
                }
105
                lstSymbolPrivate.ItemsSource = Custom_List;
106

  
107
                Custom = new Symbol_Custom();
108
                Custom_List = new List<Symbol_Custom>();
109

  
110
                deptlist.ItemsSource = Entity.SYMBOL_PUBLIC.Select(data => data.DEPARTMENT).ToList();
111

  
112
                var symbol_Public = Entity.SYMBOL_PUBLIC.ToList();
113

  
114
                if (deptlist.SelectedValue != null)
115
                {
116
                    symbol_Public = symbol_Public.Where(data => data.DEPARTMENT == deptlist.SelectedValue.ToString()).ToList();
117
                }
118
                //var symbol_Public = Entity.SYMBOL_PUBLIC.Where(data => data.DEPARTMENT == "PIPING").ToList();
119

  
120
                foreach (var item in symbol_Public)
121
                {
122
                    Custom.Name = item.NAME;
123
                    Custom.ImageUri = item.IMAGE_URL;
124
                    Custom.ID = item.ID;
125
                    Custom_List.Add(Custom);
126
                    Custom = new Symbol_Custom();
127
                }
128
                lstSymbolPublic.ItemsSource = Custom_List;
129
            }
130
        }
131

  
132
        public PngBitmapEncoder symImage(string data)
133
        {
134

  
135
            Canvas _canvas = new Canvas();
136
            _canvas.Background = Brushes.White;
137
            _canvas.Width = finalItem.BorderSize.Width;
138
            _canvas.Height = finalItem.BorderSize.Height;
139
            layer.markupParse(data, _canvas, "#FFFF0000", "");
140

  
141
            BitmapEncoder encoder = new PngBitmapEncoder();
142

  
143

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

  
146
            DrawingVisual dv = new DrawingVisual();
147

  
148
            _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50));
149
            //_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)));
150
            _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)));
151

  
152
            using (DrawingContext ctx = dv.RenderOpen())
153
            {
154
                VisualBrush vb = new VisualBrush(_canvas);
155
                //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)));
156
                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)));
157
            }
158

  
159
            try
160
            {
161
                renderBitmap.Render(dv);
162

  
163
                GC.Collect();
164
                GC.WaitForPendingFinalizers();
165
                GC.Collect();
166
                //bitmap.Render(controlToConvert);
167
                // encode png data
168
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
169
                // puch rendered bitmap into it
170
                pngEncoder.Interlace = PngInterlaceOption.Off;
171
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
172
                return pngEncoder;
173

  
174
            }
175
            catch (Exception ex)
176
            {
177
                return null;
178
            }
53 179

  
54
            lstSymbolPrivate.ItemsSource = Custom_List;
55 180
        }
56 181

  
182
        public void DialogMessage_Alert(string content, string header)
183
        {
184
            var box = new TextBlock();
185
            box.MinWidth = 400;
186
            box.FontSize = 11;
187
            //box.FontSize = 12;
188
            box.Text = content;
189
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
190

  
191
            DialogParameters parameters = new DialogParameters()
192
            {
193
                Content = box,
194
                Header = header,
195
                Theme = new VisualStudio2013Theme(),
196
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
197
            };
198
            RadWindow.Alert(parameters);
199
        }
200

  
201
        #region Event
202

  
203
        #region Symbol Add Event
57 204
        private void Create_Symbol(object sender, RoutedEventArgs e)
58 205
        {
59 206
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
......
95 242
            }
96 243

  
97 244
        }
245
        #endregion
98 246

  
247
        #region Symbol Add Close Event 
99 248
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
100 249
        {
101 250
            Save save = new Save();
......
114 263
                filename = fileUploader.Run(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Save.shortGuid() + ".png", Img_byte);
115 264

  
116 265
                save.SymbolSave(args.PromptResult, filename, data);
266

  
267
                DataBind();
117 268
            }
118 269
        }
270
        #endregion
119 271

  
120
        public PngBitmapEncoder symImage(string data)
272
        #region Symbol Delete Event
273
        private void Remove_Symbol(object sender, RoutedEventArgs e)
121 274
        {
275
            if (lstSymbolPrivate.SelectedItem == null)
276
            {
277
                DialogMessage_Alert("Please Select Symbol", "Alert");
278
                return;
279
            }
122 280

  
123
            Canvas _canvas = new Canvas();
124
            _canvas.Background = Brushes.White;
125
            _canvas.Width = finalItem.BorderSize.Width;
126
            _canvas.Height = finalItem.BorderSize.Height;
127
            layer.markupParse(data, _canvas, "#FFFF0000", "");
281
            using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
282
            {
283
                string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
284
                var delitem = Entity.SYMBOL_PRIVATE.Where(data => data.ID == delItem_ID).FirstOrDefault();
285
                Entity.SYMBOL_PRIVATE.DeleteObject(delitem);
286
                Entity.SaveChanges();
128 287

  
129
            BitmapEncoder encoder = new PngBitmapEncoder();
288
                DataBind();
289
            }
290
        }
291
        #endregion
130 292

  
293
        #region Symbol DoubleClick Event
294
        private void Move_Symbol(object sender, MouseButtonEventArgs e)
295
        {
296
            moveItem_id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
131 297

  
132
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
298
            IsMouseDown = true;
133 299

  
134
            DrawingVisual dv = new DrawingVisual();
300
            if (e.ClickCount > 1)
301
            {
302
                //string moveItem_id = ((e.Source as ListBox).SelectedItem as Symbol_Custom).ID;
303
                string Data_ = "";
135 304

  
136
            _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50));
137
            //_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)));
138
            _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)));
305
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
306
                {
307
                    if (RadTab.SelectedIndex == 0)
308
                        Data_ = Entity.SYMBOL_PRIVATE.Where(data => data.ID == moveItem_id).FirstOrDefault().DATA;
309
                    else
310
                        Data_ = Entity.SYMBOL_PUBLIC.Where(data => data.ID == moveItem_id).FirstOrDefault().DATA;
311
                }
139 312

  
140
            using (DrawingContext ctx = dv.RenderOpen())
313
                if (Data_.Contains("|DZ|"))
314
                {
315
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
316

  
317
                    string[] delimiterChars = { "|DZ|" };
318
                    string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
319

  
320
                    foreach (string parse in data)
321
                    {
322
                        if (parse != "")
323
                        {
324
                            System.Windows.Controls.Control item = layer.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
325
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
326

  
327
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
328
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
329

  
330
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
331
                        }
332
                    }
333
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
334

  
335
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
336
                }
337
            }
338
        }
339
        #endregion
340

  
341
        #region Symbol Rename Event
342
        private void Rename_Symbol(object sender, RoutedEventArgs e)
343
        {
344
            if (lstSymbolPrivate.SelectedItem == null)
141 345
            {
142
                VisualBrush vb = new VisualBrush(_canvas);
143
                //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)));
144
                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)));
346
                DialogMessage_Alert("Please Select Symbol", "Alert");
347
                return;
145 348
            }
146 349

  
147
            try
350
            DialogParameters parameters = new DialogParameters()
148 351
            {
149
                renderBitmap.Render(dv);
352
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
353
                //DefaultPromptResultValue = "Custom State",
354
                DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name,
355
                Content = "Name :",
356
                Header = "Update Custom Symbol Name",
357
                Theme = new VisualStudio2013Theme(),
358
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
359
            };
360
            RadWindow.Prompt(parameters);
150 361

  
151
                GC.Collect();
152
                GC.WaitForPendingFinalizers();
153
                GC.Collect();
154
                //bitmap.Render(controlToConvert);
155
                // encode png data
156
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
157
                // puch rendered bitmap into it
158
                pngEncoder.Interlace = PngInterlaceOption.Off;
159
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
160
                return pngEncoder;
362
        }
363
        #endregion
161 364

  
365
        #region Symbol Rename Close Event
366
        private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args)
367
        {
368
            if (args.DialogResult != null && args.DialogResult.Value)
369
            {
370
                using (KCOMEntities Entity = new KCOMEntities(ConnectStringBuilder.KCOMConnectionString().ToString()))
371
                {
372
                    string ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
373
                    var UpdateItem = Entity.SYMBOL_PRIVATE.Where(info => info.ID == ID).FirstOrDefault();
374

  
375
                    UpdateItem.NAME = args.PromptResult;
376
                    Entity.SaveChanges();
377
                    DataBind();
378
                    //args.PromptResult
379
                }
162 380
            }
163
            catch (Exception ex)
381
        }
382
        #endregion
383

  
384
        #region Wheel Event
385
        private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
386
        {
387
            ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2));
388
        }
389
        private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
390
        {
391
            ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2));
392
        }
393
        #endregion
394

  
395
        #region Tab Selection Event
396
        private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e)
397
        {
398
            foreach (var item in (e.OriginalSource as RadTabControl).Items)
164 399
            {
165
                return null;
400
                (item as RadTabItem).FontWeight = FontWeights.Normal;
166 401
            }
402
            ((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold;
403
        }
404
        #endregion
167 405

  
406
        #region Department Selection Event
407
        private void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
408
        {
409
            DataBind();
168 410
        }
411
        #endregion
169 412

  
413
        #endregion
170 414

  
171
        public void DialogMessage_Alert(string content, string header)
415
        private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
416
        {
417

  
418
        }
419

  
420
        private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e)
421
        {
422

  
423
        }
424

  
425
        private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e)
172 426
        {
173
            var box = new TextBlock();
174
            box.MinWidth = 400;
175
            box.FontSize = 11;
176
            //box.FontSize = 12;
177
            box.Text = content;
178
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
179 427

  
180
            DialogParameters parameters = new DialogParameters()
181
            {
182
                Content = box,
183
                Header = header,
184
                Theme = new VisualStudio2013Theme(),
185
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
186
            };
187
            RadWindow.Alert(parameters);
188 428
        }
189 429

  
190
        private void lsySymbolPrivate_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
430
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
191 431
        {
432
            if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed)
433
            {
434
                ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id;
435
            }
436
            else
437
            {
438
                IsMouseDown = false;
439
            }
440
        }
192 441

  
442
        private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
443
        {
444
            IsMouseDown = false;
193 445
        }
194 446
    }
195 447
}

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)