// ADDITIONAL UTILITIES // CreateRandomShape: Creates a Shape with variable size, type, color, and location private static void CreateRandomShape() { int sizeXY = generator.RandomNumber(30, 50); ProtocolModel.ShapeType type = (ProtocolModel.ShapeType)generator.RandomNumber(0, AveragePoints.Length); ProtocolModel.ShapeColor color = (ProtocolModel.ShapeColor)generator.RandomNumber(0, AveragePoints.Length); CreateShape(type, Color.FromName(Enum.GetName(typeof(ProtocolModel.ShapeColor), color)), sizeXY, sizeXY, generator.RandomNumber(0, GamePanelSizeX), generator.RandomNumber(0, GamePanelSizeY), AveragePoints[(int)color]); }
public static bool ContainsShape(ProtocolModel.ShapeType type, Point pos, RectangleF bounds) { switch (type) { case ProtocolModel.ShapeType.Ellipse: return(ContainsEllipse(pos, bounds)); case ProtocolModel.ShapeType.Rectangle: return(ContainsRectangle(pos, bounds)); case ProtocolModel.ShapeType.Triangle: return(ContainsTriangle(pos, bounds)); default: return(false); } }
// CreateShape: Create a shape using the specified arguments, updating and re-broadcasting the ShapesPanel afterwards private static void CreateShape(ProtocolModel.ShapeType type, Color color, int sizeX, int sizeY, int posX, int posY, int value, int ticksExisted = 0) { ProtocolModel.Shape shape = new ProtocolModel.Shape { Type = type, Color = color, Location = new RectangleF(new PointF(posX, posY), new SizeF(sizeX, sizeY)), Value = value, TicksExisted = ticksExisted }; SyncShapeTicks(); if (ShapesPanel.Count < MaxShapeCount) { ShapesPanel.Add(shape); BroadcastShapes(); } }
public static Graphics FillShape(ProtocolModel.ShapeType type, Graphics panel, SolidBrush brush, RectangleF bounds) { switch (type) { case ProtocolModel.ShapeType.Ellipse: panel.FillEllipse(brush, bounds); break; case ProtocolModel.ShapeType.Rectangle: panel.FillRectangle(brush, bounds); break; case ProtocolModel.ShapeType.Triangle: FillTriangle(panel, brush, bounds); break; default: break; } return(panel); }