From 9ca3a893e951fa9ee757d421d3491446db6505aa Mon Sep 17 00:00:00 2001 From: adri Date: Fri, 5 Jan 2018 16:28:13 +0100 Subject: [PATCH] Nettoyage + test OK --- Bonhomme02/BaseBJ.cs | 21 +++--- Bonhomme02/BaseDessin.cs | 20 ------ Bonhomme02/Bonhomme.cs | 15 +++-- Bonhomme02/Bonhomme02.csproj | 1 - Bonhomme02/Bras.cs | 24 +++++++ Bonhomme02/Form1.cs | 2 +- Bonhomme02/Form1.resx | 123 +++++++++++++++++++++++++++++++++++ Bonhomme02/Jambe.cs | 2 - Bonhomme02/Peau.cs | 16 +---- Bonhomme02/Vecteur.cs | 4 +- Bonhomme02/Vecteur_.cs | 12 ---- 11 files changed, 169 insertions(+), 71 deletions(-) create mode 100644 Bonhomme02/Form1.resx delete mode 100644 Bonhomme02/Vecteur_.cs diff --git a/Bonhomme02/BaseBJ.cs b/Bonhomme02/BaseBJ.cs index 61db7b8..fc41bb9 100644 --- a/Bonhomme02/BaseBJ.cs +++ b/Bonhomme02/BaseBJ.cs @@ -13,10 +13,10 @@ using System.Windows.Forms; namespace Bonhomme02 { - class BaseBJ + class BaseBJ : Peau { enum Articulation { Epaule, Coude, Poignet, Bassin = Epaule, Genou = Coude, Cheville = Poignet }; - public Peau Haut, Millieux, Bas, parent; + public Peau Haut, Millieux, Bas; double longueur; public BaseBJ() { @@ -28,27 +28,22 @@ namespace Bonhomme02 this.Bas.parent = this.Millieux; } - public BaseBJ(PictureBox Hebergeur, ref Peau parent, double longueur, double epaisseur, double angle) + public BaseBJ(PictureBox Hebergeur, ref Peau parent, double longueur, double epaisseur, double angle) : base(Hebergeur, ref parent, longueur / 2, epaisseur, angle) { this.parent = parent; this.longueur = longueur; - this.Haut = new Peau(Hebergeur, ref parent, longueur / 2, epaisseur, angle); + this.Haut = this; 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) + + public new void Afficher(IntPtr handle) { Haut.Afficher(handle); Millieux.Afficher(handle); Bas.Afficher(handle); } - public void Cacher(IntPtr handle) + public new void Cacher(IntPtr handle) { Haut.Cacher(handle); Millieux.Cacher(handle); @@ -72,7 +67,7 @@ namespace Bonhomme02 { Point H = Haut.Coordonnee; //Point M = new Point() ; //Inconnue - Point B = new Point(bas.X - H.X, bas.Y - H.Y); //On part du principe que H est 0;0 + Point B = new Point(bas.X - H.X, bas.Y - H.Y); //On part du principe que H est 0;0 , on rapatrie donc B pour que se soit le cas Complex tt = new Complex(B.X, B.Y); diff --git a/Bonhomme02/BaseDessin.cs b/Bonhomme02/BaseDessin.cs index ddd0646..ab67f21 100644 --- a/Bonhomme02/BaseDessin.cs +++ b/Bonhomme02/BaseDessin.cs @@ -84,26 +84,6 @@ namespace Bonhomme02 #region Méthodes - - /* 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 } } diff --git a/Bonhomme02/Bonhomme.cs b/Bonhomme02/Bonhomme.cs index b5d47d6..53a2d69 100644 --- a/Bonhomme02/Bonhomme.cs +++ b/Bonhomme02/Bonhomme.cs @@ -11,7 +11,8 @@ namespace Bonhomme02 class Bonhomme : Peau { Tete tete; - public Jambe jambe; + public Jambe jambe1, jambe2; + public Bras bras; public Bonhomme() : base() { @@ -32,7 +33,8 @@ namespace Bonhomme02 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); + jambe1 = new Jambe(hebergeur, ref me, lg, ep/4, Math.PI / 2);
 jambe2 = new Jambe(hebergeur, ref me, lg, ep / 4, Math.PI / 2);
 tete = new Tete(hebergeur, ref me, (int)(ep*3.5/4)); + bras = new Bras(hebergeur, ref me, lg, ep/4, Math.PI / 2); } public Bonhomme(PictureBox hebergeur, ref Peau parent, double lg, double ep, double angle) : base( hebergeur, ref parent, lg, ep, angle) { @@ -42,15 +44,18 @@ namespace Bonhomme02 { base.Afficher(handle); tete.Afficher(handle); - jambe.Afficher(handle); + jambe1.Afficher(handle); + jambe2.Afficher(handle); + bras.Afficher(handle); } public new void Cacher(IntPtr handle) { base.Cacher(handle); tete.Cacher(handle); - jambe.Cacher(handle); - + jambe1.Cacher(handle); + jambe2.Cacher(handle); + bras.Cacher(handle); } } } diff --git a/Bonhomme02/Bonhomme02.csproj b/Bonhomme02/Bonhomme02.csproj index fe6e3a1..36b2145 100644 --- a/Bonhomme02/Bonhomme02.csproj +++ b/Bonhomme02/Bonhomme02.csproj @@ -63,7 +63,6 @@ - Form1.cs diff --git a/Bonhomme02/Bras.cs b/Bonhomme02/Bras.cs index 6ace844..9be31d4 100644 --- a/Bonhomme02/Bras.cs +++ b/Bonhomme02/Bras.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,6 +10,29 @@ namespace Bonhomme02 { class Bras : BaseBJ { + public override Point Coordonnee + { + get + { + if (parent != null) + { + return parent.Coordonnee + parent.longueur/8; + } + else + return coordonnee; + } + set + { + if (parent != null) + { + Console.WriteLine("Un enfant ne peut modifier ces coordonée !"); + } + else + { + coordonnee = value; + } + } + } public Bras() { diff --git a/Bonhomme02/Form1.cs b/Bonhomme02/Form1.cs index da961fd..0bf0920 100644 --- a/Bonhomme02/Form1.cs +++ b/Bonhomme02/Form1.cs @@ -1 +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 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 +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.jambe1.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, 50, 20, Math.PI / 2);
 bonhomme.Afficher(this.TV.Handle);
 this.btnStopDeplacerCTick.Enabled = true;
 this.timerImage.Start();

 }
 } 
}
 \ No newline at end of file diff --git a/Bonhomme02/Form1.resx b/Bonhomme02/Form1.resx new file mode 100644 index 0000000..361d8ef --- /dev/null +++ b/Bonhomme02/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Bonhomme02/Jambe.cs b/Bonhomme02/Jambe.cs index 14b8b68..eb93776 100644 --- a/Bonhomme02/Jambe.cs +++ b/Bonhomme02/Jambe.cs @@ -9,8 +9,6 @@ namespace Bonhomme02 { class Jambe : BaseBJ { - /*pied = new Pied(this.TV, 25, 10, 0); - jambe = new BaseBJ(this.TV, ref corp, pied, 80, 10, Math.PI / 2);*/ public Jambe() { diff --git a/Bonhomme02/Peau.cs b/Bonhomme02/Peau.cs index 7e62d3d..9554a4e 100644 --- a/Bonhomme02/Peau.cs +++ b/Bonhomme02/Peau.cs @@ -108,7 +108,7 @@ namespace Bonhomme02 set { epaisseur.Angle = value; //Pour que le parent de eppaiseur soit mis a jour - //Si on met longueur epaisseur ne sera pas mis a jour + //Si on met longueur, epaisseur ne sera pas mis a jour } } @@ -146,20 +146,6 @@ namespace Bonhomme02 } } } - /*public override public void Afficher(IntPtr handle, float angle) - { - this.angleRotation = angle; - if (visible) - { - Graphics gr = Graphics.FromHwnd(handle); - Point[] l = new Point[4] { CSG, CSD, CID, CIG }; - if (remplir) - { - gr.FillClosedCurve(new SolidBrush(fond), l); - } - gr.DrawClosedCurve(new Pen(contour, eppaisseurContour), l); - } - }*/ public virtual void Cacher(IntPtr handle) { try diff --git a/Bonhomme02/Vecteur.cs b/Bonhomme02/Vecteur.cs index e7124e3..d703bfd 100644 --- a/Bonhomme02/Vecteur.cs +++ b/Bonhomme02/Vecteur.cs @@ -100,11 +100,11 @@ namespace Bonhomme02 } public static Vecteur operator /(double d, Vecteur v) { - return new Vecteur(v.ABS/d, v.Angle); + return new Vecteur(d / v.ABS, v.Angle); } public static Vecteur operator /(Vecteur v, double d) { - return new Vecteur(d/v.ABS, v.Angle); + return new Vecteur(v.ABS / d, v.Angle); } #endregion diff --git a/Bonhomme02/Vecteur_.cs b/Bonhomme02/Vecteur_.cs deleted file mode 100644 index 226c7d3..0000000 --- a/Bonhomme02/Vecteur_.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Bonhomme02 -{ - class Vecteur_ - { - } -}