code_junkie

C# Splash Screen Problem

Nov 13th, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. [STAThread]
  2. static void Main()
  3. {
  4. new SplashScreen(_tempAL);// where _tempAL is an arrayList
  5. Application.Run(new Form1(_tempAL));
  6. }
  7.  
  8. public SplashScreen(ArrayList _Data)
  9. {
  10. DisplaySplash()
  11. }
  12. private void DisplaySplash()
  13. {
  14. this.Show();
  15. this.TopMost = true;
  16. this.CenterToScreen();
  17. this.SetTopLevel(true);
  18.  
  19. _allServerNarrators = new string[10];
  20. for (int i = 0; i < _allServerNarrators.Length; i++)
  21. _allServerNarrators[i] = null;
  22.  
  23. GetFromServer();
  24.  
  25. this.Hide();
  26. _serverData = new ArrayList();
  27. _thisData.Add(_allServerNarrators);
  28. _thisData.Add(_serverNarrators);
  29.  
  30. }
  31. private void GetFromServer()
  32. {
  33. _serverNarrators = new ArrayList();
  34. string _file = "Suras.serverNar";
  35.  
  36. if (!Directory.Exists("c:\ASGAQuraan"))
  37. Directory.CreateDirectory("c:\ASGAQuraan");
  38.  
  39. while (counter < 4 && _serverFiles == null)
  40. {
  41. if (Download("c:\ASGAQuraan", _ftpServerIP, _file))
  42. {
  43. StreamReader _strReader = new StreamReader
  44. ("c:\ASGAQuraan\"+_file,System.Text.Encoding.Default);
  45. string _line = _strReader.ReadLine();
  46. string _word;
  47.  
  48. while (true)
  49. {
  50. while (_line != null)
  51. {
  52. _word = _line.Substring(0, _line.IndexOf("*"));
  53. int _narId = Convert.ToInt32(_word);
  54. _line = _line.Substring(2);
  55. int k = 0;
  56. _serverNarratorNode = new ArrayList();
  57. while (true)
  58. {
  59. int ind = _line.IndexOf("*");
  60. if (ind > 0 && ind < _line.Length)
  61. {
  62. string str = _line.Substring(0, (ind));
  63. if (k == 0)
  64. {
  65. _allServerNarrators[_narId] = str;
  66. _serverNarratorNode.Add(str);
  67. }
  68. else
  69. {
  70. _serverNarratorNode.Add(str);
  71. }
  72. _line = _line.Substring(ind + 1);
  73. k++;
  74. }
  75. else
  76. {
  77. _line = null;
  78. break;
  79. }
  80. }
  81. _serverNarrators.Add(_serverNarratorNode);
  82. _serverFiles = "added";
  83. }
  84. _line = _strReader.ReadLine();
  85. if (_line == null)
  86. {
  87. break;
  88. }
  89. }
  90. }
  91. else
  92. counter++;
  93. }
  94. }
  95.  
  96. using System;
  97. using System.Windows.Forms;
  98. using Microsoft.VisualBasic.ApplicationServices;
  99.  
  100. namespace WindowsFormsApplication1 {
  101. static class Program {
  102. [STAThread]
  103. static void Main(string[] args) {
  104. Application.EnableVisualStyles();
  105. Application.SetCompatibleTextRenderingDefault(false);
  106. new MyApp().Run(args);
  107. }
  108. }
  109. class MyApp : WindowsFormsApplicationBase {
  110. protected override void OnCreateSplashScreen() {
  111. this.SplashScreen = new frmSplash();
  112. }
  113. protected override void OnCreateMainForm() {
  114. // Do your time consuming stuff here...
  115. //...
  116. System.Threading.Thread.Sleep(3000);
  117. // Then create the main form, the splash screen will close automatically
  118. this.MainForm = new Form1();
  119. }
  120. }
  121. }
  122.  
  123. this.Hide();
  124. _serverData = new ArrayList();
  125. _thisData.Add(_allServerNarrators);
  126. _thisData.Add(_serverNarrators);
  127.  
  128. BackgroundWorker myWorker = new BackgroundWorker();
  129.  
  130. myWorker.DoWork += new DoWorkEventHandler(myWorker_DoWork);
  131. //put the work you want done in this one
  132.  
  133. myWorker.RunWorkerCompleted +=
  134. new RunWorkerCompletedEventHandler(myWorker_RunWorkerCompleted);
  135. //this gets fired when the work is finished
Add Comment
Please, Sign In to add comment