Exemplo n.º 1
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            if (checkedShape is IEditable)
            {
                shapeList[lbFigures.SelectedIndex].X1       = Convert.ToInt32(tbX.Text);
                shapeList[lbFigures.SelectedIndex].Y1       = Convert.ToInt32(tbY.Text);
                shapeList[lbFigures.SelectedIndex].Width    = Convert.ToInt32(tbW.Text);
                shapeList[lbFigures.SelectedIndex].Height   = Convert.ToInt32(tbH.Text);
                shapeList[lbFigures.SelectedIndex].Color    = tbColor.BackColor.ToArgb();
                shapeList[lbFigures.SelectedIndex].PenWidth = Convert.ToInt32(tbPenWidth.Text);
                shapeList[lbFigures.SelectedIndex].Calculate(shapeList[lbFigures.SelectedIndex].X1, shapeList[lbFigures.SelectedIndex].Y1, shapeList[lbFigures.SelectedIndex].Width, shapeList[lbFigures.SelectedIndex].Height);
                DrawShapes();
            }

            SelectedShape.SetSel(checkedShape.X1, checkedShape.Y1, checkedShape.X1 + checkedShape.Width,
                                 checkedShape.Y1 + checkedShape.Height, checkedPen);
            g.DrawRectangle(checkedPen, SelectedShape.GetX(), SelectedShape.GetY(), SelectedShape.GetW(), SelectedShape.GetH());
            GetPictureBox().Image = pic;
        }
Exemplo n.º 2
0
        private void lbFigures_SelectedIndexChanged(object sender, EventArgs e)
        {
            checkedShape = (Shape)lbFigures.SelectedItem;

            if (checkedShape is ISelectable)
            {
                DrawShapes();


                if (checkedShape == null)
                {
                    MessageBox.Show("Figure was not selected");
                }
                else
                {
                    SelectedShape.SetSel(checkedShape.X1, checkedShape.Y1, checkedShape.X1 + checkedShape.Width,
                                         checkedShape.Y1 + checkedShape.Height, checkedPen);
                    g.DrawRectangle(checkedPen, SelectedShape.GetX(), SelectedShape.GetY(), SelectedShape.GetW(), SelectedShape.GetH());



                    tbX.Clear();
                    tbY.Clear();
                    tbH.Clear();
                    tbW.Clear();
                    tbPenWidth.Clear();

                    tbX.AppendText(checkedShape.X1.ToString());
                    tbY.AppendText(checkedShape.Y1.ToString());
                    tbW.AppendText(checkedShape.Width.ToString());
                    tbH.AppendText(checkedShape.Height.ToString());
                    tbColor.BackColor = Color.FromArgb(checkedShape.Color);
                    tbPenWidth.AppendText(checkedShape.PenWidth.ToString());
                }

                GetPictureBox().Image = pic;
            }
        }