Ejemplo n.º 1
0
 public SavedConnectionItem(SavedConnection connection)
 {
     InitializeComponent();
     FriendlyNameLabel.Text = connection.FriendlyName;
     AddressLabel.Text      = connection.Address;
     usernameLabel.Text     = connection.Username;
 }
Ejemplo n.º 2
0
        private void connectButton_Click(object sender, EventArgs e, SavedConnection connection = null)
        {
            SavedConnection toConnect;

            if (connection == null)
            {
                //update saved connections list
                //TODO: Check if connection already exists
                var connectionItem = new SavedConnection
                {
                    Address      = serverAddressTextbox.Text,
                    FriendlyName = nameTextbox.Text,
                    Username     = usernameTextbox.Text,
                    Password     = passwordTextbox.Text,
                    Tag          = Guid.NewGuid().ToString()
                };
                var savedConnections = Properties.Settings.Default.SavedConnections;
                savedConnections.Add(connectionItem);
                Properties.Settings.Default.SavedConnections = savedConnections;
                Properties.Settings.Default.Save();
                toConnect = connectionItem;
            }
            else
            {
                toConnect = connection;
            }
            //TODO add connection loading graphic.

            //connect
            this.Hide();
            var browserForm = new Browser(new FTPclient(toConnect.Address, toConnect.Username, toConnect.Password));

            browserForm.ShowDialog();
            this.Close();
        }
Ejemplo n.º 3
0
        public static List <SavedConnection> getSavedConnections()
        {
            List <SavedConnection> conns = new List <SavedConnection>();

            if (File.Exists(fileName))
            {
                foreach (var line in File.ReadAllLines(fileName))
                {
                    string[] fields = line.Split(",");
                    if (fields != null && fields.Length == 2)
                    {
                        SavedConnection temp = new SavedConnection(fields[0], fields[1]);
                        conns.Add(temp);
                    }
                }
            }

            return(conns);
        }