Exemplo n.º 1
0
 /// <summary>
 /// Shows the clicked directory content in the list view
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     TreeNode newSelected = e.Node;
     listView1.Items.Clear();
     currentDir=new Directories((DirectoryInfo)newSelected.Tag);
     PopulateListView(currentDir);
     
 }
Exemplo n.º 2
0
 /// <summary>
 /// Populates the tree view with a directory and its subdirectories
 /// </summary>
 /// <param name="path">The path of the source directory</param>
 private void PopulateTreeView(string path)
 {
     TreeNode rootNode;
     currentDir = new Directories(path);
     if (currentDir.Directory.Exists)
     {
         rootNode = new TreeNode(currentDir.Name);
         rootNode.Tag = currentDir.Directory;
         AddSubNodes(currentDir.SubDirectories, rootNode);
         treeView1.Nodes.Add(rootNode);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds secondary nodes representing subdirectories
 /// </summary>
 /// <param name="subDirs">The array of subdirectories</param>
 /// <param name="nodeToAddTo">The superior node</param>
 private void AddSubNodes(DirectoryInfo[] subDirs,TreeNode nodeToAddTo)
 {
     TreeNode aNode;
     if(subDirs!=null)
     foreach (DirectoryInfo subDir in subDirs)
     {
         currentDir = new Directories(subDir);
         aNode = new TreeNode(currentDir.Directory.Name, 0, 0);
         aNode.Tag = currentDir.Directory;
         aNode.ImageKey = "folder";
         if (currentDir.SubDirectories != null)
             {
                 AddSubNodes(currentDir.SubDirectories, aNode);
                 nodeToAddTo.Nodes.Add(aNode);
             }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Adds secondary nodes representing subdirectories
        /// </summary>
        /// <param name="subDirs">The array of subdirectories</param>
        /// <param name="nodeToAddTo">The superior node</param>
        private void AddSubNodes(DirectoryInfo[] subDirs, TreeNode nodeToAddTo)
        {
            TreeNode aNode;

            if (subDirs != null)
            {
                foreach (DirectoryInfo subDir in subDirs)
                {
                    currentDir     = new Directories(subDir);
                    aNode          = new TreeNode(currentDir.Directory.Name, 0, 0);
                    aNode.Tag      = currentDir.Directory;
                    aNode.ImageKey = "folder";
                    if (currentDir.SubDirectories != null)
                    {
                        AddSubNodes(currentDir.SubDirectories, aNode);
                        nodeToAddTo.Nodes.Add(aNode);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Shows the content of the given directory in the list view
        /// </summary>
        /// <param name="dirinfo">Source directory</param>
        private void PopulateListView(Directories dirinfo)
        {
            listView1.Items.Clear();
            ListViewItem.ListViewSubItem[] subItems;
            ListViewItem item = null;

            if (dirinfo.SubDirectories != null)
            {
                foreach (DirectoryInfo dir in dirinfo.SubDirectories)
                {
                    item     = new ListViewItem(dir.Name, 0);
                    subItems = new ListViewItem.ListViewSubItem[]
                    { new ListViewItem.ListViewSubItem(item, "Directory"),
                      new ListViewItem.ListViewSubItem(item,
                                                       dir.LastAccessTime.ToShortDateString()) };
                    item.SubItems.AddRange(subItems);
                    item.Tag        = dir;
                    item.ImageIndex = 0;
                    listView1.Items.Add(item);
                }
            }
            if (dirinfo.Files != null)
            {
                foreach (FileInfo file in dirinfo.Files)
                {
                    item     = new ListViewItem(file.Name, 1);
                    subItems = new ListViewItem.ListViewSubItem[]
                    { new ListViewItem.ListViewSubItem(item, "File"),
                      new ListViewItem.ListViewSubItem(item,
                                                       file.LastAccessTime.ToShortDateString()) };
                    item.SubItems.AddRange(subItems);
                    item.Tag = file;
                    SetImageExtension(item);
                    listView1.Items.Add(item);
                }
            }
            comboBox1.Text = dirinfo.Path;
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Exemplo n.º 6
0
    public void ObterIcones(string nomeIcon, FileManager.Directories tipo, Action <Texture2D> callback)
    {
        if (!string.IsNullOrEmpty(nomeIcon))
        {
            if (FileManager.Exists(tipo, nomeIcon))
            {
                Texture2D texture2d = FileManager.ConvertToTexture2D(FileManager.LoadFile(tipo, nomeIcon));
                callback(texture2d);
                return;
            }

            StartCoroutine(DownloadAPI.DownloadImage(nomeIcon, tipo.ToString(), (texture, bytes) =>
            {
                if (texture != null)
                {
                    FileManager.SaveFile(tipo, nomeIcon, bytes);
                }

                callback(texture);
            }));
        }
    }
Exemplo n.º 7
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count == 1)
         if (listView1.SelectedItems[0].Tag is DirectoryInfo)
         {
             currentDir = new Directories((DirectoryInfo)listView1.SelectedItems[0].Tag);
             PopulateListView(currentDir);
         }
         else
         {
             FileInfo file = new FileInfo(((FileInfo)listView1.SelectedItems[0].Tag).FullName);
             Process.Start(file.FullName);
         }
 }    
Exemplo n.º 8
0
 private void button1_Click(object sender, EventArgs e)
 {
     currentDir = new Directories(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
     PopulateListView(currentDir);
 }
Exemplo n.º 9
0
 private void button2_Click(object sender, EventArgs e)
 {
     currentDir = new Directories(comboBox1.Text);
     if (currentDir.Directory.Parent != null)
         currentDir = new Directories(currentDir.Directory.Parent);
     PopulateListView(currentDir);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Inserts previously selected files into the current directory
 /// </summary>
 private void PasteCommand()
 {
     
     if (Operations.copyPaths.Count == 0)
         MessageBox.Show("No files to paste!");
     else
         if (Directory.Exists(comboBox1.Text))
         {
             this.Cursor = Cursors.WaitCursor;
             foreach (string path in Operations.copyPaths)
             {
                 if (Operations.CheckType(path) == Operations.isFile)
                     Operations.FileCopy(path, comboBox1.Text);
                 else
                     Operations.DirectoryCopy(path, comboBox1.Text);
             }
             Operations.delAfterCopy = false;
             Operations.copyPaths = null;
             currentDir = new Directories(comboBox1.Text);
             PopulateListView(currentDir);
             this.Cursor = Cursors.Default;
         }
         else
             MessageBox.Show("Invalid target");
 }
Exemplo n.º 11
0
 /// <summary>
 /// Searches for files/directories in the computer by the keyword given in comboBox
 /// </summary>
 private void SearchCommand()
 {
     if (Directory.Exists(comboBox1.Text))
     {
         currentDir = new Directories(comboBox1.Text);
         PopulateListView(currentDir);
     }
     else
     {
         Operations show = new Operations();
         show.FoundResult += new Operations.ChangedListHandler(AddToListView);
         listView1.Items.Clear();
         this.Cursor = Cursors.WaitCursor;
         
         foreach (DriveInfo d in DriveInfo.GetDrives())
         {
             if (d.IsReady)
             {
                 currentDir = new Directories(d.Name);
                 show.DirSearch(comboBox1.Text, currentDir.Directory);
             }
         }
         if (listView1.Items.Count != 0)
         {
             comboBox1.Text = "Search results: " + comboBox1.Text;
             MessageBox.Show(listView1.Items.Count + " results found", "Search done");
         }
         else
             comboBox1.Text = "No results";
         this.Cursor = Cursors.Default;
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Deletes the selected items after confirmation
 /// </summary>
 private void DeleteCommand()
 {
     if (listView1.SelectedItems.Count != 0 || listView1.CheckedItems.Count != 0)
     {
         DialogResult result = MessageBox.Show("Are you sure you want to delete the selected files?", "Confirmation", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             if (listView1.CheckedItems.Count != 0)
                 foreach (ListViewItem item in listView1.CheckedItems)
                     Operations.DeleteItem(item.Tag);
             else if (listView1.SelectedItems.Count != 0)
                 foreach (ListViewItem item in listView1.SelectedItems)
                     Operations.DeleteItem(item.Tag);
             currentDir = new Directories(comboBox1.Text);
             PopulateListView(currentDir);
         }
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Shows the content of the given directory in the list view
        /// </summary>
        /// <param name="dirinfo">Source directory</param>
        private void PopulateListView(Directories dirinfo)
        {
            listView1.Items.Clear();
            ListViewItem.ListViewSubItem[] subItems;
            ListViewItem item = null;
            if (dirinfo.SubDirectories != null)
            {
                foreach (DirectoryInfo dir in dirinfo.SubDirectories)
                {
                    item = new ListViewItem(dir.Name, 0);
                    subItems = new ListViewItem.ListViewSubItem[]
                  {new ListViewItem.ListViewSubItem(item, "Directory"), 
                   new ListViewItem.ListViewSubItem(item, 
				dir.LastAccessTime.ToShortDateString())};
                    item.SubItems.AddRange(subItems);
                    item.Tag = dir;
                    item.ImageIndex = 0;
                    listView1.Items.Add(item);
                }
            }
            if (dirinfo.Files != null)
            {
                foreach (FileInfo file in dirinfo.Files)
                {
                    item = new ListViewItem(file.Name, 1);
                    subItems = new ListViewItem.ListViewSubItem[]
                  { new ListViewItem.ListViewSubItem(item, "File"), 
                   new ListViewItem.ListViewSubItem(item, 
				file.LastAccessTime.ToShortDateString())};
                    item.SubItems.AddRange(subItems);
                    item.Tag = file;
                    SetImageExtension(item);
                    listView1.Items.Add(item);
                }
            }
            comboBox1.Text = dirinfo.Path;
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Exemplo n.º 14
0
 private void button1_Click(object sender, EventArgs e)
 {
     currentDir = new Directories(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
     PopulateListView(currentDir);
 }