PInputEventArgs is used to pass keyboard and mouse event data to PInputEventListeners.
This class has methods for normal event properties such as event modifier keys and event canvas location.

In addition it has methods to get the mouse position and delta in a variety of coordinate systems.

Last of all, it provides access to the dispatch manager that can be queried to find the current mouse over, mouse focus, and keyboard focus.

Пример #1
0
 /// <summary>
 /// When the user drags with both mouse actual, move the document
 /// </summary>
 public override void OnMouseDrag(object sender, PInputEventArgs e)
 {
     PNode aNode = (PNode)sender;
     SizeF delta = e.GetDeltaRelativeTo(aNode);
     aNode.TranslateBy(delta.Width, delta.Height);
     aNode.MoveToFront();
 }
Пример #2
0
        /// <summary>
        /// When the user presses a key, handle it appropriately
        /// </summary>
        /// <param Name="sender">The object that fired the event</param>
        /// <param Name="e">The key press</param>
        public override void OnKeyDown(object sender, PInputEventArgs e)
        {
            base.OnKeyDown(sender, e);
            char c = (char)e.KeyCode;

            //Keydown seems to assume they're all caps
            //All lower case looks better than all caps
            //So we'll force them to lower case
            if (c >= 'A' && c <= 'Z')
            {
                c = (char)(c + 32);
            }

            //If it's a letter or a number, add it to the text
            if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) { Owner.Entry.Text += c; }
            else
            {
                //Deal with control characters
                switch (c)
                {
                    case (char)Keys.Back: //Backspace
                        Owner.Entry.Text = Owner.Entry.Text.Substring(0, Owner.Entry.Text.Length - 1);
                        break;

                    case ' ': //Space
                        Owner.Entry.Text += ' ';
                        break;
                }
            }

            //Update the Width of the entry box
            UpdateWidth();
        }
 /// <summary>
 /// Called when a <see cref="PNode.MouseDrag">MouseDrag</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnMouseDrag(object sender, PInputEventArgs e)
 {
     if (MouseDrag != null)
     {
         MouseDrag(sender, e);
     }
 }
		protected void aNode_MouseDrag(object sender, PInputEventArgs e) {
			PNode aNode = (PNode)sender;
			SizeF delta = e.GetDeltaRelativeTo(aNode);
			aNode.TranslateBy(delta.Width, delta.Height);
			PrintEventCoords(e);
			e.Handled = true;
		}
 /// <summary>
 /// Called when a <see cref="PNode.MouseEnter">MouseEnter</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnMouseEnter(object sender, PInputEventArgs e)
 {
     if (MouseEnter != null)
     {
         MouseEnter(sender, e);
     }
 }
 /// <summary>
 /// Called when a <see cref="PNode.MouseLeave">MouseLeave</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnMouseLeave(object sender, PInputEventArgs e)
 {
     if (MouseLeave != null)
     {
         MouseLeave(sender, e);
     }
 }
 /// <summary>
 /// Called when a <see cref="PNode.DragDrop">DragDrop</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnDragDrop(object sender, PInputEventArgs e)
 {
     if (DragDrop != null)
     {
         DragDrop(sender, e);
     }
 }
 /// <summary>
 /// Called when a <see cref="PNode.KeyUp">KeyUp</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnKeyUp(object sender, PInputEventArgs e)
 {
     if (KeyUp != null)
     {
         KeyUp(sender, e);
     }
 }
 /// <summary>
 /// Called when a <see cref="PNode.DragOver">DragOver</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnDragOver(object sender, PInputEventArgs e)
 {
     if (DragOver != null)
     {
         DragOver(sender, e);
     }
 }
