Exemplo n.º 1
0
 private void DeCompressButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (SelectedItemList != null)
         {
             string startPath = Path.Combine(ListFiles.varListPath, SelectedItemList.Name);
             if (Path.GetExtension(startPath).ToUpper() == ".ZIP")
             {
                 try
                 {
                     string decompPath = Path.Combine(ListFiles.varListPath, Path.GetFileNameWithoutExtension(SelectedItemList.Name));
                     //Directory.CreateDirectory(decompPath);
                     ZipFile.ExtractToDirectory(startPath, decompPath);
                     ListFiles.OutDirAndFiles(RightListFile, ListFiles.varListPath);
                 }
                 catch (System.IO.IOException)
                 {
                     MessageBoxResult res = MessageBox.Show("Файл уже существует. Заменить файл?", "Предупреждение", MessageBoxButton.YesNo);
                     if (res == MessageBoxResult.Yes)
                     {
                         string decompPath = Path.Combine(ListFiles.varListPath, Path.GetFileNameWithoutExtension(SelectedItemList.Name));
                         Directory.Delete(decompPath, true);
                         ZipFile.ExtractToDirectory(startPath, decompPath);
                     }
                     else
                     {
                         return;
                     }
                 }
             }
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); }
 }
Exemplo n.º 2
0
        private static void treeItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            TreeViewItem item = (TreeViewItem)mw.FolderView.SelectedItem;

            //MessageBox.Show(item.Tag.ToString());
            ListFiles.InTreeClick(mw.RightListFile, mw.RightSearchDirText, item.Tag.ToString());
        }
Exemplo n.º 3
0
 void checkThread(Thread thread)
 {
     while (thread.IsAlive)
     {
     }
     LoadScreenStop();
     Dispatcher.Invoke(() => ListFiles.OutDirAndFiles(RightListFile, ListFiles.varListPath));
 }
Exemplo n.º 4
0
 //Возвращаемся назад в папку
 private void UpPathButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ListFiles.UpInPath(RightListFile, RightSearchDirText, ListFiles.varListPath);
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
Exemplo n.º 5
0
 //Вывод всех дисков в правый лист
 private void RightDrivesButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         RightSearchDirText.Text = "";
         ListFiles.OutputDrives(RightListFile, RightSearchDirText);
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
Exemplo n.º 6
0
 // двойной щелчек по ListBox элементу (отрытие папок, запуск файлов)
 private void RightListFile_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try
     {
         ListFiles.DB_ClickInList(RightListFile, RightSearchDirText, SelectedItemList.Name);
     }
     catch (System.NullReferenceException) { }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
Exemplo n.º 7
0
 private void RightSearchDirText_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Enter)
         {
             ListFiles.SearchDir(RightListFile, RightSearchDirText);
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
Exemplo n.º 8
0
 public MainForm()
 {
     InitializeComponent();
     listFiles1.addressText = textBox1;
     listFiles1.ShowMyComputer();
     listFiles2.addressText = textBox2;
     listFiles2.ShowMyComputer();
     ActiveList    = listFiles1;
     selectedFiles = new List <string>(10);
     listFiles1.ContextMenuStrip = contextMenuStrip1;
     listFiles2.ContextMenuStrip = contextMenuStrip1;
 }
Exemplo n.º 9
0
        void checkHashThread(Thread thread, string file)
        {
            while (thread.IsAlive)
            {
            }
            LoadScreenStop();
            Dispatcher.Invoke(() => ListFiles.OutDirAndFiles(RightListFile, ListFiles.varListPath));
            hashWin hw = null;

            Dispatcher.Invoke(() => hw = new hashWin(file, hash));
            Dispatcher.Invoke(() => hw.Show());
        }
Exemplo n.º 10
0
 async Task DragDropCopy(ListFiles list, DragEventArgs e)
 {
     foreach (string f in (string[])e.Data.GetData(DataFormats.FileDrop))
     {
         if (File.Exists(f))
         {
             File.Copy(f, list.addressText.Text + Path.GetFileName(f), true);
         }
         else
         {
             await DirectoryCopy(f, list.addressText.Text);
         }
         list.UpdateContent();
     }
 }
Exemplo n.º 11
0
 private void RightSearchDirButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (RightSearchDirText.Text != null && RightSearchDirText.Text != "")
         {
             ListFiles.OutDirAndFiles(RightListFile, RightSearchDirText.Text);
         }
         else
         {
             MainWindow mainWindow = new MainWindow();
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message); }
 }
Exemplo n.º 12
0
 private void listFiles2_MouseClick(object sender, MouseEventArgs e)
 {
     ActiveList = listFiles2;
 }
