private void settings_Click(object sender, EventArgs e) { Form login = new Settings(true); DialogResult result=login.ShowDialog(); if (result == DialogResult.OK) { LoadCreditials(); } }
public Main() { InitializeComponent(); LoadCreditials(); if (Properties.Settings.Default.mode == "standard") { mode = Mode.Standard; } else if (Properties.Settings.Default.mode == "expert") { mode = Mode.Expert; } mutex = new Mutex(true, Application.ProductName, out is_single_instance); //Create Mutex if (!is_single_instance) //If second instance of application is running { this.Close(); //Close current application return; } this.Hide(); //Hide window cpu = new PerformanceCounter(); //Create CPU usage counter object ram = new PerformanceCounter(); //Create RAM usage counter object harddisk_read = new PerformanceCounter(); //Create harddisk read usage counter object harddisk_write = new PerformanceCounter(); //Create harddisk write usage couter object network_interface = new PerformanceCounterCategory("Network Interface"); //Create network interface network_instances = network_interface.GetInstanceNames(); //Get all instances from network interface network_download = new PerformanceCounter[network_instances.Length]; //Get number of all network instances (download) server_uptime = new PerformanceCounter(); for (int instance = 0; instance < network_download.Length; instance++) //For all network instances (download) { network_download[instance] = new PerformanceCounter(); //Add network instance (download) to an array } network_upload = new PerformanceCounter[network_instances.Length]; //Get number of all network instances (upload) for (int instance = 0; instance < network_upload.Length; instance++) //For all network instances (upload) { network_upload[instance] = new PerformanceCounter(); //Add network instance (upload) to an array } harddisk_read.CategoryName = "PhysicalDisk"; //Get Harddisk counter category harddisk_read.CounterName = "Disk Read Bytes/sec"; //Get Harddisk counter name harddisk_read.InstanceName = "_Total"; //Get Harddisk counter instance name if (login_showed == false) //If login dialog was not showed { //If values in registry is null or values are default if (server_petname == null || contact_email == null || secret_key == null || server_petname == "server_petname" || contact_email == "*****@*****.**" || secret_key == "secret_key") { Form login = new Settings(); //Create form Login login.ShowDialog(); //Show login } login_showed = true; //Set Login dialog was showed } if(login_showed==true) { timerSender.Start(); //Start timer update } hostname = Dns.GetHostName(); ip_host_entry = Dns.GetHostEntry(hostname); ip_addresses = ip_host_entry.AddressList; startToolStripMenuItemStartStop.Text = "Stop"; startToolStripMenuItemStartStop.Image = Properties.Resources.stop; sending = Sending.Run; updater = Process.GetProcessesByName("Cloudiff updater"); if (updater.Length != 0) { foreach (Process process in updater) { process.Kill(); } } if (Environment.Is64BitOperatingSystem) { operation_system_32_64bit = "64bit"; } else { operation_system_32_64bit = "32bit"; } cpu_cores = Environment.ProcessorCount; RegistryKey cpu_32_64bit_key = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); if (cpu_32_64bit_key.GetValue("Identifier").ToString().IndexOf("64") > 0) { cpu_32_64bit = "64bit"; } else { cpu_32_64bit = "32bit"; } cpu_architecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); power = SystemInformation.PowerStatus; power_line_status = power.PowerLineStatus; }
private void LoadLoginForm() { Form login = new Settings(true); DialogResult result = login.ShowDialog(); if (result == DialogResult.OK) { LoadCreditials(); } }