示例#1
0
        /// <summary>
        /// Load a list of remote hosts from the registry into the list box
        /// </summary>
        private void RefreshRemoteHosts()
        {
            listHosts.Items.Clear();
            try
            {
                string[] keys;
                using (var reg = Registry.CurrentUser.OpenSubKey(PuTTY_Regkey, false))
                {
                    keys = reg.GetValueNames();
                }

                foreach (string key in keys)
                {
                    ClassUrl.Url url = ClassUrl.Parse(key);
                    // Decipher the registry host format using our URL parse functions,
                    // the fields align in the following way:
                    // Ex. rsa2@22:github.com
                    if (url.Ok)
                    {
                        listHosts.Items.Add(url.Path + "  Port: " + url.Host + "  Type: " + url.User);
                    }
                    else
                    {
                        listHosts.Items.Add(key);
                    }
                }
                listHosts.Tag = keys;   // Store list of keys in the listBox tag
            }
            catch { }
        }
示例#2
0
        /// <summary>
        /// Test connection to the selected host
        /// </summary>
        private void BtTestHostClick(object sender, EventArgs e)
        {
            string[] keys = listHosts.Tag as string[];
            string   key  = keys[listHosts.SelectedIndex];

            ClassUrl.Url url = ClassUrl.Parse(key);
            App.Putty.RunPLink(String.Format("-agent git@{0} -P {1}", url.Path, url.Host));
        }
示例#3
0
        /// <summary>
        /// Text in the input box has changed. Validate it and if it's a valid HTTPS URL, enable the "Add" button
        /// </summary>
        private void TextBoxHostTextChanged(object sender, EventArgs e)
        {
            // First, a simple test that allows users to paste a clone command
            textBoxHost.Text = textBoxHost.Text.Replace("git clone ", "");

            ClassUrl.Url host = ClassUrl.Parse(textBoxHost.Text);
            btAddHost.Enabled = host.Type == ClassUrl.UrlType.Https;
        }
示例#4
0
        /// <summary>
        /// Validate entries and return true if they are reasonably valid
        /// </summary>
        public bool IsValid()
        {
            _fetchUrl = ClassUrl.Parse(textUrlFetch.Text.Trim());
            _pushUrl  = ClassUrl.Parse(textUrlPush.Text.Trim());

            // Consider valid entry if the name is ok and some combination of urls
            return(textName.Text.Trim().Length > 0 && _fetchUrl.Type != ClassUrl.UrlType.Unknown);
        }
示例#5
0
 /// <summary>
 /// Disable or enable Add Host button based on the validity of the host address
 /// </summary>
 private void TextBoxHostTextChanged(object sender, EventArgs e)
 {
     remoteUrl         = ClassUrl.Parse(textBoxHost.Text);
     btAddHost.Enabled = textBoxHost.Text.Length > 0 && remoteUrl.Type == ClassUrl.UrlType.Ssh;
 }
示例#6
0
 /// <summary>
 /// User clicked on the Add host button, prompt for user name and password and then add it
 /// </summary>
 private void BtAddHostClick(object sender, EventArgs e)
 {
     // We assume the URL in the text box is a well formatted HTTPS string since Add button would not be enabled otherwise
     ClassUrl.Url host = ClassUrl.Parse(textBoxHost.Text.Trim());
     AddEdit(host.Host); // Use only the host part of the address
 }
示例#7
0
 /// <summary>
 /// Checks the given web target link and returns true if it is reasonably valid URL
 /// </summary>
 private bool isValidUrl(string target)
 {
     ClassUrl.Url url = ClassUrl.Parse(target.Trim());
     return(url.Ok);
 }