Beispiel #1
0
 /// <summary>
 /// The try parse.
 /// </summary>
 /// <param name="line">
 /// The line.
 /// </param>
 /// <param name="pop">
 /// The pop.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public static bool TryParse(string line, out Pop pop)
 {
     if (line is null)
     {
         pop = new Pop {
             Name = string.Empty, Number = int.MinValue, Exclusive = false, Size = int.MinValue, Type = string.Empty
         };
         return(false);
     }
     else
     {
         var tokens = line.Split(Delimiter);
         pop = new Pop {
             Name = tokens[0], Number = int.Parse(tokens[1]), Exclusive = bool.Parse(tokens[2]), Size = int.Parse(tokens[3]), Type = tokens[4]
         };
         return(true);
     }
 }
Beispiel #2
0
        /// <summary>
        /// signals that the user is done entering values.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void DoneButton_Click(object sender, EventArgs e)
        {
            bool IsNumber = int.TryParse(this.NumberTextBox.Text, out var NewNumber);
            bool IsSize   = int.TryParse(this.SizeTextBox.Text, out var NewSize);
            var  name     = this.NameTextBox.Text;
            var  type     = this.TypeTextBox.Text;

            if (IsNumber &&
                IsSize &&
                this.NameTextBox.Text != string.Empty &&
                this.TypeTextBox.Text != string.Empty)
            {
                this.EditFormPop = new Pop
                {
                    Name      = name,
                    Number    = NewNumber,
                    Exclusive = this.ExclusiveCheckBox.Checked,
                    Size      = NewSize,
                    Type      = type
                };
            }
            else
            {
                if (!IsNumber)
                {
                    this.NumberTextBox.BackColor = Color.Red;
                } // else, is a number DoNothing();

                if (!IsSize)
                {
                    this.SizeTextBox.BackColor = Color.Red;
                } // else, is valid size DoNothing();

                this.DialogResult = DialogResult.None;
            }
        }
Beispiel #3
0
 /// <summary>
 /// The to file string.
 /// </summary>
 /// <param name="pop">
 /// The pop.
 /// </param>
 /// <returns>
 /// The <see cref="string"/>.
 /// </returns>
 public static string ToFileString(Pop pop) =>
 $"{pop.Name}{Delimiter}{pop.Number}{Delimiter}{pop.Exclusive}{Delimiter}{pop.Size}{Delimiter}{pop.Type}";