/// <summary> /// Refresh view based on the model's state /// </summary> public void RefreshView() { // clear drawOn panel clearPanel(); IEnumerable <Animal> theAnimals = myModel.AnimalsList.Cast <Animal>(); if (animalType != null) { theAnimals = theAnimals.Where(a => a.GetType() == animalType); } Graphics g = this.pnlDraw.CreateGraphics(); // draw all animals in array foreach (Animal a in theAnimals) { a.Display(g); } //draw the center of mass Brush br = new SolidBrush(Color.Red); int pointSize = 10; g.FillEllipse(br, myModel.CenterOfMass().X + 30 - pointSize / 2, myModel.CenterOfMass().Y + 30 - pointSize / 2, pointSize, pointSize); DrawAxes(); }
/// <summary> /// Refreshes this particular form based on the model's state /// </summary> public void RefreshView() { // clear drawing panel clearPanel(); Graphics g = this.pnlDraw.CreateGraphics(); // draw all animals in array foreach (Animal a in myModel.AnimalsList.Cast <Animal>()) { a.Display(g); } //draw the center of mass Brush br = new SolidBrush(Color.Red); int pointSize = 10; g.FillEllipse(br, myModel.CenterOfMass().X + 30 - pointSize / 2, myModel.CenterOfMass().Y + 30 - pointSize / 2, pointSize, pointSize); DrawAxes(); }
/// <summary> /// Refreshes this particular form based on the model's state /// </summary> public void RefreshView() { // clear listBox lbObjects.Items.Clear(); IEnumerable <Animal> animalList = myModel.AnimalsList.Cast <Animal>(); // add each animal in the array to the listBox foreach (Animal a in animalList) { lbObjects.Items.Add(a); } if (animalList.Count() > 0) { lblCenterOfMass.Text = $"Center of mass is at: ({myModel.CenterOfMass().X};{myModel.CenterOfMass().Y}), " + $"total mass is {myModel.TotalMass}"; } else { lblCenterOfMass.Text = ""; } }