Пример #10
0
		protected void Camera_MouseDown(object sender, PInputEventArgs e) {
			if (e.PickedNode is PCamera) {
			} else {
				e.Handled = true;
				Canvas.Camera.AnimateViewToPanToBounds(e.PickedNode.GlobalFullBounds, 500);
			}
		}
 /// <summary>
 /// Called when a <see cref="PNode.MouseWheel">MouseWheel</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnMouseWheel(object sender, PInputEventArgs e)
 {
     if (MouseWheel != null)
     {
         MouseWheel(sender, e);
     }
 }
 /// <summary>
 /// Called when a <see cref="PNode.DragLeave">DragLeave</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnDragLeave(object sender, PInputEventArgs e)
 {
     if (DragLeave != null)
     {
         DragLeave(sender, e);
     }
 }
 /// <summary>
 /// Called when a <see cref="PNode.LostFocus">LostFocus</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnLostFocus(object sender, PInputEventArgs e)
 {
     if (LostFocus != null)
     {
         LostFocus(sender, e);
     }
 }
 /// <summary>
 /// Override this method to get notified when the drag activity stops stepping.
 /// </summary>
 /// <param name="sender">The source of the drag event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 protected virtual void OnDragActivityFinalStep(object sender, PInputEventArgs e)
 {
     if (DragActivityFinalStep != null)
     {
         DragActivityFinalStep(sender, e);
     }
 }
        /// <summary>
        /// Schedules the drag activity to run.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void StartDragActivity(PInputEventArgs e)
        {
            dragActivity = new PActivity(-1, PUtil.DEFAULT_ACTIVITY_STEP_RATE);
            dragActivity.ActivityDelegate = this;

            e.Camera.Root.AddActivity(dragActivity);
        }
 /// <summary>
 /// Called when a <see cref="PNode.DoubleClick">DoubleClick</see> event is sent to this
 /// listener.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 public virtual void OnDoubleClick(object sender, PInputEventArgs e)
 {
     if (DoubleClick != null)
     {
         DoubleClick(sender, e);
     }
 }
 /// <summary>
 /// Subclasses should override this method to get notified of the drag events in
 /// a drag sequence.
 /// </summary>
 /// <param name="sender">The source of the end drag event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 /// <remarks>
 /// This method is called in the middle of a drag sequence, between the
 /// <see cref="OnStartDrag"/> and the <see cref="OnEndDrag"/> methods.
 /// <para>
 /// Unlike the <see cref="OnMouseDrag"/> method, this method will not get called
 /// until after the <see cref="MinDragStartDistance"/> has been reached.
 /// </para>
 /// <para>
 /// <b>Notes to Inheritors:</b>  Overriding methods must still call
 /// <c>base.OnDrag()</c> for correct behavior.
 /// </para>
 /// </remarks>
 protected virtual void OnDrag(object sender, PInputEventArgs e)
 {
     dragEvent = e;
     if (Drag != null)
     {
         Drag(sender, e);
     }
 }
        /// <summary>
        /// Overridden.  See <see cref="PDragSequenceEventHandler.OnDrag">
        /// PDragSequenceEventHandler.OnDrag</see>.
        /// </summary>
        protected override void OnDrag(object sender, PInputEventArgs e)
        {
            base.OnDrag(sender, e);
            SizeF s = e.GetDeltaRelativeTo(draggedNode);

            s = draggedNode.LocalToParent(s);
            draggedNode.OffsetBy(s.Width, s.Height);
        }
 /// <summary>
 /// The filter for a PDragEventHandler.  This method only accepts left mouse button
 /// events that have not yet been handled.
 /// </summary>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 /// <returns>
 /// True if the event is an unhandled left mouse button event; otherwise, false.
 /// </returns>
 protected virtual bool PDragEventHandlerAcceptsEvent(PInputEventArgs e)
 {
     if (!e.Handled && e.IsMouseEvent && e.Button == MouseButtons.Left)
     {
         return(true);
     }
     return(false);
 }
