bonhomeExamJanvier/Bonhomme02/BaseDessin.cs

158 lines
4.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Bonhomme02
{
class BaseDessin
{
#region Données membres
public Point coordonnee; // Les coordonée du point seront basé sur le millieux des dessin pour facilité les rotations !
private bool _Visible = true;
private PictureBox _Hebergeur;
private Color _Fond = Color.Blue;
private Color _Crayon = Color.Black;
private Boolean remplir = true;
public double eppaisseurContour = 5;
#endregion
#region Constructeurs
public BaseDessin()
{
this._Hebergeur = null;
coordonnee = new Point();
}
public BaseDessin(PictureBox hebergeur)
{
this._Hebergeur = hebergeur;
}
public BaseDessin(PictureBox hebergeur, int xy) : this (hebergeur)
{
this.coordonnee = new Point(xy, xy);
}
public BaseDessin(PictureBox hebergeur, int x, int y) : this(hebergeur)
{
this.coordonnee = new Point(x, x);
}
public BaseDessin(int x, int y)
{
this.coordonnee = new Point(x, x);
}
public BaseDessin(PictureBox hebergeur, int xy, Color crayon) : this(hebergeur, xy)
{
Crayon = crayon;
}
public BaseDessin(PictureBox hebergeur, int x, int y, Color crayon) : this(hebergeur, x, y)
{
Crayon = crayon;
}
#endregion
#region Accesseurs
public virtual Point Coordonnee
{
get
{
return coordonnee;
}
}
public int X
{
get { return Coordonnee.X; }
set
{
if (value < 0) { coordonnee.X = 0; }
else if (value > this._Hebergeur.Bounds.Size.Width) { coordonnee.X = this._Hebergeur.Bounds.Size.Width; }
else { coordonnee.X = value; }
}
}
public int Y
{
get { return Coordonnee.Y; }
set
{
if (value < 0) { coordonnee.Y = 0; }
else if (value > coordonnee.Y) { coordonnee.Y = this._Hebergeur.Bounds.Size.Height; }
else { coordonnee.Y = value; }
}
}
public bool Visible
{
get { return _Visible; }
set { _Visible = value; }
}
public bool Remplir
{
get { return remplir; }
set { remplir = value; }
}
public Color Fond
{
get { return _Fond; }
set
{
try { _Fond = value; }
catch (Exception e) { Console.WriteLine("Erreur couleur invalide : " + e.ToString());}
}
}
public Color Crayon
{
get { return _Crayon; }
set
{
try { _Crayon = value; }
catch (Exception e) { Console.WriteLine("Erreur couleur invalide : " + e.ToString()); }
}
}
public PictureBox Hebergeur
{
get { return _Hebergeur; }
set { _Hebergeur = value; }
}
#endregion
#region Méthodes
public void Bouger(int deplX, int deplY)
{
X += deplX;
Y += deplY;
}
/* public virtual void Afficher(IntPtr handle)
{
if (this.Visible)
{
Graphics gr = Graphics.FromHwnd(handle);
gr.FillEllipse(new SolidBrush(Color.Yellow), this.X, this.Y, 6, 6);
gr.DrawEllipse(new Pen(this._Crayon, 2), this.X, this.Y, 6, 6);
}
}
public virtual void Cacher(IntPtr handle)
{
if (this.Visible)
{
Graphics gr = Graphics.FromHwnd(handle);
gr.FillEllipse(new SolidBrush(this.Fond), this.X, this.Y, 6, 6);
gr.DrawEllipse(new Pen(this.Fond, 2), this.X, this.Y, 6, 6);
}
}*/
#endregion
}
}