Пример #1
0
        private void MainPage_FormLoad(object sender, EventArgs e)
        {
            attributionlabel.Text = Program.assembly.GetName().Name + " v" + Program.assembly.GetName().Version;

            delay = Properties.Settings.Default.RefreshRate;

            Height   = Properties.Settings.Default.Height;
            Width    = Properties.Settings.Default.Width;
            Location = Properties.Settings.Default.WindowLocation;

            if (Properties.Settings.Default.Maximized)
            {
                WindowState = FormWindowState.Maximized;
            }

            refreshintervaltrackbar.Value = delay;
            refreshintervallabel.Text     = "Refresh Interval: " + Decimal.Divide(delay, 1000).ToString("0.00") + "s";

            int index = 0;

            foreach (string u in Properties.Settings.Default.IPs)
            {
                try
                {
                    Uri         uri   = new Uri("http://" + u);
                    MinerObject miner = new MinerObject(uri, Properties.Settings.Default.Usernames[index], Properties.Settings.Default.Passwords[index]);
                    if (miner.isInitialized)
                    {
                        Program.minerList.Add(miner);
                        miner.startLoop();
                    }
                    index++;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Console.WriteLine(ex.Message);
                }
            }

            if (maintabcontrol.Controls.Count != 0)
            {
                removeminerbutton.Visible = true;
            }
            else
            {
                removeminerbutton.Visible = false;
            }

            background = new ValueUpdater();
        }
        private void addminerbutton_Click(object sender, EventArgs e)
        {
            try
            {
                Uri    uri;
                string url = ipaddresstextbox.Text;
                if (url.Contains("http://"))
                {
                    uri = new Uri(url);
                }
                else
                {
                    uri = new Uri("http://" + url);
                }

                if (minerExists(uri.Authority) == true)
                {
                    MessageBox.Show("Miner already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Console.WriteLine("Miner already exists!");
                }
                else
                {
                    Visible = false;
                    MinerObject miner = new MinerObject(uri, null, null);
                    if (miner.isInitialized)
                    {
                        Program.minerList.Add(miner);
                        miner.startLoop();

                        Dispose();
                    }
                    else
                    {
                        Dispose();
                    }
                }
                Dispose();
            }
            catch (Exception ex)
            {
                if (ex is ThreadAbortException != true)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Console.WriteLine(ex.Message);
                }
            }
        }