Beispiel #1
0
        void PopulateView()
        {
            CurrentItems.Clear();
            System.Drawing.Icon icon;
            icon = Etier.IconHelper.IconReader.GetFolderIcon(Etier.IconHelper.IconReader.IconSize.Small, Etier.IconHelper.IconReader.FolderType.Closed);

            try
            {
                foreach (string s in Directory.EnumerateDirectories(CurrentFolder))
                {
                    FSItemVM info = new FSItemVM()
                    {
                        FullPath    = s,
                        DisplayName = System.IO.Path.GetFileName(s),
                        type        = FSItemType.Folder,
                        DisplayIcon = Etier.IconHelper.IconReader.GetFolderIcon(s, Etier.IconHelper.IconReader.IconSize.Small, Etier.IconHelper.IconReader.FolderType.Closed).ToImageSource()
                    };
                    CurrentItems.Add(info);
                }
            } catch (Exception) {}

            try
            {
                foreach (string s in Directory.EnumerateFiles(CurrentFolder))
                {
                    FSItemVM info = new FSItemVM()
                    {
                        FullPath = s, DisplayName = System.IO.Path.GetFileName(s), type = FSItemType.File
                    };
                    try
                    {
                        icon             = Etier.IconHelper.IconReader.GetFileIcon(info.FullPath, Etier.IconHelper.IconReader.IconSize.Small, false);
                        info.DisplayIcon = icon.ToImageSource();
                    }
                    catch (Exception)
                    {
                        info.DisplayIcon = null;
                    }
                    CurrentItems.Add(info);
                }
            }
            catch (Exception) { }

            if (RecentFolders.Count == 0 || String.Compare(CurrentFolder, RecentFolders.Last()) != 0)
            {
                RecentFolders.Push(CurrentFolder);
            }
            if (ClearFuture)
            {
                FutureFolders.Clear();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Fills the ListView, or rather CurrentItems
        /// </summary>
        public void PopulateView()
        {
            CurrentItems.Clear();
            if (!Directory.Exists(FV.CurrentFolder))
            {
                return;
            }

            try
            {
                DirectoryInfo cur   = new DirectoryInfo(FV.CurrentFolder);
                ImageSource   dummy = new BitmapImage();
                if (FV.ShowFolders)
                {
                    foreach (DirectoryInfo dir in cur.GetDirectories())
                    {
                        if (!FV.ShowHidden && dir.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }
                        FSItemVM info = new FSItemVM()
                        {
                            FullPath    = dir.FullName,
                            DisplayName = dir.Name,
                            type        = FSItemType.Folder
                        };
                        if (!FV.ShowIcons)
                        {
                            info.DisplayIcon = dummy;  // to prevent the icon from being loaded from file later
                        }
                        CurrentItems.Add(info);
                    }
                }

                string FilterString = "*";
                if (FV.FilterIndex >= 0 && FV.FilterIndex < FilterCount)
                {
                    FilterString = FilterList[FV.FilterIndex].ToString();
                }
                foreach (var CurFilterString in FilterString.Split(';'))
                {
                    foreach (FileInfo f in cur.EnumerateFiles(CurFilterString))
                    {
                        if (!FV.ShowHidden && f.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }

                        FSItemVM info = new FSItemVM()
                        {
                            FullPath    = f.FullName,
                            DisplayName = f.Name, //System.IO.Path.GetFileName(s),
                            type        = FSItemType.File
                        };
                        if (!FV.ShowIcons)
                        {
                            info.DisplayIcon = dummy; // to prevent the icon from being loaded from file later
                        }
                        CurrentItems.Add(info);
                    }
                }
            }
            catch (Exception) { }

            // reset column width manually (otherwise it is not updated)
            FV.TheGVColumn.Width = FV.TheGVColumn.ActualWidth;
            FV.TheGVColumn.Width = Double.NaN;

            if (RecentFolders.Count == 0 || String.Compare(FV.CurrentFolder, RecentFolders.Last()) != 0)
            {
                if (Directory.Exists(FV.CurrentFolder))
                {
                    RecentFolders.Push(FV.CurrentFolder);
                    if (ClearFuture)
                    {
                        FutureFolders.Clear();
                    }
                }
            }
        }