コード例 #1
0
        private void mToolStripMenuItemDelete_Click(object sender, EventArgs e)
        {
            int selectFileCount = this.listViewExplorer.SelectedItems.Count;

            if (selectFileCount > 0)
            {
                ExplorerFileInfo file    = (ExplorerFileInfo)this.listViewExplorer.SelectedItems[0].Tag;
                string           message = "确认删除设备上文件" + file.FileName + "?";
                if (selectFileCount > 1)
                {
                    message = "确认删除选择的文件或者文件夹?";
                }
                else if (file.IsFolder)
                {
                    message = "确认删除设备上文件夹" + file.FileFullPath + ",会删除该文件夹下所有文件";
                }
                if (MessageBox.Show(message, "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    willDeleteFileCount = selectFileCount;
                    hasDeleteFileCount  = 0;
                    for (int i = 0; i < selectFileCount; i++)
                    {
                        ExplorerFileInfo f = (ExplorerFileInfo)this.listViewExplorer.SelectedItems[i].Tag;
                        deleteFile(f.FileFullPath);
                    }
                }
            }
        }
コード例 #2
0
        private void renameFileResult(object[] result)
        {
            ExplorerFileInfo file = (ExplorerFileInfo)this.listViewExplorer.SelectedItems[0].Tag;

            file.FileName     = currentEditAfterLabel;
            file.FileFullPath = Path.Combine(FileKit.GetUpFolder(file.FileFullPath), file.FileName);
        }
コード例 #3
0
 private void listViewExplorer_ItemDrag(object sender, ItemDragEventArgs e)
 {
     if (ListViewKit.hasSelectedItem(listViewExplorer))
     {
         ExplorerFileInfo file = (ExplorerFileInfo)listViewExplorer.SelectedItems[0].Tag;
         listViewExplorer.DoDragDrop(new DataObject(DataFormats.FileDrop, @"C:\Users\Maison\Pictures\iikura_04_l.jpg"), DragDropEffects.Copy);
     }
 }
コード例 #4
0
        private ListViewItem createListViewItem(ExplorerFileInfo file)
        {
            ListViewItem item = new ListViewItem(file.FileName);

            item.ImageKey = FileKit.GetFileIconName(this.imageListFile, file);
            item.SubItems.Add(file.FileSize > 0 ? FileKit.FormatFileSize(file.FileSize) : "");
            item.SubItems.Add(file.CreateDateTime.ToString("yyyy-MM-dd HH:mm"));
            item.SubItems.Add(file.IsFolder ? "文件夹" : "文件");
            item.Tag = file;
            return(item);
        }
コード例 #5
0
 private void listViewExplorer_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ListViewKit.hasSelectedItem(this.listViewExplorer))
     {
         ExplorerFileInfo file = (ExplorerFileInfo)this.listViewExplorer.SelectedItems[0].Tag;
         // 预览图上显示
         this.labelFileName.Text       = file.FileName;
         this.labelFileDatetime.Text   = "创建时间:" + file.CreateDateTime.ToString("yyyy-MM-dd HH:mm");
         this.labelFileSize.Text       = file.FileSize > 0 ? "文件大小:" + FileKit.FormatFileSize(file.FileSize) : "";
         this.pictureBoxFileIcon.Image = FileKit.GetFileIconImage(this.imageListLargeIcon, file);
     }
 }
コード例 #6
0
 private void listViewExplorer_AfterLabelEdit(object sender, LabelEditEventArgs e)
 {
     if (e.Label == currentEditBeforeLabel)
     {
         e.CancelEdit = true;
     }
     else
     {
         ExplorerFileInfo file = (ExplorerFileInfo)this.listViewExplorer.SelectedItems[0].Tag;
         currentEditAfterLabel = e.Label;
         renameFile(file.FileFullPath, Path.Combine(this.currentExplorerPath, e.Label));
     }
 }
コード例 #7
0
 private void listViewExplorer_DoubleClick(object sender, EventArgs e)
 {
     if (ListViewKit.hasSelectedItem(this.listViewExplorer))
     {
         ExplorerFileInfo file = (ExplorerFileInfo)this.listViewExplorer.SelectedItems[0].Tag;
         if (file.IsFolder)
         {
             string path = file.FileFullPath;
             getNodeList(path, false, new TaskInfo.EventResultHandler(getExplorerListResult));
             this.buttonBackFolder.Enabled = true;
             this.currentExplorerPath      = path;
         }
     }
 }
コード例 #8
0
 private void mToolStripMenuItemExport_Click(object sender, EventArgs e)
 {
     if (ListViewKit.hasSelectedItem(this.listViewExplorer))
     {
         ExplorerFileInfo file     = (ExplorerFileInfo)this.listViewExplorer.SelectedItems[0].Tag;
         string           savePath = null;
         if (file.IsFolder)
         {
             // 选择文件夹
             savePath = DialogKit.ShowSaveFolderDialog();
             savePath = Path.Combine(savePath, Path.GetFileName(file.FileFullPath));
         }
         else
         {
             // 选择文件存储路径
             savePath = DialogKit.ShowSaveDialog(file.FileName);
         }
         pullFileFromDevice(file.FileFullPath, savePath);
     }
 }
コード例 #9
0
ファイル: FileKit.cs プロジェクト: lvqiling/ArkController
        /// <summary>
        /// 得到文件图标的key
        /// </summary>
        /// <param name="imageList"></param>
        /// <param name="fileExp"></param>
        /// <returns></returns>
        public static string GetFileIconName(ImageList imageList, ExplorerFileInfo fileInfo)
        {
            if (fileInfo != null && fileInfo.IsFolder)
            {
                return("folder.png");
            }
            string fileExp = Path.GetExtension(fileInfo.FileName);

            if (string.IsNullOrEmpty(fileExp))
            {
                return("unknown.png"); // 没有扩展名的文件
            }
            foreach (string key in imageList.Images.Keys)
            {
                if (key == fileExp.Substring(1) + ".png")
                {
                    return(key);
                }
            }
            return("unknown.png"); // 有扩展名,但是不认识
        }
コード例 #10
0
ファイル: FileKit.cs プロジェクト: lvqiling/ArkController
 /// <summary>
 /// 根据扩展名得到文件图标的名字
 /// </summary>
 /// <param name="fileExp">文件扩展名</param>
 /// <returns></returns>
 public static Image GetFileIconImage(ImageList imageList, ExplorerFileInfo fileInfo)
 {
     return(imageList.Images[GetFileIconName(imageList, fileInfo)]);
 }