public int CompareTo(ILogicItem other)
 {
     return(Name == BackEntry && other.Name == BackEntry ? 0 : Name == BackEntry
                                                                                              ? -1 : other.Name == BackEntry
                                                                                              ? 1 : IsFolder
                                                                                              ? Name.CompareTo(other.Name) : 0);
 }
        /// <summary>
        /// При медленном нажатии по ячейке колонки "Имя" открывается редактирование имени
        /// </summary>
        /// <param name="sender">DataGrid</param>
        /// <param name="e">MouseButtonEventArgs</param>
        private void DataGridMouseUp(object sender, MouseButtonEventArgs e)
        {
            OnSetFocusedDataGrid(e);

            // Get selected DataGrid Item to rename
            var item = (ILogicItem)dataGrid.CurrentItem;

            if (item == null)
            {
                return;
            }

            if (item.Name == ViewDataItem.BackEntry)
            {
                dataGrid.CurrentCell.Column.IsReadOnly = true;
                return;
            }

            if (_selectedItem == item)
            {
                item.Name = item.Info.Name;

                dataGrid.CurrentCell.Column.IsReadOnly =
                    (dataGrid.CurrentCell.Column.Header.ToString() != "Имя");
                return;
            }

            _selectedItem = item;
        }
        public bool FilePropertiesDialog(ILogicItem itemToAttribute)
        {
            if (itemToAttribute == null)
                throw new ArgumentNullException("itemToAttribute", "Не выбрана сущность для получения атрибутов");

            var shInfo = new SHELLEXECUTEINFO
            {
                cbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO)),
                lpFile = itemToAttribute.Info.FullName,
                nShow = SwShow,
                fMask = SeeMaskInvokeidlist,
                lpVerb = "properties"
            };

            return ShellExecuteEx(shInfo) == 1;
        }
        private void CopyOnExecute(object sender, ExecutedRoutedEventArgs args)
        {
            var copyToDat = ((FocusedExplorer == expLeft)
                                 ? expRight.CurrentPath
                                 : expLeft.CurrentPath);

            if (MessageBox.ShowDialog(
                    MakeMessageStr("Копировать"),
                    "Ultimate Commander - Подсистема копирования данных",
                    MessageBoxButton.YesNo
                    ) != true)
            {
                return;
            }

            ILogicItem currentItem = null;

            try
            {
                foreach (ILogicItem t in FocusedExplorer.SelectedItems)
                {
                    currentItem = t;

                    if (currentItem.IsFolder)
                    {
                        _fileSystem.CopyDirectory(currentItem.Info.FullName, Path.Combine(copyToDat, currentItem.Info.Name));
                    }
                    else
                    {
                        _fileSystem.CopyFile(currentItem.Info.FullName, Path.Combine(copyToDat, currentItem.Info.Name));
                    }
                }
            }
            catch (System.SystemException ex)
            {
                if (currentItem != null)
                {
                    MessageBox.ShowDialog(
                        string.Format("Невозможно копировать файл {0}, " +
                                      "возможно, файл используется или защищен:\n{1}",
                                      currentItem.Info.FullName,
                                      ex.Message),
                        "Ultimate Commander - Подсистема доступа",
                        MessageBoxButton.OK);
                }
            }
        }
        public bool FilePropertiesDialog(ILogicItem itemToAttribute)
        {
            if (itemToAttribute == null)
            {
                throw new ArgumentNullException("itemToAttribute", "Не выбрана сущность для получения атрибутов");
            }

            var shInfo = new SHELLEXECUTEINFO
            {
                cbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO)),
                lpFile = itemToAttribute.Info.FullName,
                nShow  = SwShow,
                fMask  = SeeMaskInvokeidlist,
                lpVerb = "properties"
            };

            return(ShellExecuteEx(shInfo) == 1);
        }
        private void DeleteOnExecute(object sender, ExecutedRoutedEventArgs args)
        {
            if (MessageBox.ShowDialog(
                    MakeMessageStr("Удалить"),
                    "Ultimate Commander - Подсистема данных",
                    MessageBoxButton.YesNo
                    ) != true)
            {
                return;
            }

            ILogicItem currentItem = null;

            try
            {
                foreach (ILogicItem t in FocusedExplorer.SelectedItems)
                {
                    currentItem = t;

                    if (currentItem.IsFolder)
                    {
                        _fileSystem.DeleteDirectory(currentItem.Info.FullName);
                    }
                    else
                    {
                        _fileSystem.DeleteFile(currentItem.Info.FullName);
                    }
                }
            }
            catch (System.SystemException ex)
            {
                if (currentItem != null)
                {
                    MessageBox.ShowDialog(
                        string.Format("Невозможно удалить файл {0}, " +
                                      "возможно, файл используется или защищен:\n{1}",
                                      currentItem.Info.FullName,
                                      ex.Message),
                        "Ultimate Commander - Подсистема доступа",
                        MessageBoxButton.OK);
                }
            }
        }
        public static bool OpenWithDialog(ILogicItem itemToOpenWith)
        {
            if (itemToOpenWith == null)
                throw new ArgumentNullException("itemToOpenWith", "Не выбрана сущность для получения атрибутов");

            if (itemToOpenWith.Length == long.MinValue)
                throw new ArgumentException("itemToOpenWith", "Выбрана папка");

            var shInfo = new SHELLEXECUTEINFO
            {
                cbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO)),
                lpFile = "rundll32.exe",
                lpParameters = "shell32.dll,OpenAs_RunDLL " + itemToOpenWith.Info.FullName,
                nShow = SwShow,
                fMask = SeeMaskInvokeidlist,
                lpVerb = "open"
            };

            return ShellExecuteEx(shInfo) == 1;
        }
        /// <summary>
        /// Переименновываем файл в момент удаления текст бокса
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBoxUnloaded(object sender, RoutedEventArgs e)
        {
            var item        = _selectedItem;
            var textBox     = ((TextBox)sender);
            var newFileName = textBox.Text;

            try
            {
                if (item == null)
                {
                    return;
                }
                if (item.Info.Name != newFileName)
                {
                    if (!item.IsFolder)
                    {
                        var file = (FileInfo)item.Info;
                        _fileSystem.RenameFile(item.Info.FullName, Path.Combine(file.DirectoryName, newFileName));
                    }
                    else
                    {
                        var file = Path.GetDirectoryName(item.Info.FullName);
                        _fileSystem.RenameDirectory(item.Info.FullName, Path.Combine(file, newFileName));
                    }
                }
                else
                {
                    item.Name = Path.GetFileNameWithoutExtension(item.Info.Name);
                    dataGrid.Items.Refresh();
                }
            }
            finally
            {
                _selectedItem = null;
                dataGrid.CurrentCell.Column.IsReadOnly = true;
            }
        }
        public static bool OpenWithDialog(ILogicItem itemToOpenWith)
        {
            if (itemToOpenWith == null)
            {
                throw new ArgumentNullException("itemToOpenWith", "Не выбрана сущность для получения атрибутов");
            }

            if (itemToOpenWith.Length == long.MinValue)
            {
                throw new ArgumentException("itemToOpenWith", "Выбрана папка");
            }

            var shInfo = new SHELLEXECUTEINFO
            {
                cbSize       = Marshal.SizeOf(typeof(SHELLEXECUTEINFO)),
                lpFile       = "rundll32.exe",
                lpParameters = "shell32.dll,OpenAs_RunDLL " + itemToOpenWith.Info.FullName,
                nShow        = SwShow,
                fMask        = SeeMaskInvokeidlist,
                lpVerb       = "open"
            };

            return(ShellExecuteEx(shInfo) == 1);
        }
 /// <summary>
 /// Compares to length.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToLength(ILogicItem x, ILogicItem y, int dir)
 {
     return x.IsFolder&&y.IsFolder ? 0 :x.IsFolder?-1:y.IsFolder?1: x.Length.CompareTo(y.Length) * dir;
 }
 /// <summary>
 /// Compares to date.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToDate(ILogicItem x, ILogicItem y, int dir)
 {
     return x.IsFolder && y.IsFolder ? 0 : x.IsFolder ? -1 : y.IsFolder ? 1 : x.Info.LastAccessTime.CompareTo(y.Info.LastAccessTime) * dir;
 }
        /// <summary>
        /// Переименновываем файл в момент удаления текст бокса
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBoxUnloaded(object sender, RoutedEventArgs e)
        {
            var item = _selectedItem;
            var textBox = ((TextBox)sender);
            var newFileName = textBox.Text;

            try
            {
                if (item == null) return;
                if (item.Info.Name != newFileName)
                {
                    if (!item.IsFolder)
                    {
                        var file = (FileInfo)item.Info;
                        _fileSystem.RenameFile(item.Info.FullName, Path.Combine(file.DirectoryName, newFileName));
                    }
                    else
                    {
                        var file = Path.GetDirectoryName(item.Info.FullName);
                        _fileSystem.RenameDirectory(item.Info.FullName, Path.Combine(file, newFileName));
                    }
                }
                else
                {
                    item.Name = Path.GetFileNameWithoutExtension(item.Info.Name);
                    dataGrid.Items.Refresh();
                }
            }
            finally
            {
                _selectedItem = null;
                dataGrid.CurrentCell.Column.IsReadOnly = true;
            }
        }
