Beyound
13-01-2011, 19:54
Здравствуйте, есть форма, на которой обьект - PictureBox. И вот такой незамысловатый код. Вопрос в том - как определить конец проигрывания gif анимации, ну или заставить ее проигрывать покадрово командой, а не как по дефилту - автоматом по-кругу. Просто время засечь не катит ибо на разных машинах оно разное (вопрос производительности в конкретный момент)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public int local_time;
Random rand;
int last;
public Form1()
{
InitializeComponent();
local_time = 0;
rand = new Random();
choise.Start();
this.SetDesktopLocation(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Right - 109, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Bottom - 121);
}
private void choise_Tick(object sender, EventArgs e)
{
int choises;
do
{
choises = rand.Next(4, 11);
}
while (choises == last);
if (choises == 10)
{
pictureBox1.Image = WindowsFormsApplication3.Properties.Resources._1_4_5sec;
pos1.Start();
}
else
if (choises == 9)
{
pictureBox1.Image = WindowsFormsApplication3.Properties.Resources._2_3sec;
pos2.Start();
}
else
{
pictureBox1.Image = WindowsFormsApplication3.Properties.Resources.stay_0_4sec;
pos3.Start();
}
last = choises;
choise.Stop();
}
private void pos1_Tick(object sender, EventArgs e)
{
pos1.Stop();
choise.Start();
}
private void pos2_Tick(object sender, EventArgs e)
{
pos2.Stop();
choise.Start();
}
private void pos3_Tick(object sender, EventArgs e)
{
pos3.Stop();
choise.Start();
}
private void picture_refresher_Tick(object sender, EventArgs e)
{
pictureBox1.Refresh();
}
}
}
в ресурсах - 3-и gif анимашки разной длительности.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public int local_time;
Random rand;
int last;
public Form1()
{
InitializeComponent();
local_time = 0;
rand = new Random();
choise.Start();
this.SetDesktopLocation(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Right - 109, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Bottom - 121);
}
private void choise_Tick(object sender, EventArgs e)
{
int choises;
do
{
choises = rand.Next(4, 11);
}
while (choises == last);
if (choises == 10)
{
pictureBox1.Image = WindowsFormsApplication3.Properties.Resources._1_4_5sec;
pos1.Start();
}
else
if (choises == 9)
{
pictureBox1.Image = WindowsFormsApplication3.Properties.Resources._2_3sec;
pos2.Start();
}
else
{
pictureBox1.Image = WindowsFormsApplication3.Properties.Resources.stay_0_4sec;
pos3.Start();
}
last = choises;
choise.Stop();
}
private void pos1_Tick(object sender, EventArgs e)
{
pos1.Stop();
choise.Start();
}
private void pos2_Tick(object sender, EventArgs e)
{
pos2.Stop();
choise.Start();
}
private void pos3_Tick(object sender, EventArgs e)
{
pos3.Stop();
choise.Start();
}
private void picture_refresher_Tick(object sender, EventArgs e)
{
pictureBox1.Refresh();
}
}
}
в ресурсах - 3-и gif анимашки разной длительности.