コード例 #1
0
        public void SideLeftListRightClick(ref ListView SideLeftList, MenuActions menu, object sender)
        {
            if (menu.IsFull)
            {
                var item = (DirectoryItems)SideLeftList.SelectedItem;
                if (item != null)
                    ItemLeft = item.Name;
            }
            else if (menu.IsTree)
            {
                var leftPanel = (TreeView)sender;
                var item = (string)(((TreeViewItem)leftPanel.SelectedItem).Tag);
                if (item != null)
                    ItemLeft = item;
            }

            IsVisibleLeft = true;
        }
コード例 #2
0
        public void SideRightListRightClick(ref ListView SideRightList, MenuActions menu, object sender, CommandsForLeftSide commands)
        {
            if (menu.IsFull)
            {
                var item = (DirectoryItems)SideRightList.SelectedItem;
                if (item != null)
                {
                    ItemRight = item.Name;
                }
            }
            else if (menu.IsTree)
            {
                var rightPanel = (TreeView)sender;
                var item       = (string)(((TreeViewItem)rightPanel.SelectedItem).Tag);
                if (item != null)
                {
                    ItemRight = item;
                }
            }

            commands.IsVisibleLeft = false;
            IsVisibleRight         = true;
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        public void SideRightListDoubleClick(ref ListView SideRightList, CommandsForLeftSide commands, ref TextBlock PathRightSide, MenuActions menu, object sender)
        {
            if (menu.IsFull)
            {
                var item = (DirectoryItems)SideRightList.SelectedItem;
                if (item != null)
                {
                    if (File.Exists(Path + item.Name))
                    {
                        Process.Start(Path + item.Name);
                    }
                    Path = Path + item.Name + "\\";
                    ChangeListOfDirectories(Path);
                    SideRightList.ItemsSource = Directories;
                    PathRightSide.Text        = Path;
                }
            }
            else if (menu.IsTree)
            {
                var rightPanel = (TreeView)sender;
                var item       = (string)(((TreeViewItem)rightPanel.SelectedItem).Tag);
                if (item != null)
                {
                    if (File.Exists(item))
                    {
                        Process.Start(item);
                    }
                }
            }

            IsVisibleRight         = true;
            commands.IsVisibleLeft = false;
        }
コード例 #5
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");
                }
            }
        }
コード例 #6
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");
                }
            }
        }
コード例 #7
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");
                }
            }
        }
コード例 #8
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");
                }
            }
        }