Пример #20
0
			protected override void OnStartDrag(object sender, PInputEventArgs e) {
				base.OnStartDrag (sender, e);

				squiggle = new PPath();
				lastPoint = e.Position;
				squiggle.Pen = new Pen(Brushes.Black, (float)(1/ e.Camera.ViewScale));
				layer.AddChild(squiggle);
			}
        //****************************************************************
        // Event Filter - All event listeners can be associated with event
        // filters.  An event filter is simply a callback that either
        // accepts or rejects events.  Inheriters can override
        // DoesAcceptEvent and filter out undesirable events there.  Or,
        // the AcceptsEvent delegate can be set directly to a method that
        // filters events.
        //****************************************************************

        /// <summary>
        /// Returns true if the filter accepts the given event and false otherwise.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        /// <returns>True if the filter accepts the event; otherwise, false.</returns>
        public virtual bool DoesAcceptEvent(PInputEventArgs e)
        {
            if (this.AcceptsEvent != null)
            {
                return(AcceptsEvent(e));
            }
            return(true);
        }
 /// <summary>
 /// Overridden.  See <see cref="PDragSequenceEventHandler.ShouldStartDragInteraction">
 /// PDragSequenceEventHandler.ShouldStartDragInteraction</see>.
 /// </summary>
 protected override bool ShouldStartDragInteraction(PInputEventArgs e)
 {
     if (base.ShouldStartDragInteraction(e))
     {
         return(e.PickedNode != e.TopCamera);
     }
     return(false);
 }
 /// <summary>
 /// When the drag is started, record the location it started at
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="end"></param>
 protected override void OnStartDrag(object sender, PInputEventArgs e)
 {
     base.OnStartDrag(sender, e);
     if (sender is PStyledText)
     {
         DragStart = e.Position;
         CurrentSelection = null;
     }
 }
 /// <summary>
 /// Overridden.  See <see cref="PDragSequenceEventHandler.OnStartDrag">
 /// PDragSequenceEventHandler.OnStartDrag</see>.
 /// </summary>
 protected override void OnStartDrag(object sender, PInputEventArgs e)
 {
     base.OnStartDrag(sender, e);
     draggedNode = e.PickedNode;
     if (moveToFrontOnPress)
     {
         draggedNode.MoveToFront();
     }
 }
Пример #25
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected override void ResizeHandle_MouseDown(object sender, PInputEventArgs e)
 {
     // If selected system overlaps another, reset system region.
     if (m_canvas.DoesSystemOverlaps((PPathwaySystem)m_obj) || !m_obj.Offset.IsEmpty)
     {
         ResetSystemResize();
         return;
     }
     base.ResizeHandle_MouseDown(sender, e);
 }
		public override void OnMouseDown(object sender, PInputEventArgs e) {
			if (lastEditedControl != null) lastEditedControl.Editing = false;

			PNode node = e.PickedNode;
			if (node is PControl) {
				e.Handled = true;
				base.OnMouseDown (sender, e);
				lastEditedControl = (PControl)node;
			}
		}
        /// <summary>
        /// Accept only unhandled mouse events that invlove the left mouse button
        /// </summary>
        /// <param name="end"></param>
        /// <returns></returns>
        public override bool DoesAcceptEvent(PInputEventArgs e)
        {
            if (base.DoesAcceptEvent(e) && !e.Handled && e.IsMouseEvent && e.Button == MouseButtons.Left)
            {
                e.Handled = true;
                return true;

            }
            return false;
        }
Пример #28
0
 /// <summary>
 /// Whether the handler fires for a specific event
 /// </summary>
 /// <param Name="e">The event to test</param>
 /// <returns>Whether it fires</returns>
 public override bool DoesAcceptEvent(PInputEventArgs e)
 {
     //If either the user presses escape, or the interface will accept the event, accept the event
     if ((Interface.Accepts(e) || (e.IsKeyEvent && e.KeyCode == Keys.Escape)) && base.DoesAcceptEvent(e))
     {
         e.Handled = true;
         return true;
     }
     return false;
 }
Пример #29
0
		public void UpdateToolTip(PInputEventArgs e) {
			PNode n = e.InputManager.MouseOver.PickedNode;
			String tooltipString = (String) n.Tag;
			PointF p = e.CanvasPosition;

			p = e.Path.CanvasToLocal(p, Canvas.Camera);
				
			tooltipNode.Text = tooltipString;
			tooltipNode.SetOffset(p.X + 8, p.Y - 8);
		}
Пример #30
0
        /// <summary>
        /// Pans the camera as the mouse is dragged.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void Pan(PInputEventArgs e)
        {
            PCamera c = e.Camera;
            PointF  l = e.Position;

            if (c.ViewBounds.Contains(l))
            {
                SizeF s = e.Delta;
                c.TranslateViewBy(s.Width, s.Height);
            }
        }
		/// <summary>
		/// Overridden.  Accepts left mouse button events and non-mouse events.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <returns>
		/// True if the event is a left mouse button event or non-mouse event; otherwise,
		/// false.
		/// </returns>
		public override bool DoesAcceptEvent(PInputEventArgs e) {
			if (base.DoesAcceptEvent (e)) {
				if (e.IsMouseEvent) {
					if (e.Button == MouseButtons.Left) {
						return true;
					}
				}
				else return true;
			}
			return false;
		}
 /// <summary>
 /// Subclasses should override this method to get notified of the end event in
 /// a drag sequence.
 /// </summary>
 /// <param name="sender">The source of the end drag event.</param>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 /// <remarks>
 /// This method is called at the end of a drag sequence.
 /// <para>
 /// </para>
 /// Unlike the <see cref="OnMouseDrag"/> method, this method will not get called
 /// until after the <see cref="MinDragStartDistance"/> has been reached.
 /// <para>
 /// <b>Notes to Inheritors:</b>  Overriding methods must still call
 /// <c>base.OnEndDrag()</c> for correct behavior.
 /// </para>
 /// </remarks>
 protected virtual void OnEndDrag(object sender, PInputEventArgs e)
 {
     StopDragActivity(e);
     dragEvent            = null;
     source               = null;
     e.Canvas.Interacting = false;
     Dragging             = false;
     if (EndDrag != null)
     {
         EndDrag(sender, e);
     }
 }
		public override void OnMouseDown(object sender, PInputEventArgs e) {
			base.OnMouseDown (sender, e);

			if (lastEditedControl != null) lastEditedControl.Editing = false;

			PNode node = e.PickedNode;
			if (node is PControl) {
				e.Handled = true;
				DirectCameraViewToFocus(e.Camera, node, e.Path, 300);
				lastEditedControl = (PControl)node;
			}
		}
Пример #34
0
        public void MasterLayer_OnMouseDown(object sender, PInputEventArgs e)
        {
            if (e.PickedNode.Tag.GetType().ToString().Contains("SectorSprite"))
                {
                    setOriginalText(pSelectedNode);

                    SectorSprite tmp2 = (SectorSprite)e.PickedNode.Tag;
                    PText pnameNew = tmp2.getText();
                    pnameNew.TextBrush = Brushes.Red;
                }
                pSelectedNode = e.PickedNode;
        }
		/// <summary>
		/// Animates the camera's view, panning and scaling when necessary, to fully fit the
		/// bounds of the picked node into the camera's view bounds.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		protected virtual void ZoomTo(PInputEventArgs e) {
			RectangleF zoomToBounds;
			PNode picked = e.PickedNode;
		
			if (picked is PCamera) {
				PCamera c = (PCamera) picked;
				zoomToBounds = c.UnionOfLayerFullBounds;
			} else {
				zoomToBounds = picked.GlobalFullBounds;
			}
		
			e.Camera.AnimateViewToCenterBounds(zoomToBounds, true, 500);
		}
        /// <summary>
        /// Overridden.  See <see cref="PBasicInputEventHandler.OnMouseUp">
        /// PBasicInputEventHandler.OnMouseUp</see>.
        /// </summary>
        public override void OnMouseUp(object sender, PInputEventArgs e)
        {
            base.OnMouseUp(sender, e);

            if (sequenceInitiatedButton == e.Button)
            {
                if (Dragging)
                {
                    OnEndDrag(sender, e);
                }
                sequenceInitiatedButton = MouseButtons.None;
            }
        }
        //****************************************************************
        // Dragging - Methods to indicate the stages of the drag sequence.
        //****************************************************************

        /// <summary>
        /// Subclasses should override this method to get notified of the start of a new
        /// drag sequence.
        /// </summary>
        /// <param name="sender">The source of the start drag event.</param>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        /// <remarks>
        /// This method is called at the beginning of a drag sequence.
        /// <para>
        /// Unlike the <see cref="OnMouseDrag"/> method, this method will not get called
        /// until after the <see cref="MinDragStartDistance"/> has been reached.
        /// </para>
        /// <para>
        /// <b>Notes to Inheritors:</b>  Overriding methods must still call
        /// <c>base.OnStartDrag()</c> for correct behavior.
        /// </para>
        /// </remarks>
        protected virtual void OnStartDrag(object sender, PInputEventArgs e)
        {
            dragEvent = e;
            source    = sender;
            StartDragActivity(e);
            Dragging             = true;
            e.Canvas.Interacting = true;

            if (StartDrag != null)
            {
                StartDrag(sender, e);
            }
        }
        /// <summary>
        /// Overridden.  See <see cref="PBasicInputEventHandler.OnMouseDrag">
        /// PBasicInputEventHandler.OnMouseDrag</see>.
        /// </summary>
        public override void OnMouseDrag(object sender, PInputEventArgs e)
        {
            base.OnMouseDrag(sender, e);

            if (sequenceInitiatedButton != MouseButtons.None)
            {
                if (!Dragging)
                {
                    if (ShouldStartDragInteraction(e))
                    {
                        OnStartDrag(sender, e);
                    }
                    return;
                }
                OnDrag(sender, e);
            }
        }
Пример #39
0
        /// <summary>
        /// When the user types, create a new document and put the input inside of it
        /// </summary>
        public override void OnKeyPress(object sender, PInputEventArgs e)
        {
            base.OnKeyPress(sender, e);
            //Only fire if it isn't a control character
            if (e.KeyChar >= ' ' && e.KeyChar <= '~')
            {
                //Create the document in the last clicked location
                float x = LastPoint.X;
                float y = LastPoint.Y;
                Document created = new Document(x, y, e.KeyChar, (Window)Owner.FindForm());
                Owner.Layer.AddChild(created);

                //Shift the keyboard focus to the newly created document
                PStyledText firstPage = created.Pages[0];
                e.InputManager.KeyboardFocus = firstPage.ToPickPath(e.Camera, firstPage.Bounds);
            }
        }
Пример #40
0
        /// <summary>
        /// Perform the search
        /// </summary>
        public override void Execute(object sender, UMD.HCIL.Piccolo.Event.PInputEventArgs e)
        {
            //If the user is highlighting the last jump, do that
            if (SearchType == Direction.Highlight)
            {
                Highlight();
            }
            //If the user is searching, perform the search
            else if (SearchType == Direction.Forward || SearchType == Direction.Backward)
            {
                Search();
            }

            //Reset the direction detection flags
            _ForwardPressed = _BackPressed = false;
            SearchType      = Direction.None;
        }
			public override void OnMouseDown(object sender, PInputEventArgs e) {
				base.OnMouseDown (sender, e);

				PLayer layer = canvas.Layer;

				// Initialize the locations.
				pressPoint = e.Position;
				dragPoint = pressPoint; 			
				
				// create a new rectangle and add it to the canvas layer so that
				// we can see it.
				rectangle = new PPath();
				rectangle.Pen = new Pen(Brushes.Black, (float)(1/ e.Camera.ViewScale));
				layer.AddChild(rectangle);
				
				// update the rectangle shape.
				UpdateRectangle();
			}
 public void OnMouseWheel(object o, PInputEventArgs ea)
 {
     float currentScale = camera.ViewScale;
     float scaleDelta = (1.0f + (0.001f * ea.WheelDelta));
     float newScale = currentScale * scaleDelta;
     if (newScale < MIN_SCALE)
     {
         camera.ViewScale = MIN_SCALE;
         return;
     }
     if ((MAX_SCALE > 0) && (newScale > MAX_SCALE))
     {
         camera.ViewScale = MAX_SCALE;
         return;
     }
     PointF pos = ea.Position;
     camera.ScaleViewBy(scaleDelta, pos.X, pos.Y);
 }
Пример #43
0
        /// <summary>
        /// Overridden.  Do auto-panning even when the mouse is not moving.
        /// </summary>
        /// <param name="sender">The source of the drag event.</param>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected override void OnDragActivityStep(object sender, PInputEventArgs e)
        {
            base.OnDragActivityStep(sender, e);

            if (!autopan)
            {
                return;
            }

            PCamera    c = e.Camera;
            RectangleF b = c.Bounds;
            PointF     l = e.GetPositionRelativeTo(c);

            PUtil.OutCode outcode = PUtil.RectangleOutCode(l, b);
            SizeF         delta   = SizeF.Empty;

            if ((outcode & PUtil.OutCode.Top) != 0)
            {
                delta.Height = ValidatePanningDelta(-1.0f - (0.5f * Math.Abs(l.Y - b.Y)));
            }
            else if ((outcode & PUtil.OutCode.Bottom) != 0)
            {
                delta.Height = ValidatePanningDelta(1.0f + (0.5f * Math.Abs(l.Y - (b.Y + b.Height))));
            }

            if ((outcode & PUtil.OutCode.Right) != 0)
            {
                delta.Width = ValidatePanningDelta(1.0f + (0.5f * Math.Abs(l.X - (b.X + b.Width))));
            }
            else if ((outcode & PUtil.OutCode.Left) != 0)
            {
                delta.Width = ValidatePanningDelta(-1.0f - (0.5f * Math.Abs(l.X - b.X)));
            }

            delta = c.LocalToView(delta);

            if (delta.Width != 0 || delta.Height != 0)
            {
                c.TranslateViewBy(delta.Width, delta.Height);
            }
        }
        //****************************************************************
        // Events - Subclasses should not override these methods, instead
        // override the appropriate drag method.
        //****************************************************************

        /// <summary>
        /// Overridden.  See <see cref="PBasicInputEventHandler.OnMouseDown">
        /// PBasicInputEventHandler.OnMouseDown</see>.
        /// </summary>
        public override void OnMouseDown(object sender, PInputEventArgs e)
        {
            base.OnMouseDown(sender, e);

            if (sequenceInitiatedButton == MouseButtons.None)
            {
                sequenceInitiatedButton = e.Button;
            }
            else
            {
                return;
            }

            MousePressedCanvasPoint = e.CanvasPosition;
            if (!Dragging)
            {
                if (ShouldStartDragInteraction(e))
                {
                    OnStartDrag(sender, e);
                }
            }
        }
