Animate a bitmap?


Author
Message
Ron Sawyer
Ron Sawyer
Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)
Group: Forum Members
Posts: 16, Visits: 1
I have custom shape that displays a bitmap using a rectangle shape and NImageFillStyle like so:

MyRect.Style.FillStyle = new NImageFillStyle(MyImageBitmap1);

Descended from this custom shape is an Animated Shape. The Animate function is called on a timer tick and simply changes the FillStyle, (See below). Is this the best way to do this? Is there anything I have to dispose, to avoid a memory leak?

protected void Animate()
{

////////////////////////////////////////
// Check to see if there is a bitmap
// for the index. If not, go to the next
// one and try again. If so, break from
// our loop. Always break on Index 0
bool Found = false;
while (!Found)
{
MyImageIndex++;
if (MyImageIndex > 4)
MyImageIndex = 0;
switch (MyImageIndex)
{
case 0:
if (MyImageBitmap1 != null)
MyRect.Style.FillStyle = new NImageFillStyle(MyImageBitmap1);
Found = true;
break;
case 1:
if (MyImageBitmap2 != null)
{
MyRect.Style.FillStyle = new NImageFillStyle(MyImageBitmap2);
Found = true;
}
break;
case 2:
if (MyImageBitmap3 != null)
{
MyRect.Style.FillStyle = new NImageFillStyle(MyImageBitmap3);
Found = true;
}
break;
case 3:
if (MyImageBitmap4 != null)
{
MyRect.Style.FillStyle = new NImageFillStyle(MyImageBitmap4);
Found = true;
}
break;
case 4:
if (MyImageBitmap5 != null)
{
MyRect.Style.FillStyle = new NImageFillStyle(MyImageBitmap5);
Found = true;
}
break;
}
} // end while not found
}


As an aside, I am porting an application from a competitor's diagram tool. I have a few questions on trying to map some of their functionality to yours. Do you prefer that I post one question per thread, or do you prefer I post all my questions in one thread?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search