private void OnMouseDown(object sender, MouseButtonEventArgs e) { UiSpikeElement uiSpikeElement = (UiSpikeElement)sender; OnSpikeClicked?.Invoke(uiSpikeElement.Row, uiSpikeElement.Column, cube1, cube2); Update(); }
private void SetInGrid(UiSpikeElement element, int row, int column) { if (column > 5) { column++; } Grid.SetRow(element, row); Grid.SetColumn(element, column); BoardGrid.Children.Add(element); }
public MainWindow() { InitializeComponent(); LogicBoard = new Board(); UiBoard = new UiSpikeElement[2, 12]; Board.RollCubeEvent += BoardOnRollCubeEvent; for (int i = 0; i < 2; i++) { for (int j = 0; j < 12; j++) { Spike spike = LogicBoard[i, j]; UiBoard[i, j] = new UiSpikeElement(i, j); UiBoard[i, j].MouseDown += OnMouseDown; // UiBoard[i, j].MouseEnter += OnMouseEnter; // UiBoard[i, j].MouseLeave += OnMouseLeave; SetInGrid(UiBoard[i, j], i, j); UiBoard[i, j].Update(spike); } } }