private void pBox_img_MouseClick(object sender, MouseEventArgs e) { switch (modJob) { case MOD_DRAW: { int x = e.X; int y = e.Y; // MessageBox.Show(x + " " + y); PaintedObject po = new PaintedObject(new Pen(color), new GraphicsPath()); po.Path.AddRectangle(new Rectangle(x, y, (int)widthValue, (int)heightValue)); po.Color = color; po.Composition = composition; po.Rotation = angleValue; po.Width = widthValue; po.Height = heightValue; po.Location = e.Location; po.Path.Transform(setAngleRotation(po.Rotation, po.Location, po.Width, po.Height)); // showMessage(po.Color.ToString() + "" + po.Composition.ToString()); //listObj.Add(po); //Добавления элемента в начала списка, чтобы элементы маленького размера // можно было подхватить. В алгоритме выбирается первый встречающийся по списку listObj.Insert(0, po); referechDrawObj(); // Color col = Color.FromName(cbox_color.Text); break; } case MOD_EDIT: { foreach (PaintedObject po in listObj) { if (po.Path.GetBounds().Contains(e.Location)) { if (currentObj != null && currentObj.Path != null) { currentObj.Pen.Width -= 1; } //currentObj.Pen.Width -= 1; currentObj = po; currentObj.Pen.Width += 1; referechDrawObj(); return; } } break; } } }
private void pBox_img_MouseUp(object sender, MouseEventArgs e) { switch (modJob) { case MOD_MOVE: { if (currentObj != null) { currentObj.Pen.Width -= 1; currentObj = null; } break; } } }
private void pBox_img_MouseDown(object sender, MouseEventArgs e) { switch (modJob) { case MOD_MOVE: { startPoint = e.Location; foreach (PaintedObject po in listObj) { if (po.Path.GetBounds().Contains(e.Location)) { currentObj = po; currentObj.Pen.Width += 1; //со swith не работет if (currentObj.Color == Color.Green) { cbox_color.Text = COLOR_GREEN; } if (currentObj.Color == Color.Yellow) { cbox_color.Text = COLOR_YELLOW; } if (currentObj.Color == Color.LightBlue) { cbox_color.Text = COLOR_LIGHT_BLUE; } if (currentObj.Color == Color.Orange) { cbox_color.Text = COLOR_ORANGE; } if (currentObj.Color == Color.Red) { cbox_color.Text = COLOR_RED; } if (currentObj.Color == Color.Blue) { cbox_color.Text = COLOR_BLUE; } if (currentObj.Color == Color.Gray) { cbox_color.Text = COLOR_GRAY; } if (currentObj.Color == Color.Purple) { cbox_color.Text = COLOR_PURPLE; // cbox_color.SelectedItem = COLOR_PURPLE; // cbox_color.sele //showMessage("COLOR_PURPLE"); } cbox_material.Text = currentObj.Composition; return; } } break; } } }