public virtual IReadOnlyCollection <IGeometricShape> Paint(SubThemeStatus status) { if (Shapes.Count == 0) { AddShapes(); } if (status == SubThemeStatus.Stay && Index == 0) { var currentState = States[Index]; UpdateFields(currentState); UpdateShapes(currentState.Colors); } else if (status == SubThemeStatus.NextStep && Index < States.Count - 1) { Index++; var currentState = States[Index]; UpdateFields(currentState); UpdateShapes(currentState.Colors); } else if (status == SubThemeStatus.BackStep && Index > 0) { Index--; var currentState = States[Index]; UpdateFields(currentState); UpdateShapes(currentState.Colors); } return(Shapes.AsReadOnly()); }
public IReadOnlyCollection <IGeometricShape> Paint(SubThemeStatus status) { if (currentSubTheme is null) { return(null); } return(currentSubTheme.Paint(status)); }
private void Drawing(Graphics graphics) { graphics.Clear(Color.Aqua); graphics.SmoothingMode = SmoothingMode.HighQuality; if (currentTheme != null) { var shapes = currentTheme.Paint(currentSubThemeStatus); currentSubThemeStatus = SubThemeStatus.Stay; if (shapes != null) { foreach (var shape in shapes) { if (shape is IClosedLine closedLine) { graphics.FillPolygon(closedLine.Color, closedLine.Points.ToArray()); } else if (shape is ILine line) { graphics.DrawLine(line.Pen, line.Start.X, line.Start.Y, line.End.X, line.End.Y); } else if (shape is IEllipse ellipse) { graphics.FillEllipse(ellipse.Color, ellipse.Point.X, ellipse.Point.Y, ellipse.Size.Width, ellipse.Size.Height); } if (!shape.Text.IsEmpty) { if (shape is IRectangleText rectangleText) { graphics.DrawString( rectangleText.Text.TextLine, new Font("Arial", 20), rectangleText.Color, new Rectangle(rectangleText.Text.Point.X, rectangleText.Text.Point.Y, rectangleText.Size.Width, rectangleText.Size.Height) // new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, FormatFlags = StringFormatFlags.FitBlackBox } ); } else { graphics.DrawString( shape.Text.TextLine, new Font("Arial", 20), Brushes.Black, shape.Text.Point ); } } } } } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (!(currentTheme is null)) { if (keyData == (Keys.Left)) { currentSubThemeStatus = SubThemeStatus.BackStep; } if (keyData == (Keys.Right)) { currentSubThemeStatus = SubThemeStatus.NextStep; } } Invalidate(); return(base.ProcessCmdKey(ref msg, keyData)); }