public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DirectoryItemType directoryItemType = (DirectoryItemType)value;
            string            image             = "";

            switch (directoryItemType)
            {
            case DirectoryItemType.Drive:
                image = "drive.png";
                break;

            case DirectoryItemType.File:
                image = "file.png";

                break;

            case DirectoryItemType.Folder:
                image = "closed-folder-1.png";

                break;

            default:
                break;
            }

            Uri uri = new Uri($"pack://application:,,,/Images/{image}");

            return(new BitmapImage(uri));
        }
示例#2
0
        public static string GetFileFolderName(string path, DirectoryItemType type)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(string.Empty);
            }

            if (type == DirectoryItemType.Drive)
            {
                return(path);
            }

            //Correct slashes
            var correctedPath = path.Replace('/', '\\');

            //Search last \\ index in the path
            var lastIndex = correctedPath.LastIndexOf('\\');

            if (lastIndex <= 0)
            {
                return(path);
            }

            return(path.Substring(lastIndex + 1));
        }
示例#3
0
        private ImageSource GetIcon(DirectoryItemType type, string filePath)
        {
            BitmapImage bitmap = new BitmapImage();

            if (type == DirectoryItemType.BaseDirectory)
            {
                bitmap.BeginInit();
                bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_basedirectory.png");
                bitmap.EndInit();
            }
            else if (type == DirectoryItemType.Directory)
            {
                bitmap.BeginInit();
                bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_directory.png");
                bitmap.EndInit();
            }
            else
            {
                string extension = Path.GetExtension(filePath).ToLower();

                if (extension == ".ogg" || extension == ".m4a" || extension == ".wav")
                {
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_audiofile.png");
                    bitmap.EndInit();
                }
                else if (extension == ".png")
                {
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_image.png");
                    bitmap.EndInit();
                }
                else if (extension == ".rpgmvo" || extension == ".rpgmvm" || extension == ".rpgmvw" || extension == ".rpgmvp" || extension == ".ogg_" || extension == ".m4a_" || extension == ".wav_" || extension == ".png_")
                {
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_encrypted.png");
                    bitmap.EndInit();
                }
                else if (extension == ".json" || extension == ".script")
                {
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_data.png");
                    bitmap.EndInit();
                }
                else if (extension == ".rpgsave")
                {
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_savedata.png");
                    bitmap.EndInit();
                }
                else
                {
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri("pack://application:,,/Resources/icon_file.png");
                    bitmap.EndInit();
                }
            }

            return(bitmap);
        }
示例#4
0
        /// <summary>
        /// Retrieves contents of directory of specific type
        /// </summary>
        /// <param name="type">DirectoryItemType</param>
        /// <param name="fullPath">Full path of directory</param>
        /// <returns></returns>
        private static IEnumerable <DirectoryItem> GetDirectoryContents(DirectoryItemType type, string fullPath)
        {
            var contents = new List <DirectoryItem>();

            try
            {
                var items = new List <string>();

                if (type == DirectoryItemType.Folder)
                {
                    items = System.IO.Directory.GetDirectories(fullPath).ToList();
                }
                else if (type == DirectoryItemType.File)
                {
                    items = System.IO.Directory.GetFiles(fullPath).ToList();;
                }

                contents.AddRange(items.Select(item => new DirectoryItem {
                    FullPath = item,
                    Type     = type
                }));
            }
            catch { }

            return(contents);
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DirectoryViewModel"/> class.
 /// default Costrutor
 /// </summary>
 public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
 {
     this.FullPath      = fullPath;
     this.Type          = type;
     this.ExpandCommand = new RelayCommand(Expand);
     this.Collapse();
 }
示例#6
0
        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="_path_id"></param>
        /// <param name="_unc_path_name"></param>
        /// <param name="_owner_sid"></param>
        /// <param name="_has_children"></param>
        /// <param name="_size"></param>
        /// <param name="_path_name"></param>
        /// <param name="_hidden"></param>
        public PermissionItem(int _path_id, string _unc_path_name, string _owner_sid, bool _has_children, long _size,
                              bool _hidden, List <ADElement> allGroups, DirectoryItemType itemType)
        {
            PathID      = _path_id;
            UncPath     = _unc_path_name;
            OwnerSid    = _owner_sid;
            HasChildren = _has_children;
            Size        = _size;
            IsHidden    = _hidden;
            AllGroups   = allGroups;
            ItemType    = itemType;

            // Erstelle Commands
            ExpandCommand             = new RelayCommand(Expand);
            ContextShowDetailsCommand = new RelayCommand(ContextShowDetails);
            ShowInExplorerCommand     = new RelayCommand(ShowInExplorer);
            ShowFilePropsCommand      = new RelayCommand(ShowFileProps);


            Children = new ObservableCollection <PermissionItem>();
            if (HasChildren)
            {
                Children.Add(null);
            }

            directoryACEs = new List <DirectoryACE>();
        }
示例#7
0
 public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
 {
     ExpandCommand = new RelayCommand(Expand);
     FullPath      = fullPath;
     Type          = type;
     ClearChildren();
 }
 public DirectoryItemViewModel(string Fullpath, DirectoryItemType Type)
 {
     this.ExpandCommand = new RelayCommand(Expand);
     this.FullPath      = Fullpath;
     this.Type          = Type;
     this.ClearChildren();
 }
 public DirectoryItemVM(string fullPath, DirectoryItemType type)
 {
     expandCommand = new RelayCommand(expand);
     this.FullPath = fullPath;
     this.type     = type;
     this.ClearChild();
 }
示例#10
0
 public DirectoryItemViewModel(string fullpath, DirectoryItemType type)
 {
     ExpandCommand = new RelayCommand(Expand);
     this.FullPath = fullpath;
     this.Type     = type;
     this.ClearChildern();
 }
        public SelectPathViewModel(DirectoryItemType searchToLevel, string startPath = "", string fileExtantion = "")
        {
            this.searchToLevel       = searchToLevel;
            this.selectedPath        = startPath;
            this.newFolderCommand    = new RelayCommand <object>(OnNewFolderClick);
            this.renameFolderCommand = new RelayCommand <object>(OnRenameFolderClick);
            this.deleteFolderCommand = new RelayCommand <object>(OnDeleteFolderClick);
            this.okCommand           = new RelayCommand <object>(OkCommandClick);
            this.closeCommand        = new RelayCommand <object>(OnCloseCliked);
            this.pathChangeCommand   = new RelayCommand <object>(OnPathChange);

            this.SelectionChanged += OnFolderPathChange;
            this.DirectoryItems    = new ObservableCollection <DirectoryItemViewModel>();
            var children = DirectoryStructure.GetLogicalDrives();


            foreach (DirectoryItem drive in children)
            {
                var childViewModel = new DirectoryItemViewModel(drive.FullPath, drive.Type, searchToLevel, fileExtantion);
                childViewModel.SelectDirectoryItem += OnSelectDirectoryItem;
                this.DirectoryItems.Add(childViewModel);
            }

            if (!string.IsNullOrEmpty(startPath) && (System.IO.Directory.Exists(startPath) || File.Exists(startPath)))
            {
                var pathList = startPath.Split(Path.DirectorySeparatorChar).ToList();
                Navigate(this.DirectoryItems, pathList);
            }
            //TODO: navigate to path
        }
示例#12
0
 public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
 {
     this.ExpandCommand = new RelayCommand(Expand);
     this.FullPath = fullPath;
     this.Type = type;
     this.Children = new ObservableCollection<DirectoryItemViewModel>();
     this.ClearChildren();
 }
示例#13
0
        //default constructor
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            //create commands
            this.ExpandCommand = new RelayCommand(Expand);

            this.FullPath = fullPath;
            this.Type     = type;
        }
        public DirectoryItemViewModel(string fullPath, DirectoryItemType directoryItemType)
        {
            ExpandCommand = new RelayCommand(Expand);
            FullPath      = fullPath;
            Type          = directoryItemType;

            Collapse();
        }
 public DirectoryItemViewModel(string fullPath, DirectoryItemType itemType)
 {
     this.FullPath      = fullPath;
     this.Type          = itemType;
     this.ExpandCommand = new RelayCommand(Expand);
     this.SelectCommand = new RelayCommand(ShowDetails);
     this.ClearChildren();
 }
示例#16
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="fullpath">full path of this item</param>
        /// <param name="type">The type of this item</param>
        public DirectoryItemViewModel(string fullpath, DirectoryItemType type, bool isHidden)
        {
            ExpandCommand = new RelayCommand(Expand);
            FullPath      = fullpath;
            Type          = type;
            IsHidden      = isHidden;

            ClearChildren();
        }
示例#17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="fullPath">Full path of this item</param>
 /// <param name="type">Type of item</param>
 public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
 {
     // set Expand method.
     this.ExpandCommand = new RelayCommand(Expand);
     this.FullPath      = fullPath;
     this.type          = type;
     // Setup children as needed.
     this.ClearChildren();
 }
示例#18
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="fullPath">The full path of this item</param>
        /// <param name="type">The type of item</param>
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            // Set path and type
            this.FullPath = fullPath;
            this.Type     = type;

            // Setup the children as needed
            this.ClearChildren();
        }
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="fullPath"> The full path of this item</param>
 /// <param name="type">The type of item</param>
 public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
 {
     this.ExpandCommand = new RelayCommand(Expand);
     // Set the type
     this.FullPath = fullPath;
     this.Type     = type;
     // Setup the children as need
     this.ClearChildren();
 }
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type, DirectoryItemType searchToLevel, string fileExtention = "")
        {
            this.FullPath      = fullPath;
            this.Type          = type;
            this.searchToLevel = searchToLevel;
            this.fileExtention = fileExtention;
            this.ExpandCommand = new RelayCommand(Expand);

            this.ClearChildren();
        }
        public SelectPathViewModel(IDialogFactory dialogFactory, DirectoryItemType searchToLevel, IIOWrapper iOWrapper, string rootPath = "", string startPath = "", string fileExtantion = "")
        {
            if (dialogFactory == null)
            {
                throw new ArgumentNullException(nameof(dialogFactory));
            }
            if (iOWrapper == null)
            {
                throw new ArgumentNullException(nameof(iOWrapper));
            }

            this.dialogFactory       = dialogFactory;
            this.iOWrapper           = iOWrapper;
            this.searchToLevel       = searchToLevel;
            this.selectedPath        = startPath;
            this.newFolderCommand    = new RelayCommand <object>(OnNewFolderClick);
            this.renameFolderCommand = new RelayCommand <object>(OnRenameFolderClick);
            this.deleteFolderCommand = new RelayCommand <object>(OnDeleteFolderClick);
            this.okCommand           = new RelayCommand <object>(OkCommandClick);
            this.closeCommand        = new RelayCommand <object>(OnCloseCliked);
            this.pathChangeCommand   = new RelayCommand <object>(OnPathChange);

            this.SelectionChanged += OnFolderPathChange;
            this.DirectoryItems    = new ObservableCollection <DirectoryItemViewModel>();

            List <DirectoryItem> children;

            if (System.IO.Directory.Exists(rootPath))
            {
                children = new List <DirectoryItem> {
                    new DirectoryItem()
                    {
                        FullPath = rootPath, Type = DirectoryItemType.Folder
                    }
                };
            }
            else
            {
                children = DirectoryStructure.GetLogicalDrives();
            }

            foreach (DirectoryItem drive in children)
            {
                var childViewModel = new DirectoryItemViewModel(drive.FullPath, drive.Type, searchToLevel, fileExtantion);
                childViewModel.SelectDirectoryItem += OnSelectDirectoryItem;
                this.DirectoryItems.Add(childViewModel);
            }

            if (!string.IsNullOrEmpty(startPath) && (System.IO.Directory.Exists(startPath) || File.Exists(startPath)))
            {
                var pathList = startPath.Split(Path.DirectorySeparatorChar).ToList();
                Navigate(this.DirectoryItems, pathList);
            }
            //TODO: navigate to path
        }