Пример #45
0
        /// <summary>
        /// Overridden.  See <see cref="PDragSequenceEventHandler.OnDragActivityStep">
        /// PDragSequenceEventHandler.OnDragActivityStep</see>.
        /// </summary>
        protected override void OnDragActivityStep(object sender, PInputEventArgs e)
        {
            base.OnDragActivityStep(sender, e);

            PCamera camera     = e.Camera;
            float   dx         = e.CanvasPosition.X - MousePressedCanvasPoint.X;
            float   scaleDelta = (1.0f + (0.001f * dx));

            float currentScale = camera.ViewScale;
            float newScale     = currentScale * scaleDelta;

            if (newScale < minScale)
            {
                scaleDelta = minScale / currentScale;
            }

            if ((maxScale > 0) && (newScale > maxScale))
            {
                scaleDelta = maxScale / currentScale;
            }

            camera.ScaleViewBy(scaleDelta, viewZoomPoint.X, viewZoomPoint.Y);
        }
		/// <summary>
		/// Ends a marquee selection sequence.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified
		/// at the End of a marquee selection sequence.
		/// <para>
		/// Overriding methods must still call <c>base.EndMarqueeSelection()</c> for correct
		/// behavior.
		/// </para>
		/// </remarks>
		protected virtual void EndMarqueeSelection(PInputEventArgs e) {
			// Remove marquee
			marquee.RemoveFromParent();
			marquee = null;
		}
		/// <summary>
		/// Drags the nodes in a standard selection.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified
		/// while a standard selection is being dragged.
		/// <para>
		/// Overriding methods must still call <c>base.DragStandardSelection()</c> for correct
		/// behavior.
		/// </para>
		/// </remarks>
		protected virtual void DragStandardSelection(PInputEventArgs e) {
			// There was a press node, so drag selection
			SizeF s = e.CanvasDelta;
			s = e.TopCamera.LocalToView(s);

			ICollection sel = selection.Keys;
			foreach (PNode node in sel) {
				s = node.Parent.GlobalToLocal(s);
				node.OffsetBy(s.Width, s.Height);
			}
		}
		/// <summary>
		/// Select the selectable nodes whose bounds intersect the marquee, without
		/// unselecting previously selected nodes.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		protected virtual void ComputeOptionMarqueeSelection(PInputEventArgs e) {
			unselectList.Clear();
			// Make just the items in the list selected
			// Do this efficiently by first unselecting things not in the list
			ICollection sel = selection.Keys;
			foreach (PNode node in sel) {
				if (!allItems.ContainsKey(node) && marqueeMap.ContainsKey(node)) {
					marqueeMap.Remove(node);
					unselectList.Add(node);
				}
			}
			Unselect(unselectList);
		
			// Then select the rest
			TEMP_LIST.Clear();
			TEMP_LIST.AddRange(allItems.Keys);

			foreach (PNode node in TEMP_LIST) {
				if (!selection.ContainsKey(node) && !marqueeMap.ContainsKey(node) && IsSelectable(node)) {
					marqueeMap.Add(node,true);
				}
				else if (!IsSelectable(node)) {
					allItems.Remove(node);
				}
			}

			Select(allItems);
		}
		/// <summary>
		/// Update the marquee bounds based on the given event data.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		protected virtual void UpdateMarquee(PInputEventArgs e) {
			RectangleF r = RectangleF.Empty;

			if (marqueeParent is PCamera) {
				r = PUtil.AddPointToRect(r, canvasPressPt);
				r = PUtil.AddPointToRect(r, e.CanvasPosition);
			}
			else {
				r = PUtil.AddPointToRect(r, presspt);
				r = PUtil.AddPointToRect(r, e.Position);
			}

			r = marquee.GlobalToLocal(r);
			marquee.Reset();
			SetSafeMarqueePen(r.Width, r.Height);
			marquee.AddRectangle(r.X, r.Y, r.Width, r.Height);

			r = RectangleF.Empty;
			r = PUtil.AddPointToRect(r, presspt);
			r = PUtil.AddPointToRect(r, e.Position);

			allItems.Clear();
			PNodeFilter filter = CreateNodeFilter(r);
			foreach (PNode parent in selectableParents) {			
				PNodeList items;
				if (parent is PCamera) {
					items = new PNodeList();
					PCamera cameraParent = (PCamera)parent;
					for(int i=0; i<cameraParent.LayerCount; i++) {
						cameraParent.GetLayer(i).GetAllNodes(filter,items);	
					}
				}
				else {
					items = parent.GetAllNodes(filter, null);
				}
			
				foreach (PNode node in items) {
					allItems.Add(node, true);
				}
			}
		}
		/// <summary>
		/// Starts an option selection sequence (i.e. a selection sequence where the
		/// <c>Shift</c> key was pressed).
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified at
		/// the beginning of an option selection sequence.
		/// <para>
		/// Overriding methods must still call <c>base.StartStandardOptionSelection()</c> for
		/// correct behavior.
		/// </para>
		/// </remarks>
		protected virtual void StartStandardOptionSelection(PInputEventArgs e) {
			// Option indicator is down, toggle selection
			if (IsSelectable(pressNode)) {
				if (IsSelected(pressNode)) {
					Unselect(pressNode);
				} else {
					Select(pressNode);
				}
			}
		}
		/// <summary>
		/// Starts a standard selection sequence.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified at
		/// the beginning of a standard selection sequence.
		/// <para>
		/// Overriding methods must still call <c>base.StartStandardSelection()</c> for correct
		/// behavior.
		/// </para>
		/// </remarks>
		protected virtual void StartStandardSelection(PInputEventArgs e) {
			// Option indicator not down - clear selection, and Start fresh
			if (!IsSelected(pressNode)) {
				UnselectAll();
			
				if (IsSelectable(pressNode)) {
					Select(pressNode);
				}
			}
		}
		/// <summary>
		/// Overridden.  Deletes selection when delete key is pressed (if enabled).
		/// </summary>
		/// <param name="sender">The source of the PInputEvent.</param>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		public override void OnKeyDown(object sender, PInputEventArgs e) {
			base.OnKeyDown (sender, e);
			switch (e.KeyCode) {
				case Keys.Delete:
					if (deleteKeyActive) {
						ICollection sel = selection.Keys;
						foreach (PNode node in sel) {
							node.RemoveFromParent();
						}
						selection.Clear();
					}
					break;
			}
		}
		/// <summary>
		/// Starts an option marquee selection sequence (i.e. a marquee selection
		/// sequence where the <c>Shift</c> key was pressed).
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified at
		/// the beginning of an option marquee selection sequence.
		/// <para>
		/// Overriding methods must still call <c>base.StartOptionMarqueeSelection()</c> for
		/// correct behavior.
		/// </para>
		/// </remarks>
		protected virtual void StartOptionMarqueeSelection(PInputEventArgs e) {
		}
