Lista de obiecte

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using System.IO;
using System.Drawing.Imaging;

namespace ImageListExample
{

public class ImageListExample : System.Windows.Forms.Form
{
internal System.Windows.Forms.Button contruieste_lista;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Button button1;
private System.ComponentModel.IContainer components;

public ImageListExample()
{

InitializeComponent();

}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.contruieste_lista = new System.Windows.Forms.Button();
this.imageList1 = new System.Windows.Forms.ImageList this.components);
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.SuspendLayout();

this.contruieste_lista.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.contruieste_lista.Location = new System.Drawing.Point(23, 248);
this.contruieste_lista.Name = „contruieste_lista”;
this.contruieste_lista.Size = new System.Drawing.Size(120, 32);
this.contruieste_lista.TabIndex = 2;
this.contruieste_lista.Text = „Desene”;
this.contruieste_lista.Click += new System.EventHandler(this.contruieste_lista_Click);
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// pictureBox2
//
this.pictureBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
this.pictureBox2.Location = new System.Drawing.Point(298, 190);
this.pictureBox2.Name = „pictureBox2”;
this.pictureBox2.Size = new System.Drawing.Size(136, 96);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox2.TabIndex = 4;
this.pictureBox2.TabStop = false;
this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(177, 248);
this.button1.Name = „button1”;
this.button1.Size = new System.Drawing.Size(104, 32);
this.button1.TabIndex = 5;
this.button1.Text = „Animate”;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// ImageListExample
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(950, 312);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.contruieste_lista);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Name = „ImageListExample”;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.Text = „PV6”;
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new ImageListExample());
}

ImageList desene_animate = new System.Windows.Forms.ImageList();

private void contruieste_lista_Click(object sender, System.EventArgs e)
{
// Configureaza lista
desene_animate.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
desene_animate.ImageSize = new System.Drawing.Size(60, 60);
desene_animate.Images.Clear();

string[] gif_uri = Directory.GetFiles(„\\Imagini”, „*.gif”);

// se construieste un obiect Imagine pentru fiecare fisier si se adauga la ImageList.

foreach (string fisier_gif in gif_uri)
{
Bitmap desen= new Bitmap (fisier_gif);
desene_animate.Images.Add(desen);
pictureBox2.Image=desen;
}

Graphics g = this.CreateGraphics();

// Deseneaza fiecare imagine utilizand metoda ImageList.Draw()
//MessageBox.Show(„”+desene_animate.Images.Count);

for (int i = 0; i < desene_animate.Images.Count; i++)
{
//if (i<10)
desene_animate.Draw(g, 60 + i * 60, 60, i);
//else desene_animate.Draw(g, 60 + (i-10) * 60, 120, i);
}
g.Dispose();

}

private void button1_Click(object sender, System.EventArgs e)
{
string[] gif_uri = Directory.GetFiles(„E:\\Imagini”, „*.gif”);

foreach (string fisier_gif in gif_uri)
{
Bitmap desen= new Bitmap (fisier_gif);
pictureBox2.Image=desen;
MessageBox.Show(„Next”);
}

}

private void pictureBox2_Click(object sender, EventArgs e)
{

}

}
}

Despre scoalamultimedia
la 3 click distanta :)

Lasă un răspuns

Completează mai jos detaliile despre tine sau dă clic pe un icon pentru autentificare:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s

%d blogeri au apreciat asta: