Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Collections;
  11.  
  12. namespace WindowsFormsApp30
  13. {
  14.     abstract class Figure
  15.     {
  16.         public Point point1;
  17.         public bool vis = false;
  18.        
  19.         public Figure(Point point1)
  20.         {
  21.             this.point1 = point1;
  22.         }
  23.  
  24.         public abstract void Draw(Graphics g, Point point);
  25.         public abstract void DrawDash(Graphics g, Point point2);
  26.         public abstract void Hide(Graphics g);
  27.         public abstract void Show(Graphics g);
  28.         public abstract Point getPoint1();
  29.         public abstract Point getPoint2();
  30.     }
  31.     class Rectangle : Figure
  32.     {
  33.         int Xmin, Ymin;
  34.         int Xmax, Ymax;
  35.         Pen pen = new Pen(Color.Black, 2);
  36.         Point point2;
  37.         public Rectangle(Point point1, Point point2) : base(point1)
  38.         {
  39.  
  40.         }
  41.        
  42.         public override void Draw(Graphics g)
  43.         {
  44.            
  45.             if (point1.X >= point2.X)
  46.             { Xmax = point1.X - point2.X; Xmin = point2.X; }
  47.             else
  48.             { Xmax = point2.X - point1.X; Xmin = point1.X; }
  49.             if (point1.Y >= point2.Y)
  50.             { Ymax = point1.Y - point2.Y; Ymin = point2.Y; }
  51.             else
  52.             { Ymax = point2.Y - point1.Y; Ymin = point1.Y; }
  53.             g.DrawRectangle(pen, Xmin, Ymin, Xmax, Ymax);
  54.         }
  55.         public override void DrawDash(Graphics g, Point point2)
  56.         {
  57.             g.Clear(Color.White);
  58.             this.point2.X = point2.X;
  59.             this.point2.Y = point2.Y;
  60.             pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
  61.             Draw(g, this.point2);
  62.             pen = new Pen(Color.Black, 1);
  63.         }
  64.         public override void Hide(Graphics g)
  65.         {
  66.  
  67.         }
  68.         public override void Show(Graphics g)
  69.         {
  70.  
  71.         }
  72.         public override Point getPoint1(){ return point1; }
  73.         public override Point getPoint2(){ return point2; }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement