From 9a471eafa01078b6177c747d37a722d1e2a7483b Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 14 Feb 2018 20:00:27 +0000 Subject: [PATCH] Animation Class --- EduNetworkBuilder/AnimationClass.cs | 69 ++++++++++++++++++++++ EduNetworkBuilder/EduNetworkBuilder.csproj | 1 + EduNetworkBuilder/NB.cs | 1 + 3 files changed, 71 insertions(+) create mode 100644 EduNetworkBuilder/AnimationClass.cs diff --git a/EduNetworkBuilder/AnimationClass.cs b/EduNetworkBuilder/AnimationClass.cs new file mode 100644 index 0000000..a340fe7 --- /dev/null +++ b/EduNetworkBuilder/AnimationClass.cs @@ -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); + } + } +} diff --git a/EduNetworkBuilder/EduNetworkBuilder.csproj b/EduNetworkBuilder/EduNetworkBuilder.csproj index 5c22aeb..6bbf555 100644 --- a/EduNetworkBuilder/EduNetworkBuilder.csproj +++ b/EduNetworkBuilder/EduNetworkBuilder.csproj @@ -84,6 +84,7 @@ + Form diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index b899817..fe8f95e 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -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 }