diff --git a/Bonhomme02/BaseBJ.cs b/Bonhomme02/BaseBJ.cs index fc41bb9..5891fd1 100644 --- a/Bonhomme02/BaseBJ.cs +++ b/Bonhomme02/BaseBJ.cs @@ -39,9 +39,13 @@ namespace Bonhomme02 public new void Afficher(IntPtr handle) { - Haut.Afficher(handle); - Millieux.Afficher(handle); - Bas.Afficher(handle); + if(base.Visible) + { + Haut.Afficher(handle); + Millieux.Afficher(handle); + Bas.Afficher(handle); + } + } public new void Cacher(IntPtr handle) { @@ -102,6 +106,12 @@ namespace Bonhomme02 Millieux.Angle = TrouverAngleMillieux(nouveauPtBas); } } + public void SetAngle(double h, double m, double b) + { + Haut.Angle = h; + Millieux.Angle = m; + Bas.Angle = b; + } } } diff --git a/Bonhomme02/Bonhomme02.csproj b/Bonhomme02/Bonhomme02.csproj index 36b2145..ce4550b 100644 --- a/Bonhomme02/Bonhomme02.csproj +++ b/Bonhomme02/Bonhomme02.csproj @@ -48,6 +48,7 @@ + @@ -74,6 +75,7 @@ True Resources.resx + True SettingsSingleFileGenerator @@ -88,5 +90,8 @@ + + + \ No newline at end of file diff --git a/Bonhomme02/Form1.Designer.cs b/Bonhomme02/Form1.Designer.cs index 4879d15..5c2deb0 100644 --- a/Bonhomme02/Form1.Designer.cs +++ b/Bonhomme02/Form1.Designer.cs @@ -34,12 +34,14 @@ this.btnEffacer = new System.Windows.Forms.Button(); this.btnStopDeplacerCTick = new System.Windows.Forms.Button(); this.btnCreationCarrosse = new System.Windows.Forms.Button(); + this.Sol = new System.Windows.Forms.PictureBox(); ((System.ComponentModel.ISupportInitialize)(this.TV)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.Sol)).BeginInit(); this.SuspendLayout(); // // TV // - this.TV.Location = new System.Drawing.Point(13, 13); + this.TV.Location = new System.Drawing.Point(12, 13); this.TV.Name = "TV"; this.TV.Size = new System.Drawing.Size(782, 449); this.TV.TabIndex = 0; @@ -81,18 +83,32 @@ this.btnCreationCarrosse.UseVisualStyleBackColor = true; this.btnCreationCarrosse.Click += new System.EventHandler(this.btnCreationCarrosse_Click); // + // Sol + // + this.Sol.BackgroundImage = global::Bonhomme02.Properties.Resources.moon; + this.Sol.InitialImage = global::Bonhomme02.Properties.Resources.moon; + this.Sol.Location = new System.Drawing.Point(12, 415); + this.Sol.Name = "Sol"; + this.Sol.Size = new System.Drawing.Size(782, 47); + this.Sol.TabIndex = 12; + this.Sol.TabStop = false; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(807, 538); + this.Controls.Add(this.Sol); this.Controls.Add(this.btnCreationCarrosse); this.Controls.Add(this.btnEffacer); this.Controls.Add(this.btnStopDeplacerCTick); this.Controls.Add(this.TV); this.Name = "Form1"; this.Text = "Dessins Animés"; + this.Load += new System.EventHandler(this.Form1_Load); + this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove); ((System.ComponentModel.ISupportInitialize)(this.TV)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.Sol)).EndInit(); this.ResumeLayout(false); } @@ -104,6 +120,7 @@ private System.Windows.Forms.Button btnEffacer; private System.Windows.Forms.Button btnStopDeplacerCTick; private System.Windows.Forms.Button btnCreationCarrosse; + private System.Windows.Forms.PictureBox Sol; } } diff --git a/Bonhomme02/Form1.cs b/Bonhomme02/Form1.cs index 0bf0920..72a26c6 100644 --- a/Bonhomme02/Form1.cs +++ b/Bonhomme02/Form1.cs @@ -1 +1,81 @@ -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 +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Bonhomme02 +{ + public partial class Form1 : Form + { + private Bonhomme bonhomme; + private Marcher marche; + 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); + marche = new Marcher(ref bonhomme, this.TV.Handle, this.Sol.Location.Y-this.TV.Location.Y); + Thread.Sleep(1000); + Task.Factory.StartNew(() => marche.Avancer(5)); + //this.btnStopDeplacerCTick.Enabled = true; + // this.timerImage.Start(); + + } + + private void Form1_Load(object sender, EventArgs e) + { + + } + + private void Form1_MouseMove(object sender, MouseEventArgs e) + { + MousePosition.Offset(this.Location); + Console.WriteLine(MousePosition); + } + } +} diff --git a/Bonhomme02/Properties/Resources.Designer.cs b/Bonhomme02/Properties/Resources.Designer.cs index 8ddafee..9ed0597 100644 --- a/Bonhomme02/Properties/Resources.Designer.cs +++ b/Bonhomme02/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace Bonhomme02.Properties -{ - - +namespace Bonhomme02.Properties { + using System; + + /// /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. /// @@ -19,53 +19,55 @@ namespace Bonhomme02.Properties // à l'aide d'un outil, tel que ResGen ou Visual Studio. // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen // avec l'option /str ou régénérez votre projet VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bonhomme02.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Remplace la propriété CurrentUICulture du thread actuel pour toutes /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } + + /// + /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap moon { + get { + object obj = ResourceManager.GetObject("moon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Bonhomme02/Properties/Resources.resx b/Bonhomme02/Properties/Resources.resx index af7dbeb..d8b477c 100644 --- a/Bonhomme02/Properties/Resources.resx +++ b/Bonhomme02/Properties/Resources.resx @@ -46,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -60,6 +60,7 @@ : and then encoded with base64 encoding. --> + @@ -68,9 +69,10 @@ - + + @@ -85,9 +87,10 @@ - + + @@ -109,9 +112,13 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\moon.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file