Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Collections.Generic;
- using System.Linq;
- class CEmblem
- {
- const int DefaultRadius = 50;
- private Graphics graphics;
- private int _radius;
- public int X { get; set; }
- public int Y { get; set; }
- public int Radius
- {
- get
- {
- return _radius;
- }
- set
- {
- _radius = value >= 200 ? 200 : value;
- _radius = value <= 5 ? 5 : value;
- }
- }
- public CEmblem(Graphics graphics, int X, int Y)
- {
- this.graphics = graphics;
- this.X = X;
- this.Y = Y;
- this.Radius = DefaultRadius;
- }
- public CEmblem(Graphics graphics, int X, int Y, int Radius)
- {
- this.graphics = graphics;
- this.X = X;
- this.Y = Y;
- this.Radius = Radius;
- }
- private void Draw(Pen pen)
- {
- Rectangle rectangle = new(X + 15, Y + 15,
- (int)(Radius * 1.4f), (int)(Radius * 1.4f));
- graphics.DrawRectangle(pen, rectangle);
- rectangle = new(X-25, Y-25,
- (3 * Radius), (3 * Radius));
- graphics.DrawEllipse(pen, rectangle);
- rectangle = new(X-3, Y-3,
- (int)(Radius * 2.1f), (int)(Radius * 2.1f));
- graphics.DrawRectangle(pen, rectangle);
- //Point[] points = new Point[4];
- //points[0].X = X+50; points[0].Y = Y-25; // Up
- //points[1].X = X-30; points[1].Y = Y+50; // R
- //points[2].X = X+20; points[2].Y = Y+40; // Down
- //points[3].X = X-60; points[3].Y = Y+30; // L
- //graphics.DrawPolygon(Pens.Black, points);
- //Point[] points = new Point[3];
- //points[0].X = X+10; points[0].Y = Y+10;
- //points[1].X = X+100; points[1].Y = Y+200;
- //points[2].X = X+30; points[2].Y = Y+150;
- //graphics.DrawPolygon(Pens.Black, points);
- }
- public void Show()
- {
- Draw(Pens.Red);
- }
- public void Hide()
- {
- Draw(Pens.White);
- }
- public void Expand()
- {
- Hide();
- Radius++;
- Show();
- }
- public void Expand(int dR)
- {
- Hide();
- Radius += dR;
- Show();
- }
- public void Collapse()
- {
- Hide();
- Radius--;
- Show();
- }
- public void Collapse(int dR)
- {
- Hide();
- Radius -= dR;
- Show();
- }
- public void Move(int dX, int dY)
- {
- Hide();
- X += dX;
- Y += dY;
- Show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment