public Boolean RemoveItem(connectiondata obj)
        {
            int i;
            Boolean bRemoved = false;

            for (i = 0; i <mylist.Count ;i++)
            {
                if (obj.Equals(mylist[i]))
                {
                    mylist.RemoveAt(i);
                    bRemoved = true;
                    break;
                }
            }
            return bRemoved;
        }
        public Boolean SearchItem(connectiondata obj)
        {
            int i;
            connectiondata cdata;
            Boolean bFound = false;

            for (i = 0; i <mylist.Count ;i++)
            {
                cdata = (connectiondata) mylist[i];
                if ( (obj.address == cdata.address) &&
                    (obj.username == cdata.username) &&
                    (obj.password == cdata.password) &&
                    (obj.port == cdata.port) &&
                    (obj.anonymous == cdata.anonymous) )
                {
                    bFound = true;
                    break;
                }
            }
            return bFound;
        }
Ejemplo n.º 3
0
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            connectiondata conndata = new connectiondata();
            try
            {
                conndata.address = txtAddress.Text;
                conndata.username = txtUsername.Text;
                conndata.password = txtPwd.Text;
                conndata.port= txtPort.Text;
                conndata.anonymous = (checkBox1.Checked)?true:false;
                if ( !connectionlist.SearchItem(conndata) )
                {
                    connectionlist.AddItem(conndata);
                }
                Login();

                btnConnect.Enabled = false;
                btnDisconnect.Enabled=true;

                lvwColumnSorter.Order = SortOrder.Ascending;
                ChangeDir("/");
                lvFiles.AllowDrop = true;

                // set context menu for the remote file list
                lvFiles.ContextMenu = contextMenuRemote;

                // reset address changement
                txtAddress.TextChanged -= new System.EventHandler(this.txtAddress_TextChanged);
            }
            catch
            {
                ftpClient.Close();
                ftpClient=null;
                btnConnect.Enabled = true;
                btnDisconnect.Enabled = false;
                lvFiles.AllowDrop = false;
            }
        }
 public int AddItem(connectiondata obj )
 {
     return mylist.Add(obj);
 }