Skip to content

Commit

Permalink
can do some stuff wiht the things to import
Browse files Browse the repository at this point in the history
  • Loading branch information
factubsio committed Mar 11, 2023
1 parent 8199c72 commit 9dd3302
Show file tree
Hide file tree
Showing 12 changed files with 593 additions and 393 deletions.
52 changes: 47 additions & 5 deletions BlueprintExplorer/AnimatedImageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class AnimatedImageBox : Control
private FrameDimension _FrameDim;
private int _Count = 0;
private Bitmap _Image;
private double _Progress = 0;
private readonly Font _CaptionFont;
private string _Caption;
public Bitmap Image
{
get => _Image;
Expand Down Expand Up @@ -57,37 +60,76 @@ public int Percent
{
set
{
Frame = (int)((value / 100.0) * _Count);
_Progress = (value / 100.0);
Frame++;
}
}

public string Caption
{
get => _Caption;
set
{
if (value != _Caption)
{
_Caption = value;
Invalidate();
}

}
}
public bool ShowProgressBar;

protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
Rectangle rect = new(Point.Empty, ClientSize);
if (_Image != null)
{
g.DrawImage(_Image, rect, new(Point.Empty, new(_Image.Width, _Image.Height)), GraphicsUnit.Pixel);

const int barThickness = 30;
const int barMargin = 10;
if (ShowProgressBar)
{
Rectangle progRect = new(barMargin, rect.Bottom - barMargin - barThickness, rect.Width - barMargin * 2, barThickness);
g.FillRectangle(Brushes.BlanchedAlmond, progRect);
g.DrawRectangle(new Pen(Brushes.DarkBlue, 2), progRect);
progRect.Inflate(-3, -3);
progRect.Width = (int)((progRect.Width - 6) * _Progress);
g.FillRectangle(Brushes.DarkBlue, progRect);

}
if (Caption != null)
{
var height = _CaptionFont.Height;
g.DrawString(Caption, _CaptionFont, Brushes.White, barMargin, rect.Bottom - barMargin - barThickness - height - barMargin);
}
}
else
{
g.FillRectangle(Brushes.Orange, rect);
}
}
internal void SetPercentSafe(int value)
{
Invoke(new Action(() => Percent = value));
}

internal void IncrementSafe()
internal void SetSafe(int value)
{
Invoke(new Action(IncrementUnsafe));
Invoke(new Action(() => Frame = value));
}

private void IncrementUnsafe()
internal void IncrementSafe()
{
Frame++;
Invoke(new Action(() => Frame++));
}

public AnimatedImageBox()
{
DoubleBuffered = true;
_CaptionFont = new(this.Font.FontFamily, 24);
}
}
}
Loading

0 comments on commit 9dd3302

Please sign in to comment.