프로젝트

일반

사용자정보

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

markus / KCOM / Messenger / ConversationView.xaml.cs @ e0cfc73c

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

1
using KCOM.Common;
2
using KCOM.Views;
3
using System;
4
using System.Collections.Generic;
5
using System.ComponentModel;
6
using System.Diagnostics;
7
using System.Linq;
8
using System.Text;
9
using System.Windows;
10
using System.Windows.Controls;
11
using System.Windows.Data;
12
using System.Windows.Documents;
13
using System.Windows.Input;
14
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16
using System.Windows.Navigation;
17
using System.Windows.Shapes;
18
using Telerik.Windows.Controls;
19
namespace KCOM.Messenger
20
{
21
    /// <summary>
22
    /// Interaction logic for ConversationView.xaml
23
    /// </summary>
24
    public partial class ConversationView : UserControl, INotifyPropertyChanged
25
    {
26
        public Telerik.Windows.Controls.DelegateCommand ClickAnchorCommand { get; set; }
27
        MainWindow main;
28

    
29
        public ConversationView()
30
        {
31
            App.splashString(ISplashMessage.CONVERSATIONVIEW);
32
            InitializeComponent();
33
            this.DataContext = this;
34
            
35
            this.Loaded += ConversationView_Loaded;
36
            btnMark.MouseLeftButtonDown += BtnMark_Click;
37
            btnMail.MouseLeftButtonDown += BtnMail_Click;
38
            btnFile.MouseLeftButtonDown += BtnFile_Click;
39
            //강인구 추가
40
            btnSend.PreviewMouseLeftButtonDown += BtnSend_Click;
41
        }
42

    
43
        private void BtnMark_Click(object sender, RoutedEventArgs e)
44
        {
45
            if (main.dzMainMenu.SelectLayer.Children.Count > 0)
46
            {
47
                DialogParameters parameters = new DialogParameters()
48
                {
49
                    Owner = Application.Current.MainWindow,
50
                    Closed = (obj, args) => this.MarkupNameUpdatePromptClose(args),
51
                    Content = "메모 :",
52
                    Header = "앵커에 대한 메모을 남겨주세요",
53
                    Theme = new VisualStudio2013Theme(),
54
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
55
                };
56
                RadWindow.Prompt(parameters);
57

    
58

    
59
            }
60
            else
61
            {
62
                MessageBox.Show("먼저 코멘트를 선택해주세요", "안내");
63
            }
64
        }
65

    
66
        private void BtnFile_Click(object sender, RoutedEventArgs e)
67
        {
68
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
69
        }
70

    
71
        private void BtnMail_Click(object sender, RoutedEventArgs e)
72
        {
73
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
74
        }
75

    
76
        //강인구 추가
77
        private void BtnSend_Click(object sender, MouseButtonEventArgs e)
78
        {
79
            AddText();
80
        }
81

    
82
        private void MarkupNameUpdatePromptClose(WindowClosedEventArgs args)
83
        {
84
            if (args.DialogResult.Value)
85
            {
86
                if (String.IsNullOrWhiteSpace(args.PromptResult) || args.PromptResult == null)
87
                {
88
                    MessageBox.Show("공백으로 입력하시면 등록이 불가능합니다", "안내");
89
                }
90
                else
91
                {
92
                    Controls.AdornerFinal finalItem = main.dzMainMenu.SelectLayer.Children[0] as Controls.AdornerFinal;
93
                    Rect rect = new Rect(new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100), new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100));
94

    
95
                    var instanceMain = this.ParentOfType<MainWindow>();
96
                    if (instanceMain.dzMainMenu.rotate.Angle == 90)
97
                    {
98
                        rect = new Rect(new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100), new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100));
99
                        double y = rect.Y;
100
                        double x = rect.X;
101
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
102
                        rect.Y = y;
103
                    }
104
                    else if (instanceMain.dzMainMenu.rotate.Angle == 180)
105
                    {
106
                        rect = new Rect(new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100), new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100));
107
                        double y = rect.Y;
108
                        double x = rect.X;
109
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
110
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
111
                    }
112
                    else if (instanceMain.dzMainMenu.rotate.Angle == 270)
113
                    {
114
                        rect = new Rect(new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100), new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100));
115
                        double y = rect.Y;
116
                        double x = rect.X;
117
                        rect.X = x;
118
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
119
                    }
120

    
121
                    // Load 시 페이지 이동 없이 TALK 작성 시 Page값이 0으로 들어감, TALK TABLE에 PAGENUMBER가 0일 경우 Angle이 적용되지 않음.                 
122
                    if (Common.ViewerDataModel.Instance.PageNumber == 0)
123
                    {
124
                        Common.ViewerDataModel.Instance.PageNumber = 1;
125
                    }
126
                    //Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
127
                    KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
128
                    {
129
                        TEXT = args.PromptResult,
130
                        MSGSIDE = (int)MessageSide.Me,
131
                        MEMBER_ID = App.ViewInfo.UserID,
132
                        MEMBER_NAME = App.UserName,
133
                        MSGTYPE = (int)MessageType.Anchor,
134
                        TIMESTAMP = DateTime.Now,
135
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
136
                        RECT_X = rect.X,
137
                        RECT_Y = rect.Y,
138
                        RECT_WIDTH = rect.Width,
139
                        RECT_HEIGHT = rect.Height,
140
                        PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber,
141
                        ANGLE = (int)instanceMain.dzMainMenu.rotate.Angle
142
                    };
