Example #1
1
		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]));
			}

		}
Example #2
0
        public ThreadCanvas(UIElement parent, ScrollBar bar) : base(parent)
        {
            Bar = bar;

            Bar.Minimum     = 0;
            Bar.SmallChange = 33.0;
            Bar.LargeChange = Bar.SmallChange * 10.0;

            Binding binding = new Binding("IsVisible");

            binding.Source    = parent;
            binding.Converter = new BooleanToVisibilityConverter();
            base.SetBinding(VisibilityProperty, binding);

            Bar.Scroll += new ScrollEventHandler(Bar_Scroll);

            PreviewMouseWheel += new MouseWheelEventHandler(ThreadCanvas_PreviewMouseWheel);

            MouseLeftButtonUp   += new MouseButtonEventHandler(ThreadCanvas_MouseLeftButtonUp);
            MouseLeftButtonDown += new MouseButtonEventHandler(ThreadCanvas_MouseLeftButtonDown);

            MouseRightButtonUp   += new MouseButtonEventHandler(ThreadCanvas_MouseRightButtonUp);
            MouseRightButtonDown += new MouseButtonEventHandler(ThreadCanvas_MouseRightButtonDown);

            MouseLeave += new MouseEventHandler(ThreadCanvas_MouseLeave);

            MouseMove += new MouseEventHandler(ThreadCanvas_MouseMove);
        }
Example #3
0
 /// <summary>
 /// Register new event for the given page
 /// </summary>
 /// <param name="page">Name of the current page</param>
 /// <param name="keyboard">Handler to call when a KeyDown event is triggered</param>
 /// <param name="mousewheel">Handler to call when a MouseWheel event is triggered</param>
 public static void RegisterShortcuts(string page, KeyEventHandler keyboard, MouseWheelEventHandler mousewheel)
 {
     if (!isRegister)
     {
         isRegister = true;
         Application.Current.MainWindow.PreviewKeyDown += App_PreviewKeyDown;
         Application.Current.MainWindow.PreviewMouseWheel += App_PreviewMouseWheel;
     }
     if (!keyboardEvents.ContainsKey(page))
     {
         keyboardEvents.Add(page, new List<KeyEventHandler>());
     }
     if (!mouseWheelEvents.ContainsKey(page))
     {
         mouseWheelEvents.Add(page, new List<MouseWheelEventHandler>());
     }
     if (keyboard != null)
     {
         keyboardEvents[page].Add(keyboard);
     }
     if (mousewheel != null)
     {
         mouseWheelEvents[page].Add(mousewheel);
     }
 }
Example #4
0
        /// <summary>
        /// Creates the hosted <see cref="MapView"/>.</summary>
        /// <remarks>
        /// <b>CreateMapView</b> (re-)creates the associated <see cref="WorldState"/> if none exists
        /// or if the <see cref="ScenarioChanged"/> flag is set, and then (re-)creates the global
        /// <see cref="MapViewManager"/> and the hosted <see cref="MapView"/>.</remarks>

        private void CreateMapView()
        {
            if (ScenarioChanged || this._worldState == null)
            {
                ScenarioChanged = false;

                // (re)create world state from scenario
                this._worldState = new WorldState();
                this._worldState.Initialize(null);
            }

            // (re)create map view manager for current scenario
            if (MapViewManager.Instance != null)
            {
                MapViewManager.Instance.Dispose();
            }

            MapViewManager.CreateInstance(Dispatcher);

            // create mouse event handlers
            MouseButtonEventHandler onMouseDown  = OnMapMouseDown;
            MouseWheelEventHandler  onMouseWheel = MainWindow.Instance.OnMapMouseWheel;

            // create map view from world state
            MapViewManager.Instance.CreateView("default",
                                               this._worldState, MapViewHost, onMouseDown, onMouseWheel);
        }
Example #5
0
        public SignalTrack(Signal signal) : this()
        {
            pen.Freeze();

            Signal      = signal;
            MouseWheel += new MouseWheelEventHandler(OnSignalTrackMouseWheel);
        }
