splash: Cleaned up code

This commit is contained in:
Nathan Woodburn 2023-06-21 19:40:31 +10:00
parent 9f0f7214e2
commit a4a35ad62e
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -1,6 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging; using System.Drawing.Imaging;
//using Microsoft.DirectX.AudioVideoPlayback;
namespace FireWallet namespace FireWallet
@ -14,6 +13,7 @@ namespace FireWallet
IsClosed = false; IsClosed = false;
} }
bool close; bool close;
float opacity = 0.0f;
private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e) private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
{ {
if (!close) if (!close)
@ -30,7 +30,6 @@ namespace FireWallet
timerIn.Stop(); timerIn.Stop();
timerOut.Start(); timerOut.Start();
} }
private void label2_Click(object sender, EventArgs e) private void label2_Click(object sender, EventArgs e)
{ {
ProcessStartInfo psi = new ProcessStartInfo ProcessStartInfo psi = new ProcessStartInfo
@ -51,38 +50,22 @@ namespace FireWallet
{ {
try try
{ {
//create a Bitmap the size of the image provided
Bitmap bmp = new Bitmap(image.Width, image.Height); Bitmap bmp = new Bitmap(image.Width, image.Height);
//create a graphics object from the image
using (Graphics gfx = Graphics.FromImage(bmp)) using (Graphics gfx = Graphics.FromImage(bmp))
{ {
//create a color matrix object
ColorMatrix matrix = new ColorMatrix(); ColorMatrix matrix = new ColorMatrix();
//set the opacity
matrix.Matrix33 = opacity; matrix.Matrix33 = opacity;
//create image attributes
ImageAttributes attributes = new ImageAttributes(); ImageAttributes attributes = new ImageAttributes();
//set the color(opacity) of the image
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
//now draw the image
gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes);
} }
return bmp; return bmp;
} }
catch (Exception ex) catch
{ {
MessageBox.Show(ex.Message);
return null; return null;
} }
} }
float opacity = 0.0f;
private void timerIn_Tick(object sender, EventArgs e) private void timerIn_Tick(object sender, EventArgs e)
{ {
if (opacity >= 1) if (opacity >= 1)
@ -94,7 +77,6 @@ namespace FireWallet
pictureBoxNew.Image = SetImageOpacity(splash, opacity); pictureBoxNew.Image = SetImageOpacity(splash, opacity);
pictureBoxNew.Invalidate(); pictureBoxNew.Invalidate();
} }
private void timerOut_Tick(object sender, EventArgs e) private void timerOut_Tick(object sender, EventArgs e)
{ {
if (opacity <= 0) if (opacity <= 0)