예제 #1
0
 public void HandleCopyResponce(Guid id, bool success)
 {
     if (BucketHandler.ContainsKey(id))
     {
         Invoke((MethodInvoker) delegate()
         {
             FileBucketInfo info = BucketHandler[id];
             ListViewItem i      = (ListViewItem)info.DisplayInfo;
             i.SubItems[3].Text  = success ? "Copied Successfully." : "Failed to copy.";
             info.DoingOperation = false;
             if (success && info.RemoteDestinationDirectory == CurrentDirectory)
             {
                 if (lvFileView.View == View.List)
                 {
                     return;
                 }
                 lvFileView.View = View.List;
                 lvFileView.Items.Clear();
                 lvFileView.Items.Add("Loading...");
                 Console.WriteLine("Current directory: {0}", CurrentDirectory);
                 Client.Send((byte)NetworkCommand.FileManager, (byte)FileManagerCommand.Update, CurrentDirectory);
             }
         });
     }
 }
예제 #2
0
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem i in lvFileView.SelectedItems)
            {
                if (i.ImageKey == "File")
                {
                    ListViewItem   bi         = new ListViewItem(i.Text);
                    FileBucketInfo bucketInfo = new FileBucketInfo();
                    bucketInfo.RemotePath      = Path.Combine(CurrentDirectory, i.Text);
                    bucketInfo.RenameTo        = i.Text;
                    bucketInfo.DisplayInfo     = bi;
                    bucketInfo.RemoteDirectory = CurrentDirectory;

                    bi.SubItems.Add(bucketInfo.RenameTo);
                    bi.SubItems.Add(bucketInfo.RemotePath);
                    bi.SubItems.Add("...");
                    bi.Tag      = bucketInfo;
                    bi.ImageKey = "File";
                    lvFileBucket.Items.Add(bi);
                    Guid id = Guid.NewGuid();
                    while (BucketHandler.ContainsKey(id))
                    {
                        id = Guid.NewGuid();
                    }
                    bucketInfo.ID = id;
                    BucketHandler.Add(id, bucketInfo);
                }
            }
        }
예제 #3
0
        private void removeFromBucketToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lvFileBucket.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewItem   i          = lvFileBucket.SelectedItems[0];
            FileBucketInfo bucketInfo = (FileBucketInfo)i.Tag;

            if (bucketInfo.DoingOperation)
            {
                return;
            }
            if (MessageBox.Show(string.Format("Remove {0} from bucket?", i.Text), "Remove from bucket", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (BucketHandler.ContainsKey(bucketInfo.ID))
                {
                    BucketHandler.Remove(bucketInfo.ID);
                }
                lvFileBucket.Items.Remove(i);
            }
        }
예제 #4
0
        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lvFileBucket.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewItem   i          = lvFileBucket.SelectedItems[0];
            FileBucketInfo bucketInfo = (FileBucketInfo)i.Tag;

            if (bucketInfo.DoingOperation)
            {
                return;
            }
            using (formInput rename = new formInput("Rename", i.Text))
            {
                if (rename.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                bucketInfo.RenameTo = rename.InputText;
            }
            i.SubItems[1].Text = bucketInfo.RenameTo;
        }
예제 #5
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (lvFileBucket.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewItem   i          = lvFileBucket.SelectedItems[0];
            FileBucketInfo bucketInfo = (FileBucketInfo)i.Tag;

            if (bucketInfo.DoingOperation)
            {
                return;
            }
            if (bucketInfo.RemoteDirectory == CurrentDirectory)
            {
                MessageBox.Show("You are in the same directory.");
                return;
            }
            bucketInfo.RemoteDestination          = Path.Combine(CurrentDirectory, bucketInfo.RenameTo);
            bucketInfo.RemoteDestinationDirectory = CurrentDirectory;
            bucketInfo.DoingOperation             = true;
            Client.Send((byte)NetworkCommand.FileManager, (byte)FileManagerCommand.MoveFile, bucketInfo.ID, bucketInfo.RemotePath, bucketInfo.RemoteDestination);
            i.SubItems[3].Text = "Moving...";
        }