Example #6
0
        /// <summary>
        /// Creates a new <see cref="MapView"/> with the specified parameters.</summary>
        /// <param name="id">
        /// The initial value for the <see cref="MapView.Id"/> property of the new <see
        /// cref="MapView"/>.</param>
        /// <param name="worldState">
        /// The initial value for the <see cref="MapView.WorldState"/> property of the new <see
        /// cref="MapView"/>.</param>
        /// <param name="parent">
        /// The <see cref="ContentControl"/> hosting the <see cref="MapViewControl"/> of the new
        /// <see cref="MapView"/>.</param>
        /// <param name="onMouseDown">
        /// An optional handler for <see cref="UIElement.MouseDown"/> events raised by the <see
        /// cref="MapViewControl"/>. This argument may be a null reference.</param>
        /// <param name="onMouseWheel">
        /// An optional handler for <see cref="UIElement.MouseWheel"/> events raised by the <see
        /// cref="MapViewControl"/>. This argument may be a null reference.</param>
        /// <returns>
        /// A new <see cref="MapView"/> object created with the specified parameters.</returns>
        /// <exception cref="ArgumentException">
        /// <paramref name="id"/> already exists as an <see cref="MapView.Id"/> value in the <see
        /// cref="MapViews"/> collection.</exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="worldState"/> or <paramref name="parent"/> is a null reference.
        /// </exception>
        /// <exception cref="ArgumentNullOrEmptyException">
        /// <paramref name="id"/> is a null reference or an empty string.</exception>
        /// <exception cref="ObjectDisposedException">
        /// The <see cref="MapViewManager"/> object has been disposed of.</exception>
        /// <remarks>
        /// <b>CreateView</b> adds the newly created <see cref="MapView"/> to the <see
        /// cref="MapViews"/> collection. It will be automatically disposed of when this <see
        /// cref="MapViewManager"/> object is disposed of.</remarks>

        public MapView CreateView(string id, WorldState worldState, ContentControl parent,
                                  MouseButtonEventHandler onMouseDown, MouseWheelEventHandler onMouseWheel)
        {
            if (IsDisposed)
            {
                ThrowHelper.ThrowObjectDisposedException(null);
            }
            if (String.IsNullOrEmpty(id))
            {
                ThrowHelper.ThrowArgumentNullOrEmptyException("id");
            }

            if (MapViews.ContainsKey(id))
            {
                ThrowHelper.ThrowArgumentException("id", Tektosyne.Strings.ArgumentInCollection);
            }

            // create new map view with supplied parameters
            MapView mapView = new MapView(String.Intern(id),
                                          worldState, parent, onMouseDown, onMouseWheel);

            // add map view to manager's list
            this._mapViews.Add(mapView);

            return(mapView);
        }
Example #7
0
 /// <summary>
 /// Register new event for the given page
 /// </summary>
 /// <param name="page">Name of the current page</param>
 /// <param name="keyboard">Handler to call when a KeyDown event is triggered</param>
 /// <param name="mousewheel">Handler to call when a MouseWheel event is triggered</param>
 public static void RegisterShortcuts(string page, KeyEventHandler keyboard, MouseWheelEventHandler mousewheel)
 {
     if (!isRegister)
     {
         isRegister = true;
         Application.Current.MainWindow.PreviewKeyDown    += App_PreviewKeyDown;
         Application.Current.MainWindow.PreviewMouseWheel += App_PreviewMouseWheel;
     }
     if (!keyboardEvents.ContainsKey(page))
     {
         keyboardEvents.Add(page, new List <KeyEventHandler>());
     }
     if (!mouseWheelEvents.ContainsKey(page))
     {
         mouseWheelEvents.Add(page, new List <MouseWheelEventHandler>());
     }
     if (keyboard != null)
     {
         keyboardEvents[page].Add(keyboard);
     }
     if (mousewheel != null)
     {
         mouseWheelEvents[page].Add(mousewheel);
     }
 }
Example #8
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// mousewheeleventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this MouseWheelEventHandler mousewheeleventhandler, Object sender, MouseWheelEventArgs e, AsyncCallback callback)
        {
            if (mousewheeleventhandler == null)
            {
                throw new ArgumentNullException("mousewheeleventhandler");
            }

            return(mousewheeleventhandler.BeginInvoke(sender, e, callback, null));
        }
        internal static new void InvokeHandler(Delegate handler, IntPtr sender, IntPtr args)
        {
            MouseWheelEventHandler handler_ = (MouseWheelEventHandler)handler;

            if (handler_ != null)
            {
                handler_(Extend.GetProxy(sender, false), new MouseWheelEventArgs(args, false));
            }
        }
Example #10
0
        public DatePartTextBox()
        {
            GotKeyboardFocus           += new KeyboardFocusChangedEventHandler(DatePartTextBox_GotKeyboardFocus);
            PreviewMouseLeftButtonDown += new MouseButtonEventHandler(DatePartTextBox_PreviewMouseLeftButtonDown);
            MouseWheel += new MouseWheelEventHandler(DatePartTextBox_MouseWheel);
            KeyUp      += new KeyEventHandler(DatePartTextBox_KeyUp);

            IsReadOnlyCaretVisible = false;
            //IsReadOnly = true;
        }
