private void OnDisable() { foreach (Delegate d in onClick.GetInvocationList()) { onClick -= d as OnClick; } foreach (Delegate d in onDrag.GetInvocationList()) { onDrag -= d as OnDrag; } }
public Button(string n) { name = n; OnClick += clicked_received; OnClick += changeColorAfterClick; Delegate[] aufrufliste = OnClick.GetInvocationList(); OnClick = new Clickhandler(() => { }); OnClick += (Clickhandler)aufrufliste[1]; OnClick += (Clickhandler)aufrufliste[0]; Console.WriteLine("Knopf erstellt"); }
protected void OnOsTouch( uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) { if (!m_localIds.Contains(originalID)) { return; } lock (m_interactions) { if (m_interactions.ContainsKey(remoteClient.AgentId)) { m_interactions[remoteClient.AgentId].Close(); m_interactions.Remove(remoteClient.AgentId); } AbstractInteraction interaction = CreateInteraction(remoteClient); // Not all clickable buttons implement interactions // FIXME: May change this at some stage for simplicity. if (interaction != null) { m_interactions.Add(remoteClient.AgentId, interaction); } } if (OnClick != null) { foreach (OnClickDelegate d in OnClick.GetInvocationList()) { try { d(offsetPos, remoteClient, surfaceArgs); } catch (Exception e) { m_log.ErrorFormat( "[WATER WARS]: Delegate for OnOsTouch failed - continuing. {0}{1}", e.Message, e.StackTrace); } } } // m_log.InfoFormat( // "[OS WIDGETS]: Fired OnTouch() with localID {0}, originalID {1} (part has localID {2}, Text {3})", // localID, originalID, m_part.LocalId, DisplayBehaviour.Text.Replace("\n", @"\n")); }
protected void SendOnClick() { if (null != OnClick) { foreach (EventHandler eh in OnClick.GetInvocationList()) { try { OnClick(this, EventArgs.Empty); } catch (Exception e) { Log.postException(e); } } } }
public override void Update(GameTime gameTime) { MouseState mouseClick = Mouse.GetState(); Vector2 ul = GetUpperLeft(); Rectangle bound = GetBounds(); //TODO: Create a proper button UI class (Actor?) if (Mouse.GetState().X >= ul.X && Mouse.GetState().Y >= ul.Y) { if (Mouse.GetState().X <= ul.X + bound.Width && Mouse.GetState().Y <= ul.Y + bound.Height) { if (mouseClick.LeftButton == ButtonState.Pressed && lastState.LeftButton != ButtonState.Pressed) { if (OnClick.GetInvocationList().Length > 0) { OnClick(); } } } } lastState = mouseClick; }