Exemple #13
0
 public IconExtractor(ILogicItem file)
 {
     File = file;
 }
 public IconExtractor(ILogicItem file)
 {
     File = file;
 }
 /// <summary>
 /// Compares to type.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToType(ILogicItem x, ILogicItem y, int dir)
 {
     return(x.IsFolder && y.IsFolder ? 0 : x.IsFolder ? -1 : y.IsFolder ? 1 : x.Type.CompareTo(y.Type) * dir);
 }
 /// <summary>
 /// Compares to name.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToName(ILogicItem x, ILogicItem y, int dir)
 {
     return(x.Name == y.Name && y.IsFolder && x.IsFolder? 0 :x.IsFolder && y.IsFolder && x.IsFolder
                                                                                                     ?-1:y.IsFolder
                                                                                                     ?1: x.Info.Name.CompareTo(y.Info.Name) * dir);
 }
 /// <summary>
 /// Compares to length.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToLength(ILogicItem x, ILogicItem y, int dir)
 {
     return(x.IsFolder && y.IsFolder ? 0 :x.IsFolder?-1:y.IsFolder?1: x.Length.CompareTo(y.Length) * dir);
 }
 /// <summary>
 /// Compares to date.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToDate(ILogicItem x, ILogicItem y, int dir)
 {
     return(x.IsFolder && y.IsFolder ? 0 : x.IsFolder ? -1 : y.IsFolder ? 1 : x.Info.LastAccessTime.CompareTo(y.Info.LastAccessTime) * dir);
 }
 public int CompareTo(ILogicItem other)
 {
     return Name == BackEntry && other.Name == BackEntry ? 0 : Name == BackEntry
                                                                                              ? -1 : other.Name == BackEntry
                                                                                              ? 1 : IsFolder
                                                                                              ? Name.CompareTo(other.Name) : 0;
 }
 /// <summary>
 /// Compares to name.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToName(ILogicItem x,ILogicItem y,int dir)
 {
     return  x.Name==y.Name&&y.IsFolder&&x.IsFolder? 0 :x.IsFolder&&y.IsFolder&&x.IsFolder
                                                                                                     ?-1:y.IsFolder
                                                                                                     ?1: x.Info.Name.CompareTo(y.Info.Name) * dir;
 }
 /// <summary>
 /// Compares to type.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="dir">The dir.</param>
 private static int CompareToType(ILogicItem x, ILogicItem y, int dir)
 {
     return x.IsFolder && y.IsFolder ? 0 : x.IsFolder ? -1 : y.IsFolder ? 1 : x.Type.CompareTo(y.Type) * dir;
 }
        /// <summary>
        /// При медленном нажатии по ячейке колонки "Имя" открывается редактирование имени
        /// </summary>
        /// <param name="sender">DataGrid</param>
        /// <param name="e">MouseButtonEventArgs</param>
        private void DataGridMouseUp(object sender, MouseButtonEventArgs e)
        {
            OnSetFocusedDataGrid(e);

            // Get selected DataGrid Item to rename
            var item = (ILogicItem)dataGrid.CurrentItem;
            if (item == null) return;

            if (item.Name == ViewDataItem.BackEntry)
            {
                dataGrid.CurrentCell.Column.IsReadOnly = true;
                return;
            }

            if (_selectedItem == item)
            {
                item.Name = item.Info.Name;

                dataGrid.CurrentCell.Column.IsReadOnly =
                    (dataGrid.CurrentCell.Column.Header.ToString() != "Имя");
                return;
            }

            _selectedItem = item;
        }