Example #11
0
        }//很难简化,或简化收益太小的代码

        #endregion
        public void WaitForClick(UIElement Home = null)
        {
            if (Home == null)
            {
                Home = bkSre;
            }
            if (skipping_flag)
            {
                MainWindow.m_window.Dispatcher.Invoke(new Action(() =>
                {
                    MainWindow.m_window.sl_process.Value = 100.0 * ((double)saved_frame / (double)locatPlace);
                    MainWindow.m_window.sl_tepro.Text    = ((int)(100.0 * ((double)saved_frame / (double)locatPlace))).ToString() + "%";
                }));
            }
            if (locatPlace == saved_frame)
            {
                GamingTheatre.isSkiping = false;
                skipping_flag           = false;
                MainWindow.m_window.Dispatcher.Invoke(new Action(() => {
                    MainWindow.m_window.sys_con_pite.Visibility       = Visibility.Visible;
                    MainWindow.m_window.saveLoadingProcess.Visibility = Visibility.Hidden;
                }));
            }
            if (GamingTheatre.isSkiping)
            {
                return;
            }
            if (GamingTheatre.AutoMode)
            {
                Thread.Sleep((int)(SharedSetting.AutoTime * 1000.0));
                return;
            }
            MouseButtonEventHandler localtion = new MouseButtonEventHandler((e, v) => { if (!Usage.locked)
                                                                                        {
                                                                                            call_next.Set();
                                                                                        }
                                                                            });
            MouseWheelEventHandler location2 = new MouseWheelEventHandler((e, v) => { if (!Usage.locked && v.Delta < 0 && !v.Handled)
                                                                                      {
                                                                                          call_next.Set();
                                                                                      }
                                                                          });

            Home.Dispatcher.Invoke(() => { Home.MouseLeftButtonUp += localtion; Home.MouseWheel += location2; });
            canCtrl = true;
            call_next.WaitOne();
            canCtrl = false;
            if (IsDisposed)
            {
                throw new Exception("Exitted");
            }
            Home.Dispatcher.Invoke(() => { Home.MouseLeftButtonUp -= localtion; Home.MouseWheel -= location2; });
            call_next.Reset();
        }
        private void InitHandlers()
        {
            _mouseWeelHandler = new MouseWheelEventHandler(BrowserOnMouseWheel);
            _mouseUpHandler   = new MouseButtonEventHandler(BrowserMouseUp);
            _mouseDownHandler = new MouseButtonEventHandler(BrowserMouseDown);
            _mouseMoveHandler = new MouseEventHandler(BrowserMouseMove);

            _touchMoveHandler = new EventHandler <TouchEventArgs>(BrowserTouchMove);
            _touchUpHandler   = new EventHandler <TouchEventArgs>(BrowserTouchUp);
            _touchDownHandler = new EventHandler <TouchEventArgs>(BrowserTouchDown);
        }
Example #13
0
        public GridRuler()
        {
            this.ClipToBounds = true;

            MouseWheel += new MouseWheelEventHandler(CurveEditorControl_MouseWheel);
            MouseMove += new MouseEventHandler(CurveEditorControl_MouseMove);
            MouseDown += new MouseButtonEventHandler(CurveEditorControl_MouseDown);
            MouseUp += new MouseButtonEventHandler(CurveEditorControl_MouseUp);

            InitializeResources();
        }
Example #14
0
        public GridRuler()
        {
            this.ClipToBounds = true;

            MouseWheel += new MouseWheelEventHandler(CurveEditorControl_MouseWheel);
            MouseMove  += new MouseEventHandler(CurveEditorControl_MouseMove);
            MouseDown  += new MouseButtonEventHandler(CurveEditorControl_MouseDown);
            MouseUp    += new MouseButtonEventHandler(CurveEditorControl_MouseUp);

            InitializeResources();
        }
Example #15
0
        private void OnMouseWheelEvent(object sender, MouseWheelEventArgs e)
        {
            MouseWheelEventHandler handler = (MouseWheelEventHandler)eventDestination.Target;

            if (handler != null)
            {
                handler.Invoke(sender, e);
            }
            else
            {
                Deregister();
            }
        }
