1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| | using System.Windows.Controls;
using System.Windows;
using System;
namespace MyProject.Views {
public partial class UserInformation : UserControl {
public object sender;
private static string mode;
public static readonly RoutedEvent evt_MouseRightOnText = EventManager.RegisterRoutedEvent("EventMouseRightClickOnText", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(TextBox));
public static readonly RoutedEvent evt_ctxContextMenu_Opening = EventManager.RegisterRoutedEvent("EventContextMenu_Opening", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ContextMenu));
public static readonly RoutedEvent evt_ctxContextMenu_Opened = EventManager.RegisterRoutedEvent("EventContextMenu_Opened", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ContextMenu));
public static readonly RoutedEvent evt_MenuItem1_Click = EventManager.RegisterRoutedEvent("EventMenuItem1_Click", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MenuItem));
internal static readonly DependencyProperty ModeProperty = DependencyProperty.Register("Mode", typeof(string), typeof(UserInformation), new PropertyMetadata(null, new PropertyChangedCallback(OnTweetModeChanged)));
internal string Mode {
get { return (string)GetValue(ModeProperty); }
set { SetValue(ModeProperty, value); }
}
public event MouseButtonEventHandler EventMouseRightClickOnText{
add { AddHandler(evt_MouseRightOnText, value); }
remove { RemoveHandler(evt_MouseRightOnText, value); }
}
public event RoutedEventHandler EventContextMenu_Opening {
add { AddHandler(evt_ctxContextMenu_Opening, value); }
remove { RemoveHandler(evt_ctxContextMenu_Opening, value); }
}
public event RoutedEventHandler EventContextMenu_Opened {
add { AddHandler(evt_ctxContextMenu_Opened, value); }
remove { RemoveHandler(evt_ctxContextMenu_Opened, value); }
}
public event RoutedEventHandler EventMenuItem1_Click {
add { AddHandler(evt_MenuItem1_Click, value); }
remove { RemoveHandler(evt_MenuItem1_Click, value); }
}
public UserInformation() {
InitializeComponent();
}
private void txtPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) {
MouseButtonEventArgs eventArgs = new MouseButtonEventArgs(e.MouseDevice, e.Timestamp, e.ChangedButton) {
RoutedEvent = evt_MouseRightOnText,
};
this.sender = sender;
RaiseEvent(eventArgs);
}
private void ctxContextMenu_Opening(object sender, ContextMenuEventArgs e) {
if (mode.Equals("modeB")) {
e.Handled = true;
} else {
RoutedEventArgs eventArgs = new RoutedEventArgs(evt_ctxContextMenu_Opening);
this.sender = sender;
RaiseEvent(eventArgs);
}
}
private void ctxContextMenu_Opened(object sender, RoutedEventArgs e) {
RoutedEventArgs eventArgs = new RoutedEventArgs(evt_ContextMenu_Opened);
this.sender = sender;
RaiseEvent(eventArgs);
}
private void MenuItem1_Click(object sender, RoutedEventArgs e) {
RoutedEventArgs eventArgs = new RoutedEventArgs(evt_MenuItem1_Click);
this.sender = sender;
RaiseEvent(eventArgs);
}
private static void OnModeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) {
UserInformation ui = (UserInformation)obj;
mode = (string)args.NewValue;
}
}
}
|