private IHoverListener HoverEntity(MouseEventArgs e, IShapeMaterial material) { IHoverListener listener; listener = material.GetService(typeof(IHoverListener)) as IHoverListener; if (listener != null) //the caught material does listen { if (currentHoveredMaterial == listener) //it's the same as the previous time { listener.MouseHover(e); } else //we moved from one material to another listening material { if (currentHoveredMaterial != null) //tell the previous material we are leaving { currentHoveredMaterial.MouseLeave(e); } listener.MouseEnter(e); //tell the current one we enter currentHoveredMaterial = listener; } } else //the caught material does not listen { if (currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } } return(listener); }
/// <summary> /// <see cref="IHoverListener"/> implementation /// </summary> /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> public void MouseHover(MouseEventArgs e) { if (header.Rectangle.Contains(e.Location)) { HoverEntity(e, header); return; } if (plusminus.Rectangle.Contains(e.Location)) { HoverEntity(e, plusminus); return; } if (!mCollapsed) //no need to check the rest if the folder is collapsed! { IHoverListener listener; foreach (IShapeMaterial material in this.Entries) { if (material.Rectangle.Contains(e.Location)) //we caught an material { listener = HoverEntity(e, material); return; //only one material at a time } } } if (currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } }
public void MouseMove(MouseEventArgs e) { if (!IsSuspended && this.Enabled) { IHoverListener listener = null; CollectionBase<IDiagramEntity> paintables= this.Controller.Model.Paintables; IDiagramEntity entity; if(paintables.Count==0) return; //going from top to the bottom of the z-order for (int k=paintables.Count-1; k>=0; k--) { entity = paintables[k]; if(entity.Rectangle.Contains(e.Location)) //we caught an entity { //unhover the previous, if any if(previousHovered != null) previousHovered.Hovered = false; entity.Hovered = true; //tell the current one it's being hovered //fetch the hovering service, if defined listener = entity.GetService(typeof(IHoverListener)) as IHoverListener; if(listener != null) //the caught entity does listen { if(currentListener == listener) //it's the same as the previous time listener.MouseHover(e); else //we moved from one entity to another listening entity { if(currentListener!=null) //tell the previous entity we are leaving currentListener.MouseLeave(e); listener.MouseEnter(e); //tell the current one we enter currentListener = listener; } } else //the caught entity does not listen { if(currentListener != null) { currentListener.MouseLeave(e); currentListener = null; } } previousHovered = entity;//remember, for the next time return; //if another entity is listening underneath this entity it will not receive the notification } } if(currentListener != null) { currentListener.MouseLeave(e); currentListener = null; } //unhover the previous, if any if(previousHovered != null) previousHovered.Hovered = false; } }
// ------------------------------------------------------------------ /// <summary> /// Handles the MouseHover event. /// </summary> /// <param name="e">The /// <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance /// containing the event data.</param> // ------------------------------------------------------------------ public override void MouseHover(MouseEventArgs e) { base.MouseHover(e); IHoverListener listener; foreach (IShapeMaterial material in this.Children) { if (material.Rectangle.Contains(e.Location) && material.Visible) //we caught an material and it's visible { listener = material.GetService(typeof(IHoverListener)) as IHoverListener; if (listener != null) //the caught material does listen { if (currentHoveredMaterial == listener) //it's the same as the previous time { listener.MouseHover(e); } else //we moved from one material to another listening material { if (currentHoveredMaterial != null) //tell the previous material we are leaving { currentHoveredMaterial.MouseLeave(e); } listener.MouseEnter(e); //tell the current one we enter currentHoveredMaterial = listener; } } else //the caught material does not listen { if (currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } } return; //only one material at a time } } if (currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } }
/// <summary> /// Handles the MouseHover event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> public void MouseHover(System.Windows.Forms.MouseEventArgs e) { IHoverListener listener; foreach(IShapeMaterial material in this.Children) { if(material.Rectangle.Contains(e.Location) && material.Visible) //we caught an material and it's visible { listener = material.GetService(typeof(IHoverListener)) as IHoverListener; if(listener != null) //the caught material does listen { if(currentHoveredMaterial == listener) //it's the same as the previous time listener.MouseHover(e); else //we moved from one material to another listening material { if(currentHoveredMaterial != null) //tell the previous material we are leaving currentHoveredMaterial.MouseLeave(e); listener.MouseEnter(e); //tell the current one we enter currentHoveredMaterial = listener; } } else //the caught material does not listen { if(currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } } return; //only one material at a time } } if(currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } }
/// <summary> /// <see cref="IHoverListener"/> implementation /// </summary> /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> public virtual void MouseLeave(MouseEventArgs e) { currentHoveredMaterial = null; this.Shape.Model.RaiseOnCursorChange(Cursors.Default);//HACK: should be the cursor before entering into another one }
protected virtual IHoverListener HoverEntity( MouseEventArgs e, IShapeMaterial material) { IHoverListener listener; listener = material.GetService(typeof(IHoverListener)) as IHoverListener; if (listener != null) //the caught material does listen { if (currentHoveredMaterial == listener) //it's the same as the previous time listener.MouseHover(e); else //we moved from one material to another listening material { if (currentHoveredMaterial != null) //tell the previous material we are leaving currentHoveredMaterial.MouseLeave(e); listener.MouseEnter(e); //tell the current one we enter currentHoveredMaterial = listener; } } else //the caught material does not listen { if (currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } } return listener; }
/// <summary> /// <see cref="IHoverListener"/> implementation /// </summary> /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> public virtual void MouseHover(MouseEventArgs e) { if (header.Rectangle.Contains(e.Location)) { HoverEntity(e, header); return; } if (plusminus.Rectangle.Contains(e.Location)) { HoverEntity(e, plusminus); return; } if (!mCollapsed) //no need to check the rest if the folder is collapsed! { IHoverListener listener; foreach (IShapeMaterial material in this.Entries) { if (material.Rectangle.Contains(e.Location)) //we caught an material { listener = HoverEntity(e, material); return; //only one material at a time } } } if (currentHoveredMaterial != null) { currentHoveredMaterial.MouseLeave(e); currentHoveredMaterial = null; } }
/// <summary> /// <see cref="IHoverListener"/> implementation /// </summary> /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> public void MouseLeave(MouseEventArgs e) { currentHoveredMaterial = null; this.Shape.Model.RaiseOnCursorChange(Cursors.Default);//HACK: should be the cursor before entering into another one }
// ------------------------------------------------------------------ /// <summary> /// Handles the mouse move event /// </summary> /// <param name="e">The <see cref= /// "T:System.Windows.Forms.MouseEventArgs"/> instance containing /// the event data.</param> // ------------------------------------------------------------------ public void MouseMove(MouseEventArgs e) { if (!IsSuspended && this.Enabled) { IHoverListener listener = null; CollectionBase <IDiagramEntity> paintables = this.Controller.Model.Paintables; IDiagramEntity entity; if (paintables.Count == 0) { return; } //going from top to the bottom of the z-order for (int k = paintables.Count - 1; k >= 0; k--) { entity = paintables[k]; if (entity.Hit(e.Location)) //we caught an entity { //unhover the previous, if any if (previousHovered != null) { previousHovered.Hovered = false; } //tell the current one it's being hovered entity.Hovered = true; //fetch the hovering service, if defined listener = entity.GetService( typeof(IHoverListener)) as IHoverListener; if (listener != null) //the caught entity does listen { if (currentListener == listener) //it's the same as the previous time { listener.MouseHover(e); } else //we moved from one entity to another listening entity { if (currentListener != null) //tell the previous entity we are leaving { currentListener.MouseLeave(e); } listener.MouseEnter(e); //tell the current one we enter currentListener = listener; } } else //the caught entity does not listen { if (currentListener != null) { currentListener.MouseLeave(e); currentListener = null; } } previousHovered = entity; //remember, for the next time return; //if another entity is listening underneath this entity it will not receive the notification } } if (currentListener != null) { currentListener.MouseLeave(e); currentListener = null; } //unhover the previous, if any if (previousHovered != null) { previousHovered.Hovered = false; } } }