本文整理汇总了C#中MouseButtonEventHandler类的典型用法代码示例。如果您正苦于以下问题:C# MouseButtonEventHandler类的具体用法?C# MouseButtonEventHandler怎么用?C# MouseButtonEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseButtonEventHandler类属于命名空间,在下文中一共展示了MouseButtonEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRemoveHandler
public void AddRemoveHandler ()
{
Delegate eh = new EventHandler ((object sender, EventArgs ea) => { });
Delegate keh = new KeyEventHandler ((object sender, KeyEventArgs ea) => { });
Delegate meh = new MouseButtonEventHandler ((object sender, MouseButtonEventArgs ea) => { });
Delegate weh = new MouseWheelEventHandler ((object sender, MouseWheelEventArgs ea) => { });
Delegate teh = new TextCompositionEventHandler ((object sender, TextCompositionEventArgs ea) => { });
// OK
RoutedEvent [] events1 = new RoutedEvent [] { UIElement.KeyDownEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonDownEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseWheelEvent, UIElement.TextInputEvent, UIElement.TextInputStartEvent, UIElement.TextInputUpdateEvent };
Delegate [] handlers1 = new Delegate [] { keh, keh, meh, meh, weh, teh, teh, teh };
// ArgumentNullException
RoutedEvent [] events2 = new RoutedEvent [] { null, UIElement.KeyUpEvent };
Delegate [] handlers2 = new Delegate [] { keh, null };
// ArgumentException
RoutedEvent [] events3 = new RoutedEvent [] { FrameworkElement.LoadedEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.TextInputUpdateEvent, UIElement.MouseWheelEvent };
Delegate [] handlers3 = new Delegate [] { eh, meh, keh, teh, eh , meh};
// NotImplementedException
RoutedEvent [] events4 = new RoutedEvent [] { UIElement.ManipulationCompletedEvent, UIElement.ManipulationDeltaEvent, UIElement.ManipulationStartedEvent };
Delegate [] handlers4 = new Delegate [] { eh, eh, eh };
UIElement ctrl = new MediaElement ();
// AddHandler
for (int i = 0; i < events1.Length; i++) {
ctrl.AddHandler (events1 [i], handlers1 [i], false);
}
for (int i = 0; i < events2.Length; i++) {
Assert.Throws<ArgumentNullException> (() => ctrl.AddHandler (events2 [i], handlers2 [i], false));
}
for (int i = 0; i < events3.Length; i++) {
Assert.Throws<ArgumentException> (() => ctrl.AddHandler (events3 [i], handlers3 [i], false));
}
for (int i = 0; i < events4.Length; i++) {
Assert.Throws<NotImplementedException> (() => ctrl.AddHandler (events4 [i], handlers4 [i], false));
}
// RemoveHandler
for (int i = 0; i < events1.Length; i++) {
ctrl.RemoveHandler (events1 [i], handlers1 [i]);
}
for (int i = 0; i < events2.Length; i++) {
Assert.Throws<ArgumentNullException> (() => ctrl.RemoveHandler (events2 [i], handlers2 [i]));
}
for (int i = 0; i < events3.Length; i++) {
Assert.Throws<ArgumentException> (() => ctrl.RemoveHandler (events3 [i], handlers3 [i]));
}
for (int i = 0; i < events4.Length; i++) {
Assert.Throws<NotImplementedException> (() => ctrl.RemoveHandler (events4 [i], handlers4 [i]));
}
}
示例2: MovableChartLabelPoint
//public bool Moving { get { return isMoving; } }
/// <summary>
/// Creates an instance of MovableChartLabelPoint
/// </summary>
public MovableChartLabelPoint()
{
IsMovable = false;
MouseLeftButtonDown += new MouseButtonEventHandler(MovableChartLabelPoint_MouseLeftButtonDown);
MouseLeftButtonUp += new MouseButtonEventHandler(MovableChartLabelPoint_MouseLeftButtonUp);
MouseMove += new MouseEventHandler(MovableChartLabelPoint_MouseMove);
}
示例3: InitializeDragHandler
protected void InitializeDragHandler(FrameworkElement element)
{
this.element = element;
this.handler = new MouseButtonEventHandler(DoMoveWindowBegin);
element.MouseLeftButtonDown += handler;
}
示例4: OnMouseLeftButtonDown
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
//因为图钉是添加在MapLayer上的
var parentLayer = this.Parent as MapLayer;
if (parentLayer != null)
{
//MapLayer是Map的一个子对象
var parentMap = parentLayer.ParentMap;
if (parentMap != null)
{
if (this.MapMouseDragHandler == null)
{
this.MapMouseDragHandler = new EventHandler<MapMouseDragEventArgs>(ParnetMap_MousePan);
parentMap.MousePan += this.MapMouseDragHandler;
}
if (this.MapMouseLeftButtonUpHandler == null)
{
this.MapMouseLeftButtonUpHandler = new MouseButtonEventHandler(PrentMap_MouseLeftButtonUp);
parentMap.MouseLeftButtonUp += this.MapMouseLeftButtonUpHandler;
}
if (this.MapMouseMoveHandler == null)
{
this.MapMouseMoveHandler = new MouseEventHandler(PrentMap_MouseMove);
parentMap.MouseMove += this.MapMouseMoveHandler;
}
}
}
this.IsDragging = true;
base.OnMouseLeftButtonDown(e);
}
示例5: StartCapture
/// <summary>
/// 开始鼠标捕捉
/// </summary>
/// <param name="element"></param>
/// <param name="mouseMoveHandler"></param>
/// <param name="mouseUpHandler"></param>
public static void StartCapture(this FrameworkElement element, MouseEventHandler mouseMoveHandler,
MouseButtonEventHandler mouseUpHandler)
{
element.MouseMove += mouseMoveHandler;
element.MouseUp += mouseUpHandler;
element.CaptureMouse();
}
示例6: OnMouseLeftButtonDown
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
var parentLayer = Parent as MapLayer;
if (parentLayer != null)
{
var parentMap = parentLayer.ParentMap;
if (parentMap != null)
{
if (this.ParentMapMousePanHandler == null)
{
ParentMapMousePanHandler = new EventHandler<MapMouseDragEventArgs>(ParentMap_MousePan);
parentMap.MousePan += ParentMapMousePanHandler;
}
if (ParentMapMouseLeftButtonUpHandler == null)
{
ParentMapMouseLeftButtonUpHandler = new MouseButtonEventHandler(ParentMap_MouseLeftButtonUp);
parentMap.MouseLeftButtonUp += ParentMapMouseLeftButtonUpHandler;
}
if (ParentMapMouseMoveHandler == null)
{
ParentMapMouseMoveHandler = new MouseEventHandler(ParentMap_MouseMove);
parentMap.MouseMove += ParentMapMouseMoveHandler;
}
}
}
IsDragging = true;
base.OnMouseLeftButtonDown(e);
}
示例7: MyVisualHost
/// <summary>
/// Constructor
/// </summary>
public MyVisualHost()
{
children = new VisualCollection(this);
MouseLeftButtonDown += new MouseButtonEventHandler(MyVisualHost_MouseLeftButtonDown);
MouseRightButtonDown += new MouseButtonEventHandler(MyVisualHost_MouseRightButtonDown);
}
示例8: ScreenObject
public ScreenObject(string source, int zIndex = 0, MouseButtonEventHandler uIElement_OnMouseDown = null)
{
ImageSource = source;
ZIndex = zIndex;
if(uIElement_OnMouseDown != null)
Image.MouseDown += uIElement_OnMouseDown;
}
示例9: DataGridPro
public DataGridPro(DataManager _manager, MouseButtonEventHandler method)
{
InitializeComponent();
dgItems.MouseDoubleClick += method;
manager = _manager;
foreach (DataGridColumn c in manager.DataColumns)
dgItems.Columns.Add(c);
}
示例10: StopCapture
/// <summary>
/// 结束鼠标捕捉
/// </summary>
/// <param name="element"></param>
/// <param name="mouseMoveHandler"></param>
/// <param name="mouseUpHandler"></param>
public static void StopCapture(this FrameworkElement element, MouseEventHandler mouseMoveHandler,
MouseButtonEventHandler mouseUpHandler)
{
element.MouseMove -= mouseMoveHandler;
element.MouseUp -= mouseUpHandler;
if (element.IsMouseCaptured)
element.ReleaseMouseCapture();
}
示例11: ContentControlBase
public ContentControlBase()
{
DoubleClickTimer.Interval = new TimeSpan(0, 0, 0, 3000);
DoubleClickTimer.Tick += new EventHandler(DoubleClickTimer_Tick);
MouseLeftButtonDown += new MouseButtonEventHandler(ContentControlBase_MouseLeftButtonDown);
MouseLeftButtonUp += new MouseButtonEventHandler(ContentControlBase_MouseLeftButtonUp);
MouseMove += new MouseEventHandler(ContentControlBase_MouseMove);
}
示例12: MainWindow
public MainWindow()
{
InitializeComponent();
graphs = new List<GraphPosition>();
Application.Current.Exit += new ExitEventHandler(Current_Exit);
Topmost = true;
MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);
}
示例13: SnapGridItemContainer
public SnapGridItemContainer()
{
Background = new SolidColorBrush(Colors.Cyan);
var t = DefaultStyleKey;
Background = new SolidColorBrush(Colors.Cyan);
MouseLeftButtonUp += new MouseButtonEventHandler(SnapGridItem_MouseLeftButtonUp);
}
示例14: MainWindow
public MainWindow()
{
InitializeComponent();
this.myMap = new Map();
MouseLeftButtonDown += new MouseButtonEventHandler(MainWindow_MouseLeftButtonDown);
}
示例15: MainWindow
public MainWindow()
{
InitializeComponent();
KeyUp += new KeyEventHandler(MainWindow_KeyUp);
MouseDown += new MouseButtonEventHandler(MainWindow_MouseDown);
MouseUp += new MouseButtonEventHandler(MainWindow_MouseUp);
MouseMove += new MouseEventHandler(MainWindow_MouseMove);
SetColor(Colors.Black);
}