Example #16
0
 /// <summary>
 /// This is the constructor, we make the states we will be using and set the mouse events.
 /// </summary>
 public DrawingCanvas()
     : base()
 {
     // Set event listeners
     MouseEnter           += new MouseEventHandler(MouseEnterHandler);
     MouseLeave           += new MouseEventHandler(MouseLeaveHandler);
     MouseMove            += new MouseEventHandler(MouseMoveHandler);
     MouseWheel           += new MouseWheelEventHandler(MouseWheelHandler);
     MouseLeftButtonDown  += new MouseButtonEventHandler(MouseLeftButtonDownHandler);
     MouseLeftButtonUp    += new MouseButtonEventHandler(MouseLeftButtonUpHandler);
     MouseRightButtonDown += new MouseButtonEventHandler(MouseRightButtonDownHandler);
     MouseRightButtonUp   += new MouseButtonEventHandler(MouseRightButtonUpHandler);
     SizeChanged          += new SizeChangedEventHandler(DrawingCanvas_SizeChanged);
 }
Example #17
0
        public UIElementEventWrapper(UIElement source, EventType eventType, MouseWheelEventHandler handler)
        {
            eventSource      = source;
            eventDestination = new WeakReference(handler);

            if (eventType == EventType.MouseWheel)
            {
                eventSource.MouseWheel += OnMouseWheelEvent;
            }
            else
            {
                eventSource      = null;
                eventDestination = null;
            }
        }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapViewControl"/> class.</summary>
        /// <param name="mapView">
        /// The initial value for the <see cref="MapView"/> property.</param>
        /// <param name="onMouseDown">
        /// An optional handler for the <see cref="UIElement.MouseDown"/> event. This argument may
        /// be a null reference.</param>
        /// <param name="onMouseWheel">
        /// An optional handler for the <see cref="UIElement.MouseWheel"/> event. This argument may
        /// be a null reference.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="mapView"/> is a null reference.</exception>
        /// <remarks>
        /// Use <see cref="MapViewManager.CreateView"/> to create a new <see
        /// cref="Graphics.MapView"/> object and all associated controls.</remarks>

        public MapViewControl(MapView mapView,
                              MouseButtonEventHandler onMouseDown, MouseWheelEventHandler onMouseWheel)
        {
            if (mapView == null)
            {
                ThrowHelper.ThrowArgumentNullException("mapView");
            }

            // background color for borders
            Background = new SolidColorBrush(Color.FromRgb(63, 63, 63));

            // always show both scroll bars
            HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
            VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;

            this._mapView      = mapView;
            this._onMouseDown  = onMouseDown;
            this._onMouseWheel = onMouseWheel;

            // overlay image below renderer
            this._overlay         = new Image();
            this._overlay.Stretch = Stretch.Fill;

            // renderer for actual map display
            this._renderer = new MapViewRenderer(mapView, this);

            // overlay image above renderer (Hexkit Editor only)
            this._editorOverlay         = new Image();
            this._editorOverlay.Stretch = Stretch.Fill;

            // helper for attack & move arrows
            this._arrowDrawer = new ArrowDrawer(mapView);

            // site marker for selected polygon
            this._siteMarker = new Polygon();
            this._siteMarker.StrokeThickness = 3.0;
            this._siteMarker.Visibility      = Visibility.Collapsed;
            UpdateMarker();

            // canvas covering map extent
            Canvas canvas = new Canvas();

            canvas.Children.Add(this._overlay);
            canvas.Children.Add(this._renderer);
            canvas.Children.Add(this._editorOverlay);
            canvas.Children.Add(this._siteMarker);
            Content = canvas;
        }
Example #19
0
        /// <summary>
        /// Initializes a new instance of <see cref="MouseNavigation"/> class.
        /// </summary>
        public MouseNavigation()
        {
            Children.Add(navigationCanvas);


            Loaded   += MouseNavigationLoaded;
            Unloaded += MouseNavigationUnloaded;

            MouseLeave          += new MouseEventHandler(MouseNavigationLayer_MouseLeave);
            MouseMove           += new MouseEventHandler(MouseNavigationLayer_MouseMove);
            MouseLeftButtonUp   += new MouseButtonEventHandler(MouseNavigationLayer_MouseLeftButtonUp);
            MouseLeftButtonDown += new MouseButtonEventHandler(MouseNavigationLayer_MouseLeftButtonDown);
            MouseWheel          += new MouseWheelEventHandler(MouseNavigationLayer_MouseWheel);

            LayoutUpdated += (s, a) => transformChangeRequested = false;
        }
