/// <summary> /// Bubbles the specified action. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="action">The action.</param> /// <param name="e">The e.</param> public void Bubble <T>(GuiControlEventDelegate <T> action, T e) where T : BlackbirdEventArgument { if (Hide) { return; } renderingStack.Push(this); if (this is IDataContainer) { dataContainerStack.Push(this as IDataContainer); } try { PerformBubbleAction(action, e); } finally { renderingStack.Pop(); if (this is IDataContainer) { dataContainerStack.Pop(); } } }
/// <summary> /// Performs the bubble action. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="action">The action.</param> /// <param name="e">The e.</param> public override void PerformBubbleAction <T>(GuiControlEventDelegate <T> action, T e) { if (this.FaceId.HasValue && this.DataSource.HasValue) { GuiFace face = Game.GuiManager.GetFace(this.FaceId.Value); DataIndex = 0; int x = X.GetValueOrDefault(0); int y = Y.GetValueOrDefault(0); foreach (var dataItem in this.DataSource.Value) { DataItem = dataItem; // Note that ChildOffsetX is usually a data bound and would be called with a different DataItem each time - exactly the way we want it. int childOffsetX = ChildOffsetX.GetValueOrDefault(0); int childOffsetY = ChildOffsetY.GetValueOrDefault(0); if (e is MouseEventArgument) { (e as MouseEventArgument).X -= childOffsetX + x; (e as MouseEventArgument).Y -= childOffsetY + y; } foreach (var control in Enumerable.Reverse(face.Controls)) { control.Bubble(action, e); } if (e is MouseEventArgument) { (e as MouseEventArgument).X += childOffsetX + x; (e as MouseEventArgument).Y += childOffsetY + y; } DataIndex++; } DataItem = null; } }
/// <summary> /// Performs the bubble action. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="action">The action.</param> /// <param name="e">The e.</param> public virtual void PerformBubbleAction <T>(GuiControlEventDelegate <T> action, T e) where T : BlackbirdEventArgument { action(this, e); }
/// <summary> /// Binds the specified method. /// </summary> /// <param name="method">The method.</param> public void BindMethod(GuiControlEventDelegate <T> method) { this.eventDelegate = method; }