Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset
Commentaires fermés

Exemple d’animation avec ‘DoubleBuffered’

Modifier,le,mode,de,composition,d'une,image
Download

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
public class AnimationDoubleBuffer : Form
{
 
    /**
     *  Animation des objets avec DoubleBuffered
     *
     *
     *
     *
     *           */
 
    private int taille = 0;
    private bool aRetrecir = true;
 
    private System.Windows.Forms.Timer monTimer;
    private IContainer components;
    private System.Windows.Forms.CheckBox checkBoxEtat;
      public AnimationDoubleBuffer()
      {
      InitializeComponent();
      monTimer.Start();
      }
 
    private void tmrRefresh_Tick(object sender, System.EventArgs e)
    {
      if (aRetrecir)
        taille--;
      else
        taille++;
 
      if (taille > this.Width/2)
        aRetrecir = true;
      else if (taille < 1)
        aRetrecir = false;
 
      this.Invalidate();
    }
 
    private void DoubleBuffering_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
      this.DoubleBuffered = checkBoxEtat.Checked;
 
      Graphics g = e.Graphics;
      g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
      g.DrawEllipse(new Pen(Color.Black, 10), 50, 50, 50 + taille, 50 + taille);
 
    }
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        this.monTimer = new System.Windows.Forms.Timer(this.components);
        this.checkBoxEtat = new System.Windows.Forms.CheckBox();
        this.SuspendLayout();
        //
        // monTimer
        //
        this.monTimer.Interval = 1;
        this.monTimer.Tick += new System.EventHandler(this.tmrRefresh_Tick);
        //
        // checkBoxEtat
        //
        this.checkBoxEtat.BackColor = System.Drawing.Color.DarkSalmon;
        this.checkBoxEtat.Location = new System.Drawing.Point(12, 12);
        this.checkBoxEtat.Name = "checkBoxEtat";
        this.checkBoxEtat.Size = new System.Drawing.Size(336, 16);
        this.checkBoxEtat.TabIndex = 2;
        this.checkBoxEtat.Text = "Utiliser le Double Buffering";
        this.checkBoxEtat.UseVisualStyleBackColor = false;
        //
        // AnimationDoubleBuffer
        //
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(422, 373);
        this.Controls.Add(this.checkBoxEtat);
        this.Name = "AnimationDoubleBuffer";
        this.Text = "Animation Double Buffer";
        this.Paint += new System.Windows.Forms.PaintEventHandler(this.DoubleBuffering_Paint);
        this.ResumeLayout(false);
 
    }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new AnimationDoubleBuffer());
  }
 
}
----------------------------------------------------------------------------

No comments yet.

Leave a Comment

*