Exemple #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Console.WriteLine("ComboBox::SelectedIndexChanged()");
            //Console.WriteLine("Selected Index: {0}", mPlantSelect.SelectedIndex);

            System.Drawing.PointF SelectedPlantCoords = (System.Drawing.PointF)mPlantSelect.SelectedItem;
            //Console.WriteLine("Selected Item: {0}", mPlantSelect.SelectedItem);
            Console.WriteLine("Selected Plant Coords: {0}", SelectedPlantCoords);

            foreach (Plant PlantItem in mPlants)
            {
                System.Drawing.PointF CurrentPlantCenter = PlantItem.GetCenter();

                if (ArePointsEqual(CurrentPlantCenter, SelectedPlantCoords))
                {
                    Console.WriteLine("Found matching plant!");
                    PlantItem.SetFillColor(System.Drawing.Color.Black);
                }
                else
                {
                    PlantItem.ResetFillColor();
                }
            }
            Invalidate();

            //Console.WriteLine("Selected Value: {0}", mPlantSelect.SelectedValue);
        }
Exemple #2
0
        /*void OnPlantSelected(object sender, System.EventArgs e)
         * {
         *  Console.WriteLine("OnPlantSelected()");
         * }*/

        public Form1()
        {
            InitializeComponent();
            this.Paint      += new PaintEventHandler(Form1_Paint);
            this.MouseHover += new EventHandler(Form1_OnMouseHover);
            this.MouseMove  += new MouseEventHandler(Form1_OnMouseMove);

            FillAgeData();

            List <Plant> plants = CreatePlants();

            SetPlants(plants);
            SortPlantsByCoords();
            int IntersectionsNum = CalcIntersections();

            Console.WriteLine("IntersectionsNum: {0}", IntersectionsNum);

            /*comboBox1.Items.Add("Test item 1");
            *  comboBox1.Items.Add("Test item 2");
            *  comboBox1.Items.Add("Test item 3");*/

            foreach (Plant PlantItem in mPlants)
            {
                mPlantSelect.Items.Add(PlantItem.GetCenter());
            }

            //mPlantSelect.SelectionChangeCommitted += new EventHandler(OnPlantSelected);

            //pictureBox1.Paint += new PaintEventHandler(OnPictureBoxPaint);
        }