public override void BindContent(Animal fox) { FoxForm._fox = (Fox)fox; name.Text = _fox.Name; age.Text = _fox.Age.ToString(); foxsay.Text = _fox.WhatDoesTheFoxSay; areal.Text = _fox.Areal.ToString(); }
public FoxForm() { InitializeComponent(); _fox = new Fox(); name.Text = _fox.Name; age.Text = _fox.Age.ToString(); foxsay.Text = _fox.WhatDoesTheFoxSay; areal.Text = _fox.Areal.ToString(); this.ControlBox = false; }
private void Fox_Click(object sender, EventArgs e) { try { if (IsValid(WalkersAge.Text)) { Fox f = new Fox(WalkersName.Text, int.Parse(WalkersAge.Text), WhatDoesTheSay.Text, WalkersAreal.Text); ListOfAnimal.Add(f); ChooseAnimal.Items.Add(f); List <TextBox> LT = new List <TextBox>(); LT.Add(WalkersName); LT.Add(WalkersAge); LT.Add(WhatDoesTheSay); LT.Add(WalkersAreal); ClearFields(LT); } } catch (Exception ex) { } }
public static void ValidateFox(ref Fox fox, string name, string age, string foxsay, string areal) { Regex reg = new Regex(@"[\w]{1,15}"); Match na = reg.Match(name.Trim()); if (na.Value == "") { ValidateError("name"); return; } reg = new Regex(@"[\d]{1,2}"); Match ag = reg.Match(age.Trim()); if (ag.Value == "") { ValidateError("age"); return; } reg = new Regex(@"[\w]{1,15}"); Match fo = reg.Match(foxsay.Trim()); if (fo.Value == "") { ValidateError("whatdoesthefoxsay"); return; } reg = new Regex(@"[\w]{1,15}"); Match ar = reg.Match(areal.Trim()); if (ar.Value == "") { ValidateError("areal"); return; } fox.Name = na.Value; fox.Age = int.Parse(ag.Value); fox.WhatDoesTheFoxSay = fo.Value; fox.Areal = ar.Value; fox.IsWalker = false; }
public static void ConfigFox(Fox fox, string name, string age, string foxsay, string areal) { ValidateFox(ref fox, name, age, foxsay, areal); }