markus / KCOM / Messenger / ConversationView.xaml.cs @ 0c997b99
이력 | 보기 | 이력해설 | 다운로드 (8.64 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 |
|
35 |
} |
36 |
|
37 |
private void BtnMark_Click(object sender, RoutedEventArgs e) |
38 |
{ |
39 |
if (main.dzMainMenu.SelectLayer.Children.Count > 0) |
40 |
{ |
41 |
DialogParameters parameters = new DialogParameters() |
42 |
{ |
43 |
Closed = (obj, args) => this.MarkupNameUpdatePromptClose(args), |
44 |
Content = "메모 :", |
45 |
Header = "앵커에 대한 메모을 남겨주세요", |
46 |
Theme = new VisualStudio2013Theme(), |
47 |
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
48 |
}; |
49 |
RadWindow.Prompt(parameters); |
50 |
|
51 |
|
52 |
} |
53 |
else |
54 |
{ |
55 |
MessageBox.Show("먼저 코멘트를 선택해주세요", "안내"); |
56 |
} |
57 |
} |
58 |
|
59 |
private void BtnFile_Click(object sender, RoutedEventArgs e) |
60 |
{ |
61 |
MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내"); |
62 |
} |
63 |
|
64 |
private void BtnMail_Click(object sender, RoutedEventArgs e) |
65 |
{ |
66 |
MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내"); |
67 |
} |
68 |
|
69 |
//강인구 추가 |
70 |
private void BtnSend_Click(object sender, MouseButtonEventArgs e) |
71 |
{ |
72 |
AddText(); |
73 |
} |
74 |
|
75 |
private void MarkupNameUpdatePromptClose(WindowClosedEventArgs args) |
76 |
{ |
77 |
if (args.DialogResult.Value) |
78 |
{ |
79 |
if (String.IsNullOrWhiteSpace(args.PromptResult) || args.PromptResult == null) |
80 |
{ |
81 |
MessageBox.Show("공백으로 입력하시면 등록이 불가능합니다", "안내"); |
82 |
} |
83 |
else |
84 |
{ |
85 |
Controls.AdornerFinal finalItem = main.dzMainMenu.SelectLayer.Children[0] as Controls.AdornerFinal; |
86 |
Rect rect = new Rect(new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100), new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100)); |
87 |
KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK |
88 |
{ |
89 |
TEXT = args.PromptResult, |
90 |
MSGSIDE = (int)MessageSide.Me, |
91 |
MEMBER_ID = App.ViewInfo.UserID, |
92 |
MEMBER_NAME = App.UserName, |
93 |
MSGTYPE = (int)MessageType.Anchor, |
94 |
TIMESTAMP = DateTime.Now, |
95 |
DOCUMENT_ID = App.ViewInfo.DocumentItemID, |
96 |
RECT_X = rect.X, |
97 |
RECT_Y = rect.Y, |
98 |
RECT_WIDTH = rect.Width, |
99 |
RECT_HEIGHT = rect.Height, |
100 |
PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber |
101 |
}; |
102 |
|
103 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message); |
104 |
|
105 |
List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
106 |
|
107 |
messagelist.ForEach(a => |
108 |
{ |
109 |
Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
110 |
}); |
111 |
|
112 |
tbContent.Text = ""; |
113 |
tbContent.Focus(); |
114 |
(lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
115 |
} |
116 |
} |
117 |
} |
118 |
|
119 |
protected virtual void OnPropertyChanged(String info) |
120 |
{ |
121 |
if (PropertyChanged != null) |
122 |
PropertyChanged(this, new PropertyChangedEventArgs(info)); |
123 |
} |
124 |
|
125 |
private void SaveAuthorization(object parameter) |
126 |
{ |
127 |
KCOMDataModel.DataModel.TALK instance = parameter as KCOMDataModel.DataModel.TALK; |
128 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(instance.PAGENUMBER.Value); |
129 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(new Rect { X = instance.RECT_X.Value, Y = instance.RECT_Y.Value, Width = instance.RECT_WIDTH.Value, Height = instance.RECT_HEIGHT.Value }); |
130 |
} |
131 |
|
132 |
public event PropertyChangedEventHandler PropertyChanged; |
133 |
|
134 |
private void ConversationView_Loaded(object sender, RoutedEventArgs e) |
135 |
{ |
136 |
//측정 |
137 |
//Stopwatch sw = new Stopwatch(); |
138 |
//sw.Start(); |
139 |
InitializeComponent(); |
140 |
//System.Diagnostics.Debug.WriteLine("ConversationView() : " + sw.ElapsedMilliseconds.ToString() + "ms"); |
141 |
|
142 |
btnMark.MouseLeftButtonDown += BtnMark_Click; |
143 |
btnMail.MouseLeftButtonDown += BtnMail_Click; |
144 |
btnFile.MouseLeftButtonDown += BtnFile_Click; |
145 |
//강인구 추가 |
146 |
btnSend.PreviewMouseLeftButtonDown += BtnSend_Click; |
147 |
|
148 |
main = this.ParentOfType<MainWindow>(); |
149 |
if (App.ParameterMode) |
150 |
{ |
151 |
ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization); |
152 |
if (string.IsNullOrEmpty(App.UserName)) |
153 |
{ |
154 |
App.UserName = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID).NAME; |
155 |
} |
156 |
if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0) |
157 |
{ |
158 |
List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
159 |
|
160 |
messagelist.ForEach(a => |
161 |
{ |
162 |
Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
163 |
}); |
164 |
(lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
165 |
} |
166 |
tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea); |
167 |
|
168 |
} |
169 |
} |
170 |
|
171 |
private async System.Threading.Tasks.Task OnKeyDownHandler(object sender, KeyEventArgs e) |
172 |
{ |
173 |
|
174 |
if (e.Key == Key.Return) |
175 |
{ |
176 |
if (Keyboard.Modifiers != ModifierKeys.Shift) |
177 |
{ |
178 |
AddText(); |
179 |
e.Handled = true; |
180 |
} |
181 |
else |
182 |
{ |
183 |
tbContent.Text = tbContent.Text + Environment.NewLine; |
184 |
tbContent.CaretIndex = tbContent.Text.Length; |
185 |
e.Handled = true; |
186 |
} |
187 |
} |
188 |
} |
189 |
|
190 |
private void AddText() |
191 |
{ |
192 |
Common.ViewerDataModel.Instance.k_talkMessageSet.Clear(); |
193 |
|
194 |
KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK |
195 |
{ |
196 |
TEXT = tbContent.Text, |
197 |
MSGSIDE = (int)MessageSide.Me, |
198 |
MEMBER_ID = App.ViewInfo.UserID, |
199 |
MEMBER_NAME = App.UserName, |
200 |
MSGTYPE = (int)MessageType.Normal, |
201 |
TIMESTAMP = DateTime.Now, |
202 |
DOCUMENT_ID = App.ViewInfo.DocumentItemID |
203 |
}; |
204 |
|
205 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message); |
206 |
|
207 |
List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
208 |
|
209 |
messagelist.ForEach(a => |
210 |
{ |
211 |
Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
212 |
}); |
213 |
tbContent.Text = ""; |
214 |
tbContent.Focus(); |
215 |
(lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
216 |
|
217 |
} |
218 |
} |
219 |
} |