Example #20
0
        public FrameViewer()
        {
            InitializeComponent();

            ReloadSettings();

            _primary.Background = new SolidColorBrush(SdeAppConfiguration.ActEditorBackgroundColor);

            _components.Add(new GridLine(Orientation.Horizontal));
            _components.Add(new GridLine(Orientation.Vertical));

            SizeChanged += new SizeChangedEventHandler(_framePreview_SizeChanged);
            MouseMove   += new MouseEventHandler(_framePreview_MouseMove);
            MouseDown   += new MouseButtonEventHandler(_framePreview_MouseDown);
            MouseUp     += new MouseButtonEventHandler(_framePreview_MouseUp);
            MouseWheel  += new MouseWheelEventHandler(_framePreview_MouseWheel);
        }
Example #21
0
        private static void HookToScrollViewer(ScrollViewer viewer, bool hook, UIElement owner)
        {
            if (!scrollViewerEventHandlers.TryGetValue(viewer, out var scrollViewerEventHandler))
            {
                scrollViewerEventHandler = new MouseWheelEventHandler((x, y) => HandlePreviewMouseWheel(viewer, y, owner));
                scrollViewerEventHandlers.Add(viewer, scrollViewerEventHandler);
            }


            if (hook)
            {
                viewer.PreviewMouseWheel += scrollViewerEventHandler;
            }
            else
            {
                viewer.PreviewMouseWheel -= scrollViewerEventHandler;
            }
        }
        static AttachEventHandlerAction()
        {
            //
            // Initialize event handlers.
            //
            eventHandlers[typeof(EventHandler)]       = new EventHandler(OnGenericEvent);
            eventHandlers[typeof(RoutedEventHandler)] = new RoutedEventHandler(OnRoutedEvent);
            eventHandlers[typeof(KeyEventHandler)]    = new KeyEventHandler(OnKeyEvent);
            eventHandlers[typeof(KeyboardFocusChangedEventHandler)] = new KeyboardFocusChangedEventHandler(OnFocusEvent);
            eventHandlers[typeof(TextCompositionEventHandler)]      = new TextCompositionEventHandler(OnTextCompositionEvent);
            eventHandlers[typeof(MouseEventHandler)]                     = new MouseEventHandler(OnMouseEvent);
            eventHandlers[typeof(MouseButtonEventHandler)]               = new MouseButtonEventHandler(OnMouseButtonEvent);
            eventHandlers[typeof(MouseButtonEventHandler)]               = new MouseButtonEventHandler(OnMouseDoubleClickEvent);
            eventHandlers[typeof(MouseWheelEventHandler)]                = new MouseWheelEventHandler(OnMouseWheelEvent);
            eventHandlers[typeof(DragEventHandler)]                      = new DragEventHandler(OnDragEvent);
            eventHandlers[typeof(GiveFeedbackEventHandler)]              = new GiveFeedbackEventHandler(OnFeedbackEvent);
            eventHandlers[typeof(QueryCursorEventHandler)]               = new QueryCursorEventHandler(OnQueryCursorEvent);
            eventHandlers[typeof(ExecutedRoutedEventHandler)]            = new ExecutedRoutedEventHandler(OnExecutedEvent);
            eventHandlers[typeof(CanExecuteRoutedEventHandler)]          = new CanExecuteRoutedEventHandler(OnCanExecuteEvent);
            eventHandlers[typeof(DependencyPropertyChangedEventHandler)] = new DependencyPropertyChangedEventHandler(OnPropertyChangedEvent);

            //
            // Initialize routed event static method list.
            //
            staticMethods = new List <MethodInfo>();

            Type[] types = new Type[] { typeof(Mouse), typeof(Keyboard), typeof(CommandManager) };

            foreach (Type type in types)
            {
                MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
                foreach (MethodInfo methodInfo in methodInfos)
                {
                    if (methodInfo.Name.EndsWith("Handler", StringComparison.InvariantCulture) &&
                        (methodInfo.Name.StartsWith("Add", StringComparison.InvariantCulture) ||
                         methodInfo.Name.StartsWith("Remove", StringComparison.InvariantCulture)))
                    {
                        staticMethods.Add(methodInfo);
                    }
                }
            }
        }
Example #23
0
        public ServerLabel(int interval, MouseButtonEventHandler ClickDrag, MouseWheelEventHandler ChangeSize, double fontSize)
        {
            InitTimer(interval);

            HorizontalAlignment        = HorizontalAlignment.Left;
            HorizontalContentAlignment = HorizontalAlignment.Left;
            VerticalAlignment          = VerticalAlignment.Top;
            Margin = new Thickness(45, 0, 492, 0);

            Opacity     = 1;
            Background  = new SolidColorBrush(Colors.Transparent);
            BorderBrush = new SolidColorBrush(Colors.Black);

            FontSize    = fontSize;
            FontStretch = FontStretches.SemiCondensed;
            FontWeight  = FontWeights.Bold;

            MouseLeftButtonDown += ClickDrag;
            MouseWheel          += ChangeSize;
        }
