프로젝트

일반

사용자정보

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

markus / KCOM / Messenger / ConversationView.xaml.cs @ 3b62305d

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

1 e0cfc73c ljiyeon
using KCOM.Common;
2
using KCOM.Views;
3 787a4489 KangIngu
using System;
4
using System.Collections.Generic;
5
using System.ComponentModel;
6 0c997b99 ljiyeon
using System.Diagnostics;
7 787a4489 KangIngu
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 e0cfc73c ljiyeon
            App.splashString(ISplashMessage.CONVERSATIONVIEW);
32 fd4e6a36 djkim
            InitializeComponent();
33 787a4489 KangIngu
            this.DataContext = this;
34 e0cfc73c ljiyeon
            
35 787a4489 KangIngu
            this.Loaded += ConversationView_Loaded;
36 fd4e6a36 djkim
            btnMark.MouseLeftButtonDown += BtnMark_Click;
37
            btnMail.MouseLeftButtonDown += BtnMail_Click;
38
            btnFile.MouseLeftButtonDown += BtnFile_Click;
39
            //강인구 추가
40
            btnSend.PreviewMouseLeftButtonDown += BtnSend_Click;
41 787a4489 KangIngu
        }
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 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
50 787a4489 KangIngu
                    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 d974f3f8 ljiyeon
95
                    var instanceMain = this.ParentOfType<MainWindow>();
96
                    if (instanceMain.dzMainMenu.rotate.Angle == 90)
97
                    {
98 29010418 ljiyeon
                        rect = new Rect(new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100), new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100));
99 d974f3f8 ljiyeon
                        double y = rect.Y;
100 29010418 ljiyeon
                        double x = rect.X;
101 d974f3f8 ljiyeon
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
102
                        rect.Y = y;
103
                    }
104 29010418 ljiyeon
                    else if (instanceMain.dzMainMenu.rotate.Angle == 180)
105 d974f3f8 ljiyeon
                    {
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 29010418 ljiyeon
                    else if (instanceMain.dzMainMenu.rotate.Angle == 270)
113 d974f3f8 ljiyeon
                    {
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 29010418 ljiyeon
                    if (Common.ViewerDataModel.Instance.PageNumber == 0)
123 d974f3f8 ljiyeon
                    {
124
                        Common.ViewerDataModel.Instance.PageNumber = 1;
125
                    }
126 90e7968d ljiyeon
                    //Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
127 c460df05 djkim
                    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 d974f3f8 ljiyeon
                        PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber,
141
                        ANGLE = (int)instanceMain.dzMainMenu.rotate.Angle
142 c460df05 djkim
                    };
143
144 0f065e57 ljiyeon
                    Logger.sendReqLog("AddMessage: ", App.ViewInfo.ProjectNO + "," + message, 1);
145 29010418 ljiyeon
                    Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);
146 0f065e57 ljiyeon
                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
147 c460df05 djkim
148 29010418 ljiyeon
                    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 0f065e57 ljiyeon
                    {
152
                        Logger.sendResLog("GetMessage", "TRUE", 1);
153
                    }
154
                    else
155
                    {
156
                        Logger.sendResLog("GetMessage", "FALSE", 1);
157
                    }
158 c460df05 djkim
                    messagelist.ForEach(a =>
159 787a4489 KangIngu
                    {
160 c460df05 djkim
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
161
                    });
162 787a4489 KangIngu
163
                    tbContent.Text = "";
164
                    tbContent.Focus();
165 c460df05 djkim
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
166 787a4489 KangIngu
                }
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 29010418 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = instance.ANGLE;
180 d974f3f8 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPageTALK(instance.PAGENUMBER.Value, instance.ANGLE);
181 29010418 ljiyeon
            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 787a4489 KangIngu
        }
183
184
        public event PropertyChangedEventHandler PropertyChanged;
185
186
        private void ConversationView_Loaded(object sender, RoutedEventArgs e)
187
        {
188 0c997b99 ljiyeon
            //측정
189
            //Stopwatch sw = new Stopwatch();
190
            //sw.Start();
191 fd4e6a36 djkim
            //InitializeComponent();
192 0c997b99 ljiyeon
            //System.Diagnostics.Debug.WriteLine("ConversationView() : " + sw.ElapsedMilliseconds.ToString() + "ms");
193 29010418 ljiyeon
194 787a4489 KangIngu
            main = this.ParentOfType<MainWindow>();
195
            if (App.ParameterMode)
196
            {
197
                ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
198 c460df05 djkim
                if (string.IsNullOrEmpty(App.UserName))
199
                {
200 29010418 ljiyeon
                    Logger.sendReqLog("GetMember: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID, 1);
201 c460df05 djkim
                    App.UserName = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID).NAME;
202 29010418 ljiyeon
                    if (App.UserName != null || App.UserName != "")
203 0f065e57 ljiyeon
                    {
204
                        Logger.sendResLog("AddMessage", "TRUE", 1);
205
                    }
206
                    else
207
                    {
208
                        Logger.sendResLog("AddMessage", "FALSE", 1);
209 29010418 ljiyeon
                    }
210 c460df05 djkim
                }
211 787a4489 KangIngu
                if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
212
                {
213 0f065e57 ljiyeon
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
214 c460df05 djkim
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
215 0f065e57 ljiyeon
                    if (messagelist.Count() > 0)
216
                    {
217
                        Logger.sendResLog("GetMessage", "TRUE", 1);
218
                    }
219
                    else
220
                    {
221
                        Logger.sendResLog("GetMessage", "FALSE", 1);
222
                    }
223 c460df05 djkim
                    messagelist.ForEach(a =>
224 787a4489 KangIngu
                    {
225 c460df05 djkim
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
226
                    });
227
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
228 787a4489 KangIngu
                }
229
                tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea);
230 c460df05 djkim
231 787a4489 KangIngu
            }
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 c460df05 djkim
            Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
256 29010418 ljiyeon
257 c460df05 djkim
            KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
258 787a4489 KangIngu
            {
259 c460df05 djkim
                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 787a4489 KangIngu
268 0f065e57 ljiyeon
            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 787a4489 KangIngu
272 0f065e57 ljiyeon
            Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
273 29010418 ljiyeon
            List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
274 0f065e57 ljiyeon
            if (messagelist.Count() > 0)
275
            {
276
                Logger.sendResLog("GetMessage", "TRUE", 1);
277
            }
278
            else
279
            {
280
                Logger.sendResLog("GetMessage", "FALSE", 1);
281
            }
282 787a4489 KangIngu
283 c460df05 djkim
            messagelist.ForEach(a =>
284
            {
285
                Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
286
            });
287
            tbContent.Text = "";
288 29010418 ljiyeon
            tbContent.Focus();
289 c460df05 djkim
            (lstMessage.Parent as ScrollViewer).ScrollToEnd();
290 29010418 ljiyeon
291 787a4489 KangIngu
        }
292
    }
293
}
클립보드 이미지 추가 (최대 크기: 500 MB)