forked from jadaradix/dsgamemaker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPreview.cs
More file actions
53 lines (47 loc) · 1.66 KB
/
Preview.cs
File metadata and controls
53 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace DS_Game_Maker
{
public partial class Preview
{
public Image TheImage;
public Size ImageSize = new Size();
public byte Speed;
private byte FrameOn = 0;
private byte FrameCount = 0;
public Preview()
{
InitializeComponent();
}
public Bitmap GetFrame(short FrameNumber)
{
var Returnable = new Bitmap(ImageSize.Width, ImageSize.Height);
var NewGFX = Graphics.FromImage(Returnable);
NewGFX.DrawImage(TheImage, new Point(0, FrameNumber * ImageSize.Height * -1));
NewGFX.Dispose();
if ((int)Convert.ToByte(SettingsLib.GetSetting("TRANSPARENT_ANIMATIONS")) == 1)
Returnable = (Bitmap)DSGMlib.MakeBMPTransparent(Returnable, Color.Magenta);
return Returnable;
}
private void DCloseButton_Click(object sender, EventArgs e)
{
MainTimer.Enabled = false;
Close();
}
private void Preview_Load(object sender, EventArgs e)
{
FrameOn = 0;
byte WaitTime = (byte)Math.Round(60d / Speed);
MainTimer.Interval = (int)Math.Round(WaitTime / 60d * 1000d);
FrameCount = (byte)Math.Round(TheImage.Height / (double)ImageSize.Height);
MainTimer.Enabled = true;
}
private void MainTimer_Tick(object sender, EventArgs e)
{
FrameOn = (byte)(FrameOn + 1);
// MsgError("Showing " + FrameOn.ToString)
if (FrameOn == FrameCount)
FrameOn = 0;
PreviewPanel.BackgroundImage = GetFrame(FrameOn);
}
}
}