Ejemplo n.º 1
0
        private void treeListViewRootPath_SelectedIndexChanged(object sender, EventArgs e)
        {
            ArrayList roots = new ArrayList();

            OLVListItem selectedItem = ((TreeListView)sender).SelectedItem;

            if (selectedItem != null && selectedItem.RowObject != null)
            {
                MyFileSystemInfo dir = ((MyFileSystemInfo)((TreeListView)sender).SelectedItem.RowObject);
                Configuration.LastRootPath = dir.FullName;
                foreach (MyFileSystemInfo subdir in dir.GetFileSystemInfos())
                {
                    if (subdir.IsDirectory || Configuration.IsValidVideo(subdir.Name))
                    {
                        roots.Add(subdir);
                    }
                }
            }
            this.treeListViewFilesAndTags.Roots = roots;
        }
Ejemplo n.º 2
0
        private void SetupColumns()
        {
            // The column setup here is identical to the File Explorer example tab --
            // nothing specific to the TreeListView.

            // The only difference is that we don't setup anything to do with grouping,
            // since TreeListViews can't show groups.

            SysImageListHelper helper = new SysImageListHelper(this.treeListViewFilesAndTags);

            this.colFilename.ImageGetter = delegate(object x) {
                if (x == null)
                {
                    return(null);
                }
                return(helper.GetImageIndex(((MyFileSystemInfo)x).FullName));
            };
            this.colFilename.AspectGetter = delegate(object x) {
                if (((MyFileSystemInfo)x) != null)
                {
                    return(((MyFileSystemInfo)x).Name);
                }
                return("");
            };

            // Get the size of the file system entity.
            // Folders and errors are represented as negative numbers
            this.colSize.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }

                MyFileSystemInfo myFileSystemInfo = (MyFileSystemInfo)x;

                if (myFileSystemInfo.IsDirectory)
                {
                    return((long)-1);
                }

                try
                {
                    return(myFileSystemInfo.Length);
                }
                catch (System.IO.FileNotFoundException)
                {
                    // Mono 1.2.6 throws this for hidden files
                    return((long)-2);
                }
            };

            // Show the size of files as GB, MB and KBs. By returning the actual
            // size in the AspectGetter, and doing the conversion in the
            // AspectToStringConverter, sorting on this column will work off the
            // actual sizes, rather than the formatted string.
            this.colSize.AspectToStringConverter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }

                long sizeInBytes = (long)x;
                if (sizeInBytes < 0) // folder or error
                {
                    return("");
                }
                return(HelperFunctions.FormatFileSize(sizeInBytes));
            };

            // Show the system description for this object
            this.colFormat.AspectGetter = delegate(object x) {
                if (x == null)
                {
                    return("");
                }

                return(ShellUtilities.GetFileType(((MyFileSystemInfo)x).FullName));
            };

            //this.colSeries.AspectGetter = delegate (object x) {
            //    return VideoInformation.Series((MyFileSystemInfo)x);
            //};
            //this.colSeason.AspectGetter = delegate (object x) {
            //    return VideoInformation.Season((MyFileSystemInfo)x);
            //};
            //this.colEpisodeNumber.AspectGetter = delegate (object x) {
            //    return VideoInformation.EpisodeNumber((MyFileSystemInfo)x);
            //};
            //this.colEpisodeTitle.AspectGetter = delegate (object x) {
            //    return VideoInformation.EpisodeTitle((MyFileSystemInfo)x);
            //};
            //this.colResolution.AspectGetter = delegate (object x) {
            //    return VideoInformation.Resolution((MyFileSystemInfo)x);
            //};
            //this.colYear.AspectGetter = delegate (object x) {
            //    return VideoInformation.Year((MyFileSystemInfo)x);
            //};
            //this.colThumb.AspectGetter = delegate (object x) {
            //    return VideoInformation.Thumb((MyFileSystemInfo)x);
            //};


            //// Show the file attributes for this object
            //// A FlagRenderer masks off various values and draws zero or images based
            //// on the presence of individual bits.
            //this.olvColumnAttributes.AspectGetter = delegate (object x) {
            //    return ((MyFileSystemInfo)x).Attributes;
            //};
            //FlagRenderer attributesRenderer = new FlagRenderer();
            //attributesRenderer.ImageList = imageListSmall;
            //attributesRenderer.Add(FileAttributes.Archive, "archive");
            //attributesRenderer.Add(FileAttributes.ReadOnly, "readonly");
            //attributesRenderer.Add(FileAttributes.System, "system");
            //attributesRenderer.Add(FileAttributes.Hidden, "hidden");
            //attributesRenderer.Add(FileAttributes.Temporary, "temporary");
            //this.olvColumnAttributes.Renderer = attributesRenderer;

            //// Tell the filtering subsystem that the attributes column is a collection of flags
            //this.olvColumnAttributes.ClusteringStrategy = new FlagClusteringStrategy(typeof(FileAttributes));

            this.colPath.AspectGetter = delegate(object x) {
                if (x != null)
                {
                    return(((MyFileSystemInfo)x).FullName);
                }
                else
                {
                    return("");
                }
            };
        }