示例#1
0
        private void SwarmRadio_Checked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!_isInitialized || _programaticallySettingSwarmSettings)
                {
                    return;
                }

                RadioButton senderCast = sender as RadioButton;
                if (senderCast == null)
                {
                    MessageBox.Show("Unknown radio button", "Space Dock", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                // Figure out what they clicked on
                Ship.SwarmFormation formation = (Ship.SwarmFormation)Enum.Parse(typeof(Ship.SwarmFormation), senderCast.Name.Substring(SWARMRADIOPREFIX.Length));

                if (formation == _ship.Swarmbots)
                {
                    return;
                }

                //TODO:  Exchange money first

                _ship.Swarmbots = formation;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Space Dock", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#2
0
        private void AddSwarmRadioButton(Ship.SwarmFormation formation, string text, bool isChecked)
        {
            RadioButton radio = new RadioButton();

            radio.Name      = SWARMRADIOPREFIX + formation.ToString();
            radio.Content   = text;
            radio.IsChecked = isChecked;
            radio.Checked  += new RoutedEventHandler(SwarmRadio_Checked);
            radio.Margin    = new Thickness(2);
            radio.FontSize  = 12;               // stupid things inherit from the expander's font size

            pnlSwarmBots.Children.Add(radio);
        }