Skip to content

Commit

Permalink
Fix splash screen flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
pixtur committed Aug 23, 2023
1 parent b531f94 commit 5fa337a
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions Editor/SplashScreen/SplashScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,37 @@ namespace T3.Editor.SplashScreen;

internal class SplashScreen : ISplashScreen
{
private class SplashForm : Form
{
public SplashForm()
{

}

public void PreventFlickering()
{
SetStyle(ControlStyles.DoubleBuffer
| ControlStyles.UserPaint
| ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
}
}

public void Show(string imagePath)
{
var backgroundImage = Image.FromFile(imagePath);
var imageSize = GetScaledSize(backgroundImage);

_splashForm = new Form
_splashForm = new SplashForm
{
FormBorderStyle = FormBorderStyle.None,
StartPosition = FormStartPosition.CenterScreen,
BackgroundImage = backgroundImage,
BackgroundImageLayout = ImageLayout.Stretch,
Size = imageSize
Size = imageSize,
};
_splashForm.PreventFlickering();


var tableLayoutPanel = new TableLayoutPanel
{
Expand All @@ -31,6 +49,7 @@ public void Show(string imagePath)
CellBorderStyle = TableLayoutPanelCellBorderStyle.None,
BackColor = Color.Transparent,
};

tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80F));

Expand All @@ -45,6 +64,7 @@ public void Show(string imagePath)
UseMnemonic = false,
Font = new Font("Arial", 8),
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,

}, 0, 0);

_logMessageLabel = new Label
Expand Down Expand Up @@ -116,7 +136,7 @@ private void WriteTextSafe(string text)
{
_logMessageLabel.Text = text;
_logMessageLabel.Refresh();
_splashForm.Refresh();
//_splashForm.Refresh();
_invoked = false;

}
Expand All @@ -138,7 +158,7 @@ public void ProcessEntry(ILogEntry entry)
#endregion

private static readonly Size _baseDpi = new(96, 96);
private Form _splashForm;
private SplashForm _splashForm;
private Label _logMessageLabel;

}

0 comments on commit 5fa337a

Please sign in to comment.