markus / TEST_WPF / MessageContentPresenter.cs @ 58c9a957
이력 | 보기 | 이력해설 | 다운로드 (2.09 KB)
1 | 787a4489 | KangIngu | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Windows; |
||
6 | using System.Windows.Controls; |
||
7 | using TEST_WPF.TalkPane; |
||
8 | |||
9 | namespace TEST_WPF |
||
10 | { |
||
11 | public class MessageContentPresenter : ContentControl |
||
12 | { |
||
13 | /// <summary> |
||
14 | /// The DataTemplate to use when Message.Side == Side.Me |
||
15 | /// </summary> |
||
16 | public DataTemplate MeTemplate { get; set; } |
||
17 | |||
18 | /// <summary> |
||
19 | /// The DataTemplate to use when Message.Side == Side.You |
||
20 | /// </summary> |
||
21 | public DataTemplate YouTemplate { get; set; } |
||
22 | |||
23 | protected override void OnContentChanged(object oldContent, object newContent) |
||
24 | { |
||
25 | base.OnContentChanged(oldContent, newContent); |
||
26 | |||
27 | // apply the required template |
||
28 | KCOMDataModel.DataModel.TALK message = newContent as KCOMDataModel.DataModel.TALK; |
||
29 | if (message == null) |
||
30 | { |
||
31 | message = oldContent as KCOMDataModel.DataModel.TALK; |
||
32 | } |
||
33 | else |
||
34 | { |
||
35 | if ((MessageType)message.MSGTYPE == MessageType.Normal) |
||
36 | { |
||
37 | if ((MessageSide)message.MSGSIDE == MessageSide.Me) |
||
38 | { |
||
39 | ContentTemplate = App.Current.Resources["MeTemplate"] as DataTemplate; |
||
40 | //ContentTemplate = MeTemplate; |
||
41 | } |
||
42 | else |
||
43 | { |
||
44 | ContentTemplate = App.Current.Resources["YouTemplate"] as DataTemplate; |
||
45 | } |
||
46 | } |
||
47 | else |
||
48 | { |
||
49 | if ((MessageSide)message.MSGSIDE == MessageSide.Me) |
||
50 | { |
||
51 | ContentTemplate = App.Current.Resources["MeTemplate_Anchor"] as DataTemplate; |
||
52 | //ContentTemplate = MeTemplate; |
||
53 | } |
||
54 | else |
||
55 | { |
||
56 | ContentTemplate = App.Current.Resources["YouTemplate_Anchor"] as DataTemplate; |
||
57 | } |
||
58 | |||
59 | |||
60 | } |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | } |