프로젝트

일반

사용자정보

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

markus / KCOM / Messenger / ConversationView.xaml.cs @ 224f1503

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

1
using KCOM.Views;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5
using System.Diagnostics;
6
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
            InitializeComponent();
31
            
32
            this.DataContext = this;
33
            this.Loaded += ConversationView_Loaded;
34
            btnMark.MouseLeftButtonDown += BtnMark_Click;
35
            btnMail.MouseLeftButtonDown += BtnMail_Click;
36
            btnFile.MouseLeftButtonDown += BtnFile_Click;
37
            //강인구 추가
38
            btnSend.PreviewMouseLeftButtonDown += BtnSend_Click;
39
        }
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

    
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
                    Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
124
                    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
                        PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber,
138
                        ANGLE = (int)instanceMain.dzMainMenu.rotate.Angle
139
                    };
140

    
141
                    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

    
145
                    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
                    messagelist.ForEach(a =>
156
                    {
157
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
158
                    });
159

    
160
                    tbContent.Text = "";
161
                    tbContent.Focus();
162
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
163
                }
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
            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
        }
180

    
181
        public event PropertyChangedEventHandler PropertyChanged;
182

    
183
        private void ConversationView_Loaded(object sender, RoutedEventArgs e)
184
        {
185
            //측정
186
            //Stopwatch sw = new Stopwatch();
187
            //sw.Start();
188
            //InitializeComponent();
189
            //System.Diagnostics.Debug.WriteLine("ConversationView() : " + sw.ElapsedMilliseconds.ToString() + "ms");
190
            
191
            main = this.ParentOfType<MainWindow>();
192
            if (App.ParameterMode)
193
            {
194
                ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
195
                if (string.IsNullOrEmpty(App.UserName))
196
                {
197
                    Logger.sendReqLog("GetMember: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID, 1);                  
198
                    App.UserName = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID).NAME;
199
                    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
                }
208
                if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
209
                {
210
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
211
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
212
                    if (messagelist.Count() > 0)
213
                    {
214
                        Logger.sendResLog("GetMessage", "TRUE", 1);
215
                    }
216
                    else
217
                    {
218
                        Logger.sendResLog("GetMessage", "FALSE", 1);
219
                    }
220
                    messagelist.ForEach(a =>
221
                    {
222
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
223
                    });
224
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
225
                }
226
                tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea);
227

    
228
            }
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
            Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
253
            
254
            KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
255
            {
256
                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

    
265
            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

    
269
            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

    
280
            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
        }
289
    }
290
}
클립보드 이미지 추가 (최대 크기: 500 MB)