Nettoyage + test OK

This commit is contained in:
adri 2018-01-05 16:28:13 +01:00
parent 0a5907f303
commit 9ca3a893e9
11 changed files with 169 additions and 71 deletions

View File

@ -13,10 +13,10 @@ using System.Windows.Forms;
namespace Bonhomme02 namespace Bonhomme02
{ {
class BaseBJ class BaseBJ : Peau
{ {
enum Articulation { Epaule, Coude, Poignet, Bassin = Epaule, Genou = Coude, Cheville = Poignet }; enum Articulation { Epaule, Coude, Poignet, Bassin = Epaule, Genou = Coude, Cheville = Poignet };
public Peau Haut, Millieux, Bas, parent; public Peau Haut, Millieux, Bas;
double longueur; double longueur;
public BaseBJ() public BaseBJ()
{ {
@ -28,27 +28,22 @@ namespace Bonhomme02
this.Bas.parent = this.Millieux; 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.parent = parent;
this.longueur = longueur; 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); this.Millieux = new Peau(Hebergeur, ref this.Haut, longueur / 2, epaisseur, angle);
} }
public BaseBJ(PictureBox Hebergeur, double longueur, double epaisseur, double angle)
{ public new void Afficher(IntPtr handle)
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); Haut.Afficher(handle);
Millieux.Afficher(handle); Millieux.Afficher(handle);
Bas.Afficher(handle); Bas.Afficher(handle);
} }
public void Cacher(IntPtr handle) public new void Cacher(IntPtr handle)
{ {
Haut.Cacher(handle); Haut.Cacher(handle);
Millieux.Cacher(handle); Millieux.Cacher(handle);
@ -72,7 +67,7 @@ namespace Bonhomme02
{ {
Point H = Haut.Coordonnee; Point H = Haut.Coordonnee;
//Point M = new Point() ; //Inconnue //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); Complex tt = new Complex(B.X, B.Y);

View File

@ -84,26 +84,6 @@ namespace Bonhomme02
#region Méthodes #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 #endregion
} }
} }

View File

@ -11,7 +11,8 @@ namespace Bonhomme02
class Bonhomme : Peau class Bonhomme : Peau
{ {
Tete tete; Tete tete;
public Jambe jambe; public Jambe jambe1, jambe2;
public Bras bras;
public Bonhomme() : base() 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) public Bonhomme(PictureBox hebergeur, int x, int y, double lg, double ep, double angle) : base( hebergeur, x, y, lg, ep, angle)
{ {
Peau me = this; 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) 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); base.Afficher(handle);
tete.Afficher(handle); tete.Afficher(handle);
jambe.Afficher(handle); jambe1.Afficher(handle);
jambe2.Afficher(handle);
bras.Afficher(handle);
} }
public new void Cacher(IntPtr handle) public new void Cacher(IntPtr handle)
{ {
base.Cacher(handle); base.Cacher(handle);
tete.Cacher(handle); tete.Cacher(handle);
jambe.Cacher(handle); jambe1.Cacher(handle);
jambe2.Cacher(handle);
bras.Cacher(handle);
} }
} }
} }

View File

@ -63,7 +63,6 @@
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tete.cs" /> <Compile Include="Tete.cs" />
<Compile Include="Vecteur_.cs" />
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -9,6 +10,29 @@ namespace Bonhomme02
{ {
class Bras : BaseBJ 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() public Bras()
{ {

View File

@ -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(); } } } 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(); } } }

123
Bonhomme02/Form1.resx Normal file
View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timerImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -9,8 +9,6 @@ namespace Bonhomme02
{ {
class Jambe : BaseBJ 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() public Jambe()
{ {

View File

@ -108,7 +108,7 @@ namespace Bonhomme02
set set
{ {
epaisseur.Angle = value; //Pour que le parent de eppaiseur soit mis a jour 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) public virtual void Cacher(IntPtr handle)
{ {
try try

View File

@ -100,11 +100,11 @@ namespace Bonhomme02
} }
public static Vecteur operator /(double d, Vecteur v) 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) 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 #endregion

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bonhomme02
{
class Vecteur_
{
}
}