Пример #1
0
        private void mnuFileRemove_Click(object sender, EventArgs e)
        {
            FileTransferControl control = (FileTransferControl)mnuFile.Tag;
            int index = fileTransferList.GetIndex(control.Key);

            RemoveTransferFromList(control);
            PopulateTransferList(index);
        }
Пример #2
0
 private void SelectControl(FileTransferControl control)
 {
     foreach (FileTransferControl fileTransferControl in fileTransferList)
     {
         if (fileTransferControl.IsSelected)
         {
             fileTransferControl.IsSelected = false;
             break;
         }
     }
     control.IsSelected = true;
 }
Пример #3
0
        private void FileTransferControl_LayoutChanged(object sender, EventArgs e)
        {
            FileTransferControl control = (FileTransferControl)sender;
            int startIndex = fileTransferList.GetIndex(control.Key);

            if (startIndex >= 0)
            {
                panel.SuspendLayout();
                int lastControlBottom = fileTransferList[startIndex].Bottom;
                for (int index = startIndex + 1; index < fileTransferList.Count; index++)
                {
                    fileTransferList[index].Top = lastControlBottom;
                    lastControlBottom           = fileTransferList[index].Bottom;
                }
                panel.ResumeLayout();
            }
        }
Пример #4
0
        /// <summary>
        /// Add a new File Transfer control to the form. A connection is established between
        /// the client and server. Depending on the transfer mode, the local machine acts as
        /// a server or a client.
        /// </summary>
        /// <param name="mode">The transfer mode. Can be Send or Receive.</param>
        /// <param name="remoteUserName">Remote user's name.</param>
        /// <param name="remoteAddress">IP address of remote user.</param>
        /// <param name="key">Unique key for this file transfer.</param>
        /// <param name="fileName">Name of file to be sent/received.</param>
        /// <param name="fileSize">Size of the file.</param>
        public void AddFileTransfer(FileTransfer.Modes mode, string remoteUserName, string remoteAddress, string key, string fileName, string fileSize)
        {
            //  Create a new File Transfer control and set its properties.
            FileTransferControl fileTransferControl = null;

            try {
                fileTransferControl          = new FileTransferControl(mode, key, bAutoReceiveFile);
                fileTransferControl.UserName = remoteUserName;
                fileTransferControl.FileName = fileName;
                fileTransferControl.FileSize = long.Parse(fileSize);
                //  This will force the system to create a handle for the control.
                IntPtr dummy = fileTransferControl.Handle;
                fileTransferControl.Selected      += new FileTransferControl.SelectedEventHandler(FileTransferControl_Selected);
                fileTransferControl.MouseClick    += new FileTransferControl.MouseClickEventHandler(FileTransferControl_MouseClick);
                fileTransferControl.Notify        += new FileTransferControl.NotifyEventhandler(FileTransferControl_Notify);
                fileTransferControl.LayoutChanged += new FileTransferControl.LayoutChangedEventHandler(FileTransferControl_LayoutChanged);
                fileTransferControl.InitControl();
                //  Add the control to the top of the File transfer list.
                fileTransferList.Insert(0, fileTransferControl);

                if (mode == FileTransfer.Modes.Send)
                {
                    ShowWindow(false, false);
                    BeginAccept(key);
                }
                else
                {
                    ShowWindow(bFileToForeground, false);
                    BeginConnect(key, remoteAddress);
                }

                //  Update the panel's controls.
                PopulateTransferList(0);
                //  Set the UI theme.
                SetTheme(Properties.Settings.Default.UseThemes, Properties.Settings.Default.ThemeFile);
                //  Make the new control the selected control.
                SelectControl(fileTransferControl);
            }
            catch (Exception ex) {
                fileTransferControl.Dispose();
            }
        }
Пример #5
0
        private void FileTransferControl_MouseClick(object sender, MouseEventArgs e)
        {
            FileTransferControl control = (FileTransferControl)sender;

            //  Show context menu if right mouse button was clicked.
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //  No need to show menu when waiting for receive confirmation.
                if (control.Status == FileTransfer.Status.Confirming)
                {
                    return;
                }

                Point pos = this.PointToClient(Cursor.Position);
                mnuFile.Tag               = control;
                mnuFileOpen.Visible       = ((control.Status & FileTransfer.Status.Completed) != 0);
                mnuFileOpen.Enabled       = control.FileExists;
                mnuFileCancel.Visible     = ((control.Status & FileTransfer.Status.Sending) != 0);
                mnuFileOpenFolder.Enabled = control.FileExists;
                mnuFileRemove.Enabled     = ((control.Status & FileTransfer.Status.Completed) != 0);
                mnuFile.Show(this, pos);
            }
        }
Пример #6
0
        private void mnuFileCancel_Click(object sender, EventArgs e)
        {
            FileTransferControl control = (FileTransferControl)mnuFile.Tag;

            control.CancelTransfer();
        }
Пример #7
0
        private void mnuFileOpenFolder_Click(object sender, EventArgs e)
        {
            FileTransferControl control = (FileTransferControl)mnuFile.Tag;

            control.OpenFileFolder();
        }
Пример #8
0
 private void FileTransferControl_StatusChanged(object sender, EventArgs e)
 {
     FileTransferControl control = (FileTransferControl)sender;
 }
Пример #9
0
        private void FileTransferControl_Selected(object sender, MouseEventArgs e)
        {
            FileTransferControl control = (FileTransferControl)sender;

            SelectControl(control);
        }
Пример #10
0
 private void RemoveTransferFromList(FileTransferControl control)
 {
     fileTransferList.Remove(control);
     control.Dispose();
 }