当前位置: 首页>>代码示例>>C#>>正文


C# MouseButtonEventHandler类代码示例

本文整理汇总了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]));
			}

		}
开发者ID:dfr0,项目名称:moon,代码行数:54,代码来源:UIElementTest.cs

示例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);
 }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:11,代码来源:MovableChartLabelPoint.cs

示例3: InitializeDragHandler

        protected void InitializeDragHandler(FrameworkElement element)
        {
            this.element = element;
            this.handler = new MouseButtonEventHandler(DoMoveWindowBegin);

            element.MouseLeftButtonDown += handler;
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:7,代码来源:MovableWindow.cs

示例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);
        }
开发者ID:HogwartsRico,项目名称:AGS-PgRouting,代码行数:33,代码来源:DraggablePushpin.cs

示例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();
 }
开发者ID:dalinhuang,项目名称:tdcodes,代码行数:13,代码来源:FrameworkElementExtension.cs

示例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);
        }
开发者ID:valeriob,项目名称:Routing,代码行数:30,代码来源:DraggablePushpin.cs

示例7: MyVisualHost

        /// <summary>
        /// Constructor
        /// </summary>
        public MyVisualHost()
        {
            children = new VisualCollection(this);

            MouseLeftButtonDown += new MouseButtonEventHandler(MyVisualHost_MouseLeftButtonDown);
            MouseRightButtonDown += new MouseButtonEventHandler(MyVisualHost_MouseRightButtonDown);
        }
开发者ID:uhwgmxorg,项目名称:MyHitTest,代码行数:10,代码来源:MyVisualHost.cs

示例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;
 }
开发者ID:Kursledare,项目名称:Mookieraw,代码行数:7,代码来源:ScreenObject.cs

示例9: DataGridPro

 public DataGridPro(DataManager _manager, MouseButtonEventHandler method)
 {
     InitializeComponent();
     dgItems.MouseDoubleClick += method;
     manager = _manager;
     foreach (DataGridColumn c in manager.DataColumns)
         dgItems.Columns.Add(c);
 }
开发者ID:bashlykevich,项目名称:Drive4,代码行数:8,代码来源:DataGridPro.xaml.cs

示例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();
 }
开发者ID:dalinhuang,项目名称:tdcodes,代码行数:14,代码来源:FrameworkElementExtension.cs

示例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);
 }
开发者ID:sajithdushmantha,项目名称:silverlightscheduler,代码行数:8,代码来源:ContentControlBase.cs

示例12: MainWindow

 public MainWindow()
 {
     InitializeComponent();
     graphs = new List<GraphPosition>();
     Application.Current.Exit += new ExitEventHandler(Current_Exit);
     Topmost = true;
     MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);
 }
开发者ID:rodero95,项目名称:butterfly-dev,代码行数:8,代码来源:MainWindow.xaml.cs

示例13: SnapGridItemContainer

        public SnapGridItemContainer()
        {
            Background = new SolidColorBrush(Colors.Cyan);
            var t = DefaultStyleKey;

            Background = new SolidColorBrush(Colors.Cyan);
            MouseLeftButtonUp += new MouseButtonEventHandler(SnapGridItem_MouseLeftButtonUp);
        }
开发者ID:valeriob,项目名称:Routing,代码行数:8,代码来源:SnapGridItemContainer.cs

示例14: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            this.myMap = new Map();

            MouseLeftButtonDown += new MouseButtonEventHandler(MainWindow_MouseLeftButtonDown);
        }
开发者ID:sasalatart,项目名称:IIC2233-2013-1,代码行数:8,代码来源:MainWindow.xaml.cs

示例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);
 }
开发者ID:AlexJCarstensen,项目名称:SimpleDraw-I4GUI,代码行数:9,代码来源:MainWindow.xaml.cs


注:本文中的MouseButtonEventHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。