Guest User

Untitled

a guest
Nov 24th, 2021
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System.Drawing;
  2. using System.Drawing.Drawing2D;
  3.  
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. class CEmblem
  7. {
  8.     const int DefaultRadius = 50;
  9.  
  10.     private Graphics graphics;
  11.     private int _radius;
  12.  
  13.     public int X { get; set; }
  14.     public int Y { get; set; }
  15.     public int Radius
  16.     {
  17.         get
  18.         {
  19.             return _radius;
  20.         }
  21.         set
  22.         {
  23.             _radius = value >= 200 ? 200 : value;
  24.             _radius = value <= 5 ? 5 : value;
  25.         }
  26.     }
  27.     public CEmblem(Graphics graphics, int X, int Y)
  28.     {
  29.         this.graphics = graphics;
  30.         this.X = X;
  31.         this.Y = Y;
  32.         this.Radius = DefaultRadius;
  33.     }
  34.     public CEmblem(Graphics graphics, int X, int Y, int Radius)
  35.     {
  36.         this.graphics = graphics;
  37.         this.X = X;
  38.         this.Y = Y;
  39.         this.Radius = Radius;
  40.     }
  41.  
  42.  
  43.  
  44.     private void Draw(Pen pen)
  45.     {
  46.         Rectangle rectangle = new(X + 15, Y + 15,
  47.         (int)(Radius * 1.4f), (int)(Radius * 1.4f));
  48.         graphics.DrawRectangle(pen, rectangle);
  49.  
  50.         rectangle = new(X-25, Y-25,
  51.             (3 * Radius), (3 * Radius));
  52.         graphics.DrawEllipse(pen, rectangle);
  53.  
  54.         rectangle = new(X-3, Y-3,
  55.         (int)(Radius * 2.1f), (int)(Radius * 2.1f));
  56.         graphics.DrawRectangle(pen, rectangle);
  57.  
  58.  
  59.         //Point[] points = new Point[4];
  60.         //points[0].X = X+50; points[0].Y = Y-25; // Up
  61.         //points[1].X = X-30; points[1].Y = Y+50; // R
  62.         //points[2].X = X+20; points[2].Y = Y+40; // Down
  63.         //points[3].X = X-60; points[3].Y = Y+30; // L
  64.  
  65.         //graphics.DrawPolygon(Pens.Black, points);
  66.  
  67.         //Point[] points = new Point[3];
  68.         //points[0].X = X+10; points[0].Y = Y+10;
  69.         //points[1].X = X+100; points[1].Y = Y+200;
  70.         //points[2].X = X+30; points[2].Y = Y+150;
  71.  
  72.         //graphics.DrawPolygon(Pens.Black, points);
  73.  
  74.  
  75.  
  76.     }
  77.  
  78.     public void Show()
  79.     {
  80.         Draw(Pens.Red);
  81.     }
  82.     public void Hide()
  83.     {
  84.         Draw(Pens.White);
  85.     }
  86.     public void Expand()
  87.     {
  88.         Hide();
  89.         Radius++;
  90.         Show();
  91.     }
  92.     public void Expand(int dR)
  93.     {
  94.         Hide();
  95.         Radius += dR;
  96.         Show();
  97.     }
  98.     public void Collapse()
  99.     {
  100.         Hide();
  101.         Radius--;
  102.         Show();
  103.     }
  104.     public void Collapse(int dR)
  105.     {
  106.         Hide();
  107.         Radius -= dR;
  108.         Show();
  109.     }
  110.     public void Move(int dX, int dY)
  111.     {
  112.         Hide();
  113.         X += dX;
  114.         Y += dY;
  115.         Show();
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment