Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. private void timer1_Tick(object sender, EventArgs e)
  2. {
  3. progressBar1.Increment(1);
  4. if (progressBar1.Value == 100) timer1.Stop();
  5. }
  6.  
  7. using System.Threading;
  8.  
  9. public void splash()
  10. {
  11. Application.Run(new splash());
  12. }
  13.  
  14. public partial class login : Form
  15. {
  16. public login()
  17. {
  18. Thread t = new Thread(new ThreadStart(splash));
  19. t.Start();
  20. Thread.Sleep(15625);
  21.  
  22. InitializeComponent();
  23.  
  24. enter code here
  25.  
  26. t.Abort();
  27. }
  28. }
  29.  
  30. private void timer1_Tick(object sender, EventArgs e)
  31. {
  32. counter++;
  33. progressBar1.Value = counter *5;
  34. // label2.Text = (5*counter).ToString();
  35. if (counter ==20)
  36. {
  37. timer1.Stop();
  38. this.Close();
  39. }
  40. }
  41. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  42. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  43. this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
  44. this.ClientSize = new System.Drawing.Size(397, 283);
  45. this.ControlBox = false;
  46. this.Controls.Add(this.label2);
  47. this.Controls.Add(this.progressBar1);
  48. this.Controls.Add(this.label1);
  49. this.ForeColor = System.Drawing.SystemColors.ControlLightLight;
  50. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  51. this.Name = "Splash";
  52. this.ShowIcon = false;
  53. this.ShowInTaskbar = false;
  54. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  55. this.ResumeLayout(false);
  56. this.PerformLayout();
  57.  
  58. sp = new Splash();
  59. sp.ShowDialog();
  60.  
  61. public class SplashForm : Form
  62. {
  63. Form _Parent;
  64. BackgroundWorker worker;
  65. public SplashForm(Form parent)
  66. {
  67. InitializeComponent();
  68. BackgroundWorker worker = new BackgroundWorker();
  69. this.worker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.worker _DoWork);
  70. backgroundWorker1.RunWorkerAsync();
  71. _Parent = parent;
  72. }
  73. private void worker _DoWork(object sender, DoWorkEventArgs e)
  74. {
  75. Thread.sleep(500);
  76. this.hide();
  77. _Parent.show();
  78. }
  79. }
  80.  
  81. static class Program
  82. {
  83. [STAThread]
  84. static void Main()
  85. {
  86. Application.EnableVisualStyles();
  87. Application.SetCompatibleTextRenderingDefault(false);
  88. Application.Run(new SplashForm());
  89. }
  90. }
  91.  
  92. static void Main()
  93. {
  94. Splash frmSplash = new Splash();
  95. frmSplash.Show();
  96. Application.Run(new ReportExplorer(frmSplash));
  97. }
  98.  
  99. public ReportExplorer(Splash frmSplash)
  100. {
  101. this.frmSplash = frmSplash;
  102. InitializeComponent();
  103. }
  104.  
  105. if (frmSplash != null)
  106. {
  107. frmSplash.Close();
  108. frmSplash = null;
  109. }
  110.  
  111. [STAThread]
  112. static void Main()
  113. {
  114. Application.EnableVisualStyles();
  115. Application.SetCompatibleTextRenderingDefault(false);
  116. Thread mythread;
  117. mythread = new Thread(new ThreadStart(ThreadLoop));
  118. mythread.Start();
  119. Application.Run(new MainForm(mythread));
  120. }
  121.  
  122. public static void ThreadLoop()
  123. {
  124. Application.Run(new SplashScreenForm());
  125. }
  126.  
  127. public MainForm(Thread splashscreenthread)
  128. {
  129. InitializeComponent();
  130.  
  131. //add your constructor code
  132.  
  133. splashscreenthread.Abort();
  134. }
  135.  
  136. int status = 0;
  137. private bool IsRunning = false;
  138. public Form1()
  139. {
  140. InitializeComponent();
  141. StartAnimation();
  142. }
  143.  
  144. public void StartAnimation()
  145. {
  146. backgroundWorker1.WorkerReportsProgress = false;
  147. backgroundWorker1.WorkerSupportsCancellation = true;
  148. IsRunning = true;
  149. backgroundWorker1.RunWorkerAsync();
  150. }
  151.  
  152.  
  153. public void StopAnimation()
  154. {
  155. backgroundWorker1.CancelAsync();
  156. }
  157.  
  158. delegate void UpdatingThreadAnimation();
  159. public void UpdateAnimationFromThread()
  160. {
  161.  
  162. try
  163. {
  164. if (label1.InvokeRequired == false)
  165. {
  166. UpdateAnimation();
  167. }
  168. else
  169. {
  170. UpdatingThreadAnimation d = new UpdatingThreadAnimation(UpdateAnimationFromThread);
  171. this.Invoke(d, new object[] { });
  172. }
  173. }
  174. catch(Exception e)
  175. {
  176.  
  177. }
  178. }
  179.  
  180. private void UpdateAnimation()
  181. {
  182. if(status ==0)
  183. {
  184. // mypicture.image = image1
  185. }else if(status ==1)
  186. {
  187. // mypicture.image = image2
  188. }
  189. //doing as much as needed
  190.  
  191. status++;
  192. if(status>1) //change here if you have more image, the idea is to set a cycle of images
  193. {
  194. status = 0;
  195. }
  196. this.Refresh();
  197. }
  198.  
  199. private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  200. {
  201. BackgroundWorker worker = sender as BackgroundWorker;
  202. while (IsRunning == true)
  203. {
  204. System.Threading.Thread.Sleep(100);
  205. UpdateAnimationFromThread();
  206. }
  207. }
  208.  
  209. public partial class ssplashscreen : Form
  210. {
  211. public ssplashscreen()
  212. {
  213. InitializeComponent();
  214. }
  215.  
  216. private void timer1_Tick(object sender, EventArgs e)
  217. {
  218. progressBar1.Increment(1);
  219. if (progressBar1.Value == 100)
  220. {
  221. timer1.Stop();
  222. this.Hide();
  223. Form frm = new login();
  224. frm.Show();
  225. }
  226. }
  227. }
  228.  
  229. namespace SplashScreen
  230. {
  231. public partial class frmSplashScreen : Form
  232. {
  233. public frmSplashScreen()
  234. {
  235. InitializeComponent();
  236. }
  237.  
  238. public int LeftTime { get; set; }
  239.  
  240. private void frmSplashScreen_Load(object sender, EventArgs e)
  241. {
  242. LeftTime = 20;
  243. timer1.Start();
  244. }
  245.  
  246. private void timer1_Tick(object sender, EventArgs e)
  247. {
  248. if (LeftTime > 0)
  249. {
  250. LeftTime--;
  251. }
  252. else
  253. {
  254. timer1.Stop();
  255. new frmHomeScreen().Show();
  256. this.Hide();
  257. }
  258. }
  259. }
  260. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement