프로젝트

일반

사용자정보

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

markus / KCOM / Messenger / ConversationView.xaml.cs @ 40b3ce25

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

1 787a4489 KangIngu
using KCOM.Views;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5 0c997b99 ljiyeon
using System.Diagnostics;
6 787a4489 KangIngu
using System.Linq;
7
using System.Text;
8
using System.Windows;
9
using System.Windows.Controls;
10
using System.Windows.Data;
11
using System.Windows.Documents;
12
using System.Windows.Input;
13
using System.Windows.Media;
14
using System.Windows.Media.Imaging;
15
using System.Windows.Navigation;
16
using System.Windows.Shapes;
17
using Telerik.Windows.Controls;
18
namespace KCOM.Messenger
19
{
20
    /// <summary>
21
    /// Interaction logic for ConversationView.xaml
22
    /// </summary>
23
    public partial class ConversationView : UserControl, INotifyPropertyChanged
24
    {
25
        public Telerik.Windows.Controls.DelegateCommand ClickAnchorCommand { get; set; }
26
        MainWindow main;
27
28
        public ConversationView()
29
        {
30 fd4e6a36 djkim
            InitializeComponent();
31 0c997b99 ljiyeon
            
32 787a4489 KangIngu
            this.DataContext = this;
33
            this.Loaded += ConversationView_Loaded;
34 fd4e6a36 djkim
            btnMark.MouseLeftButtonDown += BtnMark_Click;
35
            btnMail.MouseLeftButtonDown += BtnMail_Click;
36
            btnFile.MouseLeftButtonDown += BtnFile_Click;
37
            //강인구 추가
38
            btnSend.PreviewMouseLeftButtonDown += BtnSend_Click;
39 787a4489 KangIngu
        }
40
41
        private void BtnMark_Click(object sender, RoutedEventArgs e)
42
        {
43
            if (main.dzMainMenu.SelectLayer.Children.Count > 0)
44
            {
45
                DialogParameters parameters = new DialogParameters()
46
                {
47
                    Closed = (obj, args) => this.MarkupNameUpdatePromptClose(args),
48
                    Content = "메모 :",
49
                    Header = "앵커에 대한 메모을 남겨주세요",
50
                    Theme = new VisualStudio2013Theme(),
51
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
52
                };
53
                RadWindow.Prompt(parameters);
54
55
56
            }
57
            else
58
            {
59
                MessageBox.Show("먼저 코멘트를 선택해주세요", "안내");
60
            }
61
        }
62
63
        private void BtnFile_Click(object sender, RoutedEventArgs e)
64
        {
65
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
66
        }
67
68
        private void BtnMail_Click(object sender, RoutedEventArgs e)
69
        {
70
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
71
        }
72
73
        //강인구 추가
74
        private void BtnSend_Click(object sender, MouseButtonEventArgs e)
75
        {
76
            AddText();
77
        }
78
79
        private void MarkupNameUpdatePromptClose(WindowClosedEventArgs args)
80
        {
81
            if (args.DialogResult.Value)
82
            {
83
                if (String.IsNullOrWhiteSpace(args.PromptResult) || args.PromptResult == null)
84
                {
85
                    MessageBox.Show("공백으로 입력하시면 등록이 불가능합니다", "안내");
86
                }
87
                else
88
                {
89
                    Controls.AdornerFinal finalItem = main.dzMainMenu.SelectLayer.Children[0] as Controls.AdornerFinal;
90
                    Rect rect = new Rect(new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100), new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100));
91 d974f3f8 ljiyeon
92
                    var instanceMain = this.ParentOfType<MainWindow>();
93
                    if (instanceMain.dzMainMenu.rotate.Angle == 90)
94
                    {
95
                        rect = new Rect(new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100), new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100));                         
96
                        double y = rect.Y;
97
                        double x = rect.X;     
98
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
99
                        rect.Y = y;
100
                    }
101
                    else if(instanceMain.dzMainMenu.rotate.Angle == 180)
102
                    {
103
                        rect = new Rect(new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100), new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100));
104
                        double y = rect.Y;
105
                        double x = rect.X;
106
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
107
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
108
                    }
109
                    else if(instanceMain.dzMainMenu.rotate.Angle == 270)
110
                    {
111
                        rect = new Rect(new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100), new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100));
112
                        double y = rect.Y;
113
                        double x = rect.X;
114
                        rect.X = x;
115
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
116
                    }
117
118
                    // Load 시 페이지 이동 없이 TALK 작성 시 Page값이 0으로 들어감, TALK TABLE에 PAGENUMBER가 0일 경우 Angle이 적용되지 않음.                 
119
                    if (Common.ViewerDataModel.Instance.PageNumber == 0) 
120
                    {
121
                        Common.ViewerDataModel.Instance.PageNumber = 1;
122
                    }
123
124 c460df05 djkim
                    KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
125
                    {
126
                        TEXT = args.PromptResult,
127
                        MSGSIDE = (int)MessageSide.Me,
128
                        MEMBER_ID = App.ViewInfo.UserID,
129
                        MEMBER_NAME = App.UserName,
130
                        MSGTYPE = (int)MessageType.Anchor,
131
                        TIMESTAMP = DateTime.Now,
132
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
133
                        RECT_X = rect.X,
134
                        RECT_Y = rect.Y,
135
                        RECT_WIDTH = rect.Width,
136
                        RECT_HEIGHT = rect.Height,
137 d974f3f8 ljiyeon
                        PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber,
138
                        ANGLE = (int)instanceMain.dzMainMenu.rotate.Angle
139 c460df05 djkim
                    };
140
141 0f065e57 ljiyeon
                    Logger.sendReqLog("AddMessage: ", App.ViewInfo.ProjectNO + "," + message, 1);
142
                    Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);                   
143
                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
144 c460df05 djkim
145 0f065e57 ljiyeon
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);                  
146
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);                    
147
                    if(messagelist.Count() > 0)
148
                    {
149
                        Logger.sendResLog("GetMessage", "TRUE", 1);
150
                    }
151
                    else
152
                    {
153
                        Logger.sendResLog("GetMessage", "FALSE", 1);
154
                    }
155 c460df05 djkim
                    messagelist.ForEach(a =>
156 787a4489 KangIngu
                    {
157 c460df05 djkim
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
158
                    });
159 787a4489 KangIngu
160
                    tbContent.Text = "";
161
                    tbContent.Focus();
162 c460df05 djkim
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
163 787a4489 KangIngu
                }
164
            }
165
        }
166
167
        protected virtual void OnPropertyChanged(String info)
168
        {
169
            if (PropertyChanged != null)
170
                PropertyChanged(this, new PropertyChangedEventArgs(info));
171
        }
172
173
        private void SaveAuthorization(object parameter)
174
        {
175
            KCOMDataModel.DataModel.TALK instance = parameter as KCOMDataModel.DataModel.TALK;
176 d974f3f8 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = instance.ANGLE; 
177
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPageTALK(instance.PAGENUMBER.Value, instance.ANGLE);
178
            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);
179 787a4489 KangIngu
        }
180
181
        public event PropertyChangedEventHandler PropertyChanged;
182
183
        private void ConversationView_Loaded(object sender, RoutedEventArgs e)
184
        {
185 0c997b99 ljiyeon
            //측정
186
            //Stopwatch sw = new Stopwatch();
187
            //sw.Start();
188 fd4e6a36 djkim
            //InitializeComponent();
189 0c997b99 ljiyeon
            //System.Diagnostics.Debug.WriteLine("ConversationView() : " + sw.ElapsedMilliseconds.ToString() + "ms");
190 fd4e6a36 djkim
            
191 787a4489 KangIngu
            main = this.ParentOfType<MainWindow>();
192
            if (App.ParameterMode)
193
            {
194
                ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
195 c460df05 djkim
                if (string.IsNullOrEmpty(App.UserName))
196
                {
197 0f065e57 ljiyeon
                    Logger.sendReqLog("GetMember: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID, 1);                  
198 c460df05 djkim
                    App.UserName = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID).NAME;
199 0f065e57 ljiyeon
                    if(App.UserName != null || App.UserName != "")
200
                    {
201
                        Logger.sendResLog("AddMessage", "TRUE", 1);
202
                    }
203
                    else
204
                    {
205
                        Logger.sendResLog("AddMessage", "FALSE", 1);
206
                    }                    
207 c460df05 djkim
                }
208 787a4489 KangIngu
                if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
209
                {
210 0f065e57 ljiyeon
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
211 c460df05 djkim
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
212 0f065e57 ljiyeon
                    if (messagelist.Count() > 0)
213
                    {
214
                        Logger.sendResLog("GetMessage", "TRUE", 1);
215
                    }
216
                    else
217
                    {
218
                        Logger.sendResLog("GetMessage", "FALSE", 1);
219
                    }
220 c460df05 djkim
                    messagelist.ForEach(a =>
221 787a4489 KangIngu
                    {
222 c460df05 djkim
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
223
                    });
224
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
225 787a4489 KangIngu
                }
226
                tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea);
227 c460df05 djkim
228 787a4489 KangIngu
            }
229
        }
230
231
        private async System.Threading.Tasks.Task OnKeyDownHandler(object sender, KeyEventArgs e)
232
        {
233
234
            if (e.Key == Key.Return)
235
            {
236
                if (Keyboard.Modifiers != ModifierKeys.Shift)
237
                {
238
                    AddText();
239
                    e.Handled = true;
240
                }
241
                else
242
                {
243
                    tbContent.Text = tbContent.Text + Environment.NewLine;
244
                    tbContent.CaretIndex = tbContent.Text.Length;
245
                    e.Handled = true;
246
                }
247
            }
248
        }
249
250
        private void AddText()
251
        {
252 c460df05 djkim
            Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
253
            
254
            KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
255 787a4489 KangIngu
            {
256 c460df05 djkim
                TEXT = tbContent.Text,
257
                MSGSIDE = (int)MessageSide.Me,
258
                MEMBER_ID = App.ViewInfo.UserID,
259
                MEMBER_NAME = App.UserName,
260
                MSGTYPE = (int)MessageType.Normal,
261
                TIMESTAMP = DateTime.Now,
262
                DOCUMENT_ID = App.ViewInfo.DocumentItemID
263
            };
264 787a4489 KangIngu
265 0f065e57 ljiyeon
            Logger.sendReqLog("AddMessage", App.ViewInfo.ProjectNO + "," + message, 1);
266
            Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);
267
            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
268 787a4489 KangIngu
269 0f065e57 ljiyeon
            Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
270
            List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);            
271
            if (messagelist.Count() > 0)
272
            {
273
                Logger.sendResLog("GetMessage", "TRUE", 1);
274
            }
275
            else
276
            {
277
                Logger.sendResLog("GetMessage", "FALSE", 1);
278
            }
279 787a4489 KangIngu
280 c460df05 djkim
            messagelist.ForEach(a =>
281
            {
282
                Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
283
            });
284
            tbContent.Text = "";
285
            tbContent.Focus();            
286
            (lstMessage.Parent as ScrollViewer).ScrollToEnd();
287
            
288 787a4489 KangIngu
        }
289
    }
290
}
클립보드 이미지 추가 (최대 크기: 500 MB)