Exemple #1
0
 public static void Cancel()
 {
     if (state == ConnectionTestState.Waiting)
     {
         state = ConnectionTestState.Error;
         info  = "Connection Cancelled";
         if (process != null)
         {
             process.Kill();
         }
     }
 }
Exemple #2
0
        public static void Test(string connectionType, string connectionString)
        {
            TestConnectionForm.dotCount         = 3;
            TestConnectionForm.connectionType   = connectionType;
            TestConnectionForm.connectionString = connectionString;
            TestConnectionForm.state            = ConnectionTestState.Waiting;
            TestConnectionForm.info             = null;

            string file = Zeus.FileTools.RootFolder + @".\ZeusCmd.exe";

            if (!File.Exists(file))
            {
                file = Zeus.FileTools.RootFolder + @"\..\..\..\..\ZeusCmd\bin\debug\ZeusCmd.exe";

                if (!File.Exists(file))
                {
                    file = Zeus.FileTools.RootFolder + @"\..\..\..\..\ZeusCmd\bin\release\ZeusCmd.exe";
                }
            }

            if (File.Exists(file))
            {
#if DEBUG
                string args = string.Format("-tc \"{0}\" \"{1}\" -l \"{2}\"", connectionType.Replace("\"", "\\\""), connectionString.Replace("\"", "\\\""), "ZeusCmd.log");
#else
                string args = string.Format("-tc \"{0}\" \"{1}\"", connectionType.Replace("\"", "\\\""), connectionString.Replace("\"", "\\\""));
#endif
                ProcessStartInfo psi = new ProcessStartInfo(file, args);
                psi.CreateNoWindow         = true;
                psi.UseShellExecute        = false;
                psi.RedirectStandardOutput = true;
                process           = new Process();
                process.StartInfo = psi;
                process.Start();
            }
            else
            {
                TestConnectionForm.state = ConnectionTestState.Error;
                process = null;
            }
        }
		public static void Cancel() 
		{
			if (state == ConnectionTestState.Waiting)
			{
				state = ConnectionTestState.Error;
				info = "Connection Cancelled";
				if (process != null) 
				{
					process.Kill();
				}
			}
		}
		public static void Test(string connectionType, string connectionString) 
		{
			TestConnectionForm.dotCount = 3;
			TestConnectionForm.connectionType = connectionType;
			TestConnectionForm.connectionString = connectionString;
			TestConnectionForm.state = ConnectionTestState.Waiting;
			TestConnectionForm.info = null;

            string file = Zeus.FileTools.ApplicationPath + @".\ZeusCmd.exe";
			if (!File.Exists(file)) 
			{
                file = Zeus.FileTools.ApplicationPath + @"\..\..\..\..\ZeusCmd\bin\debug\ZeusCmd.exe";
				
				if (!File.Exists(file)) 
				{
                    file = Zeus.FileTools.ApplicationPath + @"\..\..\..\..\ZeusCmd\bin\release\ZeusCmd.exe";
				}
			}

			if (File.Exists(file)) 
			{
#if DEBUG
                string args = string.Format("-tc \"{0}\" \"{1}\" -l \"{2}\"", connectionType.Replace("\"", "\\\""), connectionString.Replace("\"", "\\\""), "ZeusCmd.log");
#else
                string args = string.Format("-tc \"{0}\" \"{1}\"", connectionType.Replace("\"", "\\\""), connectionString.Replace("\"", "\\\""));
#endif
                ProcessStartInfo psi = new ProcessStartInfo(file, args);
				psi.CreateNoWindow = true;
				psi.UseShellExecute = false;
				psi.RedirectStandardOutput = true;
				process = new Process();
				process.StartInfo = psi;
				process.Start();
			}
			else 
			{
				TestConnectionForm.state = ConnectionTestState.Error;
				process = null;
			}
		}
Exemple #5
0
        private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            ConnectionTestState s = State;
            string strState       = "";

            if (s == ConnectionTestState.Waiting)
            {
                byte rg = labelState.ForeColor.G;
                if (up)
                {
                    if (rg < 160)
                    {
                        rg += 20;
                    }
                    else
                    {
                        up = false;
                    }
                }
                else
                {
                    if (rg > 0)
                    {
                        rg -= 20;
                    }
                    else
                    {
                        up = true;
                    }
                }

                //labelState.ForeColor = Color.FromArgb(0, rg, 255 - rg);
                this.SetStateColor(Color.FromArgb(0, rg, 255 - rg));
                if (randNumber == 0)
                {
                    if (dotCount == 16)
                    {
                        dotUp = false;
                    }
                    else if (dotCount == 0)
                    {
                        dotUp = true;
                    }
                    if (dotUp)
                    {
                        dotCount++;
                    }
                    else
                    {
                        dotCount--;
                    }

                    strState = string.Empty;
                    for (int i = 0; i < dotCount; i++)
                    {
                        strState += ".";
                    }
                    strState += "Connecting";
                    for (int i = 0; i < 16 - dotCount; i++)
                    {
                        strState += ".";
                    }

                    this.SetStateText(strState);
                }
                else
                {
                    if (dotCount >= 2)
                    {
                        dotUp = false;
                    }
                    else if (dotCount <= 0)
                    {
                        dotUp = true;
                    }
                    if (dotUp)
                    {
                        dotCount++;
                    }
                    else
                    {
                        dotCount--;
                    }

                    string text = "Connecting";
                    foreach (char c in text)
                    {
                        for (int i = 0; i < dotCount; i++)
                        {
                            strState += " ";
                        }
                        strState += c;
                    }

                    this.SetStateText(strState.Trim());
                    //labelState.Text = strState.Trim();
                }
            }
            else
            {
                ChangeCursor(Cursors.Default);
                this.timer.Enabled = false;
                if (s == ConnectionTestState.Error)
                {
                    this.SetStateText("Connection Error");
                    this.SetStateColor(Color.Red);
                    //labelState.Text = "Connection Error";
                    labelState.ForeColor = Color.Red;

                    this.SetDescriptionText(info);
                    //this.textBoxErrorMessage.Text = info;
                    this.ChangeSize(this.MaximumSize);
                }
                else if (s == ConnectionTestState.Success)
                {
                    this.SetStateText("Connection Successful!");
                    this.SetStateColor(Color.Green);
                    //labelState.Text = "Connection Successful!";
                    //labelState.ForeColor = Color.Green;

                    if (this.isSilent)
                    {
                        this.CloseForm();
                    }
                }

                SetButtonText("&Close");
            }
        }