public override bool DoesAcceptEvent(PInputEventArgs e) { if (e.IsDragDropEvent) { var dict = CreateDropItems(e.DragDropData); foreach (var o in dict.Values) { if (o is IIDItem) { return(Host.AcceptsSolid(o as IIDItem)); } if (o is string) { return(Host.AcceptsSolid(o as string)); } } return(false); } else { return(false); } }
/// <summary> /// Changes which suggestion is currently being selected /// Based on whether the userr pressed up or down arrow /// or another character /// </summary> /// <param Name="e">The key press that triggered the chage</param> protected void UpdateCurrentSuggestion(PInputEventArgs e) { switch (e.KeyCode) { //When the user presses down, select the next suggestion in the list if possible case Keys.Down: if (CurrentSuggestion < Suggestions.Length - 1) { CurrentSuggestion += 1; } break; //When the user presses up, select the previous suggestion in the list, if possible case Keys.Up: if (CurrentSuggestion > 0) { CurrentSuggestion -= 1; } break; //If the user presses anything else, the suggestion list probably changed //So we want the first item in the list again default: CurrentSuggestion = 0; break; } }
/// <summary> /// Update the autocomplte, suggestions, and preview every time a key is pressed /// </summary> private void EntryKeyUp(object sender, PInputEventArgs e) { if (ShouldAutoComplete) { //Because the system autofills the rest of the command Name when //it becomes unambiguous (e.g. tr -> translate) to save the user //unnecesery keypresses, pressing backspace should have a similar effect //Therefore, any backspaces should delete until there are at least two //different commands it could be if (e.KeyCode == Keys.Back) { TruncateUntilAmbiguous(); } //Prevent the user from entering text that isn't a command else { EnsureEnteredTextMatchesCommand(); } //If the Name of the command the user is trying to type is unambiuous //Or they have pressed tab, indicating they want to use the suggested command Name //Autofill the rest of the command Name for them if ((Suggestions.Length == 1 || e.KeyCode == Keys.Tab)) { ConfirmAutoComplete(); } } //Adjust which of the suggestions the user has selected UpdateCurrentSuggestion(e); //Update the suggestions or preview, as appropriate UpdateAuxillaryBox(); }
/// <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> /// Accept all drag events performed with both mouse actual /// </summary> /// <param Name="e">The event to test</param> /// <returns>Whether the event is accepted</returns> public override bool DoesAcceptEvent(PInputEventArgs e) { bool output = (base.DoesAcceptEvent(e) && (e.Button == (MouseButtons.Left | MouseButtons.Right))); e.Handled = output; return(output); }
public override void OnMouseUp(object sender, PInputEventArgs e) { base.OnMouseUp(sender, e); // update the rectangle shape. UpdateRectangle(); rectangle = null; }
/// <summary> /// Go to the slide that was clicked. /// </summary> protected void Camera_MouseDown(object sender, PInputEventArgs e) { if ((slides == null) || (slides.Count == 0)) { return; } PNode picked = e.PickedNode; if (picked.Parent == slideBar) { if (picked == focusSlide) { int newIndex = (int)focusSlide.Tag + 1; if (newIndex < slides.Count) { GoToSlide((PMultiSizeImage)slides[newIndex]); } } else { GoToSlide((PMultiSizeImage)picked); } } }
protected override void OnStartDrag(object sender, PInputEventArgs e) { DObj.MoveToBack(); e.Handled = true; PNode p1 = ((PNode)sender).Parent; PNode p2 = (PNode)sender; var edge = new DiagEdEdge(); if (p1.Tag == null) { p1.Tag = new List <DiagEdEdge>(); } if (p2.Tag == null) { p2.Tag = new List <DiagEdEdge>(); } ((List <DiagEdEdge>)p1.Tag).Add(edge); ((List <DiagEdEdge>)p2.Tag).Add(edge); edge.start = p1; edge.end = p2; edge.originator = DObj; ConvGraphEditor.addEdge(edge); base.OnStartDrag(sender, e); draggingOutlink = true; }
protected override void OnStartDrag(object sender, PInputEventArgs e) { if (e.PickedNode == bev.areaVisiblePNode) { base.OnStartDrag(sender, e); } }
//**************************************************************** // Dragging - Overridden methods from PDragSequenceEventHandler //**************************************************************** /// <summary> /// Overridden. See <see cref="PDragSequenceEventHandler.OnStartDrag"> /// PDragSequenceEventHandler.OnStartDrag</see>. /// </summary> protected override void OnStartDrag(object sender, PInputEventArgs e) { base.OnStartDrag(sender, e); InitializeSelection(e); if (IsMarqueeSelection(e)) { InitializeMarquee(e); if (!IsOptionSelection(e)) { StartMarqueeSelection(e); } else { StartOptionMarqueeSelection(e); } } else { if (!IsOptionSelection(e)) { StartStandardSelection(e); } else { StartStandardOptionSelection(e); } } }
/// <summary> /// Subclasses should override this method to get notified when the handle stops /// getting dragged. /// </summary> /// <param name="sender">The source of this handle drag event.</param> /// <param name="point">The drag position relative to the handle.</param> /// <param name="e">A PInputEventArgs that contains the event data.</param> public virtual void OnEndHandleDrag(object sender, PointFx point, PInputEventArgs e) { if (EndHandleDrag != null) { EndHandleDrag(sender, point, e); } }
/// <summary> /// Subclasses should override this method to get notified as the handle is dragged. /// </summary> /// <param name="sender">The source of this handle drag event.</param> /// <param name="size">The drag delta relative to the handle.</param> /// <param name="e">A PInputEventArgs that contains the event data.</param> public virtual void OnHandleDrag(object sender, SizeFx size, PInputEventArgs e) { if (HandleDrag != null) { HandleDrag(sender, size, e); } }
protected override void OnStartDrag(object sender, PInputEventArgs e) { base.OnStartDrag(sender, e); draggedNode = e.PickedNode; draggedNode.MoveToFront(); nodeStartPosition = draggedNode.Offset; }
/// <summary> /// Overridden. Notifies the node whose bounds this handle is locating itself on that /// the resize bounds sequence is finisheed. /// </summary> /// <param name="sender">The source of this handle drag event.</param> /// <param name="point">The drag position relative to the handle.</param> /// <param name="e">A PInputEventArgs that contains the event data.</param> public override void OnEndHandleDrag(object sender, PointF point, PInputEventArgs e) { base.OnEndHandleDrag(sender, point, e); PBoundsLocator l = (PBoundsLocator)Locator; l.Node.EndResizeBounds(); }
//**************************************************************** // Event Handling - Methods for handling events // // The dispatch manager updates the focus nodes based on the // incoming events, and dispatches those events to the appropriate // focus nodes. //**************************************************************** /// <summary> /// Create a new PInputEvent based on the next windows event and dispatch it to Piccolo. /// </summary> public virtual void ProcessInput() { if (nextInput == null) { return; } PInputEventArgs e = new PInputEventArgs(this, nextInput, nextType); //The EventArgs object for a Click event does not provide the position, so //we just ignore it here. if (e.IsMouseEvent || e.IsDragDropEvent) { lastCanvasPosition = currentCanvasPosition; if (e.IsMouseEvent) { currentCanvasPosition = new PointF(((MouseEventArgs)nextInput).X, ((MouseEventArgs)nextInput).Y); } else { Point pt = new Point((int)((DragEventArgs)nextInput).X, (int)((DragEventArgs)nextInput).Y); currentCanvasPosition = nextWindowsSource.PointToClient(pt); } PPickPath pickPath = nextInputSource.Pick(currentCanvasPosition.X, currentCanvasPosition.Y, 1); MouseOver = pickPath; } nextInput = null; nextInputSource = null; Dispatch(e); }
public void DragHandleOneHandler(object sender, SizeF localDelta, PInputEventArgs e) { SizeF parentDelta = LocalToParent(localDelta); PointOne = new PointF(PointOne.X + parentDelta.Width, PointOne.Y + parentDelta.Height); ((PHandle)sender).RelocateHandle(); }
//**************************************************************** // Handle Dragging - These are the methods the subclasses should // normally override to give a handle unique behavior. //**************************************************************** /// <summary> /// Subclasses should override this method to get notified when the handle starts /// to get dragged. /// </summary> /// <param name="sender">The source of this handle drag event.</param> /// <param name="point">The drag position relative to the handle.</param> /// <param name="e">A PInputEventArgs that contains the event data.</param> public virtual void OnStartHandleDrag(object sender, PointF point, PInputEventArgs e) { if (StartHandleDrag != null) { StartHandleDrag(sender, point, e); } }
public override void OnClick(object sender, PInputEventArgs e) { base.OnClick(sender, e); Point position = new Point((int)e.Position.X, (int)e.Position.Y); //if (e.PickedNode is Surface && MullionType != null // && !(e.PickedNode.Parent is Sash)) if (e.PickedNode is Surface && MullionType != null) { RectangleF mBounds = new RectangleF( position.X, position.Y, MullionType.ProfileType.Thickness, MullionType.ProfileType.Thickness ); if (Orientation == Orientation.Horizontal) { mBounds.Y = mBounds.Y - mBounds.Height / 2; if (e.PickedNode.Bounds.Contains(mBounds)) { SurfaceLayoutManager.AddChild(surface, position, SurfaceLayout.VERTICAL, MullionType); } } else { mBounds.X = mBounds.X - mBounds.Height / 2; if (e.PickedNode.Bounds.Contains(mBounds)) { SurfaceLayoutManager.AddChild(surface, position, SurfaceLayout.HORIZONTAL, MullionType); } } } }
public void DragHandleTwoHandler(object sender, SizeFx localDelta, PInputEventArgs e) { SizeFx parentDelta = LocalToParent(localDelta); PointTwo = new PointFx(PointTwo.X + parentDelta.Width, PointTwo.Y + parentDelta.Height); ((PHandle)sender).RelocateHandle(); }
void listEntry_MouseDown(object sender, PInputEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem openInPCCEd = new ToolStripMenuItem("Open in PCCEditor2"); openInPCCEd.Click += openInPCCEd_Click; menu.Items.AddRange(new ToolStripItem[] { openInPCCEd }); menu.Show(Cursor.Position); } else { if (collapsed) { listEntry[0].RotateInPlace(90); listEntry[0].TranslateBy(5, 5); } else { listEntry[0].TranslateBy(-5, -5); listEntry[0].RotateInPlace(-90); } bCollapsed = !collapsed; } ToTree(); }
protected override void OnDrag(object sender, PInputEventArgs e) { base.OnDrag(sender, e); if (e.PickedNode.Tag != null) { } }
protected override bool ShouldStartDragInteraction(PInputEventArgs e) { if (base.ShouldStartDragInteraction(e)) { return(e.PickedNode != e.TopCamera && !(e.PickedNode is PLayer)); } return(false); }
protected void aNode_MouseUp(object sender, PInputEventArgs e) { PNode aNode = (PNode)sender; aNode.Brush = new SolidBrush(Color.Green); PrintEventCoords(e); e.Handled = true; }
public override void OnMouseUp(object sender, PInputEventArgs e) { newP = PUtil.CenterOfRectangle(target.Camera.ViewBounds); colBarLayer.TranslateBy(0, (oldP.Y - newP.Y) / target.Layer.Scale); rowBarLayer.TranslateBy((oldP.X - newP.X) / target.Layer.Scale, 0); }
public override void OnMouseLeave(object sender, PInputEventArgs e) { base.OnMouseLeave(sender, e); if (e.Button == MouseButtons.None) { e.PickedNode.Brush = Brushes.White; } }
void PNode_MouseUp(object sender, PInputEventArgs e) { if (PreventEvent(e)) { return; } Clickable.MouseUp(e.Position, GetButton(e)); }
void GraphElement_MouseMove(object sender, PInputEventArgs e) { if (PreventEvent(e)) { return; } Hoverable.MouseHover(e.Position); }
void GraphElement_MouseLeave(object sender, PInputEventArgs e) { if (PreventEvent(e)) { return; } Hoverable.MouseLeave(e.Position, DateTime.Now - FMouseEnterTime); }
void PNode_DoubleClick(object sender, PInputEventArgs e) { if (PreventEvent(e)) { return; } Clickable.DoubleClick(e.Position, GetButton(e)); }
/// <summary> /// The filter for a PZoomToEventHandler. 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 PZoomToEventHandlerAcceptsEvent(PInputEventArgs e) { if (!e.Handled && e.IsMouseEvent && e.Button == MouseButtons.Left) { return(true); } return(false); }