Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void timer1_Tick(object sender, EventArgs e)
- {
- progressBar1.Increment(1);
- if (progressBar1.Value == 100) timer1.Stop();
- }
- using System.Threading;
- public void splash()
- {
- Application.Run(new splash());
- }
- public partial class login : Form
- {
- public login()
- {
- Thread t = new Thread(new ThreadStart(splash));
- t.Start();
- Thread.Sleep(15625);
- InitializeComponent();
- enter code here
- t.Abort();
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- counter++;
- progressBar1.Value = counter *5;
- // label2.Text = (5*counter).ToString();
- if (counter ==20)
- {
- timer1.Stop();
- this.Close();
- }
- }
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
- this.ClientSize = new System.Drawing.Size(397, 283);
- this.ControlBox = false;
- this.Controls.Add(this.label2);
- this.Controls.Add(this.progressBar1);
- this.Controls.Add(this.label1);
- this.ForeColor = System.Drawing.SystemColors.ControlLightLight;
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.Name = "Splash";
- this.ShowIcon = false;
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.ResumeLayout(false);
- this.PerformLayout();
- sp = new Splash();
- sp.ShowDialog();
- public class SplashForm : Form
- {
- Form _Parent;
- BackgroundWorker worker;
- public SplashForm(Form parent)
- {
- InitializeComponent();
- BackgroundWorker worker = new BackgroundWorker();
- this.worker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.worker _DoWork);
- backgroundWorker1.RunWorkerAsync();
- _Parent = parent;
- }
- private void worker _DoWork(object sender, DoWorkEventArgs e)
- {
- Thread.sleep(500);
- this.hide();
- _Parent.show();
- }
- }
- static class Program
- {
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.Run(new SplashForm());
- }
- }
- static void Main()
- {
- Splash frmSplash = new Splash();
- frmSplash.Show();
- Application.Run(new ReportExplorer(frmSplash));
- }
- public ReportExplorer(Splash frmSplash)
- {
- this.frmSplash = frmSplash;
- InitializeComponent();
- }
- if (frmSplash != null)
- {
- frmSplash.Close();
- frmSplash = null;
- }
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Thread mythread;
- mythread = new Thread(new ThreadStart(ThreadLoop));
- mythread.Start();
- Application.Run(new MainForm(mythread));
- }
- public static void ThreadLoop()
- {
- Application.Run(new SplashScreenForm());
- }
- public MainForm(Thread splashscreenthread)
- {
- InitializeComponent();
- //add your constructor code
- splashscreenthread.Abort();
- }
- int status = 0;
- private bool IsRunning = false;
- public Form1()
- {
- InitializeComponent();
- StartAnimation();
- }
- public void StartAnimation()
- {
- backgroundWorker1.WorkerReportsProgress = false;
- backgroundWorker1.WorkerSupportsCancellation = true;
- IsRunning = true;
- backgroundWorker1.RunWorkerAsync();
- }
- public void StopAnimation()
- {
- backgroundWorker1.CancelAsync();
- }
- delegate void UpdatingThreadAnimation();
- public void UpdateAnimationFromThread()
- {
- try
- {
- if (label1.InvokeRequired == false)
- {
- UpdateAnimation();
- }
- else
- {
- UpdatingThreadAnimation d = new UpdatingThreadAnimation(UpdateAnimationFromThread);
- this.Invoke(d, new object[] { });
- }
- }
- catch(Exception e)
- {
- }
- }
- private void UpdateAnimation()
- {
- if(status ==0)
- {
- // mypicture.image = image1
- }else if(status ==1)
- {
- // mypicture.image = image2
- }
- //doing as much as needed
- status++;
- if(status>1) //change here if you have more image, the idea is to set a cycle of images
- {
- status = 0;
- }
- this.Refresh();
- }
- private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
- {
- BackgroundWorker worker = sender as BackgroundWorker;
- while (IsRunning == true)
- {
- System.Threading.Thread.Sleep(100);
- UpdateAnimationFromThread();
- }
- }
- public partial class ssplashscreen : Form
- {
- public ssplashscreen()
- {
- InitializeComponent();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- progressBar1.Increment(1);
- if (progressBar1.Value == 100)
- {
- timer1.Stop();
- this.Hide();
- Form frm = new login();
- frm.Show();
- }
- }
- }
- namespace SplashScreen
- {
- public partial class frmSplashScreen : Form
- {
- public frmSplashScreen()
- {
- InitializeComponent();
- }
- public int LeftTime { get; set; }
- private void frmSplashScreen_Load(object sender, EventArgs e)
- {
- LeftTime = 20;
- timer1.Start();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (LeftTime > 0)
- {
- LeftTime--;
- }
- else
- {
- timer1.Stop();
- new frmHomeScreen().Show();
- this.Hide();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement