public Object(bool select, string value, int id, StyleObject style) { Select = select; value = Value; Id = id; this.style = style; }
public Entity(StyleObject style, string value, int id, int x, int y, int width, int height, List <Line> lines) : base(false, value, id, style) { XCoordinates = x; YCoordinates = y; Width = width; Height = height; list = lines; }
public Entity(StyleObject style, string value, int id, int x, int y, int width, int height, Rectangle r) : base(false, value, id, style) { Width = width; Height = height; XCoordinates = x; YCoordinates = y; list = new List <Line>(); this.r = r; }
public MainForm() { InitializeComponent(); bmp = new Drawing(BasicPictureBox.Width, BasicPictureBox.Height); Font font = new Font(FontFamily.GenericSansSerif, 14f, FontStyle.Regular); Color color = Color.Black; object[] hatchStyle = Enum.GetValues(typeof(HatchStyle)).Cast <object>().ToArray(); comboBoxHatchStyle.Items.AddRange(hatchStyle); object[] gradMode = Enum.GetValues(typeof(LinearGradientMode)).Cast <object>().ToArray(); comboBoxGradMode.Items.AddRange(gradMode); object[] lineCapStyle = Enum.GetValues(typeof(LineCap)).Cast <object>().ToArray(); comboBoxEndCap.Items.AddRange(lineCapStyle); style_o = new StyleObject(color, font, new SolidBrush(SetColorBrush.BackColor), new Pen(SetColorPen.BackColor, (float)WidthUpDown.Value), 0, false, Figure.Rectangle); style_o.myBrushTexture = new TextureBrush(new Bitmap("C:\\Users\\Valentin\\source\\repos\\Computer_Graphics\\Cg_SixthProject\\Cg_SixthProject\\bin\\Debug\\texture.bmp")); style_l = new StyleLine(color, font, new Pen(SetColorPen.BackColor, (float)WidthUpDown.Value)); }
public static void DrawNode(Entity entity) { g = Graphics.FromImage(_current_bitmap); g.SmoothingMode = SmoothingMode.HighQuality; StyleObject e = (StyleObject)entity.style.Clone(); e.Pen.Color = Color.Red; if (entity.style.Figure == Figure.Rectangle) { if (entity.style.Fill) { g.FillRectangle(entity.style.myBrush, entity.XCoordinates, entity.YCoordinates, entity.Width, entity.Height); } if (entity.Select) { g.DrawRectangle(e.Pen, entity.XCoordinates, entity.YCoordinates, entity.Width, entity.Height); } else { g.DrawRectangle(entity.style.Pen, entity.XCoordinates, entity.YCoordinates, entity.Width, entity.Height); } } else if (entity.style.Figure == Figure.Ellipse) { if (entity.style.Fill) { g.FillEllipse(entity.style.myBrush, entity.XCoordinates, entity.YCoordinates, entity.Width, entity.Height); } if (entity.Select) { g.DrawEllipse(e.Pen, entity.XCoordinates, entity.YCoordinates, entity.Width, entity.Height); } else { g.DrawEllipse(entity.style.Pen, entity.XCoordinates, entity.YCoordinates, entity.Width, entity.Height); } } if (entity.Value != null) { SizeF size = g.MeasureString(entity.Value, entity.style.Font); g.DrawString(entity.Value.ToString(), entity.style.Font, Brushes.Black, entity.XCoordinates + entity.Width / 4, entity.YCoordinates + entity.Height / 4); } }
public static void SetBrush(StyleObject flBrush) { switch (flBrush.Choose) { case 0: flBrush.myBrush = flBrush.mySolidBrush; break; case 1: flBrush.myBrush = flBrush.myHatchBrush; break; case 2: flBrush.myBrush = flBrush.myBrushTexture; break; case 3: flBrush.myBrush = flBrush.myBrushGrad; break; } }
private void BasicPictureBox_MouseUp(object sender, MouseEventArgs e) { e1 = e; if (network.e1 == null && fl_tools == 3) { network.DrawFigure(); } if (e.Button == MouseButtons.Right && network.SeacrhNode(e.X, e.Y) != null) { contextMenuStrip1.Show(MousePosition, ToolStripDropDownDirection.Right); return; } drawing = false; bmp.GetImage = Drawing.Answer; StyleObject _clone_style_o = (StyleObject)style_o.Clone(); StyleLine _clone_styleLine = (StyleLine)style_l.Clone(); switch (fl_tools) { case 0: network.AddNode(_clone_style_o, null, network.entities.Count, e0.X, e0.Y, Drawing.Width_Node, Drawing.Height_Node); break; case 1: network.DeleteNode(e.X, e.Y); network.DrawFigure(); break; case 2: network.NewXY(e0.X, e0.Y, e.X, e.Y); network.DrawFigure(); break; case 3: if (network.SeacrhNode(e.X, e.Y) != null) { network.SelectNode(e.X, e.Y); network.AddLine(_clone_styleLine); network.DrawFigure(); } break; case 4: break; case 6: network.SelectNode(e.X, e.Y); entity = network.SeacrhNode(e.X, e.Y); if (entity != null && entity.Select) { ShowIntruments(); } else { entity = null; } network.DrawFigure(); break; } Draw(); network.e1 = null; network.e2 = null; }
public void Draw(byte fl_tools, ref MouseEventArgs e0, MouseEventArgs e, StyleLine style = null, StyleObject style2 = null) { _current_bitmap = (Bitmap)bitmap.Clone(); g = Graphics.FromImage(_current_bitmap); switch (fl_tools) { case 3: g.DrawLine(style.Pen, P(e0), P(e)); break; case 0: if (style2.Figure == Figure.Rectangle) { if (!style2.Fill) { g.DrawRectangle(style2.Pen, e0.X, e0.Y, e.X - e0.X, e.Y - e0.Y); } else { SetBrush(style2); g.DrawRectangle(style2.Pen, e0.X, e0.Y, e.X - e0.X, e.Y - e0.Y); g.FillRectangle(style2.myBrush, e0.X, e0.Y, e.X - e0.X, e.Y - e0.Y); } } else if (style2.Figure == Figure.Ellipse) { if (!style2.Fill) { g.DrawEllipse(style2.Pen, e0.X, e0.Y, e.X - e0.X, e.Y - e0.Y); } else { SetBrush(style2); g.DrawEllipse(style2.Pen, e0.X, e0.Y, e.X - e0.X, e.Y - e0.Y); g.FillEllipse(style2.myBrush, e0.X, e0.Y, e.X - e0.X, e.Y - e0.Y); } } Width_Node = e.X - e0.X; Height_Node = e.Y - e0.Y; break; } }