예제 #1
0
        /// <summary>
        /// mouse up handler
        /// </summary>
        public void writePanel_MouseUp(object sender, MouseEventArgs e)
        {
            dragging = false;
            // clear drawOn panel
            clearPanel();
            // create arrayList of shapes from model and convert to array of shapes
            ArrayList theMarineLifeList = theModel.MarineLifeList;

            MarineLife[] theMarineLife = (MarineLife[])theMarineLifeList.ToArray(typeof(MarineLife));
            // graphics object to draw selected shape
            Graphics g = this.write_panel.CreateGraphics();

            // check if shape selected and if so display
            if (topCritter != null)
            {
                theMarineLife[0] = topCritter;
                topCritter.Display(g);
            }
            theModel.UpdateViews();
        }
예제 #2
0
 /// <summary>
 /// [load aquarium] button click event which loads data from a previously saved aquarium
 /// </summary>
 public void load_aquarium(object sender, EventArgs e)
 {
     Console.WriteLine("load");
     theOpenFileDialogBox = new OpenFileDialog();
     if (theOpenFileDialogBox.ShowDialog() == DialogResult.OK)
     {
         StartNewAquarium();
         FileInfo finfo = new FileInfo(theOpenFileDialogBox.FileName);
         Stream   strm  = finfo.Open(FileMode.Open);
         while (strm.Position != strm.Length)
         {
             theModel.MarineLifeList.Add(formatter.Deserialize(strm));
         }
         strm.Close();
         theModel.UpdateViews();
     }
 }
예제 #3
0
 /// <summary>
 /// commits MarineLife object modifications to theModel and updates display
 /// </summary>
 public void submitEdit_btnClicked(object sender, EventArgs e)
 {
     if (targetIndex != -1 && editCritter != null)
     {
         editCritter.yPosition = Convert.ToInt32(tbe_y.Text);
         editCritter.xPosition = Convert.ToInt32(tbe_x.Text);
         editCritter.ml_height = Convert.ToInt32(tbe_height.Text);
         editCritter.ml_width  = Convert.ToInt32(tbe_width.Text);
         if (editCritter.ml_type == "Whale")
         {
             Whale theWhale = (Whale)editCritter;
             if (rbe_baleen.Checked == true)
             {
                 theWhale.setWhaleType(WhaleType.Baleen);
             }
             else
             {
                 theWhale.setWhaleType(WhaleType.Toothed);
             }
             editCritter = theWhale;
         }
         else if (editCritter.ml_type == "Fish")
         {
             Fish theFish = (Fish)editCritter;
             if (rbe_red.Checked == true)
             {
                 theFish.setFishType(FishType.red);
             }
             else if (rbe_blue.Checked == true)
             {
                 theFish.setFishType(FishType.blue);
             }
             else if (rbe_green.Checked == true)
             {
                 theFish.setFishType(FishType.green);
             }
             else
             {
                 theFish.setFishType(FishType.orange);
             }
             editCritter = theFish;
         }
         else
         {
             Crustacean theCrustacean = (Crustacean)editCritter;
             if (rbe_crab.Checked == true)
             {
                 theCrustacean.setCrustaceanType(CrustaceanType.Crab);
             }
             else if (rbe_lobster.Checked == true)
             {
                 theCrustacean.setCrustaceanType(CrustaceanType.Lobster);
             }
             else
             {
                 theCrustacean.setCrustaceanType(CrustaceanType.Shrimp);
             }
             editCritter = theCrustacean;
         }
         theModel.UpdateViews();
     }
     edit_panel.Hide();
     add_panel.Show();
 }