示例#1
0
 protected override void SelectFileSystemEntry(FileSystemInfo fileSystemInfo)
 {
     if (fileSystemInfo != null)
     {
         if (fileSystemInfo is DirectoryInfo directoryInfo)
         {
             CurrentDirectory = directoryInfo.FullName;
             CurrentFile      = null;
         }
         else if (fileSystemInfo is FileInfo fileInfo)
         {
             CurrentFile = fileInfo.FullName;
         }
     }
 }
        protected override void SelectFileSystemEntry(FileSystemInfo fileSystemInfo)
        {
            if (fileSystemInfo != null)
            {
                if (fileSystemInfo is DirectoryInfo directoryInfo)
                {
                    CurrentDirectory = directoryInfo.FullName;

                    if (Filename != null && CurrentDirectory != null)
                    {
                        CurrentFile = m_controller.BuildFullFileNameForInCurrentDirectory(Filename);
                    }
                    else
                    {
                        CurrentFile = null;
                    }
                }
                else if (fileSystemInfo is FileInfo fileInfo)
                {
                    CurrentFile = fileInfo.FullName;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Builds a list with the items of a directory.
        /// </summary>
        /// <param name="directoriesAndFiles"></param>
        /// <param name="controller"></param>
        /// <param name="groupFoldersAndFiles"></param>
        /// <param name="isSelectedFunc"></param>
        /// <returns></returns>
        public static IEnumerable GetFileSystemEntryItems(List <FileSystemInfo> directoriesAndFiles, FileSystemController controller, bool groupFoldersAndFiles, Func <FileInfo, bool> isSelectedFunc)
        {
            if (directoriesAndFiles == null || !directoriesAndFiles.Any())
            {
                return(new ArrayList(0));
            }

            int numberOfItems = directoriesAndFiles.Count;

            if (groupFoldersAndFiles)
            {
                numberOfItems = numberOfItems + 2;
            }

            ArrayList items = new ArrayList(numberOfItems);

            for (int i = 0; i < directoriesAndFiles.Count; i++)
            {
                FileSystemInfo item = directoriesAndFiles[i];

                if (item is DirectoryInfo directoryInfo)
                {
                    if (groupFoldersAndFiles && i == 0)
                    {
                        items.Add(new FileSystemEntriesGroupHeader()
                        {
                            Header = Localization.Strings.Folders, ShowSeparator = false
                        });
                    }

                    bool isSelected = directoryInfo.FullName == controller.CurrentDirectory?.FullName;

                    items.Add(new DirectoryInfoItem()
                    {
                        IsSelected = isSelected, Value = directoryInfo
                    });
                }
                else if (item is FileInfo fileInfo)
                {
                    if (groupFoldersAndFiles)
                    {
                        if (i == 0)
                        {
                            items.Add(new FileSystemEntriesGroupHeader()
                            {
                                Header = Localization.Strings.Files, ShowSeparator = false
                            });
                        }
                        else if (directoriesAndFiles[i - 1] is DirectoryInfo)
                        {
                            items.Add(new FileSystemEntriesGroupHeader()
                            {
                                Header = Localization.Strings.Files, ShowSeparator = true
                            });
                        }
                    }

                    items.Add(new FileInfoItem()
                    {
                        IsSelected = isSelectedFunc(fileInfo), Value = fileInfo
                    });
                }
            }

            return(items);
        }
 protected abstract void SelectFileSystemEntry(FileSystemInfo fileSystemInfo);