Animation Class

This commit is contained in:
Tim Young 2018-02-14 20:00:27 +00:00
parent 9bb974c70a
commit 9a471eafa0
3 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace EduNetworkBuilder
{
//Holds a little bit of information pertaining to the current animation.
public class AnimationClass
{
Point ImageStartPoint = new Point();
Rectangle Where;
Size HowBig; //how big is each animation.
public DateTime NextAnimation;
int AnimationCount = 0;
int AnimationSpeed = 300; //ms between animations
Image BackgroundSnip;
int maxAnim = 6;
public bool AnimationDone { get { if (AnimationCount > 0) return false; return true; } }
public bool FinalErase = false;
public AnimationClass(AnimationName What, Rectangle where)
{
Where = where;
switch(What)
{
case AnimationName.Fire1:
ImageStartPoint = new Point(0,0);
HowBig = new Size(100, 100);
AnimationCount = 6;
break;
case AnimationName.Smoke1:
ImageStartPoint = new Point(0, 100);
HowBig = new Size(100, 100);
AnimationCount = 6;
break;
case AnimationName.Spark1:
ImageStartPoint = new Point(0, 200);
HowBig = new Size(100, 100);
AnimationCount = 6;
break;
}
}
public void GrabBackground(Image TheNetworkImage)
{
BackgroundSnip = new Bitmap(Where.Width, Where.Height);
Graphics.FromImage(BackgroundSnip).DrawImage(TheNetworkImage, new Rectangle(0, 0, Where.Width, Where.Height), Where, GraphicsUnit.Pixel);
}
public void DrawAnimation(Image TheNetworkImage)
{
Bitmap AnimationFrame = new Bitmap(Where.Width, Where.Height);
Rectangle AniminSnip = new Rectangle((maxAnim - AnimationCount) * HowBig.Width, ImageStartPoint.Y, HowBig.Width, HowBig.Height);
Graphics.FromImage(AnimationFrame).DrawImage(Properties.Resources.Animations, new Rectangle(0, 0, Where.Width, Where.Height), AniminSnip, GraphicsUnit.Pixel);
Graphics.FromImage(TheNetworkImage).DrawImage(AnimationFrame, new Rectangle(0, 0, Where.Width, Where.Height), Where, GraphicsUnit.Pixel);
}
public void EraseAnimation(Image TheNetworkImage)
{
Graphics.FromImage(TheNetworkImage).DrawImage(BackgroundSnip, Where, new Rectangle(0,0,Where.Width, Where.Height), GraphicsUnit.Pixel);
}
}
}

View File

@ -84,6 +84,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AnimationClass.cs" />
<Compile Include="DeviceConfig.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -50,6 +50,7 @@ namespace EduNetworkBuilder
LockVLANsOnHost, LockNicVLAN, LockInterfaceVLAN, LockVLANNames,
DeviceIsFrozen, DeviceBlowsUpWithPower, DeviceNeedsUPS,
}
public enum AnimationName { Spark1, Fire1, Smoke1 }
public enum ContextTest { ping, arp, traceroute }
public enum NetTestVerbosity { none, basic, hints, full }
public enum LBContents { routes, messages, dhcp, puzzles }