private void SettingsBox_Load(object sender, EventArgs e)
        {
            var currentEntry = ProxyControl.GetProxy();

            this.proxyUrlTxt.Text  = currentEntry.Address;
            this.proxyPortTxt.Text = currentEntry.Port.ToString();
        }
        private void saveBtn_Click(object sender, EventArgs e)
        {
            var newHost = this.proxyUrlTxt.Text;
            var newPort = this.proxyPortTxt.Text;

            ProxyEntry entry;

            if (!string.IsNullOrWhiteSpace(newHost))
            {
                if (!string.IsNullOrWhiteSpace(newPort))
                {
                    int testVal = 0;
                    if (int.TryParse(newPort, out testVal))
                    {
                        entry = new ProxyEntry(newHost, testVal);
                    }
                    else
                    {
                        entry = new ProxyEntry(newHost);
                    }
                }
                else
                {
                    entry = new ProxyEntry(newHost);
                }

                ProxyControl.SetProxy(entry);
            }

            this.Close();
        }
Beispiel #3
0
        /// <summary>
        /// Creates this instance.
        /// </summary>
        /// <returns>ContextMenuStrip</returns>
        public ContextMenuStrip Create()
        {
            // Add the default menu options.
            ContextMenuStrip   menu = new ContextMenuStrip();
            ToolStripMenuItem  item;
            ToolStripSeparator sep;

            // Enable the proxy.
            enableItem         = new ToolStripMenuItem();
            enableItem.Text    = "Enable";
            enableItem.Click  += new EventHandler(Enable_Click);
            enableItem.Enabled = !ProxyControl.IsProxyEnabled();
            menu.Items.Add(enableItem);

            // Disable the proxy.
            disableItem         = new ToolStripMenuItem();
            disableItem.Text    = "Disable";
            disableItem.Click  += new EventHandler(Disable_Click);
            disableItem.Enabled = ProxyControl.IsProxyEnabled();
            menu.Items.Add(disableItem);

            // Separator.
            sep = new ToolStripSeparator();
            menu.Items.Add(sep);

            // The Settings.
            item        = new ToolStripMenuItem();
            item.Text   = "Settings";
            item.Click += new EventHandler(Settings_Click);
            menu.Items.Add(item);

            // Exit.
            item        = new ToolStripMenuItem();
            item.Text   = "Exit";
            item.Click += new System.EventHandler(Exit_Click);
            menu.Items.Add(item);

            return(menu);
        }
Beispiel #4
0
 /// <summary>
 /// Handles the Click event of the Disable control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 void Disable_Click(object sender, EventArgs e)
 {
     enableItem.Enabled  = !enableItem.Enabled;
     disableItem.Enabled = !disableItem.Enabled;
     ProxyControl.SetProxyStatus(false);
 }