예제 #1
0
 public void UnpackClick(CommandsForLeftSide commandsForLeftSide, CommandsForRightSide commandsForRightSide, ref TextBox textBox, ref ListView SideRightList, ref ListView SideLeftList)
 {
     if (commandsForLeftSide.IsVisibleLeft)
     {
         if (IsFull)
         {
             var     path = commandsForLeftSide.Path + commandsForLeftSide.ItemLeft;
             ZipFile zip  = new ZipFile(path);
             zip.ExtractAll(commandsForRightSide.Path);
             commandsForRightSide.ChangeListOfDirectories(commandsForRightSide.Path);
             SideRightList.ItemsSource = commandsForRightSide.Directories;
         }
         else
         {
             var item = commandsForLeftSide.ItemLeft;
             int pos  = commandsForLeftSide.ItemLeft.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
             commandsForLeftSide.ItemLeft = commandsForLeftSide.ItemLeft.Substring(pos + 1);
             ZipFile zip = new ZipFile(item);
             zip.ExtractAll(commandsForRightSide.ItemRight);
         }
     }
     else
     {
         if (IsFull)
         {
             var     path = commandsForRightSide.Path + commandsForRightSide.ItemRight;
             ZipFile zip  = new ZipFile(path);
             zip.ExtractAll(commandsForLeftSide.Path);
             commandsForLeftSide.ChangeListOfDirectories(commandsForLeftSide.Path);
             SideLeftList.ItemsSource = commandsForLeftSide.Directories;
         }
         else
         {
             var item = commandsForRightSide.ItemRight;
             int pos  = commandsForRightSide.ItemRight.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
             commandsForRightSide.ItemRight = commandsForRightSide.ItemRight.Substring(pos + 1);
             ZipFile zip = new ZipFile(item);
             zip.ExtractAll(commandsForLeftSide.ItemLeft);
         }
     }
 }
예제 #2
0
        public void Copy(CommandsForLeftSide commandsForLeft, CommandsForRightSide commandsForRight, ref TextBox TextBox, MenuActions menuActions, ref ListView SideLeftList, ref ListView SideRightList)
        {
            if (commandsForLeft.IsVisibleLeft)
            {
                if (commandsForLeft.ItemLeft != null && commandsForRight.Path != null)
                {
                    if (menuActions.IsFull)
                    {
                        string pathNew = commandsForLeft.Path + commandsForLeft.ItemLeft;
                        if (File.Exists(pathNew))
                        {
                            File.Copy(pathNew, commandsForRight.Path + commandsForLeft.ItemLeft, true);
                            TextBox.Text = "File " + commandsForLeft.ItemLeft + " from: " + commandsForLeft.Path + ", was copied in: " + commandsForRight.Path;
                        }
                        else
                        {
                            DirectoryCopy(pathNew, commandsForRight.Path + commandsForLeft.ItemLeft);
                            TextBox.Text = "Directory " + commandsForLeft.ItemLeft + " from: " + commandsForLeft.Path + ", was copied in: " + commandsForRight.Path;
                        }
                        commandsForRight.ChangeListOfDirectories(commandsForRight.Path);
                        SideRightList.ItemsSource = commandsForRight.Directories;
                    }

                    else
                    {
                        string item = commandsForLeft.ItemLeft;
                        int    pos  = commandsForLeft.ItemLeft.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
                        commandsForLeft.ItemLeft = commandsForLeft.ItemLeft.Substring(pos + 1);
                        if (File.Exists(item))
                        {
                            File.Copy(item, commandsForRight.ItemRight + "\\" + commandsForLeft.ItemLeft, true);
                        }
                        else
                        {
                            DirectoryCopy(item, commandsForRight.ItemRight + "\\" + commandsForLeft.ItemLeft);
                        }
                        commandsForRight.ChangeListOfDirectories(commandsForRight.ItemRight);
                        SideRightList.ItemsSource = commandsForRight.Directories;
                    }
                }
                else
                {
                    MessageBox.Show("You don`t select an item\nOr your path is not found!", "Info");
                }
            }

            else if (commandsForRight.IsVisibleRight)
            {
                if (commandsForRight.ItemRight != null && commandsForLeft.Path != null)
                {
                    if (menuActions.IsFull)
                    {
                        string pathNew = commandsForRight.Path + commandsForRight.ItemRight;
                        if (File.Exists(pathNew))
                        {
                            File.Copy(pathNew, commandsForLeft.Path + commandsForRight.ItemRight, true);
                            TextBox.Text = "File " + commandsForRight.ItemRight + " from: " + commandsForRight.Path + ", was copied in: " + commandsForLeft.Path;
                        }
                        else
                        {
                            DirectoryCopy(pathNew, commandsForLeft.Path + commandsForRight.ItemRight);
                            TextBox.Text = "File " + commandsForRight.ItemRight + " from: " + commandsForRight.Path + ", was copied in: " + commandsForLeft.Path;
                        }
                        commandsForLeft.ChangeListOfDirectories(commandsForLeft.Path);
                        SideLeftList.ItemsSource = commandsForLeft.Directories;
                    }

                    else
                    {
                        string item = commandsForRight.ItemRight;
                        int    pos  = commandsForRight.ItemRight.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
                        commandsForRight.ItemRight = commandsForRight.ItemRight.Substring(pos + 1);
                        if (File.Exists(item))
                        {
                            File.Copy(item, commandsForLeft.ItemLeft + "\\" + commandsForRight.ItemRight, true);
                        }
                        else
                        {
                            DirectoryCopy(item, commandsForLeft.ItemLeft + "\\" + commandsForRight.ItemRight);
                        }
                        commandsForLeft.ChangeListOfDirectories(commandsForLeft.ItemLeft);
                        SideLeftList.ItemsSource = commandsForLeft.Directories;
                    }
                }
                else
                {
                    MessageBox.Show("You don`t select an item\nOr your path is not found!", "Info");
                }
            }
        }
예제 #3
0
 public void PackClick(CommandsForLeftSide commandsForLeftSide, CommandsForRightSide commandsForRightSide, ref TextBox textBox, ref ListView SideRightList, ref ListView SideLeftList)
 {
     using (ZipFile zip = new ZipFile())
     {
         if (commandsForLeftSide.IsVisibleLeft)
         {
             string item;
             if (commandsForLeftSide.ItemLeft != null && commandsForRightSide.Path != null)
             {
                 if (IsFull)
                 {
                     item = commandsForLeftSide.Path + commandsForLeftSide.ItemLeft;
                     if (File.Exists(item))
                     {
                         zip.AddFile(item);
                     }
                     else
                     {
                         zip.AddDirectory(item, commandsForLeftSide.ItemLeft);
                     }
                     zip.Save(commandsForRightSide.Path + commandsForLeftSide.ItemLeft + ".zip");
                     commandsForRightSide.ChangeListOfDirectories(commandsForRightSide.Path);
                     SideRightList.ItemsSource = commandsForRightSide.Directories;
                 }
                 else
                 {
                     item = commandsForLeftSide.ItemLeft;
                     int pos = commandsForLeftSide.ItemLeft.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
                     commandsForLeftSide.ItemLeft = commandsForLeftSide.ItemLeft.Substring(pos + 1);
                     if (File.Exists(item))
                     {
                         zip.AddFile(item);
                     }
                     else
                     {
                         zip.AddDirectory(item, commandsForLeftSide.ItemLeft);
                     }
                     zip.Save(commandsForRightSide.ItemRight + commandsForLeftSide.ItemLeft + ".zip");
                 }
             }
             else
             {
                 MessageBox.Show("You don`t select an item \nOr Your path to arhive is not found!", "Info");
             }
         }
         else if (commandsForRightSide.IsVisibleRight)
         {
             string item;
             if (commandsForRightSide.ItemRight != null && commandsForLeftSide.Path != null)
             {
                 if (IsFull)
                 {
                     item = commandsForRightSide.Path + commandsForRightSide.ItemRight;
                     if (File.Exists(item))
                     {
                         zip.AddFile(item);
                     }
                     else
                     {
                         zip.AddDirectory(item, commandsForRightSide.ItemRight);
                     }
                     zip.Save(commandsForLeftSide.Path + commandsForRightSide.ItemRight + ".zip");
                     commandsForLeftSide.ChangeListOfDirectories(commandsForLeftSide.Path);
                     SideLeftList.ItemsSource = commandsForLeftSide.Directories;
                 }
                 else
                 {
                     item = commandsForRightSide.ItemRight;
                     int pos = commandsForRightSide.ItemRight.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
                     commandsForRightSide.ItemRight = commandsForRightSide.ItemRight.Substring(pos + 1);
                     if (File.Exists(item))
                     {
                         zip.AddFile(item);
                     }
                     else
                     {
                         zip.AddDirectory(item, commandsForRightSide.ItemRight);
                     }
                     zip.Save(commandsForLeftSide.ItemLeft + commandsForRightSide.ItemRight + ".zip");
                 }
             }
             else
             {
                 MessageBox.Show("You don`t select an item \nOr Your path to arhive is not found!", "Info");
             }
         }
     }
 }
예제 #4
0
        public void Delete(CommandsForLeftSide commandsForLeft, CommandsForRightSide commandsForRight, ref TextBox TextBox, MenuActions menuActions, ref ListView SideLeftList, ref ListView SideRightList)
        {
            if (commandsForLeft.IsVisibleLeft)
            {
                if (commandsForLeft.ItemLeft != null)
                {
                    if (menuActions.IsFull)
                    {
                        string           pathNew = commandsForLeft.Path + commandsForLeft.ItemLeft;
                        MessageBoxResult result  = MessageBox.Show("Do you really want to move the selected item to the recycle bin?", "Total Commander", MessageBoxButton.YesNoCancel);

                        if (File.Exists(pathNew))
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                File.Delete(pathNew);
                                TextBox.Text = "File " + commandsForLeft.ItemLeft + " deleted";
                            }
                        }
                        else
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                Directory.Delete(pathNew, true);
                                TextBox.Text = "File " + commandsForLeft.ItemLeft + " deleted";
                            }
                        }
                        commandsForLeft.ChangeListOfDirectories(commandsForLeft.Path);
                        SideLeftList.ItemsSource = commandsForLeft.Directories;
                    }
                    else
                    {
                        MessageBoxResult result = MessageBox.Show("Do you really want to move the selected item to the recycle bin?", "Total Commander", MessageBoxButton.YesNoCancel);

                        if (File.Exists(commandsForLeft.ItemLeft))
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                File.Delete(commandsForLeft.ItemLeft);
                                TextBox.Text = "File " + commandsForLeft.ItemLeft + " deleted";
                            }
                        }
                        else
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                Directory.Delete(commandsForLeft.ItemLeft, true);
                                TextBox.Text = "File " + commandsForLeft.ItemLeft + " deleted";
                            }
                        }
                        commandsForLeft.ChangeListOfDirectories(commandsForLeft.ItemLeft);
                        SideLeftList.ItemsSource = commandsForLeft.Directories;
                    }
                }
                else
                {
                    MessageBox.Show("You don`t select an item", "Info");
                }
            }

            else if (commandsForRight.IsVisibleRight)
            {
                if (commandsForRight.ItemRight != null)
                {
                    if (menuActions.IsFull)
                    {
                        string           pathNew = commandsForRight.Path + commandsForRight.ItemRight;
                        MessageBoxResult result  = MessageBox.Show("Do you really want to move the selected item to the recycle bin?", "Total Commander", MessageBoxButton.YesNoCancel);

                        if (File.Exists(pathNew))
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                File.Delete(pathNew);
                                TextBox.Text = "File " + commandsForRight.ItemRight + " deleted";
                            }
                        }
                        else
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                Directory.Delete(pathNew, true);
                                TextBox.Text = "File " + commandsForRight.ItemRight + " deleted";
                            }
                        }
                        commandsForRight.ChangeListOfDirectories(commandsForRight.Path);
                        SideRightList.ItemsSource = commandsForRight.Directories;
                    }
                    else
                    {
                        MessageBoxResult result = MessageBox.Show("Do you really want to move the selected item to the recycle bin?", "Total Commander", MessageBoxButton.YesNoCancel);

                        if (File.Exists(commandsForRight.ItemRight))
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                File.Delete(commandsForRight.ItemRight);
                                TextBox.Text = "File " + commandsForRight.ItemRight + " deleted";
                            }
                        }
                        else
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                Directory.Delete(commandsForRight.ItemRight, true);
                                TextBox.Text = "File " + commandsForRight.ItemRight + " deleted";
                            }
                        }
                        commandsForRight.ChangeListOfDirectories(commandsForRight.ItemRight);
                        SideRightList.ItemsSource = commandsForRight.Directories;
                    }
                }
                else
                {
                    MessageBox.Show("You don`t select an item", "Info");
                }
            }
        }