TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
hamid taposh
NA
1
0
GIF image is not animated in Windows Mobile 6 professional Emulator
Mar 17 2009 8:55 AM
hi ,
I have written the following code for animating a GIF image using .Net Compact Frame Work in
C#. The GIF image would be animate . But here the GIF image is not animating here . Please tell
me where is the problem . I need the solution in emergency.
I use two class .
First Class
-----------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
namespace MobileAnimation
{
public partial class AnimateCtl : System.Windows.Forms.Control
{
Graphics graphics;
Timer fTimer;
public AnimateCtl()
{
InitializeComponent();
graphics = this.CreateGraphics();
DrawCustomGui();
}
int frameCount = 30;
int frameWidth;
int loopCount;
int loopCounter;
int frameHeight;
int currentFrame = 0;
Image animatedImage = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(@"MobileAnimation.ani-loading.gif"));
public void StartAnimation(int DelayInterval, int LoopCount)
{
frameWidth = animatedImage.Width;
// frameWidth =5;
//How many times to loop
loopCount = LoopCount;
//Reset loop counter
loopCounter = 0;
//Calculate the frameCount
//frameCount = bitmap.Width / frameWidth;
frameHeight = animatedImage.Height;
//Resize the control
this.Size = new Size(frameWidth, frameHeight);
//Assign delay interval to the timer
fTimer.Interval = DelayInterval;
//Start the timer
fTimer.Enabled = true;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if (loopCount == -1) //loop continuously
{
this.DrawFrame();
}
else
{
if (loopCount == loopCounter) //stop the animation
fTimer.Enabled = false;
else
this.DrawFrame();
}
}
private void DrawFrame()
{
if (currentFrame < frameCount - 1)
{
//move to the next frame
currentFrame++;
}
else
{
//increment the loopCounter
loopCounter++;
currentFrame = 0;
}
Draw(currentFrame);
}
private void Draw(int iframe)
{
//Calculate the left location of the drawing frame
int XLocation = iframe * frameWidth;
Rectangle rect = new Rectangle(XLocation, 0, frameWidth, frameHeight);
//Draw image
graphics.DrawImage(animatedImage, 0, 0, rect, GraphicsUnit.Pixel);
}
private void DrawCustomGui()
{
SuspendLayout();
fTimer = new System.Windows.Forms.Timer();
StartAnimation(100, 3);
fTimer.Tick += new System.EventHandler(this.timer1_Tick);
PictureBox pictBox = new PictureBox();
//Image loadImage = new Bitmap(SDSL.MobileMap.WindowsMobile6.Control.Application.Program.appDir + "\\images\\ani-loading.gif");
pictBox.Image = animatedImage;
pictBox.Location = new Point(0, 0);
//pictBox.Size = new Size(220, 180);
pictBox.Size = new Size(138, 120);
Controls.Add(pictBox);
// Controls.Add(pictBox);
ResumeLayout();
}
}
}
Second Class
----------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MobileAnimation
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
AnimateCtl animateCtl = new AnimateCtl();
animateCtl.Location = new Point(50, 50);
this.Controls.Add(animateCtl);
}
}
}
Reply
Answers (
0
)
.net Anwendung auf winCE 5.0
Flipping or mirroring text?