void OnMouseDown() { if (TileClicked != null) { TileClicked.Invoke(this, new EventArgs()); } }
private void imgMap_MouseUp(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { var p = e.GetPosition(this); double horizontalZoom = imgMap.Source.Width / imgMap.ActualWidth; double verticalZoom = imgMap.Source.Height / imgMap.ActualHeight; var difH = ActualHeight - imgMap.ActualHeight; var difW = ActualWidth - imgMap.ActualWidth; double zoom = Math.Min(horizontalZoom, verticalZoom); var x = (int)Math.Floor((p.X - (difW / 2.0)) * zoom) + Repository.Left; var y = Repository.Top - (int)Math.Floor((p.Y - (difH / 2.0)) * zoom); TileClicked?.Invoke(new TileId(x, y)); } else { Unselected?.Invoke(this, null); } }
public void Update() { UpdateInput(); Rectangle mouseRect; Rectangle viewPort; MouseState curMouseState = Mouse.GetState(); mouseRect = new Rectangle(curMouseState.X, curMouseState.Y, 1, 1); viewPort = new Rectangle(Globals.RightView.X, Globals.RightView.Y, Globals.RightView.Width, Globals.RightView.Height); if (mouseRect.Intersects(viewPort) && curMouseState.X - Globals.RightView.X < Width + Globals.DrawOffset.X && curMouseState.X - Globals.RightView.X > Globals.DrawOffset.X && curMouseState.Y - Globals.RightView.Y < Height + Globals.DrawOffset.Y && curMouseState.Y - Globals.RightView.Y > Globals.DrawOffset.Y) { _selected = SelectImage(new Vector2(curMouseState.X, curMouseState.Y)); if (curMouseState.LeftButton == ButtonState.Pressed) { TileClicked?.Invoke(); } } }
private void OnTileClicked(GameObject tileGameObject, int squareX, int squareY) { TileClicked?.Invoke(tileGameObject, squareX, squareY); }
private void OnTileClicked(TileView clicked) { TileClicked?.Invoke(this, clicked.Model.Id); }