프로젝트

일반

사용자정보

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

markus / KCOM / MainWindow.xaml.cs @ 3933072f

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

1
using KCOM.Common;
2
using KCOMDataModel;
3
using KCOMDataModel.DataModel;
4
using System;
5
using System.Collections.Generic;
6
using System.IO;
7
using System.Linq;
8
using System.Runtime.InteropServices;
9
using System.Text;
10
using System.Windows;
11
using System.Windows.Controls;
12
using System.Windows.Data;
13
using System.Windows.Documents;
14
using System.Windows.Input;
15
using System.Windows.Media;
16
using System.Windows.Media.Imaging;
17
using System.Windows.Navigation;
18
using System.Windows.Shapes;
19
using System.Xml;
20
using Telerik.Windows.Controls;
21

    
22
namespace KCOM
23
{
24
    /// <summary>
25
    /// MainWindow.xaml에 대한 상호 작용 논리
26
    /// </summary>
27
    public partial class MainWindow : Window
28
    {
29
        
30
        public MainWindow()
31
        {
32
            //InitializeComponent();
33
            this.Loaded += MainWindow_Loaded;
34
            this.KeyDown += new KeyEventHandler(KeyEventDownAction);
35
            this.KeyUp += new KeyEventHandler(KeyEventUpAction);
36
        }
37

    
38
        public static BitmapImage CursorChange()
39
        {
40
            BitmapImage bmp = new BitmapImage();
41
            bmp.BeginInit();
42
            bmp.StreamSource = System.Windows.Application.GetResourceStream(new Uri("/KCOM;Component/Resources/Cursor/customCursor2.cur", UriKind.Relative)).Stream;
43
            return bmp;
44
        }
45

    
46
        public void DialogMessage_Alert(string content, string header)
47
        {
48
            var box = new TextBlock();
49
            box.MinWidth = 400;
50
            box.FontSize = 12;
51
            box.Text = content;
52
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
53

    
54
            Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters()
55
            {
56
                Content = box,
57
                Header = header,
58
                Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(),
59
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
60
            };
61
            Telerik.Windows.Controls.RadWindow.Alert(parameters);
62
        }
63
                
64
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
65
        {
66
            InitializeComponent();
67

    
68
            //cursor change  
69
            this.Cursor = new Cursor(CursorChange().StreamSource);
70

    
71
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
72
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
73
            //this.Width += 40;
74
            double windowWidth = this.Width;
75
            double windowHeight = this.Height;
76
            this.Left = (screenWidth / 2) - (windowWidth / 2);
77
            this.Top = (screenHeight / 2) - (windowHeight / 2);
78

    
79

    
80
            ViewerDataModel.Instance.SystemMain = this;
81

    
82
            if (!App.ParameterMode)
83
            {
84
                //App.ViewInfo = new IKCOM.ViewInfo
85
                //{
86
                //    DocumentItemID = "11111112",
87
                //    //DocumentItemID = "10001",
88
                //    bPartner = false,
89
                //    CreateFinalPDFPermission = true,
90
                //    NewCommentPermission = true,
91
                //    ProjectNO = "000000",
92
                //    UserID = "H2011357",
93
                //    //UserID = "H2009115",
94
                //    //Mode = 0 , 1 , 2
95
                //};
96
                //DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
97

    
98
//#if DEBUG
99
//                App.ViewInfo = new IKCOM.ViewInfo
100
//                {
101
//                    DocumentItemID = "11111112",
102
//                    //DocumentItemID = "10001",
103
//                    bPartner = false,
104
//                    CreateFinalPDFPermission = true,
105
//                    NewCommentPermission = true,
106
//                    ProjectNO = "000000",
107
//                    UserID = "H2011357",
108
//                    //UserID = "H2009115",
109
//                    //Mode = 0 , 1 , 2
110
//                };
111
//                App.ParameterMode = true;
112
//                this.dzMainMenu.ServiceOn();
113
//                this.dzMainMenu.SetView(App.ViewInfo);
114
//#else
115

    
116
                DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
117
                this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed;
118
                this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed;
119
                this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed;
120
                this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed;
121
                this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed;
122
//#endif
123
            }
124
            else
125
            {
126
                this.dzMainMenu.ServiceOn();
127

    
128
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
129
                {
130
                    this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed;
131
                    var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList();
132
                    list.ForEach(item => item.Visibility = Visibility.Collapsed);
133
                    this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible;
134
                    this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly;
135
                    //this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed;
136
                    //this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed;
137
                    //this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false;
138
                }
139
                this.dzMainMenu.SetView(App.ViewInfo);
140
                this.dzMainMenu.HubSet();              
141
            }
142

    
143
            //App.ViewInfo = new IKCOM.ViewInfo
144
            //{
145
            //    DocumentItemID = "11111112",
146
            //    //DocumentItemID = "10001",
147
            //    bPartner = false,
148
            //    CreateFinalPDFPermission = true,
149
            //    NewCommentPermission = true,
150
            //    ProjectNO = "000000",
151
            //    UserID = "H2011357",
152
            //    //UserID = "H2009115",
153
            //    //Mode = 0 , 1 , 2
154
            //};
155

    
156
            //this.dzMainMenu.ServiceOn();
157
            //this.dzMainMenu.SetView(App.ViewInfo);
158
        }
159

    
160

    
161
        bool restoreIfMove = false;        
162

    
163
        private void WindowDragEvent(object sender, MouseButtonEventArgs e)
164
        {
165
            if (e.ClickCount == 2)
166
            {
167
                if ((ResizeMode == ResizeMode.CanResize) ||
168
                    (ResizeMode == ResizeMode.CanResizeWithGrip))
169
                {
170
                    SwitchState();
171
                }
172
            }
173
            else
174
            {
175
                if (WindowState == WindowState.Maximized)
176
                {
177
                    restoreIfMove = true;
178
                }
179

    
180
                this.DragMove();
181
            }
182
        }
183

    
184
        private void WindowDragEventUp(object sender, MouseButtonEventArgs e)
185
        {
186
            restoreIfMove = false;
187
        }
188

    
189
        private void WindowDragEventMove(object sender, MouseEventArgs e)
190
        {
191
            if (restoreIfMove)
192
            {
193
                if (Mouse.LeftButton == MouseButtonState.Pressed)
194
                {
195
                    //this.WindowState = WindowState.Normal;
196

    
197
                    restoreIfMove = false;
198

    
199
                    double percentHorizontal = e.GetPosition(this).X / ActualWidth;
200
                    double targetHorizontal = RestoreBounds.Width * percentHorizontal;
201

    
202
                    double percentVertical = e.GetPosition(this).Y / ActualHeight;
203
                    double targetVertical = RestoreBounds.Height * percentVertical;
204

    
205
                    POINT lMousePosition;
206
                    GetCursorPos(out lMousePosition);                    
207

    
208
                    Left = lMousePosition.X - targetHorizontal;
209
                    Top = lMousePosition.Y - targetVertical;
210

    
211

    
212
                    WindowState = WindowState.Normal;
213

    
214
                    this.DragMove();
215
                }
216
            }
217
        }
218

    
219
        [DllImport("user32.dll")]
220
        [return: MarshalAs(UnmanagedType.Bool)]
221
        static extern bool GetCursorPos(out POINT lpPoint);
222

    
223
        [StructLayout(LayoutKind.Sequential)]
224
        public struct POINT
225
        {
226
            public int X;
227
            public int Y;
228

    
229
            public POINT(int x, int y)
230
            {
231
                this.X = x;
232
                this.Y = y;
233
            }
234
        }
235

    
236
        private void SwitchState()
237
        {
238
            switch (WindowState)
239
            {
240
                case WindowState.Normal:
241
                    {
242
                        WindowState = WindowState.Maximized;
243
                        break;
244
                    }
245
                case WindowState.Maximized:
246
                    {
247
                        WindowState = WindowState.Normal;
248
                        break;
249
                    }
250
            }
251
        }
252

    
253
        private void RadButton_Click(object sender, RoutedEventArgs e)
254
        {
255
            Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton;
256

    
257
            switch (button.CommandParameter.ToString())
258
            {
259
                case ("Min"):
260
                    {
261
                        WindowState = WindowState.Minimized;
262
                    }
263
                    break;
264
                case ("Max"):
265
                    {
266
                        WindowState = WindowState.Maximized;
267
                    }
268
                    break;
269
                case ("Exit"):
270
                    {
271

    
272
                    }
273
                    break;
274
            }
275
        }
276

    
277
        private void WinState(object sender, MouseButtonEventArgs e)
278
        {
279
            switch ((e.Source as Image).Name)
280
            {
281
                case ("Win_min"):
282
                    {
283
                        WindowState = WindowState.Minimized;
284
                    }
285
                    break;
286
                case ("Win_max"):
287
                    {
288
                        if (WindowState == WindowState.Maximized)
289
                        {
290
                            WindowState = WindowState.Normal;
291
                        }
292
                        else
293
                        {
294
                            WindowState = WindowState.Maximized;
295
                        }
296
                    }
297
                    break;
298
                case ("Win_Close"):
299
                    {
300
                        if (ViewerDataModel.Instance.UndoDataList.Count > 0)
301
                        {
302
                            DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
303
                            DateTime updatetime = DateTime.Now.AddDays(-1);
304
                            if (ViewerDataModel.Instance._markupInfoList.Count > 0)
305
                            {
306
                                updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
307
                            }
308

    
309
                            if (undoTime > updatetime)
310
                            {
311
                                var box = new TextBlock();
312
                                box.MinWidth = 400;
313
                                box.FontSize = 11;
314
                                box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?";
315
                                box.TextWrapping = System.Windows.TextWrapping.Wrap;
316

    
317
                                DialogParameters parameters = new DialogParameters()
318
                                {
319
                                    Content = box,
320
                                    Header = "Confirm",
321
                                    Theme = new VisualStudio2013Theme(),
322
                                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
323
                                    Closed = Onclose,
324
                                };
325
                                RadWindow.Confirm(parameters);
326
                            }
327
                        }
328
                        this.Close();
329
                    }
330
                    break;
331
            }
332
        }
333

    
334
        private void Onclose(object sender, WindowClosedEventArgs e)
335
        {
336
            if (e.DialogResult == true)
337
            {
338
                dzTopMenu.SaveEvent(null, null);
339
            }
340
        }
341
    }
342
}
클립보드 이미지 추가 (최대 크기: 500 MB)