Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Collections;
- namespace WindowsFormsApp30
- {
- abstract class Figure
- {
- public Point point1;
- public bool vis = false;
- public Figure(Point point1)
- {
- this.point1 = point1;
- }
- public abstract void Draw(Graphics g, Point point);
- public abstract void DrawDash(Graphics g, Point point2);
- public abstract void Hide(Graphics g);
- public abstract void Show(Graphics g);
- public abstract Point getPoint1();
- public abstract Point getPoint2();
- }
- class Rectangle : Figure
- {
- int Xmin, Ymin;
- int Xmax, Ymax;
- Pen pen = new Pen(Color.Black, 2);
- Point point2;
- public Rectangle(Point point1, Point point2) : base(point1)
- {
- }
- public override void Draw(Graphics g)
- {
- if (point1.X >= point2.X)
- { Xmax = point1.X - point2.X; Xmin = point2.X; }
- else
- { Xmax = point2.X - point1.X; Xmin = point1.X; }
- if (point1.Y >= point2.Y)
- { Ymax = point1.Y - point2.Y; Ymin = point2.Y; }
- else
- { Ymax = point2.Y - point1.Y; Ymin = point1.Y; }
- g.DrawRectangle(pen, Xmin, Ymin, Xmax, Ymax);
- }
- public override void DrawDash(Graphics g, Point point2)
- {
- g.Clear(Color.White);
- this.point2.X = point2.X;
- this.point2.Y = point2.Y;
- pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
- Draw(g, this.point2);
- pen = new Pen(Color.Black, 1);
- }
- public override void Hide(Graphics g)
- {
- }
- public override void Show(Graphics g)
- {
- }
- public override Point getPoint1(){ return point1; }
- public override Point getPoint2(){ return point2; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement