public AddResistanceValueWindow(ResistanceValue resistance)
        {
            this.originalResistance = resistance;

            damageTypes = new List <string>();

            damageTypes.Add("acid");
            damageTypes.Add("cold");
            damageTypes.Add("fire");
            damageTypes.Add("force");
            damageTypes.Add("lightning");
            damageTypes.Add("necrotic");
            damageTypes.Add("poison");
            damageTypes.Add("psychic");
            damageTypes.Add("radiant");
            damageTypes.Add("thunder");
            damageTypes.Add("normal");

            InitializeComponent();

            this.Title = (resistance == null ? "Add Resistance Value" : "Edit Resistance Value");

            if (resistance != null)
            {
                txtAdjustment.Text = resistance.Modifier.ToString();
                cboDamageType.Text = resistance.DamageType;
                txtNote.Text       = resistance.Description;
            }
        }
Esempio n. 2
0
        private void btnDeleteResistance_Click(object sender, RoutedEventArgs e)
        {
            ResistanceValue resistance = (lvResistances.SelectedItem as ResistanceValue);

            if (resistance == null)
            {
                return;
            }

            if (MessageBox.Show("Are you sure you want to delete this resistance value?", "Delete resistance?", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
            {
                player.Resistances.Remove(resistance);
            }
        }
Esempio n. 3
0
        public double CalculateOhmValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor)
        {
            var bandAValue = GetValue(Band.A, bandAColor).Value;
            var bandBValue = GetValue(Band.B, bandBColor).Value;
            var bandCValue = GetValue(Band.C, bandCColor).Value;
            var bandDValue = GetValue(Band.D, bandDColor).Value;

            var result         = ((bandAValue * 10) + bandBValue) * bandCValue;
            var variationValue = result * bandDValue;

            ResistanceValue           = new ResistanceValue();
            ResistanceValue.Tolorance = $"±{bandDValue}";
            ResistanceValue.Minimum   = result - variationValue;
            ResistanceValue.Maximum   = result + variationValue;
            return(result);
        }
Esempio n. 4
0
        private void EditSelectedResistance()
        {
            ResistanceValue resistance = (lvResistances.SelectedItem as ResistanceValue);

            if (resistance == null)
            {
                return;
            }

            AddResistanceValueWindow window = new AddResistanceValueWindow(resistance);

            if (window.ShowDialog(Application.Current.MainWindow))
            {
                resistance.Modifier    = window.Resistance.Modifier;
                resistance.DamageType  = window.Resistance.DamageType;
                resistance.Description = window.Resistance.Description;
            }
        }
Esempio n. 5
0
    public void GetInput()
    {
        vol = GameObject.Find("Battery").GetComponent <Voltage>();
        res = GameObject.Find("Resistance").GetComponent <ResistanceValue>();

        string objectName;

        objectName = element.name;

        if (objectName == "Battery(Clone)")
        {
            vol.voltage = int.Parse(valueField.text);
        }

        if (objectName == "Resistance(Clone)")
        {
            res.resistance = int.Parse(valueField.text);
        }
        else
        {
            Start();
        }
    }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            string adjText = txtAdjustment.Text.Trim();

            if (adjText.StartsWith("+"))
            {
                adjText = adjText.Substring(1);
            }

            int tempValue;

            if (!Int32.TryParse(adjText, out tempValue))
            {
                MessageBox.Show("Please enter a number for the resistance.", "Invalid resistance", MessageBoxButton.OK, MessageBoxImage.Warning);
                txtAdjustment.Focus();
                return;
            }

            if (String.IsNullOrWhiteSpace(cboDamageType.Text))
            {
                MessageBox.Show("Please enter a damage type.", "Invalid damage type", MessageBoxButton.OK, MessageBoxImage.Warning);
                cboDamageType.Focus();
                return;
            }

            if (String.IsNullOrWhiteSpace(txtNote.Text))
            {
                MessageBox.Show("Please enter a note.", "Invalid note", MessageBoxButton.OK, MessageBoxImage.Warning);
                txtNote.Focus();
                return;
            }

            resistance = new ResistanceValue(tempValue, cboDamageType.Text, txtNote.Text);

            DialogResult = true;
            Close();
        }
Esempio n. 7
0
 public FourBandResistor(IBandColors colors) : base(colors)
 {
     //Create 4 color bands
     base.CreateBand(4);
     ResistanceValue = new ResistanceValue();
 }