143

    
144
                    Logger.sendReqLog("AddMessage: ", App.ViewInfo.ProjectNO + "," + message, 1);
145
                    Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);
146
                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
147

    
148
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
149
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
150
                    if (messagelist.Count() > 0)
151
                    {
152
                        Logger.sendResLog("GetMessage", "TRUE", 1);
153
                    }
154
                    else
155
                    {
156
                        Logger.sendResLog("GetMessage", "FALSE", 1);
157
                    }
158
                    messagelist.ForEach(a =>
159
                    {
160
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
161
                    });
162

    
163
                    tbContent.Text = "";
164
                    tbContent.Focus();
165
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
166
                }
167
            }
168
        }
169

    
170
        protected virtual void OnPropertyChanged(String info)
171
        {
172
            if (PropertyChanged != null)
173
                PropertyChanged(this, new PropertyChangedEventArgs(info));
174
        }
175

    
176
        private void SaveAuthorization(object parameter)
177
        {
178
            KCOMDataModel.DataModel.TALK instance = parameter as KCOMDataModel.DataModel.TALK;
179
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = instance.ANGLE;
180
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPageTALK(instance.PAGENUMBER.Value, instance.ANGLE);
181
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomToTalk(new Rect { X = instance.RECT_X.Value, Y = instance.RECT_Y.Value, Width = instance.RECT_WIDTH.Value, Height = instance.RECT_HEIGHT.Value }, instance.ANGLE);
182
        }
183

    
184
        public event PropertyChangedEventHandler PropertyChanged;
185

    
186
        private void ConversationView_Loaded(object sender, RoutedEventArgs e)
187
        {
188
            //측정
189
            //Stopwatch sw = new Stopwatch();
190
            //sw.Start();
191
            //InitializeComponent();
192
            //System.Diagnostics.Debug.WriteLine("ConversationView() : " + sw.ElapsedMilliseconds.ToString() + "ms");
193

    
194
            main = this.ParentOfType<MainWindow>();
195
            if (App.ParameterMode)
196
            {
197
                ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
198
                if (string.IsNullOrEmpty(App.UserName))
199
                {
200
                    Logger.sendReqLog("GetMember: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID, 1);
201
                    App.UserName = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID).NAME;
202
                    if (App.UserName != null || App.UserName != "")
203
                    {
204
                        Logger.sendResLog("AddMessage", "TRUE", 1);
205
                    }
206
                    else
207
                    {
208
                        Logger.sendResLog("AddMessage", "FALSE", 1);
209
                    }
210
                }
211
                if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
212
                {
213
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
214
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
215
                    if (messagelist.Count() > 0)
216
                    {
217
                        Logger.sendResLog("GetMessage", "TRUE", 1);
218
                    }
219
                    else
220
                    {
221
                        Logger.sendResLog("GetMessage", "FALSE", 1);
222
                    }
223
                    messagelist.ForEach(a =>
224
                    {
225
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
226
                    });
227
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
228
                }
229
                tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea);
230

    
231
            }
232
        }
233

    
234
        private async System.Threading.Tasks.Task OnKeyDownHandler(object sender, KeyEventArgs e)
235
        {
236

    
237
            if (e.Key == Key.Return)
238
            {
239
                if (Keyboard.Modifiers != ModifierKeys.Shift)
240
                {
241
                    AddText();
242
                    e.Handled = true;
243
                }
244
                else
245
                {
246
                    tbContent.Text = tbContent.Text + Environment.NewLine;
247
                    tbContent.CaretIndex = tbContent.Text.Length;
248
                    e.Handled = true;
249
                }
250
            }
251
        }
252

    
253
        private void AddText()
254
        {
255
            Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
256

    
257
            KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
258
            {
259
                TEXT = tbContent.Text,
260
                MSGSIDE = (int)MessageSide.Me,
261
                MEMBER_ID = App.ViewInfo.UserID,
262
                MEMBER_NAME = App.UserName,
263
                MSGTYPE = (int)MessageType.Normal,
264
                TIMESTAMP = DateTime.Now,
265
                DOCUMENT_ID = App.ViewInfo.DocumentItemID
266
            };
267

    
268
            Logger.sendReqLog("AddMessage", App.ViewInfo.ProjectNO + "," + message, 1);
269
            Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);
270
            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
271

    
272
            Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
273
            List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
274
            if (messagelist.Count() > 0)
275
            {
276
                Logger.sendResLog("GetMessage", "TRUE", 1);
277
            }
278
            else
279
            {
280
                Logger.sendResLog("GetMessage", "FALSE", 1);
281
            }
282

    
283
            messagelist.ForEach(a =>
284
            {
285
                Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
286
            });
287
            tbContent.Text = "";
288
            tbContent.Focus();
289
            (lstMessage.Parent as ScrollViewer).ScrollToEnd();
290

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