Example #24
0
        public MapViewerControl()
        {
            layerVisibilityMask = uint.MaxValue;
            UseLayoutRounding   = true;
            ClipToBounds        = true;
            Focusable           = true;

            startPosition = ORIGIN;
            overlays      = new List <MapOverlay>();

            DefaultZoomFactor = 1.1;
            zoomLevel         = 1;
            IsMapLoaded       = false;

            // set up layout
            mapCanvas      = new Canvas();
            overlaysCanvas = new Canvas();
            mainGrid       = new Grid();

            mainGrid.Children.Add(mapCanvas);
            mainGrid.Children.Add(overlaysCanvas);
            Child = mainGrid;

            // add transforms
            translateTransform = new TranslateTransform();
            zoomTransform      = new ScaleTransform();

            mapTransformGroup = new TransformGroup();
            mapTransformGroup.Children.Add(zoomTransform);
            mapTransformGroup.Children.Add(translateTransform);
            mapCanvas.RenderTransform = mapTransformGroup;

            // events
            KeyDown             += new KeyEventHandler(control_KeyDown);
            MouseLeftButtonDown += new MouseButtonEventHandler(control_MouseLeftButtonDown);
            MouseLeftButtonUp   += new MouseButtonEventHandler(control_MouseLeftButtonUp);
            MouseMove           += new MouseEventHandler(control_MouseMove);
            MouseWheel          += new MouseWheelEventHandler(control_MouseWheel);
            SizeChanged         += new SizeChangedEventHandler(control_SizeChanged);
        }
Example #25
0
        public static void RemovePreviewMouseWheelHandler(DependencyObject element, MouseWheelEventHandler handler)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            if (element is UIElement)
            {
                ((UIElement)element).RemoveHandler(PreviewMouseWheelEvent, handler);
            }
            else if (element is ContentElement)
            {
                ((ContentElement)element).RemoveHandler(PreviewMouseWheelEvent, handler);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #26
0
 public static void AddPreviewMouseWheelHandler(System.Windows.DependencyObject element, MouseWheelEventHandler handler)
 {
 }
Example #27
0
 public New3DPanel()
 {
     Background = new SolidColorBrush(Colors.Transparent);
     Loaded += new RoutedEventHandler(New3DPanel_Loaded);
     animateTo = new Storyboard();
     animateTo.Duration = new Duration(TimeSpan.FromSeconds(0.7));
     AnimateX = AnimateProperty(animateTo, ViewXProperty, null, TimeSpan.FromSeconds(0.7));
     AnimateY = AnimateProperty(animateTo, ViewYProperty, null, TimeSpan.FromSeconds(0.7));
     AnimateZ = AnimateProperty(animateTo, ViewZProperty, TimeSpan.FromSeconds(0.2), TimeSpan.FromSeconds(0.5));
     animateTo.Completed += new EventHandler(animateTo_Completed);
     MouseLeftButtonDown += new MouseButtonEventHandler(Panel3D_MouseLeftButtonDown);
     MouseMove += new MouseEventHandler(Panel3D_MouseMove);
     MouseLeftButtonUp += new MouseButtonEventHandler(Panel3D_MouseLeftButtonUp);
     MouseWheel += new MouseWheelEventHandler(New3DPanel_MouseWheel);
 }
        public MouseWheelValueEditor()
        {
            InitializeComponent();

            MouseWheel += new MouseWheelEventHandler(MouseWheelHandler);
        }
Example #29
0
 /// <summary> 
 ///     Removes a handler for the MouseWheel attached event
 /// </summary>
 /// <param name="element">UIElement or ContentElement that listens to this event</param>
 /// <param name="handler">Event Handler to be removed</param> 
 public static void RemoveMouseWheelHandler(DependencyObject element, MouseWheelEventHandler handler)
 { 
     UIElement.RemoveHandler(element, MouseWheelEvent, handler); 
 }
Example #30
0
 /// <summary>
 ///     Adds a handler for the MouseWheel attached event 
 /// </summary>
 /// <param name="element">UIElement or ContentElement that listens to this event</param>
 /// <param name="handler">Event Handler to be added</param>
 public static void AddMouseWheelHandler(DependencyObject element, MouseWheelEventHandler handler) 
 {
     UIElement.AddHandler(element, MouseWheelEvent, handler); 
 } 
Example #31
0
        /// <summary>
        ///     The mechanism used to call the type-specific handler on the
        ///     target.
        /// </summary>
        /// <param name="genericHandler">
        ///     The generic handler to call in a type-specific way.
        /// </param>
        /// <param name="genericTarget">
        ///     The target to call the handler on.
        /// </param>
        protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget)
        {
            MouseWheelEventHandler handler = (MouseWheelEventHandler)genericHandler;

            handler(genericTarget, this);
        }
