Ejemplo n.º 1
0
        private void textCharge_TextChanged(object sender, EventArgs e)
        {
            var helper = new MessageBoxHelper(this, false);
            int charge;

            if (!helper.ValidateSignedNumberTextBox(textCharge, _minCharge, _maxCharge, out charge))
            {
                return; // Not yet clear what the user has in mind
            }
            if (Adduct.IsEmpty || Adduct.AdductCharge != charge)
            {
                Adduct =
                    Adduct
                    .ChangeCharge(
                        charge);     // Update the adduct with this new charge - eg for new charge 2, [M+Na] -> [M+2Na]
            }
        }
Ejemplo n.º 2
0
        public Adduct GetProductAdduct(Adduct precursorAdduct)
        {
            var totalCharge = TotalCharge;

            if (totalCharge == 0)
            {
                return(precursorAdduct);
            }

            var newCharge = precursorAdduct.AdductCharge - totalCharge;

            if (Math.Sign(newCharge) != Math.Sign(precursorAdduct.AdductCharge))
            {
                return(null);
            }

            return(precursorAdduct.ChangeCharge(newCharge));
        }