Пример #54
0
 /// <summary>
 /// Overridden.  See <see cref="PDragSequenceEventHandler.OnDragActivityFirstStep">
 /// PDragSequenceEventHandler.OnDragActivityFirstStep</see>.
 /// </summary>
 protected override void OnDragActivityFirstStep(object sender, PInputEventArgs e)
 {
     viewZoomPoint = e.Position;
     base.OnDragActivityFirstStep(sender, e);
 }
		/// <summary>
		/// Ends a standard selection sequence.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified
		/// at the End of a standard selection sequence.
		/// <para>
		/// Overriding methods must still call <c>base.EndStandardSelection()</c> for correct
		/// behavior.
		/// </para>
		/// </remarks>
		protected virtual void EndStandardSelection(PInputEventArgs e) {
			pressNode = null;
		}
		/// <summary>
		/// Starts a marquee selection sequence.
		/// </summary>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified
		/// at the beginning of a marquee selection sequence.
		/// <para>
		/// Overriding methods must still call <c>base.StartMarqueeSelection()</c> for correct
		/// behavior.
		/// </para>
		/// </remarks>
		protected virtual void StartMarqueeSelection(PInputEventArgs e) {
			UnselectAll();
		}
		/// <summary>
		/// Overridden.  This gets called continuously during the drag, and is used
		/// to animate the marquee.
		/// </summary>
		/// <param name="sender">The source of the PInputEvent.</param>
		/// <param name="e">A PInputEventArgs that contains the event data.</param>
		protected override void OnDragActivityStep(object sender, PInputEventArgs e) {
			base.OnDragActivityStep (sender, e);
			if (marquee != null) {
				float origPenNum = penNum;
				penNum = (penNum + 0.5f) % NUM_PENS;	// Increment by partial steps to slow down animation
				if ((int)penNum != (int)origPenNum && !SetSafeMarqueePen(marquee.Width, marquee.Height)) {
					marquee.Pen = pens[(int)penNum];
				}
			}
		}
 /// <summary>
 /// The filter for a PBasicInputEventHandler.  This method only rejects an event
 /// if it has already been marked as handled.
 /// </summary>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 /// <returns>True if the event has not been handled; otherwise, false.</returns>
 protected virtual bool PBasicInputEventHandlerAcceptsEvent(PInputEventArgs e)
 {
     return(!e.Handled);
 }
Пример #59
0
			public override void OnMouseUp(PInputEventArgs e) {
				DayNode pickedDay = (DayNode) e.PickedNode;
				if (pickedDay.HasWidthFocus && pickedDay.HasHeightFocus) {
					SetFocusDay(null, true);
				} else {
					SetFocusDay(pickedDay, true);
				}
			}
 /// <summary>
 /// Overridden.  See <see cref="PDragSequenceEventHandler.OnEndDrag">
 /// PDragSequenceEventHandler.OnEndDrag</see>.
 /// </summary>
 protected override void OnEndDrag(object sender, PInputEventArgs e)
 {
     base.OnEndDrag(sender, e);
     draggedNode = null;
 }