// Constructor.
	public QueryContinueDragEventArgs
				(int keyState, bool escapePressed, DragAction action)
			{
				this.keyState = keyState;
				this.escapePressed = escapePressed;
				this.action = action;
			}
Ejemplo n.º 2
0
        internal bool DockDockintoDock(IDock sourceDock, IDock targetDock, DragAction action, DockOperation operation, bool bExecute)
        {
            var visible = sourceDock.VisibleDockables.ToList();

            if (visible.Count == 1)
            {
                if (DockDockableIntoDock(visible.First(), targetDock, action, operation, bExecute) == false)
                {
                    return(false);
                }
            }
            else
            {
                if (DockDockableIntoDock(visible.First(), targetDock, action, operation, bExecute) == false)
                {
                    return(false);
                }
                foreach (var dockable in visible.Skip(1))
                {
                    if (DockDockableIntoDockable(dockable, visible.First(), action, bExecute) == false)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public bool ValidateDock(IDock sourceDock, IDockable targetDockable, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (targetDockable)
            {
            case IRootDock _:
                return(DockDockableIntoWindow(sourceDock, targetDockable, operation, bExecute));

            case IToolDock toolDock:
                if (sourceDock == toolDock)
                {
                    return(false);
                }
                return(DockDockable(sourceDock, targetDockable, toolDock, action, operation, bExecute));

            case IDocumentDock documentDock:
                if (sourceDock == documentDock)
                {
                    return(false);
                }
                return(DockDockable(sourceDock, targetDockable, documentDock, action, operation, bExecute));

            default:
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Process pointer event.
        /// </summary>
        /// <param name="point">The pointer position.</param>
        /// <param name="eventType">The pointer event type.</param>
        public void Process(Point point, EventType eventType)
        {
            switch (eventType)
            {
            case EventType.Pressed:
            {
                var isDragEnabled = _hostWindow.GetValue(DockProperties.IsDragEnabledProperty);
                if (isDragEnabled != true)
                {
                    break;
                }
                _dragStartPoint    = point;
                _pointerPressed    = true;
                _doDragDrop        = false;
                _targetDockControl = null;
                _targetPoint       = default;
                _targetDropControl = null;
                _dragAction        = DragAction.Move;
            }
            break;

            case EventType.Released:
            {
                if (_doDragDrop)
                {
                    if (_targetDockControl is { } && _targetDropControl is { })
Ejemplo n.º 5
0
        ///<inheritdoc/>
        public bool ValidateTool(ITool sourceTool, IDockable targetDockable, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (targetDockable)
            {
            case IRootDock _:
                return(DockDockableIntoWindow(sourceTool, targetDockable, operation, bExecute));

            case IToolDock toolDock:
                return(DockDockableIntoDock(sourceTool, toolDock, action, operation, bExecute));

            case IDocumentDock documentDock:
                return(DockDockableIntoDock(sourceTool, documentDock, action, operation, bExecute));

            case IPinDock pinDock:
                return(DockDockableIntoDock(sourceTool, pinDock, action, operation, bExecute));

            case ITool tool:
                return(DockDockableIntoDockable(sourceTool, tool, action, bExecute));

            case IDocument document:
                return(DockDockableIntoDockable(sourceTool, document, action, bExecute));

            default:
                return(false);
            }
        }
Ejemplo n.º 6
0
        public int OleQueryContinueDrag(int fEscapePressed, int grfKeyState)
        {
            QueryContinueDragEventArgs qcdevent = null;
            bool       escapePressed            = (fEscapePressed != 0);
            DragAction action = DragAction.Continue;

            if (escapePressed)
            {
                action = DragAction.Cancel;
            }
            else if ((grfKeyState & NativeMethods.MK_LBUTTON) == 0 &&
                     (grfKeyState & NativeMethods.MK_RBUTTON) == 0 &&
                     (grfKeyState & NativeMethods.MK_MBUTTON) == 0)
            {
                action = DragAction.Drop;
            }

            qcdevent = new QueryContinueDragEventArgs(grfKeyState, escapePressed, action);
            peer.OnQueryContinueDrag(qcdevent);

            int hr = 0;

            switch (qcdevent.Action)
            {
            case DragAction.Drop:
                hr = DragDropSDrop;
                break;

            case DragAction.Cancel:
                hr = DragDropSCancel;
                break;
            }

            return(hr);
        }
Ejemplo n.º 7
0
 public void addDragAction(DragAction dragAct)
 {
     if (dragActionsCache.Count == 0)
     {
         dragActionsCache.Add(dragAct);
         return;
     }
     else if (dragActionsCache.Count == 1)
     {
         if (dragActionsCache[0].TimeStamp == dragAct.TimeStamp && dragActionsCache[0].Panel.gameObject.name == dragAct.Panel.gameObject.name)
         {
             dragActionsCache.Clear();
             dragActionsCache.Add(dragAct);
         }
         else
         {
             serializeToLocal(dragActionsCache[0], DEST_PATH_MOUSE_EVENT);
             dragActionsCache.Clear();
             dragActionsCache.Add(dragAct);
         }
     }
     else
     {
         Debug.LogError("见鬼了");
     }
 }
Ejemplo n.º 8
0
        void MouseButtonDown(int buttonNumber, int xViewport, int yViewport)
        {
            PointF worldMouse = PixelToWorld(new PointF(xViewport, yViewport));

            mouseDown[buttonNumber] = true;
            mouseDrag[buttonNumber] = false;
            canDrag[buttonNumber]   = false;
            downPos[buttonNumber]   = worldMouse;
            downTime[buttonNumber]  = Environment.TickCount;

            if (OnMouseEvent != null)
            {
                DragAction dragAction = OnMouseEvent(this, MouseAction.Down, buttonNumber, mouseDown, worldMouse, worldMouse);
                canDrag[buttonNumber] = (dragAction == DragAction.ImmediateDrag || dragAction == DragAction.DelayedDrag);
                if (dragAction == DragAction.ImmediateDrag)
                {
                    mouseDrag[buttonNumber] = true;
                    DisableHoverTimer();
                }

                if (dragAction == DragAction.MapDrag)
                {
                    // Map dragging has been requested.
                    BeginMapDragging(new Point(xViewport, yViewport), (buttonNumber == LeftMouseButton) ? MouseButtons.Left : MouseButtons.Right);
                }
            }

            return;
        }
Ejemplo n.º 9
0
        private bool Validate(Point point, DockOperation operation, DragAction dragAction, IVisual relativeTo)
        {
            if (_targetDropControl is null)
            {
                return(false);
            }

            var layout = _hostWindow.Window?.Layout;

            if (layout?.ActiveDockable is { } sourceDockable&& _targetDropControl.DataContext is IDockable targetDockable)
            {
                DockManager.Position = DockHelpers.ToDockPoint(point);

                if (relativeTo.VisualRoot is null)
                {
                    return(false);
                }
                var screenPoint = relativeTo.PointToScreen(point).ToPoint(1.0);
                DockManager.ScreenPosition = DockHelpers.ToDockPoint(screenPoint);

                return(DockManager.ValidateDockable(sourceDockable, targetDockable, dragAction, operation, bExecute: false));
            }

            return(false);
        }
Ejemplo n.º 10
0
        public HRESULT QueryContinueDrag(BOOL fEscapePressed, User32.MK grfKeyState)
        {
            bool       escapePressed = fEscapePressed != 0;
            DragAction action        = DragAction.Continue;

            if (escapePressed)
            {
                action = DragAction.Cancel;
            }
            else if ((grfKeyState & User32.MK.LBUTTON) == 0 &&
                     (grfKeyState & User32.MK.RBUTTON) == 0 &&
                     (grfKeyState & User32.MK.MBUTTON) == 0)
            {
                action = DragAction.Drop;
            }

            QueryContinueDragEventArgs qcdevent = new QueryContinueDragEventArgs((int)grfKeyState, escapePressed, action);

            _peer.OnQueryContinueDrag(qcdevent);

            switch (qcdevent.Action)
            {
            case DragAction.Drop:
                return(HRESULT.DRAGDROP_S_DROP);

            case DragAction.Cancel:
                return(HRESULT.DRAGDROP_S_CANCEL);

            default:
                return(HRESULT.S_OK);
            }
        }
        public int OleQueryContinueDrag(int fEscapePressed, int grfKeyState)
        {
            QueryContinueDragEventArgs qcdevent = null;
            bool       escapePressed            = fEscapePressed != 0;
            DragAction cancel = DragAction.Continue;

            if (escapePressed)
            {
                cancel = DragAction.Cancel;
            }
            else if ((((grfKeyState & 1) == 0) && ((grfKeyState & 2) == 0)) && ((grfKeyState & 0x10) == 0))
            {
                cancel = DragAction.Drop;
            }
            qcdevent = new QueryContinueDragEventArgs(grfKeyState, escapePressed, cancel);
            this.peer.OnQueryContinueDrag(qcdevent);
            switch (qcdevent.Action)
            {
            case DragAction.Drop:
                return(0x40100);

            case DragAction.Cancel:
                return(0x40101);
            }
            return(0);
        }
Ejemplo n.º 12
0
        internal DockOperation GetDockOperation(Point point, IVisual relativeTo, DragAction dragAction, Func <Point, DockOperation, DragAction, IVisual, bool> validate)
        {
            var result = DockOperation.Window;

            if (InvalidateIndicator(_leftSelector, _leftIndicator, point, relativeTo, DockOperation.Left, dragAction, validate))
            {
                result = DockOperation.Left;
            }

            if (InvalidateIndicator(_rightSelector, _rightIndicator, point, relativeTo, DockOperation.Right, dragAction, validate))
            {
                result = DockOperation.Right;
            }

            if (InvalidateIndicator(_topSelector, _topIndicator, point, relativeTo, DockOperation.Top, dragAction, validate))
            {
                result = DockOperation.Top;
            }

            if (InvalidateIndicator(_bottomSelector, _bottomIndicator, point, relativeTo, DockOperation.Bottom, dragAction, validate))
            {
                result = DockOperation.Bottom;
            }

            if (InvalidateIndicator(_centerSelector, _centerIndicator, point, relativeTo, DockOperation.Fill, dragAction, validate))
            {
                result = DockOperation.Fill;
            }

            return(result);
        }
Ejemplo n.º 13
0
 // Constructor.
 public QueryContinueDragEventArgs
     (int keyState, bool escapePressed, DragAction action)
 {
     this.keyState      = keyState;
     this.escapePressed = escapePressed;
     this.action        = action;
 }
Ejemplo n.º 14
0
 private void PointerDown(BaseEventData bed)
 {
     //PointerEventData ped = bed as PointerEventData;
     //Show.Log("click DOWN at " + ped.position+" "+ FrameRect().Contains(ped.position));
     ClearDrag();
     drag    = new DragAction(transform);
     enabled = true;
 }
Ejemplo n.º 15
0
 public DragNDropEventArgs(DraggableViewContainer dvc, /*DraggableView v,*/ DragAction action, float x, float y)
 {
     HoveredView = dvc;
     //  DraggedView = v;
     Action = action;
     X      = x;
     Y      = y;
 }
        public void Ctor_Int_Bool_DragAction(int keyState, bool escapePressed, DragAction action)
        {
            var e = new QueryContinueDragEventArgs(keyState, escapePressed, action);

            Assert.Equal(keyState, e.KeyState);
            Assert.Equal(escapePressed, e.EscapePressed);
            Assert.Equal(action, e.Action);
        }
Ejemplo n.º 17
0
 public void Init(DragAction funcDrag /*ref bool open*/, Action doSth)
 {
     OnDragAction = funcDrag;
     this.DoSth   = doSth;
     position     = transform.position;
     x            = transform.position.x;
     z            = transform.position.z;
     //isCanOpen = open;
 }
Ejemplo n.º 18
0
        private void Enter(Point point, DragAction dragAction, IVisual relativeTo)
        {
            var isValid = Validate(point, DockOperation.Fill, dragAction, relativeTo);

            if (isValid == true && _targetDropControl is DockPanel)
            {
                _adornerHelper.AddAdorner(_targetDropControl);
            }
        }
        public void Action_Set_GetReturnsExpected(DragAction value)
        {
            var e = new QueryContinueDragEventArgs(1, false, DragAction.Continue)
            {
                Action = value
            };

            Assert.Equal(value, e.Action);
        }
Ejemplo n.º 20
0
        private void Enter(Point point, DragAction dragAction, IVisual relativeTo)
        {
            var isValid = Validate(point, DockOperation.Fill, dragAction, relativeTo);

            if (isValid && _targetDropControl is { } control&& control.GetValue(DockProperties.IsDockTargetProperty))
            {
                _adornerHelper.AddAdorner(control);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnotatedEventVisualizationObjectView"/> class.
 /// </summary>
 public AnnotatedEventVisualizationObjectView()
 {
     this.InitializeComponent();
     this.DataContextChanged += this.AnnotatedEventVisualizationObjectView_DataContextChanged;
     this.SizeChanged        += this.AnnotatedEventVisualizationObjectView_SizeChanged;
     this.Unloaded           += this.AnnotatedEventVisualizationObjectView_Unloaded;
     this.Loaded             += (s, e) => this.Focus();
     this.dragAction          = DragAction.None;
 }
Ejemplo n.º 22
0
 void ClearDrag()
 {
     if (drag == null)
     {
         return;
     }
     drag.Cleanup();
     drag = null;
 }
Ejemplo n.º 23
0
        private void Enter(Point point, DragAction dragAction, IVisual relativeTo)
        {
            var isValid = Validate(point, DockOperation.Fill, dragAction, relativeTo);

            if (isValid == true && _targetDropControl is IControl control && control.GetValue(DockProperties.IsDockTargetProperty))
            {
                Debug.WriteLine($"[Enter] {control}");
                _adornerHelper.AddAdorner(control);
            }
        }
Ejemplo n.º 24
0
 public virtual void StopDrag(Point point)
 {
     if (IsBeingDragged)
     {
         DragAction?.Invoke(false, point, this);
         DragElement   = null;
         DragPosition  = null;
         TempDragPoint = null;
     }
 }
Ejemplo n.º 25
0
 public void End()
 {
     DragStartPoint    = default;
     PointerPressed    = false;
     DoDragDrop        = false;
     TargetDockControl = null;
     TargetPoint       = default;
     TargetDropControl = null;
     DragAction        = DragAction.Move;
 }
Ejemplo n.º 26
0
        private void Over(Point point, DragAction dragAction, IVisual relativeTo)
        {
            var operation = DockOperation.Fill;

            if (_adornerHelper.Adorner is DockTarget target)
            {
                operation = target.GetDockOperation(point, relativeTo, dragAction, Validate);
            }

            Validate(point, operation, dragAction, relativeTo);
        }
Ejemplo n.º 27
0
        public virtual void PerformClick(Point point, bool right, bool release, bool hold)
        {
            if (OutOfBounds || Disabled)
            {
                return;
            }

            if ((ClickAction != null || IsSelectable) && Bounds.Contains(point))
            {
                if (IsSelectable && !right && release)
                {
                    if (IsSelected)
                    {
                        Deselect();
                    }
                    else
                    {
                        Select();
                    }
                }

                if (IsDraggable && !right && hold && DragElement == null && DragAction != null && DragAction.Invoke(true, point, this) && !IsBeingDragged)
                {
                    DragElement   = this;
                    DragPosition  = null;
                    TempDragPoint = null;
                    if (DragPoint == Vector2.Zero)
                    {
                        var b = Bounds;
                        TempDragPoint = new Point(point.X - b.X, point.Y - b.Y);
                    }
                    PerformMouseMove(point);
                }

                if (IsBeingDragged && release && DragAction != null && DragAction.Invoke(false, point, this))
                {
                    DragPosition  = null;
                    DragElement   = null;
                    TempDragPoint = null;
                }

                ClickAction?.Invoke(point, right, release, hold, this);
            }

            foreach (UIElement child in Children.Where(c => c.Visible))
            {
                try
                {
                    child.PerformClick(point, right, release, hold);
                }
                catch { }
            }
        }
Ejemplo n.º 28
0
        private bool Validate(Point point, DockOperation operation, DragAction dragAction, IVisual relativeTo)
        {
            if (_dragControl == null || _dropControl == null)
            {
                return(false);
            }

            if (_dragControl.DataContext is IDockable sourceDockable && _dropControl.DataContext is IDockable targetDockable)
            {
                DockManager.Position       = DockHelpers.ToDockPoint(point);
                DockManager.ScreenPosition = DockHelpers.ToDockPoint(relativeTo.PointToScreen(point).ToPoint(1.0));
                return(DockManager.ValidateDockable(sourceDockable, targetDockable, dragAction, operation, bExecute: false));
            }

            return(false);
        }
Ejemplo n.º 29
0
        private void Drop(Point point, DragAction dragAction, IVisual relativeTo)
        {
            var operation = DockOperation.Window;

            if (_adornerHelper.Adorner is DockTarget target)
            {
                operation = target.GetDockOperation(point, relativeTo, dragAction, Validate);
            }

            if (_dropControl is DockPanel)
            {
                _adornerHelper.RemoveAdorner(_dropControl);
            }

            Execute(point, operation, dragAction, relativeTo);
        }
        /// <summary>
        /// Update cursor based on mouse position.
        /// </summary>
        /// <param name="pt">Postion of the mouse.</param>
        public void UpdateCursor(Point pt)
        {
            this.dragAction = this.HitTest(this.DynamicCanvas, pt);

            if (this.dragAction == DragAction.MoveStart || this.dragAction == DragAction.MoveEnd)
            {
                Mouse.OverrideCursor = Cursors.SizeWE;
            }
            else if (this.dragAction == DragAction.MoveEvent)
            {
                Mouse.OverrideCursor = Cursors.Hand;
            }
            else
            {
                Mouse.OverrideCursor = this.previousCursor;
            }
        }
Ejemplo n.º 31
0
        private void Drop(Point point, DragAction dragAction, IVisual relativeTo)
        {
            var operation = DockOperation.Window;

            if (_adornerHelper.Adorner is DockTarget target)
            {
                operation = target.GetDockOperation(point, relativeTo, dragAction, Validate);
            }

            if (_dropControl is IControl control && control.GetValue(DockProperties.IsDockTargetProperty))
            {
                Debug.WriteLine($"[Drop] {control}");
                _adornerHelper.RemoveAdorner(control);
            }

            Execute(point, operation, dragAction, relativeTo);
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Validate the drag action of DragDrop.
 /// </summary>
 internal static bool IsValidDragAction(DragAction dragAction)
 {
     if (dragAction == DragAction.Continue ||
         dragAction == DragAction.Drop ||
         dragAction == DragAction.Cancel)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 33
0
 private static int Resort(Item target, DragAction dragAction)
 {
     Assert.ArgumentNotNull(target, "target");
     int num = 0;
     int num2 = 0;
     foreach (Item item in target.Parent.Children)
     {
         item.Editing.BeginEdit();
         item.Appearance.Sortorder = num2 * 100;
         item.Editing.EndEdit();
         if (item.ID == target.ID)
         {
             num = (dragAction == DragAction.Before) ? ((num2 * 100) - 50) : ((num2 * 100) + 50);
         }
         num2++;
     }
     return num;
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Handle dragging the mouse within the game world.
 /// </summary>
 /// <param name="onStart">The method to be executed when mouse button is clicked first. Gets the mouse position as argument.</param>
 /// <param name="onDrag">The method to be executed when the mouse button remains clicked. Gets the mouse position as argument.</param>
 /// <param name="onStop">The method to be executed when the mouse button is released. Gets the mouse position as argument.</param>
 private void HandleWorldDrag(DragAction onStart, DragAction onDrag, DragAction onStop)
 {
     bool dragStart = Input.GetMouseButtonDown(0);
     bool dragContinued = Input.GetMouseButton(0);
     bool dragStopped = Input.GetMouseButtonUp(0);
     if (dragStart)
     {
         onStart.Invoke(Input.mousePosition);
     }
     if (dragContinued)
     {
         onDrag.Invoke(Input.mousePosition);
     }
     if (dragStopped)
     {
         onStop.Invoke(Input.mousePosition);
     }
 }
Ejemplo n.º 35
0
		private bool QueryContinue (bool escape, DragAction action)
		{
			QueryContinueDragEventArgs qce = new QueryContinueDragEventArgs ((int) XplatUI.State.ModifierKeys,
					escape, action);

			Control c = MwfWindow (source);
			
			if (c == null) {
				tracking = false;
				return false;
			}
			
			c.DndContinueDrag (qce);

			switch (qce.Action) {
			case DragAction.Continue:
				return true;
			case DragAction.Drop:
				SendDrop (drag_data.LastTopLevel, source, IntPtr.Zero);
				tracking = false;
				return true;
			case DragAction.Cancel:
				drag_data.Reset ();
				c.InternalCapture = false;
				break;
			}

			SendLeave (drag_data.LastTopLevel, toplevel);

			RestoreDefaultCursor ();
			tracking = false;
			return false;
		}
Ejemplo n.º 36
0
 public DragActions(DragAction onStartDrag, DragAction onKeepDrag, DragAction onStopDrag)
 {
     this.onStartDrag = onStartDrag;
     this.onKeepDrag = onKeepDrag;
     this.onStopDrag = onStopDrag;
 }
 // Constructors
 public QueryContinueDragEventArgs(int keyState, bool escapePressed, DragAction action)
 {
 }
Ejemplo n.º 38
0
        protected override void OnQueryContinueDrag( QueryContinueDragEventArgs e )
        {
            base.OnQueryContinueDrag( e );

            _lastDragAction = e.Action;
        }