示例#22
0
        /// <summary>
        /// </summary>
        /// <param name="fullPath">full path of this item</param>
        /// <param name="type">type of this item</param>
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            //create command
            this.ExpandCommand = new RelayCommand(Expand);
            //set properties
            this.FullPath = fullPath;
            this.Type     = type;

            //setup the children as needed
            this.ClearChildren();
        }
示例#23
0
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            // Create commands
            ExpandCommand = new RelayCommand(Expand);

            // Set path and type
            FullPath = fullPath;
            Type     = type;

            ClearChildren();
        }
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            // Create commands
            ExpandCommand = new RelayCommand(Expand);

            FullPath = fullPath;
            Type     = type;

            // 添加一个 dummy item 可以 让 TreeViewItem 能够展开
            ClearChildren();
        }
示例#25
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="fullPath">The full path of this item</param>
 /// <param name="type">The type of item</param>
 public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
 {
     // Create commands
     this.ExpandCommand = new RelayCommand(Expand);
     this.OpenOnClick   = new RelayCommand(OpenFile);
     // Set path and type
     this.FullPath = fullPath;
     this.Type     = type;
     // Setup the children as needed
     this.ClearChildren();
 }
示例#26
0
        /// <summary>
        /// Default construstor.
        /// </summary>
        /// <param name="fullPath">The full pfth of thid item.</param>
        /// <param name="Type">The type of item.</param>
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            //Create commands.
            ExpandCommand = new RelayCommand(Expand);

            //Set type and path.
            FullPath = fullPath;
            Type     = type;

            //Setup the children as needed
            ClearChildren();
        }
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// This Time we initialise inside the constructor because
        /// we (fear that the Expand is Before the Initialisation of the Type wich We use To NOT add A "dummy Item" to a "File" )
        /// <param name="fulName"> The full path of this Item</param>
        /// <param name="type"> The type of this item</param>
        public DirectoryItemViewModel(string fulName, DirectoryItemType type)
        {
            // Create Command
            this.ExpandCommand = new RelayCommand(Expand); // Bind the Expand Function to the U.I

            // Set Path and Type
            this.FullPath = fulName;
            this.Type     = type;

            // Set Children as Needed
            this.ClearChildrenAndCollapse();
        }
示例#28
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="fullPath">full path of this item</param>
        /// <param name="type">type of this item</param>
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            // create command
            this.ExpandCommand = new RelayCommand(Expand);

            // Set full path and type
            this.FullPath = fullPath;
            this.Type     = type;

            // Set children as needed
            this.ClearChildren();
        }
示例#29
0
        /// <summary>
        /// Constructor por defecto
        /// </summary>
        /// <param name="fullPath">La ruta completa del elemento</param>
        /// <param name="type">El tipo del elemento</param>
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            //Crea el comando
            this.ExpandCommand = new RelayCommand(Expand);

            //Establece la ruta y el tipo
            this.FullPath = fullPath;
            this.Type     = type;

            //Configura los hijos
            this.ClearChildren();
        }
示例#30
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="fullPath">the full path of this item</param>
        /// <param name="type">the type of item</param>
        public DirectoryItemViewModel(string fullPath, DirectoryItemType type)
        {
            // Create Command
            ExpandCommand = new RelayCommand(Expand);

            // set path and type
            FullPath = fullPath;
            Type     = type;

            // setup the children as needed
            ClearChildren();
        }