Example #32
0
		public static UnmanagedEventHandler CreateMouseWheelEventHandlerDispatcher (MouseWheelEventHandler handler)
		{
			return SafeDispatcher ( (sender, calldata, closure)
						=> handler (NativeDependencyObjectHelper.FromIntPtr (closure),
							    NativeDependencyObjectHelper.FromIntPtr (calldata) as MouseWheelEventArgs ?? new MouseWheelEventArgs (calldata)) );
		}
Example #33
0
 /// <summary>
 /// Adds a handler to the MouseHWheel event.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="handler">The handler.</param>
 public static void AddMouseHWheelHandler(DependencyObject element, MouseWheelEventHandler handler)
 {
     EventUtil.AddHandler(element, MouseEvents.MouseHWheelEvent, (Delegate)handler);
 }
Example #34
0
 /// <summary>
 ///     Adds a handler for the MouseWheel attached event
 /// </summary>
 /// <param name="element">UIElement or ContentElement that listens to this event</param>
 /// <param name="handler">Event Handler to be added</param>
 public static void AddMouseWheelHandler(DependencyObject element, MouseWheelEventHandler handler)
 {
     UIElement.AddHandler(element, MouseWheelEvent, handler);
 }
Example #35
0
File: Events.cs Project: ynkbt/moon
 public static UnmanagedEventHandler CreateMouseWheelEventHandlerDispatcher(MouseWheelEventHandler handler)
 {
     return(SafeDispatcher((sender, calldata, closure)
                           => handler(NativeDependencyObjectHelper.FromIntPtr(closure),
                                      NativeDependencyObjectHelper.FromIntPtr(calldata) as MouseWheelEventArgs ?? new MouseWheelEventArgs(calldata))));
 }
Example #36
0
        public static void OnAutoScrollChanged(
            DependencyObject obj,
            DependencyPropertyChangedEventArgs propertyArgs
            )
        {
            var listBox = obj as ListBox;

            if (listBox == null)
            {
                return;
            }
            ScrollViewer scrollViewer    = null;
            bool         justWheeled     = false;
            bool         userInteracting = false;
            bool         autoScroll      = true;
            var          collection      = listBox.Items.SourceCollection as INotifyCollectionChanged;
            var          onScrollChanged = new ScrollChangedEventHandler(
                (scrollChangedSender, scrollChangedArgs) => {
                if (scrollViewer.VerticalOffset + scrollViewer.ViewportHeight == scrollViewer.ExtentHeight)
                {
                    autoScroll = true;
                }
                else if (justWheeled)
                {
                    justWheeled = false;
                    autoScroll  = false;
                }
            }
                );
            var onSelectionChanged = new SelectionChangedEventHandler(
                (selectionChangedSender, selectionChangedArgs) => {
                autoScroll = false;
            }
                );
            var onGotMouse = new MouseEventHandler(
                (gotMouseSender, gotMouseArgs) => {
                userInteracting = true;
                autoScroll      = false;
            }
                );
            var onLostMouse = new MouseEventHandler(
                (lostMouseSender, lostMouseArgs) => {
                userInteracting = false;
            }
                );
            var onPreviewMouseWheel = new MouseWheelEventHandler(
                (mouseWheelSender, mouseWheelArgs) => {
                justWheeled = true;
            }
                );
            var onCollectionChangedEventHandler = new NotifyCollectionChangedEventHandler(
                (collecitonChangedSender, collectionChangedArgs) => {
                if (
                    (collectionChangedArgs.Action == NotifyCollectionChangedAction.Add) &&
                    autoScroll &&
                    !userInteracting &&
                    (scrollViewer != null)
                    )
                {
                    scrollViewer.ScrollToBottom();
                }
            }
                );
            var hook = new Action(
                () => {
                if (scrollViewer == null)
                {
                    scrollViewer = Utilities.FindDescendant <ScrollViewer>(listBox);
                    if (scrollViewer == null)
                    {
                        return;
                    }
                    else
                    {
                        justWheeled     = false;
                        userInteracting = false;
                        autoScroll      = true;
                        if (scrollViewer != null)
                        {
                            scrollViewer.ScrollToBottom();
                            scrollViewer.ScrollChanged += onScrollChanged;
                        }
                        listBox.SelectionChanged     += onSelectionChanged;
                        listBox.GotMouseCapture      += onGotMouse;
                        listBox.LostMouseCapture     += onLostMouse;
                        listBox.PreviewMouseWheel    += onPreviewMouseWheel;
                        collection.CollectionChanged += onCollectionChangedEventHandler;
                    }
                }
            }
                );
            var unhook = new Action(
                () => {
                if (scrollViewer != null)
                {
                    scrollViewer.ScrollChanged   -= onScrollChanged;
                    listBox.SelectionChanged     -= onSelectionChanged;
                    listBox.GotMouseCapture      -= onGotMouse;
                    listBox.LostMouseCapture     -= onLostMouse;
                    listBox.PreviewMouseWheel    -= onPreviewMouseWheel;
                    collection.CollectionChanged -= onCollectionChangedEventHandler;
                    scrollViewer = null;
                }
            }
                );
            var onLoaded = new RoutedEventHandler(
                (loadedSender, loadedArgs) => hook()
                );
            var onUnloaded = new RoutedEventHandler(
                (unloadedSender, unloadedArgs) => unhook()
                );

            if ((bool)propertyArgs.NewValue)
            {
                listBox.Loaded   += onLoaded;
                listBox.Unloaded += onUnloaded;
                hook();
            }
            else
            {
                listBox.Loaded   -= onLoaded;
                listBox.Unloaded -= onUnloaded;
                unhook();
            }
        }