Exemplo n.º 13
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete)
            {
                if (RightListFile.SelectedItem != null && SelectedItemList.Name != "..")
                {
                    string valid = Path.Combine(ListFiles.varListPath, SelectedItemList.Name);
                    if (valid != Directory.GetDirectoryRoot(valid))
                    {
                        if (File.Exists(Path.Combine(ListFiles.varListPath, SelectedItemList.Name)))
                        {
                            OperationsWithFiles.DeleteFile(RightListFile, SelectedItemList.Name);
                        }
                        else if (Directory.Exists(Path.Combine(ListFiles.varListPath, SelectedItemList.Name)))
                        {
                            OperationsWithDirectories.DeleteDir(RightListFile, SelectedItemList.Name);
                        }
                    }
                }
            }//Del
            if (e.Key == Key.Back)
            {
                ListFiles.UpInPath(RightListFile, RightSearchDirText, ListFiles.varListPath);
            } //Back
            if (e.Key == Key.Enter)
            {
                if (RightListFile.SelectedItem != null)
                {
                    ListFiles.DB_ClickInList(RightListFile, RightSearchDirText, SelectedItemList.Name);
                }
            }// Enter

            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.C)// Ctrl + C
            {
                if (RightListFile.SelectedItem != null && SelectedItemList.Name != "..")
                {
                    if (File.Exists(Path.Combine(ListFiles.varListPath, SelectedItemList.Name)))
                    {
                        OperationsWithFiles.CopyFile(RightListFile, "Copy", SelectedItemList.Name);
                    }

                    else if (Directory.Exists(Path.Combine(ListFiles.varListPath, RightListFile.SelectedItem.ToString())))
                    {
                        OperationsWithDirectories.CopyDir(RightListFile, SelectedItemList.Name);
                    }
                }
            }// Ctrl + C
            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.X) // Ctrl + X
            {
                if (RightListFile.SelectedValue != null && SelectedItemList.Name != "..")
                {
                    if (File.Exists(Path.Combine(ListFiles.varListPath, SelectedItemList.Name)))
                    {
                        OperationsWithFiles.CopyFile(RightListFile, "Cut", SelectedItemList.Name);
                    }

                    else if (Directory.Exists(Path.Combine(ListFiles.varListPath, SelectedItemList.Name)))
                    {
                        OperationsWithDirectories.CutDir(RightListFile, SelectedItemList.Name);
                    }
                }
            }// Ctrl + X
            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.V) // Ctrl + V
            {
                try
                {
                    if (File.Exists(ListFiles.thisPath))
                    {
                        if (ListFiles.CutOrCopy == "Copy")
                        {
                            OperationsWithFiles.PasteAfterCopyFile(RightListFile);
                        }
                        else if (ListFiles.CutOrCopy == "Cut")
                        {
                            OperationsWithFiles.PasteAfterCutFile(RightListFile);
                        }
                    }
                    else if (Directory.Exists(ListFiles.thisPath))
                    {
                        OperationsWithDirectories.PasteDir(RightListFile, ListFiles.CutOrCopy);
                    }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); }
            }// Ctrl + V
            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.R)
            {
                try
                {
                    if (RightListFile.SelectedItem != null && SelectedItemList.Name != "..")
                    {
                        string   textForNewWin = "Переименовать \"" + SelectedItemList.Name + "\"";
                        InputWin renameWin     = new InputWin(RightListFile, ListFiles.varListPath, textForNewWin);
                        renameWin.Owner = this;
                        renameWin.Show();
                        renameWin.Enter  += Rename;
                        renameWin.Output += ListFiles.OutDirAndFiles;
                    }
                }
                catch (Exception ex) { MessageBox.Show(ex.Message); }
            }// Ctrl + R
            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.D)
            {
                if (Directory.Exists(ListFiles.varListPath))
                {
                    InputWin addDirWin = new InputWin(RightListFile, ListFiles.varListPath, "Создать папку с именем: ");
                    addDirWin.Owner = this;
                    addDirWin.Show();
                    addDirWin.Enter  += OperationsWithDirectories.CreateDir;
                    addDirWin.Output += ListFiles.OutDirAndFiles;
                }
            }// Ctrl + D
            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.F)
            {
                if (Directory.Exists(ListFiles.varListPath))
                {
                    InputWin addDirWin = new InputWin(RightListFile, ListFiles.varListPath, "Создать файл с именем (и расширением): ");
                    addDirWin.Owner = this;
                    addDirWin.Show();
                    addDirWin.Enter  += OperationsWithFiles.CreateFile;
                    addDirWin.Output += ListFiles.OutDirAndFiles;
                }
            }// Ctrl + F
        }