コード例 #1
0
// ============================================================================
// Save button pressed. Build an armour object and add it to the list of all
// available components (this will also result in any existing design with the
// same name being overwritten).
// ============================================================================

        private void SaveButton_Click(object sender, EventArgs e)
        {
            string componentName = CommonProperties.ComponentName.Text;

            if (componentName == null || componentName == "")
            {
                Report.Error("You must specify a component name");
                return;
            }

            // Create a new component and copy the form details to it.
            NovaCommon.Component armorComponent = new NovaCommon.Component(CommonProperties.Value);

            Armor armorProperties = new Armor();

            armorProperties.Strength = (int)ArmourStrength.Value; // TODO change the form property to American spelling
            armorProperties.Shields  = (int)Shielding.Value;

            armorComponent.Properties.Add("Armor", armorProperties);

            AllComponents[armorComponent.Name] = armorComponent;

            CommonProperties.UpdateListBox(typeof(NovaCommon.Component));
            Report.Information("Armour design has been saved");
        }
コード例 #2
0
// ============================================================================
// When a selection in the list box changes repopulate the dialog with the
// values for that armour. The processing of this event is delegated from the
// Common Properties control.
// ============================================================================

        private void OnSelectionChanged(object sender, EventArgs e)
        {
            ListBox listBox      = sender as ListBox;
            string  CargoPodName = listBox.SelectedItem as string;

            NovaCommon.Component cargoPodComponent = AllComponents[CargoPodName] as NovaCommon.Component;
            commonProperties1.Value = cargoPodComponent;

            try
            {
                CargoPod cargoPodProperties = cargoPodComponent.Properties["CargoPod"] as CargoPod;
                Capacity.Value = cargoPodProperties.Capacity;
            }
            catch
            {
                MessageBox.Show("Selected component does not have Cargo Pod properties.");
            }
        }
コード例 #3
0
// ============================================================================
// When a selection in the list box changes repopulate the dialog with the
// values for that armour. The processing of this event is delegated from the
// Common Properties control.
// ============================================================================

        private void OnSelectionChanged(object sender, EventArgs e)
        {
            ListBox listBox   = sender as ListBox;
            string  armorName = listBox.SelectedItem as string;

            NovaCommon.Component armorComponent = AllComponents[armorName] as NovaCommon.Component;

            CommonProperties.Value = armorComponent;
            try
            {
                Armor armorProperties = armorComponent.Properties["Armor"] as Armor;
                ArmourStrength.Value = armorProperties.Strength;
                Shielding.Value      = armorProperties.Shields;
            }
            catch
            {
                MessageBox.Show("The selected component has no Armor properties.");
            }
        }
コード例 #4
0
// ============================================================================
// Save button pressed. Build a Cago Pod  object and add it to the list of all
// available components (this will also result in any existing design with the
// same name being overwritten).
// ============================================================================

        private void SaveButton_Click(object sender, EventArgs e)
        {
            string componentName = commonProperties1.ComponentName.Text;

            if (componentName == null || componentName == "")
            {
                Report.Error("You must specify a component name");
                return;
            }

            NovaCommon.Component cargoPodComponent  = new NovaCommon.Component(commonProperties1.Value);
            CargoPod             cargoPodProperties = new CargoPod();

            cargoPodProperties.Capacity = (int)Capacity.Value;
            cargoPodComponent.Properties.Add("CargoPod", cargoPodProperties);

            AllComponents[cargoPodComponent.Name] = cargoPodComponent;

            commonProperties1.UpdateListBox(typeof(NovaCommon.Component));
            Report.Information("CargoPod design has been saved");
        }