using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace PaintDotNet
{
///
/// »¶Ó½çÃæ
///
internal class SplashForm : PdnBaseForm
{
private Label copyrightLabel;
//private PdnBanner banner;
private ProgressBar progressBar;
private PictureBox pictureBox;
private Image img;
private Size imgSize = new Size(600, 400);
public SplashForm()
{
//SuspendLayout();
//
// Required for Windows Form Designer support
//
InitializeComponent();
// Fill in the status label
//banner.BannerText = PdnResources.GetString("SplashForm.StatusLabel.Text");
// Fill in the copyright label
copyrightLabel.Text = PdnInfo.GetCopyrightString();
}
public SplashForm(string path)
{
GetWelcomeImge(path);
if(this.img != null)
{
if (this.img.Width > 0 && this.img.Height > 0)
this.imgSize = new Size(img.Width, img.Height);
else
this.imgSize = new Size(600, 400);
InitializeComponent();
copyrightLabel.Text = PdnInfo.GetCopyrightString();
CombineLogo();
this.pictureBox.Image = this.img;
}
}
///
/// Get Welcome Image From Local
///
///
private void GetWelcomeImge(string path)
{
if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
{
try
{
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
int byteLength = (int)fs.Length;
byte[] fileBytes = new byte[byteLength];
fs.Read(fileBytes, 0, byteLength);
fs.Close();
this.img = Image.FromStream(new MemoryStream(fileBytes));
}
catch (System.Exception)
{
this.img = PdnResources.GetImageResource("Images.Banner1.jpg").GetCopy();
}
finally
{
}
}
else
{
this.img = PdnResources.GetImageResource("Images.Banner1.jpg").GetCopy();
}
}
///
/// Combine Image And Logo
///
private void CombineLogo()
{
try
{
Image pdnLogo = PdnResources.GetImageResource("Images.TransparentLogo.png").GetCopy();
Graphics graphics = Graphics.FromImage(this.img);
graphics.DrawImage(pdnLogo, new PointF(0, 0));
graphics.Dispose();
}
catch (System.Exception)
{
}
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
//this.banner = new PdnBanner();
this.pictureBox = new PictureBox();
this.copyrightLabel = new Label();
this.progressBar = new ProgressBar();
this.SuspendLayout();
//
// banner
//
//this.banner.Name = "banner";
//this.banner.Location = new Point(0, 0);
//this.banner.Dock = DockStyle.Top;
//
//picturebox
//
this.pictureBox.Name = "banner";
this.pictureBox.Location = new Point(0, 0);
this.pictureBox.Dock = DockStyle.Top;
this.pictureBox.Size = imgSize;
//
// copyrightLabel
//
this.copyrightLabel.BackColor = Color.White;
this.copyrightLabel.Dock = DockStyle.Top;
this.copyrightLabel.Font = new Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.copyrightLabel.Name = "copyrightLabel";
//this.copyrightLabel.Size = new Size(this.banner.ClientSize.Width, 28);
this.copyrightLabel.Size = new Size(this.pictureBox.ClientSize.Width, 28);
this.copyrightLabel.TabIndex = 3;
this.copyrightLabel.TextAlign = ContentAlignment.MiddleLeft;
//
// progressBar
//
this.progressBar.Minimum = 0;
this.progressBar.Maximum = 0;
this.progressBar.Value = 0;
this.progressBar.Style = ProgressBarStyle.Marquee;
this.progressBar.MarqueeAnimationSpeed = 30;
this.progressBar.Dock = DockStyle.Top;
//this.progressBar.Size = new Size(this.banner.ClientSize.Width, 0);
this.progressBar.Size = new Size(this.pictureBox.ClientSize.Width, 0);
//
// SplashForm
//
this.AutoScaleDimensions = new SizeF(96F, 96F);
this.AutoScaleMode = AutoScaleMode.Dpi;
//this.ClientSize = new Size(
// this.banner.ClientSize.Width,
// this.banner.ClientSize.Height + this.copyrightLabel.ClientSize.Height + this.progressBar.ClientSize.Height);
this.ClientSize = new Size(
this.pictureBox.ClientSize.Width,
this.pictureBox.ClientSize.Height + this.copyrightLabel.ClientSize.Height + this.progressBar.ClientSize.Height);
this.ControlBox = false;
this.Controls.Add(this.copyrightLabel);
this.Controls.Add(this.progressBar);
//this.Controls.Add(this.banner);
this.Controls.Add(this.pictureBox);
this.FormBorderStyle = FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SplashForm";
this.ShowInTaskbar = false;
this.SizeGripStyle = SizeGripStyle.Hide;
this.StartPosition = FormStartPosition.CenterScreen;
this.ResumeLayout(false);
}
#endregion
}
}