Example #37
0
 /// <summary>
 ///     Removes a handler for the MouseWheel attached event
 /// </summary>
 /// <param name="element">UIElement or ContentElement that listens to this event</param>
 /// <param name="handler">Event Handler to be removed</param>
 public static void RemoveMouseWheelHandler(DependencyObject element, MouseWheelEventHandler handler)
 {
     UIElement.RemoveHandler(element, MouseWheelEvent, handler);
 }
Example #38
0
 public static void SetMouseWheel(Control element, MouseWheelEventHandler value)
 {
     element.SetValue(MouseWheelProperty, value);
 }
Example #39
0
 /// <summary>
 /// Removes a handler to the PreviewMouseHWheel event.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="handler">The handler.</param>
 public static void RemovePreviewMouseHWheelHandler(DependencyObject element, MouseWheelEventHandler handler)
 {
     EventUtil.RemoveHandler(element, MouseEvents.PreviewMouseHWheelEvent, (Delegate)handler);
 }
        private int _zoomAnimCount; //Animiation Count

        #endregion Fields

        #region Constructors

        public ZoomControl()
        {
            DefaultStyleKey = typeof(ZoomControl);
            //PreviewMouseWheel += ZoomControl_MouseWheel;
            //PreviewMouseDown += ZoomControl_PreviewMouseDown;
            //MouseDown += ZoomControl_MouseDown;
            //MouseUp += ZoomControl_MouseUp;

            MouseLeftButtonDown += new MouseButtonEventHandler(ZoomControl_MouseDown);
            MouseLeftButtonUp += new MouseButtonEventHandler(ZoomControl_MouseUp);
            MouseRightButtonDown += new MouseButtonEventHandler(ZoomControl_MouseRightButtonDown);
            MouseRightButtonUp += new MouseButtonEventHandler(ZoomControl_MouseRightButtonUp);

            MouseWheel += new MouseWheelEventHandler(ZoomControl_MouseWheel);
            this.Loaded += new RoutedEventHandler(ZoomControl_Loaded);
        }
Example #41
0
		public static void RemovePreviewMouseWheelHandler (DependencyObject element, MouseWheelEventHandler handler)
		{
			if (element == null) throw new ArgumentNullException ("element");
			if (handler == null) throw new ArgumentNullException ("handler");

			if (element is UIElement)
				((UIElement)element).RemoveHandler (PreviewMouseWheelEvent, handler);
			else if (element is ContentElement)
				((ContentElement)element).RemoveHandler (PreviewMouseWheelEvent, handler);
			else
				throw new NotSupportedException ();
		}
 public static void AddPreviewMouseWheelHandler(System.Windows.DependencyObject element, MouseWheelEventHandler handler)
 {
 }