Beispiel #1
0
 public static IObservable <MouseEventArgs> MouseLeave(this DependencyObject that)
 {
     return(Observable.FromEvent <MouseEventArgs>(
                on => Mouse.AddMouseLeaveHandler(that, (o, e) => on(e)),
                on => Mouse.RemoveMouseLeaveHandler(that, (o, e) => on(e))
                ));
 }
        /// <summary>
        /// Shows the FormatBar
        /// </summary>
        void ShowAdorner()
        {
            if (_adorner.Visibility == Visibility.Visible)
            {
                return;
            }

            VerifyAdornerLayer();

            _toolbar.Update();

            Control adorningEditor = _toolbar as Control;

            if (_adorner.Child == null)
            {
                _adorner.Child = adorningEditor;
            }

            _adorner.Visibility = Visibility.Visible;

            PositionFormatBar(adorningEditor);

            _parentWindow = TreeHelper.FindParent <Window>(_adorner);
            if (_parentWindow != null)
            {
                Mouse.AddMouseMoveHandler(_parentWindow, OnPreviewMouseMoveParentWindow);
                Mouse.AddMouseLeaveHandler(_parentWindow, OnMouseLeaveParentWindow);
            }
        }
Beispiel #3
0
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            //Correctly rotate the handle for vertical movement
            if (Orientation == Orientation.VerticalMovement)
            {
                gradientRotator.Angle = 0;
            }

            if (Orientation == Orientation.BiDimentionalMovement)
            {
                //No handle visible in BiDim case
                theBorder.Background = new SolidColorBrush(Colors.Blue);
            }

            //Don't attach events during design time
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            var mainWindow = Application.Current.Windows.OfType <Window>().FirstOrDefault();

            Mouse.AddPreviewMouseDownHandler(this, OnLocalMouseDown);
            Mouse.AddMouseLeaveHandler(this, OnLocalMouseLeave);
            Mouse.AddMouseEnterHandler(this, OnLocalMouseEnter);
            Mouse.AddPreviewMouseMoveHandler(mainWindow, OnGlobalMouseMove);
            Mouse.AddPreviewMouseUpHandler(mainWindow, OnGlobalMouseUp);
        }
        public WorkspaceItem()
        {
            //MouseEventHandler
            Mouse.AddMouseEnterHandler(this, (sender, e) =>
            {
                //Debug.WriteLine("WorkspaceItem::MouseEnterHandler. e.OriginalSource: " + e.OriginalSource + " Mouse.Captured: " + Mouse.Captured);
                //Debug.WriteLine("  this.IsMouseOver: " + this.IsMouseOver);
                //Debug.WriteLine("  Mouse.DirectlyOver: " + Mouse.DirectlyOver);

                MaximumToggleButton.Visibility = System.Windows.Visibility.Visible;
            });

            Mouse.AddMouseLeaveHandler(this, (sender, e) =>
            {
                //Debug.WriteLine("WorkspaceItem::MouseLeaveHandler. e.OriginalSource: " + e.OriginalSource + " Mouse.Captured: " + Mouse.Captured);

                //Debug.WriteLine("Mouse.DirectlyOver: " + Mouse.DirectlyOver);
                //Debug.WriteLine("  this.IsMouseOver: " + this.IsMouseOver);

                //Debug.WriteLine("  Mouse.DirectlyOver: " + Mouse.DirectlyOver);

                if (!_mouseNotLeaveNotified)
                {
                    MaximumToggleButton.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    _mouseNotLeaveNotified = false;
                }
            });

            //Mouse.AddMouseDownHandler(this, (sender, e) =>
            //    {
            //        Debug.WriteLine("WorkspaceItem::MouseDownHandler. e.OriginalSource: " + e.OriginalSource + " Mouse.Captured: " + Mouse.Captured);
            //    });


            //Loaded += WorkspaceItem_Loaded;

            //Debug.WriteLine("WorkspaceItem(). X: " + X + " Y: " + Y);
        }