コード例 #1
0
        public static Site GetSite( AddressBookEntry abEntry )
        {
            if ( ! sites.ContainsKey(abEntry) )
            {
                Site site = new Site( abEntry );
                sites.Add( abEntry, site );
            }

            return sites[abEntry];
        }
コード例 #2
0
ファイル: Site.cs プロジェクト: ontytoom/AntonFtpClient
        public Site( AddressBookEntry abEntry )
        {
            this.addressBookEntry = abEntry;

            UriBuilder uriBuilder = new UriBuilder( "ftp", addressBookEntry.host );
            this.uri = uriBuilder.Uri;
            this.cred = new NetworkCredential( addressBookEntry.userName, addressBookEntry.userPass );

            this.map = new Dictionary<string, SiteEntry>();

            this.ftp = new FtpClient( uri, cred );
        }
コード例 #3
0
        private void PopulateFields( AddressBookEntry entry )
        {
            if ( entry == null )
                entry = new AddressBookEntry();

            textTitle.Text = entry.title;
            textHost.Text = entry.host;
            textPort.Text = entry.port.ToString();
            textUsername.Text = entry.userName;
            textPassword.Text = entry.userPass;
            textIniDir.Text = entry.iniDir;
            textComment.Text = entry.comment;
        }
コード例 #4
0
 private void ABE_Connect( AddressBookEntry abEntry )
 {
     try
     {
         formMain.SetConnection( abEntry );
         this.Close();
     }
     catch ( Exception ex )
     {
         MessageBox.Show(
             this,
             "There was an error:" + Environment.NewLine + Environment.NewLine + ex.Message, "Error connecting to FTP site"
         );
     }
 }
コード例 #5
0
        public FormAddressBookEntry( AddressBookEntry abEntry, AddressBookEntryAction action )
        {
            InitializeComponent();

            this.abEntry = abEntry;

            // set header
            if ( action == AddressBookEntryAction.Create )
                labelHeader.Text = "Creating new entry";
            else if ( action == AddressBookEntryAction.Edit )
                labelHeader.Text = "Editing entry";
            else
                labelHeader.Text = "Unknown operation";

            // populate fields
            PopulateFields( abEntry );
        }
コード例 #6
0
        public void SetConnection( AddressBookEntry abEntry )
        {
            site = DataWarehouse.GetSite( abEntry );
            site.SiteUpdatedEvent += HandleSiteUpdatedEvent;

            mapTree = new Dictionary<TreeNode, SiteEntry>();

            labelHostName.Text = site.addressBookEntry.host;

            SetAppState( AppState.Busy );

            SiteEntry rootEntry;
            rootEntry = ChangeDir( null, true );

            SetAppState( AppState.Available );

            TreeBuild();
        }
コード例 #7
0
        private void ABE_Edit( AddressBookEntry abEntry )
        {
            // we make a copy of the current entry, and send that for edit.
            // if user approves of his/her edit, then we replace current with data from edited copy.
            AddressBookEntry copyOfCurrent = new AddressBookEntry( abEntry );
            FormAddressBookEntry formABE = new FormAddressBookEntry( copyOfCurrent, AddressBookEntryAction.Edit );

            DialogResult result = formABE.ShowDialog( this );

            if ( result == DialogResult.Cancel )
            {
                MessageBox.Show( this, "Edit cancelled" );
                return;
            }

            // add update current entry with edited data
            abEntry.UpdateFrom( copyOfCurrent );
        }
コード例 #8
0
        // TODO: Need error checking for info: Make sure host has valid format, user name is not blank.
        private bool UnpopulateFields( AddressBookEntry entry )
        {
            entry.title = textTitle.Text;
            entry.host = textHost.Text;
            entry.userName = textUsername.Text;
            entry.userPass = textPassword.Text;
            entry.iniDir = textIniDir.Text;
            entry.comment = textComment.Text;

            try
            {
                entry.port = Int32.Parse( textPort.Text );
                if ( entry.port < 0 || entry.port > 70000 )
                    throw new Exception();
            }
            catch(Exception ex)
            {
                MessageBox.Show( this, "Please make sure the port is an integer number between 1 and 70000" );
                return false;
            }

            return true;
        }
コード例 #9
0
        private void ABE_New()
        {
            AddressBookEntry newAbEntry = new AddressBookEntry();
            FormAddressBookEntry formABE = new FormAddressBookEntry( newAbEntry, AddressBookEntryAction.Create );

            DialogResult result = formABE.ShowDialog( this );

            if ( result == DialogResult.Cancel )
            {
                MessageBox.Show( this, "Create cancelled" );
                return;
            }

            // add new entry to address book
            addressBook.AddEntry( newAbEntry );
        }
コード例 #10
0
 private void toolStripMenuItem_Clear_Click( object sender, EventArgs e )
 {
     AB_Clear();
     currentEntry = null;
     RefreshGrid();
 }
コード例 #11
0
        //TODO: Right now after refresh, selection is lost. Perhaps we should re-select after refresh what was selected before refresh. Problems: What if multiple items were selected? What if item(s) were deleted? What if item was edited?
        private void RefreshGrid()
        {
            gridAddressBookSkipEvents = true;

            map = new Dictionary<DataGridViewRow, AddressBookEntry>();
            gridAddressBook.Rows.Clear();

            foreach ( AddressBookEntry entry in addressBook.Book )
            {
                int id = gridAddressBook.Rows.Add();
                DataGridViewRow row = gridAddressBook.Rows[id];
                row.Cells["Title"].Value   = entry.title;
                row.Cells["Host"].Value    = entry.host;
                row.Cells["Comment"].Value = entry.comment;

                map.Add( row, entry );
            }

            gridAddressBook.ClearSelection();
            currentEntry = null;

            gridAddressBookSkipEvents = false;
        }
コード例 #12
0
        private void linkBookLoad_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
        {
            AB_LoadFromFile();

            // refresh grid
            currentEntry = null;
            RefreshGrid();
        }
コード例 #13
0
        private void gridAddressBook_SelectionChanged( object sender, EventArgs e )
        {
            if ( gridAddressBookSkipEvents )
                return;

            // if nothing or >1 is selected, we don't like it
            if ( gridAddressBook.SelectedRows.Count != 1 )
            {
                currentEntry = null;
                return;
            }

            DataGridViewRow row = gridAddressBook.SelectedRows[0];
            currentEntry = map[row];
        }
コード例 #14
0
 public AddressBookEntry( AddressBookEntry getDataFromHere )
 {
     this.UpdateFrom( getDataFromHere );
 }
コード例 #15
0
 public void DeleteEntry( AddressBookEntry entry )
 {
     book.Remove( entry );
 }
コード例 #16
0
 public void AddEntry( AddressBookEntry newEntry )
 {
     book.Add( newEntry );
 }
コード例 #17
0
 public void AddEntry( string title, string host, int port, string user, string pass, string iniDir, string comment )
 {
     AddressBookEntry entry = new AddressBookEntry( title, host, port, user, pass, iniDir, comment );
     book.Add( entry );
 }
コード例 #18
0
 public void UpdateFrom( AddressBookEntry getDataFromHere )
 {
     this.title    = getDataFromHere.title;
     this.host     = getDataFromHere.host;
     this.userName = getDataFromHere.userName;
     this.userPass = getDataFromHere.userPass;
     this.iniDir   = getDataFromHere.iniDir;
     this.comment  = getDataFromHere.comment;
 }