markus / KCOM / Messenger / ConversationView.xaml.cs @ 664ea2e1
이력 | 보기 | 이력해설 | 다운로드 (12.9 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 = "Memo :", |
52 |
Header = "Make a note About the Anchor", |
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("Please Select a comment first", "Info"); |
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.GetValueOrDefault()) |
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 async 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 |
try |
198 |
{ |
199 |
var mainMenu = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu; |
200 |
|
201 |
ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization); |
202 |
if (string.IsNullOrEmpty(App.UserName) && mainMenu.userData == null) |
203 |
{ |
204 |
var member = await mainMenu.BaseTaskClient.GetMemberAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID); |
205 |
if (member != null) |
206 |
App.UserName = member.NAME; |
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 = await mainMenu.BaseTaskClient.GetMessageAsync(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
212 |
|
213 |
//Logger.sendResLog("GetMessage", "messagelist.Count:" + messagelist.Count(), 1); |
214 |
|
215 |
messagelist.ForEach(a => |
216 |
{ |
217 |
Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
218 |
}); |
219 |
(lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
220 |
} |
221 |
|
222 |
tbContent.KeyDown += OnKeyDownHandler; |
223 |
} |
224 |
catch (Exception ex) |
225 |
{ |
226 |
throw; |
227 |
} |
228 |
} |
229 |
} |
230 |
|
231 |
private void OnKeyDownHandler(object sender, KeyEventArgs e) |
232 |
{ |
233 |
if (e.Key == Key.Return) |
234 |
{ |
235 |
if (Keyboard.Modifiers != ModifierKeys.Shift) |
236 |
{ |
237 |
AddText(); |
238 |
e.Handled = true; |
239 |
} |
240 |
else |
241 |
{ |
242 |
tbContent.Text = tbContent.Text + Environment.NewLine; |
243 |
tbContent.CaretIndex = tbContent.Text.Length; |
244 |
e.Handled = true; |
245 |
} |
246 |
} |
247 |
} |
248 |
|
249 |
private void AddText() |
250 |
{ |
251 |
Common.ViewerDataModel.Instance.k_talkMessageSet.Clear(); |
252 |
|
253 |
KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK |
254 |
{ |
255 |
TEXT = tbContent.Text, |
256 |
MSGSIDE = (int)MessageSide.Me, |
257 |
MEMBER_ID = App.ViewInfo.UserID, |
258 |
MEMBER_NAME = App.UserName, |
259 |
MSGTYPE = (int)MessageType.Normal, |
260 |
TIMESTAMP = DateTime.Now, |
261 |
DOCUMENT_ID = App.ViewInfo.DocumentItemID |
262 |
}; |
263 |
|
264 |
//Logger.sendReqLog("AddMessage", App.ViewInfo.ProjectNO + "," + message, 1); |
265 |
//Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1); |
266 |
//Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message); |
267 |
|
268 |
//Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1); |
269 |
List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
270 |
if (messagelist.Count() > 0) |
271 |
{ |
272 |
//Logger.sendResLog("GetMessage", "TRUE", 1); |
273 |
} |
274 |
else |
275 |
{ |
276 |
//Logger.sendResLog("GetMessage", "FALSE", 1); |
277 |
} |
278 |
|
279 |
messagelist.ForEach(a => |
280 |
{ |
281 |
Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
282 |
}); |
283 |
tbContent.Text = ""; |
284 |
tbContent.Focus(); |
285 |
(lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
286 |
|
287 |
} |
288 |
} |
289 |
} |