protected virtual void OnClick(ImageListBoxEventArgs e) { ImageListBoxEventHandler handler = Click; if (handler != null) { if (ParentScreen.Name == Storage.Instance.CurrentScreen.Name) { handler(this, e); } } }
public void IsClicked(MouseState state, Vector2 cursorPos) { if (Visible) { HoverId = -1; if (!ImageScroll.IsClicked(state, cursorPos, Visible)) { if (ListBoxArea.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { for (int i = 0; i < Items.Count; i++) { Rectangle tmpRect = new Rectangle((int)CurrentPosition.X, (int)CurrentPosition.Y + (i * (16 * Scale)) + _offsetY, Width, (16 * Scale)); if (!Clicked && state.LeftButton == ButtonState.Pressed) { if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { Clicked = true; } } else if (Clicked && state.LeftButton == ButtonState.Released) { if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { ClickedId = i; SelectedItem = Items[i]; ImageListBoxEventArgs args = new ImageListBoxEventArgs(this.Id, this.Name, this.ParentForm.Id, this.ParentScreen.Id, Items[i]); OnClick(args); Clicked = false; } } if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { HoverId = i; } } } else { Clicked = false; } } } }