SplashForm.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using System.Drawing;
  2. using System.IO;
  3. using System.Windows.Forms;
  4. namespace PaintDotNet
  5. {
  6. /// <summary>
  7. /// »¶Ó­½çÃæ
  8. /// </summary>
  9. internal class SplashForm : PdnBaseForm
  10. {
  11. private Label copyrightLabel;
  12. //private PdnBanner banner;
  13. private ProgressBar progressBar;
  14. private PictureBox pictureBox;
  15. private Image img;
  16. private Size imgSize = new Size(600, 400);
  17. public SplashForm()
  18. {
  19. //SuspendLayout();
  20. //
  21. // Required for Windows Form Designer support
  22. //
  23. InitializeComponent();
  24. // Fill in the status label
  25. //banner.BannerText = PdnResources.GetString("SplashForm.StatusLabel.Text");
  26. // Fill in the copyright label
  27. copyrightLabel.Text = PdnInfo.GetCopyrightString();
  28. }
  29. public SplashForm(string path)
  30. {
  31. GetWelcomeImge(path);
  32. if(this.img != null)
  33. {
  34. if (this.img.Width > 0 && this.img.Height > 0)
  35. this.imgSize = new Size(img.Width, img.Height);
  36. else
  37. this.imgSize = new Size(600, 400);
  38. InitializeComponent();
  39. copyrightLabel.Text = PdnInfo.GetCopyrightString();
  40. CombineLogo();
  41. this.pictureBox.Image = this.img;
  42. }
  43. }
  44. /// <summary>
  45. /// Get Welcome Image From Local
  46. /// </summary>
  47. /// <param name="path"></param>
  48. private void GetWelcomeImge(string path)
  49. {
  50. if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
  51. {
  52. try
  53. {
  54. FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
  55. int byteLength = (int)fs.Length;
  56. byte[] fileBytes = new byte[byteLength];
  57. fs.Read(fileBytes, 0, byteLength);
  58. fs.Close();
  59. this.img = Image.FromStream(new MemoryStream(fileBytes));
  60. }
  61. catch (System.Exception)
  62. {
  63. this.img = PdnResources.GetImageResource("Images.Banner1.jpg").GetCopy();
  64. }
  65. finally
  66. {
  67. }
  68. }
  69. else
  70. {
  71. this.img = PdnResources.GetImageResource("Images.Banner1.jpg").GetCopy();
  72. }
  73. }
  74. /// <summary>
  75. /// Combine Image And Logo
  76. /// </summary>
  77. private void CombineLogo()
  78. {
  79. try
  80. {
  81. Image pdnLogo = PdnResources.GetImageResource("Images.TransparentLogo.png").GetCopy();
  82. Graphics graphics = Graphics.FromImage(this.img);
  83. graphics.DrawImage(pdnLogo, new PointF(0, 0));
  84. graphics.Dispose();
  85. }
  86. catch (System.Exception)
  87. {
  88. }
  89. }
  90. #region Windows Form Designer generated code
  91. /// <summary>
  92. /// Required method for Designer support - do not modify
  93. /// the contents of this method with the code editor.
  94. /// </summary>
  95. private void InitializeComponent()
  96. {
  97. //this.banner = new PdnBanner();
  98. this.pictureBox = new PictureBox();
  99. this.copyrightLabel = new Label();
  100. this.progressBar = new ProgressBar();
  101. this.SuspendLayout();
  102. //
  103. // banner
  104. //
  105. //this.banner.Name = "banner";
  106. //this.banner.Location = new Point(0, 0);
  107. //this.banner.Dock = DockStyle.Top;
  108. //
  109. //picturebox
  110. //
  111. this.pictureBox.Name = "banner";
  112. this.pictureBox.Location = new Point(0, 0);
  113. this.pictureBox.Dock = DockStyle.Top;
  114. this.pictureBox.Size = imgSize;
  115. //
  116. // copyrightLabel
  117. //
  118. this.copyrightLabel.BackColor = Color.White;
  119. this.copyrightLabel.Dock = DockStyle.Top;
  120. this.copyrightLabel.Font = new Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
  121. this.copyrightLabel.Name = "copyrightLabel";
  122. //this.copyrightLabel.Size = new Size(this.banner.ClientSize.Width, 28);
  123. this.copyrightLabel.Size = new Size(this.pictureBox.ClientSize.Width, 28);
  124. this.copyrightLabel.TabIndex = 3;
  125. this.copyrightLabel.TextAlign = ContentAlignment.MiddleLeft;
  126. //
  127. // progressBar
  128. //
  129. this.progressBar.Minimum = 0;
  130. this.progressBar.Maximum = 0;
  131. this.progressBar.Value = 0;
  132. this.progressBar.Style = ProgressBarStyle.Marquee;
  133. this.progressBar.MarqueeAnimationSpeed = 30;
  134. this.progressBar.Dock = DockStyle.Top;
  135. //this.progressBar.Size = new Size(this.banner.ClientSize.Width, 0);
  136. this.progressBar.Size = new Size(this.pictureBox.ClientSize.Width, 0);
  137. //
  138. // SplashForm
  139. //
  140. this.AutoScaleDimensions = new SizeF(96F, 96F);
  141. this.AutoScaleMode = AutoScaleMode.Dpi;
  142. //this.ClientSize = new Size(
  143. // this.banner.ClientSize.Width,
  144. // this.banner.ClientSize.Height + this.copyrightLabel.ClientSize.Height + this.progressBar.ClientSize.Height);
  145. this.ClientSize = new Size(
  146. this.pictureBox.ClientSize.Width,
  147. this.pictureBox.ClientSize.Height + this.copyrightLabel.ClientSize.Height + this.progressBar.ClientSize.Height);
  148. this.ControlBox = false;
  149. this.Controls.Add(this.copyrightLabel);
  150. this.Controls.Add(this.progressBar);
  151. //this.Controls.Add(this.banner);
  152. this.Controls.Add(this.pictureBox);
  153. this.FormBorderStyle = FormBorderStyle.None;
  154. this.MaximizeBox = false;
  155. this.MinimizeBox = false;
  156. this.Name = "SplashForm";
  157. this.ShowInTaskbar = false;
  158. this.SizeGripStyle = SizeGripStyle.Hide;
  159. this.StartPosition = FormStartPosition.CenterScreen;
  160. this.ResumeLayout(false);
  161. }
  162. #endregion
  163. }
  164. }