示例#1
0
        UIElement BuildShortcutButton(PlayerActionShortcut playerActionShortcut)
        {
            if (highlightRectangles == null)
            {
                highlightRectangles = new Dictionary <int, Rectangle>();
            }
            StackPanel stackPanel = new StackPanel();

            stackPanel.Margin = new Thickness(2);
            stackPanel.Tag    = playerActionShortcut.Index;
            Button button = new Button();

            button.Padding = new Thickness(4, 2, 4, 2);
            stackPanel.Children.Add(button);
            button.Content = playerActionShortcut.Name;
            button.Tag     = playerActionShortcut.Index;
            button.Click  += PlayerShortcutButton_Click;
            Rectangle rectangle = new Rectangle();

            stackPanel.Children.Add(rectangle);
            rectangle.Tag        = playerActionShortcut.Index;
            rectangle.Visibility = Visibility.Hidden;
            rectangle.Height     = 3;
            rectangle.Fill       = new SolidColorBrush(Colors.Red);
            highlightRectangles.Add(playerActionShortcut.Index, rectangle);
            return(stackPanel);
        }
示例#2
0
        private void PlayerShortcutButton_Click(object sender, RoutedEventArgs e)
        {
            if (sender is Button button)
            {
                PlayerActionShortcut actionShortcut = GetActionShortcut(button.Tag);
                if (actionShortcut == null)
                {
                    return;
                }
                settingInternally = true;
                try
                {
                    HighlightPlayerShortcut((int)button.Tag);
                    tbxDamageDice.Text = actionShortcut.Dice;
                    if (actionShortcut.Modifier > 0)
                    {
                        tbxModifier.Text = "+" + actionShortcut.Modifier.ToString();
                    }
                    else
                    {
                        tbxModifier.Text = actionShortcut.Modifier.ToString();
                    }

                    ckbUseMagic.IsChecked = actionShortcut.UsesMagic;
                    NextDieRollType       = actionShortcut.Type;
                }
                finally
                {
                    settingInternally = false;
                }
            }
        }