Esempio n. 1
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            if (this.listView_fileDirectory.SelectedItems.Count == 0)
            {
                return;
            }

            this.cutOrCopyAction = new CutOrCopyAction(this.currentDirPath, this.listView_fileDirectory.SelectedItems[0].Text, ((FileOrDirectoryTag)this.listView_fileDirectory.SelectedItems[0].Tag).IsFile, false);
        }
Esempio n. 2
0
        void listView_fileDirectory_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            Cursor old = Cursor.Current;
            try
            {
                //输入为空
                if (e.Label == null || e.Label.Length == 0)
                {
                    e.CancelEdit = true;
                    return;
                }

                ListViewItem item = this.listView_fileDirectory.Items[e.Item];
                string oldName = item.Text;
                string newName = e.Label;

                foreach (ListViewItem target in this.listView_fileDirectory.Items)
                {
                    if (newName == target.Text)
                    {
                        MessageBox.Show(String.Format("{0} 已存在,请更换名称!", newName));
                        e.CancelEdit = true;
                        return;
                    }
                }

                Cursor.Current = Cursors.WaitCursor;
                if (this.cutOrCopyAction != null && this.currentDirPath == this.cutOrCopyAction.ParentPathOfCuttedOrCopyed && oldName == this.cutOrCopyAction.ItemNameOfCuttedOrCopyed)
                {
                    this.cutOrCopyAction = null;
                }

                OperationResult result = this.fileDirectoryOutter.Rename(this.ownerID, this.currentDirPath, ((FileOrDirectoryTag)item.Tag).IsFile, oldName, newName);
                if (!result.Succeed)
                {
                    e.CancelEdit = true;
                    MessageBox.Show(result.ErrorMessage);
                }
            }
            catch (Exception ee)
            {
                e.CancelEdit = true;
                MessageBox.Show(ee.Message);
            }
            finally
            {
                this.isLableEditing = false;
                Cursor.Current = old;
            }
        }
Esempio n. 3
0
        private void DeleteFileOrDir()
        {
            if (((this.ownerSharedAllDisk || this.IsNetworkDisk) && this.currentDirPath == null) || this.listView_fileDirectory.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem item = this.listView_fileDirectory.SelectedItems[0];

            if (!WindowsHelper.ShowQuery(string.Format("您确定要删除{0} {1} 吗?", ((FileOrDirectoryTag)item.Tag).IsFile ? "文件" : "文件夹", item.Text)))
            {
                return;
            }

            if (this.cutOrCopyAction != null && this.currentDirPath == this.cutOrCopyAction.ParentPathOfCuttedOrCopyed && item.Text == this.cutOrCopyAction.ItemNameOfCuttedOrCopyed)
            {
                this.cutOrCopyAction = null;
            }

            List<string> files = new List<string>();
            List<string> dirs = new List<string>();
            if (((FileOrDirectoryTag)item.Tag).IsFile)
            {
                files.Add(item.Text);
            }
            else
            {
                dirs.Add(item.Text);
            }

            OperationResult result = this.fileDirectoryOutter.Delete(this.ownerID, this.currentDirPath, files, dirs);
            if (!result.Succeed)
            {
                MessageBox.Show(result.ErrorMessage);
            }
            this.LoadDirectory(this.currentDirPath, true);
        }
Esempio n. 4
0
 /// <summary>
 /// 调用该方法可恢复到未做任何连接的初始状态。
 /// </summary>
 public void Reset()
 {
     this.ownerID = null;
     this.currentDirPath = null;
     this.cutOrCopyAction = null;
     this.fileOutter = null;
     this.fileDirectoryOutter = null;
     this.listView_fileDirectory.Clear();
     this.toolStripButton_state.Image = this.imageList2.Images[0];
     this.toolStripLabel_msg.Text = "就绪";
     this.toolStripTextBox1.Text = "";
 }
Esempio n. 5
0
 public void Initialize(string _ownerID, IFileOutter _fileOutter, INDiskOutter outter)
 {
     this.ownerID = _ownerID ?? NetServer.SystemUserID;
     this.currentDirPath = null;
     this.cutOrCopyAction = null;
     this.fileOutter = _fileOutter;
     this.fileDirectoryOutter = outter;
     this.fileTransferingViewer1.Initialize(this.fileOutter, delegate(TransferingProject pro) { return pro.Comment != null && this.ownerID == pro.DestUserID; });
     this.LoadDirectory(null, true);
 }
Esempio n. 6
0
        private void toolStripMenuItem6_Click(object sender, EventArgs e)
        {
            if (this.cutOrCopyAction == null)
            {
                return;
            }

            if (this.currentDirPath.StartsWith(this.cutOrCopyAction.ParentPathOfCuttedOrCopyed + this.cutOrCopyAction.ItemNameOfCuttedOrCopyed))
            {
                MessageBox.Show("目标文件夹是源文件夹的子文件夹!");
                return;
            }

            List<string> fileNames = new List<string>();
            List<string> dirNames = new List<string>();
            if (this.cutOrCopyAction.IsFile)
            {
                fileNames.Add(this.cutOrCopyAction.ItemNameOfCuttedOrCopyed);
            }
            else
            {
                dirNames.Add(this.cutOrCopyAction.ItemNameOfCuttedOrCopyed);
            }

            OperationResult result = null;
            if (this.cutOrCopyAction.IsCutted)
            {
                result = this.fileDirectoryOutter.Move(this.ownerID, this.cutOrCopyAction.ParentPathOfCuttedOrCopyed, fileNames, dirNames, this.currentDirPath);
                this.cutOrCopyAction = null;
            }
            else
            {
                result = this.fileDirectoryOutter.Copy(this.ownerID, this.cutOrCopyAction.ParentPathOfCuttedOrCopyed, fileNames, dirNames, this.currentDirPath);
            }

            if (result != null && !result.Succeed)
            {
                MessageBox.Show(result.ErrorMessage);
            }

            this.LoadDirectory(this.currentDirPath, true);
        }