Exemplo n.º 1
0
 public void SelectFile()
 {
     if (Selected)
     {
         return;
     }
     fl_file.Focus();
     Selected          = true;
     fl_file.BackColor = Color.SteelBlue;
     SelectedFiles.Add(Path);
 }
Exemplo n.º 2
0
 public void UnClickAll()
 {
     for (int i = 0; i < SelectedFiles.GetNames().Length; i++)
     {
         int index = files.IndexOfKey(SelectedFiles.GetNames()[i].ToString());
         if (index < 0)
         {
             return;
         }
         ((File)files.GetByIndex(index)).UnSelectFile();
     }
     SelectedFiles.Clear();
 }
Exemplo n.º 3
0
 private void Name_KeyUp(object sender, KeyEventArgs e)
 {
     try {
         if (e.KeyCode == Keys.Enter)
         {
             string newName = new System.IO.FileInfo(Path).DirectoryName + @"\" + tb_name.Text;
             FileOperation.RenameFile(Path, newName);
             SelectedFiles.Remove(Path);
             tb_name.ReadOnly = true;
             FileName         = tb_name.Text;
             Path             = newName;
             SelectFile();
         }
     } catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
Exemplo n.º 4
0
 public static void DeleteFiles(object[] files)
 {
     foreach (string path in files)
     {
         if (IsDirectory(path))
         {
             DeleteFiles(Directory.GetFileSystemEntries(path));
         }
         else if (!IsFileExists(path))
         {
             return;
         }
         try {
             System.IO.File.Delete(path);
         } catch (Exception) { throw; }
     }
     SelectedFiles.Clear();
 }
Exemplo n.º 5
0
 internal void PasteFiles()
 {
     try {
         FileOperation.CopyFiles(SelectedFiles.LastSelectedFile == null ? CurrentLocation : SelectedFiles.LastSelectedFile, true, SelectedFiles.GetCopyBufferValues());
         if (CutClicked == true)
         {
             CutClicked = false;
             pn_flow.ContextMenu.MenuItems[2].Enabled = false;
             if (CopyClicked)
             {
                 CopyClicked = false;
             }
             LoadFiles(SelectedFiles.LastSelectedFile);
             FileOperation.DeleteFiles(SelectedFiles.GetCopyBufferValues());
             SelectedFiles.ClearCopyBuffer();
         }
     } catch (Exception ex) { MessageBox.Show(ex.Message); UnClickAll(); }
 }
Exemplo n.º 6
0
        private void CreateContextMenu()
        {
            m_open   = new MenuItem("Open");
            m_cut    = new MenuItem("Cut");
            m_copy   = new MenuItem("Copy");
            m_delete = new MenuItem("Delete");
            m_paste  = new MenuItem("Paste");
            m_rename = new MenuItem("Rename");
            m_prop   = new MenuItem("Properties");

            m_open.Click += (o, e) => {
                FileDoubleClicked();
            };

            m_cut.Click += (o, e) => {
                b.CutClicked = true;
                b.pn_flow.ContextMenu.MenuItems[2].Enabled = true;
                SelectedFiles.SetCopyBuffer();
            };

            m_copy.Click += (o, e) => {
                b.CopyClicked = true;
                b.pn_flow.ContextMenu.MenuItems[2].Enabled = true;
                SelectedFiles.SetCopyBuffer();
            };

            m_delete.Click += (o, e) => {
                try {
                    FileOperation.DeleteFiles(SelectedFiles.GetNames());
                    b.LoadFiles(b.CurrentLocation);
                } catch (Exception ex) { MessageBox.Show(ex.Message); UnSelectFile(); }
            };


            m_paste.Click += (o, e) => {
                b.PasteFiles();
            };

            m_rename.Click += (o, e) => {
                RenameFile();
            };

            m_prop.Click += (o, e) => {
                FileProperties();
            };

            ContextMenu menu = new ContextMenu(new MenuItem[] { m_open, m_cut, m_copy, m_delete, m_rename, m_prop });

            fl_file.ContextMenu = menu;

            fl_file.ContextMenu.Popup += (o, ev) => {
                if (b.CutClicked || b.CopyClicked)
                {
                    if (!fl_file.ContextMenu.MenuItems.Contains(m_paste))
                    {
                        fl_file.ContextMenu.MenuItems.Add(4, m_paste);
                    }
                }
                else if (fl_file.ContextMenu.MenuItems.Contains(m_paste))
                {
                    fl_file.ContextMenu.MenuItems.Remove(m_paste);
                }
            };
        }