From def573899cdf62bf331dca96150d56fdf32cc304 Mon Sep 17 00:00:00 2001 From: adri Date: Fri, 5 Jan 2018 15:29:45 +0100 Subject: [PATCH] Commit avent modif coo. Pour integration bras --- Bonhomme02/BaseBJ.cs | 6 +++ Bonhomme02/BaseDessin.cs | 7 ++-- Bonhomme02/Bonhomme.cs | 50 +++++++++++++++++++++++++ Bonhomme02/Form1.cs | 81 +--------------------------------------- Bonhomme02/Peau.cs | 12 +++--- Bonhomme02/Tete.cs | 8 ++-- Bonhomme02/Vecteur.cs | 8 ++++ 7 files changed, 78 insertions(+), 94 deletions(-) diff --git a/Bonhomme02/BaseBJ.cs b/Bonhomme02/BaseBJ.cs index 287315c..61db7b8 100644 --- a/Bonhomme02/BaseBJ.cs +++ b/Bonhomme02/BaseBJ.cs @@ -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); diff --git a/Bonhomme02/BaseDessin.cs b/Bonhomme02/BaseDessin.cs index 4f8b183..c27962e 100644 --- a/Bonhomme02/BaseDessin.cs +++ b/Bonhomme02/BaseDessin.cs @@ -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 } } diff --git a/Bonhomme02/Bonhomme.cs b/Bonhomme02/Bonhomme.cs index cc754a8..058780f 100644 --- a/Bonhomme02/Bonhomme.cs +++ b/Bonhomme02/Bonhomme.cs @@ -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); + + } } } diff --git a/Bonhomme02/Form1.cs b/Bonhomme02/Form1.cs index 1917170..da961fd 100644 --- a/Bonhomme02/Form1.cs +++ b/Bonhomme02/Form1.cs @@ -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();

 }
 } 
}
 \ No newline at end of file diff --git a/Bonhomme02/Peau.cs b/Bonhomme02/Peau.cs index d17b5b9..65326b3 100644 --- a/Bonhomme02/Peau.cs +++ b/Bonhomme02/Peau.cs @@ -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 diff --git a/Bonhomme02/Tete.cs b/Bonhomme02/Tete.cs index 03e3d5c..3a09f96 100644 --- a/Bonhomme02/Tete.cs +++ b/Bonhomme02/Tete.cs @@ -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) diff --git a/Bonhomme02/Vecteur.cs b/Bonhomme02/Vecteur.cs index 2a3314b..e7124e3 100644 --- a/Bonhomme02/Vecteur.cs +++ b/Bonhomme02/Vecteur.cs @@ -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 }