public void SideLeftListDoubleClick(ref ListView SideLeftList,CommandsForRightSide commandsForRight,ref TextBlock PathLeftSide, MenuActions menu, object sender)
        {
            if (menu.IsFull)
            {
                var item = (DirectoryItems)SideLeftList.SelectedItem;
                if (item != null)
                {
                    if (File.Exists(Path + item.Name))
                        Process.Start(Path + item.Name);
                    Path = Path + item.Name + "\\";
                    ChangeListOfDirectories(Path);
                    SideLeftList.ItemsSource = Directories;
                    PathLeftSide.Text = Path;
                }
            }
            else
            {
                var leftPanel = (TreeView)sender;
                var item = (string)(((TreeViewItem)leftPanel.SelectedItem).Tag);
                if (item != null)
                    if (File.Exists(item))
                        Process.Start(item);
            }

            IsVisibleLeft = true;
            commandsForRight.IsVisibleRight = false;
        }
        public void ComboBoxSelect(ref ComboBox comboBox, ref ListView SideLeftList, CommandsForRightSide commandsForRight, ref TextBlock PathLeftSide)
        {
            Path = comboBox.SelectedItem.ToString();
            ChangeListOfDirectories(Path);

            SideLeftList.ItemsSource = Directories;
            IsVisibleLeft = true;
            commandsForRight.IsVisibleRight = false;

            PathLeftSide.Text = Path;
        }
示例#3
0
        public void Add(CommandsForLeftSide commandsForLeft, CommandsForRightSide commandsForRight, ref TextBox TextBox, MenuActions menuActions, ref ListView SideLeftList, ref ListView SideRightList)
        {
            string newPath = null;

            if (commandsForLeft.IsVisibleLeft && commandsForLeft.Path != null)
            {
                if (commandsForLeft.ItemLeft != null)
                {
                    if (menuActions.IsFull)
                    {
                        newPath = Path.Combine(commandsForLeft.Path + commandsForLeft.ItemLeft, "New Folder");
                    }
                    else
                    {
                        newPath = Path.Combine(commandsForLeft.ItemLeft, "New Folder");
                    }

                    TextBox.Text = "In " + commandsForLeft.Path + commandsForLeft.ItemLeft + " was created a new folder";
                    Directory.CreateDirectory(newPath);
                    commandsForLeft.ChangeListOfDirectories(commandsForLeft.Path);
                    SideLeftList.ItemsSource = commandsForLeft.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 && commandsForRight.Path != null)
                {
                    if (menuActions.IsFull)
                    {
                        newPath = Path.Combine(commandsForRight.Path + commandsForRight.ItemRight, "New Folder");
                    }
                    else
                    {
                        newPath = System.IO.Path.Combine(commandsForRight.ItemRight, "New Folder");
                    }

                    TextBox.Text = "In " + commandsForRight.Path + commandsForRight.ItemRight + " was created a new folder";
                    Directory.CreateDirectory(newPath);
                    commandsForRight.ChangeListOfDirectories(commandsForRight.Path);
                    SideRightList.ItemsSource = commandsForRight.Directories;
                }
                else
                {
                    MessageBox.Show("You don`t select an item\nOr your path is not found!", "Info");
                }
            }
        }
示例#4
0
        public void ViewTxt(CommandsForLeftSide commandsForLeft, CommandsForRightSide commandsForRight, ref TextBox TextBox, MenuActions menuActions)
        {
            if (commandsForLeft.IsVisibleLeft)
            {
                if (commandsForLeft.ItemLeft != null)
                {
                    string newPath = commandsForLeft.Path + commandsForLeft.ItemLeft;

                    if (File.Exists(newPath))
                    {
                        Process.Start("notepad.exe", newPath);
                    }
                    else
                    {
                        TextBox.Text = "Selected item is not exists.";
                    }
                }
                else
                {
                    MessageBox.Show("You don`t select an item", "Info");
                }
            }

            else if (commandsForRight.IsVisibleRight)
            {
                if (commandsForRight.ItemRight != null)
                {
                    string newPath = commandsForRight.Path + commandsForRight.ItemRight;
                    if (File.Exists(newPath))
                    {
                        Process.Start("notepad.exe", newPath);
                    }
                    else
                    {
                        TextBox.Text = "Selected item is not exists.";
                    }
                }
                else
                {
                    MessageBox.Show("You don`t select an item", "Info");
                }
            }
        }
 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);
         }
     }
 }
示例#6
0
        public VerticalArrangement()
        {
            InitializeComponent();
            commandsForLeft  = new CommandsForLeftSide();
            commandsForRight = new CommandsForRightSide();
            actions          = new Actions();
            menuActions      = new MenuActions();
            foreach (var drive in Directory.GetLogicalDrives())
            {
                var item = new TreeViewItem()
                {
                    // Set the header
                    Header = drive,
                    // And the full path
                    Tag = drive
                };

                item.Items.Add(null);
                item.Expanded += Folder_Expanded;
                SideLeftListTreeView.Items.Add(item);
            }

            foreach (var drive in Directory.GetLogicalDrives())
            {
                var item = new TreeViewItem()
                {
                    // Set the header
                    Header = drive,
                    // And the full path
                    Tag = drive
                };

                item.Items.Add(null);
                item.Expanded += Folder_Expanded;
                SideRightListTreeView.Items.Add(item);
            }
        }
        public void Compare(CommandsForLeftSide commandsForLeft, CommandsForRightSide commandsForRight)
        {
            if (!File.Exists(commandsForLeft.ItemLeft) || !File.Exists(commandsForRight.ItemRight))
            {
                return;
            }
            var ContentCompareResult = new List <CompareByContentLine>();

            string[] linesFile1 = File.ReadAllLines(commandsForLeft.Path + commandsForLeft.ItemLeft);
            string[] linesFile2 = File.ReadAllLines(commandsForRight.Path + commandsForRight.ItemRight);

            string[] linesFile1Sorted = new string[linesFile1.Length];
            linesFile1.CopyTo(linesFile1Sorted, 0);

            string[] linesFile2Sorted = new string[linesFile2.Length];
            linesFile2.CopyTo(linesFile2Sorted, 0);

            Array.Sort(linesFile1Sorted, StringComparer.InvariantCulture);
            Array.Sort(linesFile2Sorted, StringComparer.InvariantCulture);

            var minimumLength = linesFile1.Length < linesFile2.Length ? linesFile1.Length : linesFile2.Length;

            var  CommonLines = new HashSet <string>();
            uint lineCounterFile1 = 0, lineCounterFile2 = 0;

            for (; lineCounterFile1 < minimumLength && lineCounterFile2 < minimumLength;)
            {
                if (linesFile1Sorted[lineCounterFile1] == linesFile2Sorted[lineCounterFile2])
                {
                    CommonLines.Add(linesFile1Sorted[lineCounterFile1]);
                }
                if (linesFile1Sorted[lineCounterFile1].CompareTo(linesFile2Sorted[lineCounterFile2]) < 0)
                {
                    ++lineCounterFile1;
                }
                else
                {
                    ++lineCounterFile2;
                }
            }
            if (linesFile1.Length > linesFile2.Length)
            {
                foreach (var line in linesFile1)
                {
                    if (CommonLines.Contains(line))
                    {
                        ContentCompareResult.Add(new CompareByContentLine {
                            Text = line, Color = "Black"
                        });
                    }
                    else
                    {
                        ContentCompareResult.Add(new CompareByContentLine {
                            Text = line, Color = "Red"
                        });
                    }
                }
            }
            else
            {
                foreach (var line in linesFile2)
                {
                    if (CommonLines.Contains(line))
                    {
                        ContentCompareResult.Add(new CompareByContentLine {
                            Text = line, Color = "Black"
                        });
                    }
                    else
                    {
                        ContentCompareResult.Add(new CompareByContentLine {
                            Text = line, Color = "Red"
                        });
                    }
                }
            }
            //new CompareByContentWindow(ref ContentCompareResult).Show();
        }
 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");
             }
         }
     }
 }
示例#9
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");
                }
            }
        }
示例#10
0
        public void Back(ref ListView SideLeftList, ref ListView SideRightList, ref TextBlock PathLeftSide, ref TextBlock PathRightSide, CommandsForLeftSide commandsForLeft, CommandsForRightSide commandsForRight, ref TextBox TextBox)
        {
            if (commandsForLeft.IsVisibleLeft)
            {
                string newPath = commandsForLeft.Path.Substring(0, commandsForLeft.Path.Length - 1);
                int    pos     = newPath.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
                if (pos != -1)
                {
                    commandsForLeft.Path = newPath.Substring(0, pos + 1);
                    commandsForLeft.ChangeListOfDirectories(commandsForLeft.Path);
                    SideLeftList.ItemsSource = commandsForLeft.Directories;
                }
                PathLeftSide.Text = commandsForLeft.Path;

                commandsForLeft.IsVisibleLeft   = true;
                commandsForRight.IsVisibleRight = false;
            }

            else if (commandsForRight.IsVisibleRight)
            {
                string newPath = commandsForRight.Path.Substring(0, commandsForRight.Path.Length - 1);
                int    pos     = newPath.LastIndexOf("\\", StringComparison.CurrentCultureIgnoreCase);
                if (pos != -1)
                {
                    commandsForRight.Path = newPath.Substring(0, pos + 1);
                    commandsForRight.ChangeListOfDirectories(commandsForRight.Path);
                    SideRightList.ItemsSource = commandsForRight.Directories;
                }
                PathRightSide.Text = commandsForRight.Path;

                commandsForLeft.IsVisibleLeft   = false;
                commandsForRight.IsVisibleRight = true;
            }
        }
示例#11
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");
                }
            }
        }