Beispiel #1
0
        private void mnuNotifyFileTransfers_Click(object sender, EventArgs e)
        {
            FileTransferDialog fileTransferDialog = GetFileTransferDialog();

            fileTransferDialog.Show();
            fileTransferDialog.Invoke(FileTransferDialog.SetForeground);
        }
Beispiel #2
0
        private void CancelFileTransfer(object key)
        {
            string             transferKey        = (string)key;
            FileTransferDialog fileTransferDialog = GetFileTransferDialog();

            fileTransferDialog.CancelFileTransfer(transferKey);
        }
Beispiel #3
0
        private void ReceiveFile(string userKey, string userName, string sourceAddress, string messageText)
        {
            string[]         fileAttributes = messageText.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            string           key            = fileAttributes[0];
            string           fileName       = fileAttributes[1];
            string           fileSize       = fileAttributes[2];
            FileTransferInfo fileInfo       = new FileTransferInfo(FileTransfer.Modes.Receive, key, userKey, userName, sourceAddress,
                                                                   fileName, fileSize);

            FileTransferDialog fileTransferDialog = GetFileTransferDialog();

            fileTransferDialog.AddFileTransfer(fileInfo.Mode, fileInfo.UserName, fileInfo.Address, fileInfo.Key,
                                               fileInfo.FileName, fileInfo.FileSize);
            PlaySound(NotifyEvents.NewFile);
        }
Beispiel #4
0
 private FileTransferDialog GetFileTransferDialog()
 {
     if (FileTransferDialog.Instance != null)
     {
         FileTransferDialog fileTransferDialog = FileTransferDialog.Instance;
         return(fileTransferDialog);
     }
     else
     {
         FileTransferDialog fileTransferDialog = new FileTransferDialog();
         fileTransferDialog.LocalAddress  = localAddress;
         fileTransferDialog.LocalUserName = localUserName;
         fileTransferDialog.Notify       += new FileTransferDialog.NotifyEventhandler(FileTransferDialog_Notify);
         //  Call Show() method to trigger form's load event.
         fileTransferDialog.Show();
         return(fileTransferDialog);
     }
 }
Beispiel #5
0
        public FileTransferDialog()
        {
            instanceCount++;
            if (instanceCount > 1)
            {
                this.Dispose();
                return;
            }

            Instance = this;
            InitializeComponent();
            InitUI();

            Properties.Settings.Default.PropertyChanged += new PropertyChangedEventHandler(Default_PropertyChanged);
            fileTransferList = new FileTransferControlList();

            SetForeground += new EventHandler(FileTransferDialog_SetForeground);
        }
Beispiel #6
0
        private FileTransferInfo SendFile(string key, string userKey, string userName, string remoteAddress, string filePath)
        {
            System.IO.FileInfo sentFileInfo = new System.IO.FileInfo(filePath);
            //  Do not send files larger than max allowed size. 2 GB by default.
            if (sentFileInfo.Length < Properties.Settings.Default.MaxSendFileSize)
            {
                string           fileSize = sentFileInfo.Length.ToString();
                string           fileName = sentFileInfo.Name;
                FileTransferInfo fileInfo = new FileTransferInfo(FileTransfer.Modes.Send, key, userKey, userName, remoteAddress,
                                                                 fileName, fileSize);

                FileTransferDialog fileTransferDialog = GetFileTransferDialog();
                fileTransferDialog.AddFileTransfer(fileInfo.Mode, fileInfo.UserName, fileInfo.Address, fileInfo.Key,
                                                   filePath, fileInfo.FileSize);
                return(fileInfo);
            }
            else
            {
                string fileSizeString = Helper.FormatSize(Properties.Settings.Default.MaxSendFileSize);
                MessageBox.Show("Please select a file with size less than " + fileSizeString + ".",
                                AppInfo.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);
            }
        }