SplashForm.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using Resources;
  2. using SmartCoalApplication.Core;
  3. using SmartCoalApplication.Resources;
  4. using System.Drawing;
  5. using System.IO;
  6. using System.Windows.Forms;
  7. namespace SmartCoalApplication
  8. {
  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. this.imgSize = new Size(600, 400);
  39. InitializeComponent();
  40. this.Size = new Size(600, 400);
  41. copyrightLabel.Text = PdnInfo.GetCopyrightString();
  42. CombineLogo();
  43. this.pictureBox.Image = this.img;
  44. }
  45. }
  46. /// <summary>
  47. /// Get Welcome Image From Local
  48. /// </summary>
  49. /// <param name="path"></param>
  50. private void GetWelcomeImge(string path)
  51. {
  52. if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path))
  53. {
  54. try
  55. {
  56. FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
  57. int byteLength = (int)fs.Length;
  58. byte[] fileBytes = new byte[byteLength];
  59. fs.Read(fileBytes, 0, byteLength);
  60. fs.Close();
  61. this.img = Image.FromStream(new MemoryStream(fileBytes));
  62. }
  63. catch (System.Exception)
  64. {
  65. this.img = PdnResources.GetImageResource("Images.Banner1.jpg").GetCopy();
  66. }
  67. finally
  68. {
  69. }
  70. }
  71. else
  72. {
  73. this.img = PdnResources.GetImageResource("Images.Banner1.jpg").GetCopy();
  74. }
  75. }
  76. /// <summary>
  77. /// Combine Image And Logo
  78. /// </summary>
  79. private void CombineLogo()
  80. {
  81. try
  82. {
  83. Image pdnLogo = PdnResources.GetImageResource("Images.TransparentLogo.png").GetCopy();
  84. Graphics graphics = Graphics.FromImage(this.img);
  85. graphics.DrawImage(pdnLogo, new PointF(0, 0));
  86. graphics.Dispose();
  87. }
  88. catch (System.Exception)
  89. {
  90. }
  91. }
  92. #region Windows Form Designer generated code
  93. /// <summary>
  94. /// Required method for Designer support - do not modify
  95. /// the contents of this method with the code editor.
  96. /// </summary>
  97. private void InitializeComponent()
  98. {
  99. this.pictureBox = new System.Windows.Forms.PictureBox();
  100. this.copyrightLabel = new System.Windows.Forms.Label();
  101. this.progressBar = new System.Windows.Forms.ProgressBar();
  102. ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
  103. this.SuspendLayout();
  104. //
  105. // pictureBox
  106. //
  107. this.pictureBox.Dock = System.Windows.Forms.DockStyle.Top;
  108. this.pictureBox.Location = new System.Drawing.Point(0, 0);
  109. this.pictureBox.Name = "pictureBox";
  110. this.pictureBox.Size = new System.Drawing.Size(291, 400);
  111. this.pictureBox.TabIndex = 5;
  112. this.pictureBox.TabStop = false;
  113. //
  114. // copyrightLabel
  115. //
  116. this.copyrightLabel.BackColor = System.Drawing.Color.White;
  117. this.copyrightLabel.Dock = System.Windows.Forms.DockStyle.Top;
  118. this.copyrightLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  119. this.copyrightLabel.Location = new System.Drawing.Point(0, 400);
  120. this.copyrightLabel.Name = "copyrightLabel";
  121. this.copyrightLabel.Size = new System.Drawing.Size(291, 28);
  122. this.copyrightLabel.TabIndex = 3;
  123. this.copyrightLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  124. //
  125. // progressBar
  126. //
  127. this.progressBar.Dock = System.Windows.Forms.DockStyle.Top;
  128. this.progressBar.Location = new System.Drawing.Point(0, 400);
  129. this.progressBar.MarqueeAnimationSpeed = 30;
  130. this.progressBar.Maximum = 0;
  131. this.progressBar.Name = "progressBar";
  132. this.progressBar.Size = new System.Drawing.Size(291, 0);
  133. this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
  134. this.progressBar.TabIndex = 4;
  135. //
  136. // SplashForm
  137. //
  138. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  139. //this.ClientSize = new System.Drawing.Size(291, 270);
  140. this.ControlBox = false;
  141. this.Controls.Add(this.copyrightLabel);
  142. this.Controls.Add(this.progressBar);
  143. this.Controls.Add(this.pictureBox);
  144. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  145. this.MaximizeBox = false;
  146. this.MinimizeBox = false;
  147. this.Name = "SplashForm";
  148. this.ShowInTaskbar = false;
  149. this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
  150. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  151. this.Controls.SetChildIndex(this.pictureBox, 0);
  152. this.Controls.SetChildIndex(this.progressBar, 0);
  153. this.Controls.SetChildIndex(this.copyrightLabel, 0);
  154. ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
  155. this.ResumeLayout(false);
  156. }
  157. #endregion
  158. }
  159. }