private void PaintOperator(Operator op, PaintEventArgs e) { Region clip = e.Graphics.Clip; e.Graphics.Clip = new Region(op.Dimension); double brightness = 1.0; if (op.IsSelected) brightness = 1.3; double saturation = 0.0; if (op.IsProcessable) saturation = 1.0; Color color = RGBHSL.ModifyBrightness(GetOperatorColor(op), brightness); color = RGBHSL.ModifySaturation(color, saturation); Color lightColor = RGBHSL.ModifyBrightness(color, 1.3); Color darkColor = RGBHSL.ModifyBrightness(color, 0.7); String displayName = op.Name; if (displayName == null || displayName == "") displayName = op.TypeName; Brush b = new SolidBrush(color); Pen lightPen = new Pen(lightColor); Pen darkPen = new Pen(darkColor); if (op.GetType() == typeof(CoreOperator) || op.GetType() == typeof(PropagateOperator)) { e.Graphics.FillRectangle(b, op.Dimension); e.Graphics.Clip = new Region(new Rectangle(op.Left + 10, op.Top, op.Width - 20, op.Height)); SizeF stringSize = e.Graphics.MeasureString(displayName, Font); e.Graphics.DrawString(displayName, Font, Brushes.Black, op.Left + op.Width / 2 - stringSize.Width / 2, op.Top + op.Height / 2 - stringSize.Height / 2); e.Graphics.Clip = new Region(op.Dimension); e.Graphics.DrawLine(lightPen, op.Left, op.Top, op.Left + op.Width, op.Top); e.Graphics.DrawLine(lightPen, op.Left, op.Top + 1, op.Left, op.Top + op.Height - 2); e.Graphics.DrawLine(darkPen, op.Left + 1, op.Top + op.Height - 1, op.Left + op.Width, op.Top + op.Height - 1); e.Graphics.DrawLine(darkPen, op.Left + op.Width - 1, op.Top + 1, op.Left + op.Width - 1, op.Top + op.Height - 2); } else if (op.GetType() == typeof(StoreOperator)) { Point[] points1 = new Point[3]; points1[0] = new Point(op.Left, op.Top); points1[1] = new Point(op.Left + 10, op.Top); points1[2] = new Point(op.Left + 10, op.Top + op.Height - 6); e.Graphics.FillPolygon(b, points1); Point[] points2 = new Point[3]; points2[0] = new Point(op.Left + op.Width - 1, op.Top); points2[1] = new Point(op.Left + op.Width - 10, op.Top + op.Height - 6); points2[2] = new Point(op.Left + op.Width - 10, op.Top); e.Graphics.FillPolygon(b, points2); e.Graphics.FillRectangle(b, new Rectangle(op.Left + 10, op.Top, op.Width - 20, op.Height - 5)); e.Graphics.Clip = new Region(new Rectangle(op.Left + 10, op.Top, op.Width - 20, op.Height - 5)); SizeF stringSize = e.Graphics.MeasureString(displayName, Font); e.Graphics.DrawString(displayName, Font, Brushes.Black, op.Left + op.Width / 2 - stringSize.Width / 2, op.Top + (op.Height - 5) / 2 - stringSize.Height / 2); e.Graphics.Clip = new Region(op.Dimension); e.Graphics.DrawLine(darkPen, op.Left, op.Top, op.Left + 9, op.Top + op.Height - 6); e.Graphics.DrawLine(darkPen, op.Left + 10, op.Top + op.Height - 6 , op.Left + op.Width - 11, op.Top + op.Height - 6); e.Graphics.DrawLine(darkPen, op.Left + op.Width - 10, op.Top + op.Height - 6, op.Left + op.Width - 1, op.Top); e.Graphics.DrawLine(lightPen, op.Left, op.Top, op.Left + op.Width - 2, op.Top); } else if (op.GetType() == typeof(LoadOperator)) { Point[] points1 = new Point[3]; points1[0] = new Point(op.Left, op.Top + op.Height); points1[1] = new Point(op.Left + 10, op.Top + op.Height); points1[2] = new Point(op.Left + 10, op.Top + 5); e.Graphics.FillPolygon(b, points1); Point[] points2 = new Point[3]; points2[0] = new Point(op.Left + op.Width - 10, op.Top + 5); points2[1] = new Point(op.Left + op.Width, op.Top + op.Height); points2[2] = new Point(op.Left + op.Width - 10, op.Top + op.Height); e.Graphics.FillPolygon(b, points2); e.Graphics.FillRectangle(b, new Rectangle(op.Left + 10, op.Top + 5, op.Width - 20, op.Height - 5)); e.Graphics.Clip = new Region(new Rectangle(op.Left + 10, op.Top + 5, op.Width - 20, op.Height - 5)); SizeF stringSize = e.Graphics.MeasureString(displayName, Font); e.Graphics.DrawString(displayName, Font, Brushes.Black, op.Left + op.Width / 2 - stringSize.Width / 2, op.Top + 5 + (op.Height - 5) / 2 - stringSize.Height / 2); e.Graphics.Clip = new Region(op.Dimension); } b.Dispose(); lightPen.Dispose(); darkPen.Dispose(); if (!op.IsProcessable || op.IsWarningPresent) e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.warning_icon, op.Location.X + 1, op.Location.Y + 1); if (op == ViewedOperator) e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.eye_icon, op.Location.X + 1, op.Location.Y + 1); e.Graphics.Clip = clip; /* Rectangle rect = new Rectangle(op.Location, op.Size); SizeF stringSize = e.Graphics.MeasureString(op.Binding.DisplayName, Font); Point namePoint = new Point(rect.Width / 2 - (int)stringSize.Width / 2 + rect.X, rect.Height / 2 - (int)stringSize.Height / 2 + rect.Y); double brightness = 1.0; if (op.Selected) brightness = 1.3; double saturation = 0.0; if (op.Binding.IsProcessable()) saturation = 1.0; Color color = RGBHSL.ModifyBrightness(op.Color, brightness); color = RGBHSL.ModifySaturation(color, saturation); Color lightColor = RGBHSL.ModifyBrightness(color, 1.3); Color darkColor = RGBHSL.ModifyBrightness(color, 0.7); Brush brush = new SolidBrush(color); Pen lightPen = new Pen(lightColor); Pen darkPen = new Pen(darkColor); Brush gradientBrush = new LinearGradientBrush(rect, lightColor, color, 0.0f); e.Graphics.FillRectangle(brush, rect); e.Graphics.DrawLine(lightPen, op.Location.X, op.Location.Y + op.Size.Height - 1, op.Location.X, op.Location.Y); e.Graphics.DrawLine(lightPen, op.Location.X, op.Location.Y, op.Location.X + op.Size.Width - 1, op.Location.Y); e.Graphics.DrawLine(darkPen, op.Location.X + op.Size.Width - 1, op.Location.Y, op.Location.X + op.Size.Width - 1, op.Location.Y + op.Size.Height - 1); e.Graphics.DrawLine(darkPen, op.Location.X, op.Location.Y + op.Size.Height - 1, op.Location.X + op.Size.Width - 1, op.Location.Y + op.Size.Height - 1); Brush textBrush = new SolidBrush(op.TextColor); e.Graphics.DrawString(op.Binding.DisplayName, Font, textBrush, namePoint); int x1 = op.GetAreaForResize().Left; int y1 = op.Location.Y + 3; int y2 = op.Location.Y + op.Size.Height - 4; for (int i = 0; i < 4; i++) { e.Graphics.DrawLine(lightPen, x1 + i * 3, y1, x1 + i * 3, y2); e.Graphics.DrawLine(darkPen, x1 + 1 + i * 3, y1, x1 + 1 + i * 3, y2); } if (!op.Binding.IsProcessable() || op.Binding.IsWarningPresent()) e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.warning_icon, op.Location.X + 1, op.Location.Y + 1); if (op == Operators.ViewedOperator) e.Graphics.DrawImage(VerkstanEditor.Properties.Resources.eye_icon, op.Location.X + 1, op.Location.Y + 1); */ }
private Color GetOperatorColor(Operator op) { switch (op.Type) { case Verkstan.Constants.OperatorTypes.Texture: return Color.FromArgb(250, 40, 50); case Verkstan.Constants.OperatorTypes.Mesh: return Color.FromArgb(70, 245, 90); case Verkstan.Constants.OperatorTypes.Renderable: return Color.FromArgb(70, 90, 255); default: if (op.GetType() == typeof(ExportOperator)) return Color.FromArgb(220, 50, 220); else return Color.FromArgb(190, 190, 100); } }