Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using System.Drawing;
- using op4;
- namespace _figure
- {
- public class Figure
- {
- protected int x0, y0;
- protected Graphics g;
- //true - нечетное, false - четное нажатие
- protected bool click;
- public Figure()
- {
- x0 = 0; y0 = 0;
- click = true;
- }
- public virtual void Draw(Panel my_panel)
- {
- }
- public virtual Graphics MyGraphic()
- {
- return g;
- }
- public virtual bool finder(int x, int y)
- {
- return false;
- }
- public virtual bool unreal()
- {
- return false;
- }
- public virtual void recolor()
- {
- }
- public virtual void clicker()
- {
- click = !click;
- }
- }
- public class Circle : Figure
- {
- private int x, y, ray;
- public Circle()
- {
- x = 0;
- y = 0;
- ray = 0;
- }
- public Circle(int x, int y, int ray)
- {
- this.x = x - ray;
- this.y = y - ray;
- this.ray = ray;
- x0 = x;
- y0 = y;
- }
- public override string ToString()
- {
- string info = "";
- info = Convert.ToString(x) + " " + Convert.ToString(y) + " " + Convert.ToString(ray);
- return info;
- }
- public override void Draw(Panel my_panel)
- {
- g = my_panel.CreateGraphics();
- if (click) {
- g.DrawEllipse(Pens.Black, x, y, ray*2, ray*2);
- }
- else {
- g.DrawEllipse(Pens.Red, x, y, ray * 2, ray * 2);
- }
- }
- public override Graphics MyGraphic()
- {
- return g;
- }
- public override bool finder(int x, int y)
- {
- if ((x - x0) * (x - x0) + (y - y0) * (y - y0) <= ray * ray)
- return true;
- return false;
- }
- public override void recolor()
- {
- }
- }
- public class NulFigure: Figure
- {
- public override bool unreal()
- {
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement