Commit avent modif coo. Pour integration bras
This commit is contained in:
parent
289affdb8d
commit
def573899c
|
@ -36,6 +36,12 @@ namespace Bonhomme02
|
|||
this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur / 2, epaisseur, angle);
|
||||
|
||||
}
|
||||
public BaseBJ(PictureBox Hebergeur, double longueur, double epaisseur, double angle)
|
||||
{
|
||||
this.longueur = longueur;
|
||||
this.Haut = new Peau(Hebergeur, ref parent, longueur / 2, epaisseur, angle);
|
||||
this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur / 2, epaisseur, angle);
|
||||
}
|
||||
public void Afficher(IntPtr handle)
|
||||
{
|
||||
Haut.Afficher(handle);
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Bonhomme02
|
|||
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.Silver;
|
||||
private Color _Fond = Color.Blue;
|
||||
private Color _Crayon = Color.Black;
|
||||
private Boolean remplir = true;
|
||||
public double eppaisseurContour = 5;
|
||||
|
@ -30,7 +30,6 @@ namespace Bonhomme02
|
|||
public BaseDessin(PictureBox hebergeur)
|
||||
{
|
||||
this._Hebergeur = hebergeur;
|
||||
this._Fond = hebergeur.BackColor;
|
||||
}
|
||||
|
||||
public BaseDessin(PictureBox hebergeur, int xy) : this (hebergeur)
|
||||
|
@ -134,7 +133,7 @@ namespace Bonhomme02
|
|||
Y += deplY;
|
||||
}
|
||||
|
||||
public virtual void Afficher(IntPtr handle)
|
||||
/* public virtual void Afficher(IntPtr handle)
|
||||
{
|
||||
if (this.Visible)
|
||||
{
|
||||
|
@ -152,7 +151,7 @@ namespace Bonhomme02
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,62 @@
|
|||
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 Bonhomme : Peau
|
||||
{
|
||||
Tete tete;
|
||||
public Jambe jambe;
|
||||
|
||||
public Bonhomme() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Bonhomme(PictureBox hebergeur) : base( hebergeur)
|
||||
{
|
||||
}
|
||||
public Bonhomme(PictureBox hebergeur, double lg, double ep, double angle) : base( hebergeur, lg, ep, angle)
|
||||
{
|
||||
|
||||
}
|
||||
public Bonhomme(PictureBox hebergeur, int xy) : base( hebergeur, xy)
|
||||
{
|
||||
}
|
||||
|
||||
public Bonhomme(PictureBox hebergeur, int x, int y, double lg, double ep, double angle) : base( hebergeur, x, y, lg, ep, angle)
|
||||
{
|
||||
Peau me = this;
|
||||
jambe = new Jambe(hebergeur, ref me, 100, 10, Math.PI / 2);
tete = new Tete(hebergeur, ref me, 35);
|
||||
}
|
||||
public Bonhomme(PictureBox hebergeur, ref Peau parent, double lg, double ep, double angle) : base( hebergeur, ref parent, lg, ep, angle)
|
||||
{
|
||||
|
||||
}
|
||||
public Bonhomme(int x, int y) : base( x, y)
|
||||
{
|
||||
}
|
||||
public Bonhomme(PictureBox hebergeur, int xy, Color crayon) : base( hebergeur, xy, crayon)
|
||||
{
|
||||
}
|
||||
public new void Afficher(IntPtr handle)
|
||||
{
|
||||
base.Afficher(handle);
|
||||
tete.Afficher(handle);
|
||||
jambe.Afficher(handle);
|
||||
}
|
||||
|
||||
public new void Cacher(IntPtr handle)
|
||||
{
|
||||
base.Cacher(handle);
|
||||
tete.Cacher(handle);
|
||||
jambe.Cacher(handle);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,80 +1 @@
|
|||
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;
|
||||
|
||||
namespace Bonhomme02
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private Bonhomme bonhomme;
|
||||
private BaseBJ jambe;
|
||||
private Pied pied;
|
||||
private Peau corp;
|
||||
Tete tete;
|
||||
private BufferedGraphics bufferG = null;
|
||||
private Graphics g;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
// Modification contre le scintillement - Creation d'une mémoire tampon graphique
|
||||
bufferG = BufferedGraphicsManager.Current.Allocate(TV.CreateGraphics(), TV.DisplayRectangle);
|
||||
g = bufferG.Graphics;
|
||||
}
|
||||
|
||||
private void timerImage_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (/*this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width*/1==2)
|
||||
{
|
||||
this.timerImage.Stop();
|
||||
this.btnStopDeplacerCTick.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
corp.Cacher(this.TV.Handle);
|
||||
tete.Cacher(this.TV.Handle);
|
||||
jambe.Cacher(this.TV.Handle);
|
||||
corp.coordonnee = new Point(corp.coordonnee.X + 3, corp.coordonnee.Y + 0);
|
||||
jambe.Bouger(+3, -3);
|
||||
jambe.Afficher(this.TV.Handle);
|
||||
corp.Afficher(this.TV.Handle);
|
||||
tete.Afficher(this.TV.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStopDeplacerCTick_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.timerImage.Stop();
|
||||
this.btnStopDeplacerCTick.Enabled = false;
|
||||
}
|
||||
|
||||
private void btnEffacer_Click(object sender, EventArgs e)
|
||||
{
|
||||
Graphics gr = Graphics.FromHwnd(this.TV.Handle);
|
||||
gr.FillRectangle(new SolidBrush(this.TV.BackColor), 0, 0, this.TV.Bounds.Width, this.TV.Bounds.Height);
|
||||
}
|
||||
|
||||
private void btnCreationCarrosse_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
corp = new Peau(this.TV, 80, 80, 100, 40, Math.PI / 2);
|
||||
pied = new Pied(this.TV, 25, 10, 0);
|
||||
jambe = new Jambe(this.TV, ref corp, 100, 10, Math.PI / 2);
|
||||
tete = new Tete(this.TV, ref corp, 35);
|
||||
jambe.Haut.Angle = Math.PI/4;
|
||||
jambe.Millieux.Angle = Math.PI/2 + Math.PI/8 ;
|
||||
jambe.Afficher(this.TV.Handle);
|
||||
corp.Afficher(this.TV.Handle);
|
||||
tete.Afficher(this.TV.Handle);
|
||||
this.btnStopDeplacerCTick.Enabled = true;
|
||||
this.timerImage.Start();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
namespace Bonhomme02
{
public partial class Form1 : Form
{
private Bonhomme bonhomme;
private BufferedGraphics bufferG = null;
private Graphics g;
public Form1()
{
InitializeComponent();
// Modification contre le scintillement - Creation d'une mémoire tampon graphique
bufferG = BufferedGraphicsManager.Current.Allocate(TV.CreateGraphics(), TV.DisplayRectangle);
g = bufferG.Graphics;
}
private void timerImage_Tick(object sender, EventArgs e)
{
if (/*this.bonhomme.Origine.X + this.bonhomme.Lhorizontal >= this.TV.Width*/1==2)
{
this.timerImage.Stop();
this.btnStopDeplacerCTick.Enabled = false;
}
else
{
bonhomme.Cacher(this.TV.Handle);
bonhomme.coordonnee = new Point(bonhomme.coordonnee.X + 3, bonhomme.coordonnee.Y + 0);
bonhomme.jambe.Bouger(+3, -3);
bonhomme.Afficher(this.TV.Handle);
}
}
private void btnStopDeplacerCTick_Click(object sender, EventArgs e)
{
this.timerImage.Stop();
this.btnStopDeplacerCTick.Enabled = false;
}
private void btnEffacer_Click(object sender, EventArgs e)
{
Graphics gr = Graphics.FromHwnd(this.TV.Handle);
gr.FillRectangle(new SolidBrush(this.TV.BackColor), 0, 0, this.TV.Bounds.Width, this.TV.Bounds.Height);
}
private void btnCreationCarrosse_Click(object sender, EventArgs e)
{
bonhomme = new Bonhomme(this.TV, 80, 80, 100, 40, Math.PI / 2);
//pied = new Pied(this.TV, 25, 10, 0);
bonhomme.Afficher(this.TV.Handle);
this.btnStopDeplacerCTick.Enabled = true;
this.timerImage.Start();
}
}
}
|
|
@ -111,7 +111,7 @@ namespace Bonhomme02
|
|||
|
||||
}
|
||||
|
||||
public override void Afficher(IntPtr handle)
|
||||
public virtual void Afficher(IntPtr handle)
|
||||
{
|
||||
if(base.Visible)
|
||||
{
|
||||
|
@ -121,9 +121,9 @@ namespace Bonhomme02
|
|||
Point[] l = new Point[4] { CIG, CID, CSD, CSG };
|
||||
if (base.Remplir )
|
||||
{
|
||||
gr.FillClosedCurve(new SolidBrush(Color.Blue), l);
|
||||
gr.FillClosedCurve(new SolidBrush(base.Fond), l);
|
||||
}
|
||||
gr.DrawClosedCurve(new Pen(Brushes.Black), l);
|
||||
gr.DrawClosedCurve(new Pen(base.Crayon), l);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ namespace Bonhomme02
|
|||
gr.DrawClosedCurve(new Pen(contour, eppaisseurContour), l);
|
||||
}
|
||||
}*/
|
||||
public override void Cacher(IntPtr handle)
|
||||
public virtual void Cacher(IntPtr handle)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -155,9 +155,9 @@ namespace Bonhomme02
|
|||
Point[] l = new Point[4] { CIG, CID, CSD, CSG };
|
||||
if (base.Remplir)
|
||||
{
|
||||
gr.FillClosedCurve(new SolidBrush(base.Fond), l);
|
||||
gr.FillClosedCurve(new SolidBrush(base.Hebergeur.BackColor), l);
|
||||
}
|
||||
gr.DrawClosedCurve(new Pen(base.Fond), l);
|
||||
gr.DrawClosedCurve(new Pen(base.Hebergeur.BackColor), l);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Bonhomme02
|
|||
{
|
||||
|
||||
}
|
||||
public override void Cacher(IntPtr handle)
|
||||
public void Cacher(IntPtr handle)
|
||||
{
|
||||
Point posi = new Point(corp.coordonnee.X - rayon, corp.coordonnee.Y - rayon * 2);
|
||||
if (base.Visible)
|
||||
|
@ -54,12 +54,12 @@ namespace Bonhomme02
|
|||
|
||||
if (base.Remplir)
|
||||
{
|
||||
gr.FillEllipse(new SolidBrush(base.Fond), posi.X , posi.Y, rayon*2, rayon*2);
|
||||
gr.FillEllipse(new SolidBrush(base.Hebergeur.BackColor), posi.X , posi.Y, rayon*2, rayon*2);
|
||||
}
|
||||
gr.DrawEllipse(new Pen(base.Fond), posi.X, posi.Y, rayon*2, rayon*2);
|
||||
gr.DrawEllipse(new Pen(base.Hebergeur.BackColor), posi.X, posi.Y, rayon*2, rayon*2);
|
||||
}
|
||||
}
|
||||
public override void Afficher(IntPtr handle)
|
||||
public void Afficher(IntPtr handle)
|
||||
{
|
||||
|
||||
if (base.Visible)
|
||||
|
|
|
@ -98,6 +98,14 @@ namespace Bonhomme02
|
|||
{
|
||||
return new Point(pt.X - v.X, pt.Y - v.Y);
|
||||
}
|
||||
public static Vecteur operator /(double d, Vecteur v)
|
||||
{
|
||||
return new Vecteur(v.ABS/d, v.Angle);
|
||||
}
|
||||
public static Vecteur operator /(Vecteur v, double d)
|
||||
{
|
||||
return new Vecteur(d/v.ABS, v.Angle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue