public void KeyAction(Direction direction) { // move and spawn switch (direction) { case Direction.Up: Debug.WriteLine($"{direction} has been pressed."); if (Move(true, 1)) { SpawnElements(1, 2); } break; case Direction.Down: Debug.WriteLine($"{direction} has been pressed."); if (Move(true, -1)) { SpawnElements(1, 2); } break; case Direction.Right: Debug.WriteLine($"{direction} has been pressed."); if (Move(false, -1)) { SpawnElements(1, 2); } break; case Direction.Left: Debug.WriteLine($"{direction} has been pressed."); if (Move(false, 1)) { SpawnElements(1, 2); } break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } // lose if (!MovesPossible()) { BlurBehindMessageBox.Show("Cry, baby, cry"); } foreach (var element in _spielfeldElementViewModels) { if (element.Value == 2048) { BlurBehindMessageBox.Show("Well done"); } } }
private void ResetButton_OnClick(object sender, RoutedEventArgs e) { var customButtonCollection = new ButtonCollection(); foreach (var sizeOption in FieldViewModel.SizeOptions) { var optionButton = new Button { Content = sizeOption, Width = 50d, ToolTip = string.Format(Properties.Resources.WinTileToolTip, Math.Pow(FieldViewModel.StartValue, FieldViewModel.WinningPowers[sizeOption - FieldViewModel.SizeOptions[0]])) }; optionButton.Click += OptionButtonOnClick; customButtonCollection.Add(optionButton); } BlurBehindMessageBox.Show(this, Properties.Resources.ResetBody, Properties.Resources.ResetHeader, customButtonCollection); }
private void SampleInvokeButton_OnClick(object sender, RoutedEventArgs e) { //show a blur behind dialog BlurBehindMessageBox.Show("Everything behind me should appear blured now.", "I am important!", BlurryDialogButton.Ok); }