示例#1
0
        private void RefreshFileListAction()
        {
            // get the list of FileObjects
            _initialObjectsList = new List <FileListItem>();
            switch (Config.Instance.FileExplorerViewMode)
            {
            case 0:
                _initialObjectsList = FileExplorer.ListFileOjectsInDirectory(ProEnvironment.Current.BaseLocalPath);
                break;

            case 1:
                _initialObjectsList = FileExplorer.ListFileOjectsInDirectory(ProEnvironment.Current.BaseCompilationPath);
                break;

            case 2:
                foreach (var dir in ProEnvironment.Current.GetProPathDirList)
                {
                    _initialObjectsList.AddRange(FileExplorer.ListFileOjectsInDirectory(dir, false, false));
                }
                break;

            default:
                // get the list of FileObjects
                Regex regex    = new Regex(@"\\\.");
                var   fullList = new HashSet <string>(StringComparer.CurrentCultureIgnoreCase);
                fullList.Add(ProEnvironment.Current.BaseLocalPath);
                if (!fullList.Contains(ProEnvironment.Current.BaseCompilationPath))
                {
                    fullList.Add(ProEnvironment.Current.BaseCompilationPath);
                }
                // base local path
                if (Directory.Exists(ProEnvironment.Current.BaseLocalPath))
                {
                    foreach (var directory in Directory.GetDirectories(ProEnvironment.Current.BaseLocalPath, "*", SearchOption.AllDirectories))
                    {
                        if (!fullList.Contains(directory) && (!Config.Instance.FileExplorerIgnoreUnixHiddenFolders || !regex.IsMatch(directory)))
                        {
                            fullList.Add(directory);
                        }
                    }
                }
                // base compilation path
                if (Directory.Exists(ProEnvironment.Current.BaseCompilationPath))
                {
                    foreach (var directory in Directory.GetDirectories(ProEnvironment.Current.BaseCompilationPath, "*", SearchOption.AllDirectories))
                    {
                        if (!fullList.Contains(directory) && (!Config.Instance.FileExplorerIgnoreUnixHiddenFolders || !regex.IsMatch(directory)))
                        {
                            fullList.Add(directory);
                        }
                    }
                }
                // for each dir in propath
                foreach (var directory in ProEnvironment.Current.GetProPathDirList)
                {
                    if (!fullList.Contains(directory) && (!Config.Instance.FileExplorerIgnoreUnixHiddenFolders || !regex.IsMatch(directory)))
                    {
                        fullList.Add(directory);
                    }
                }
                foreach (var path in fullList)
                {
                    _initialObjectsList.AddRange(FileExplorer.ListFileOjectsInDirectory(path, false));
                }
                break;
            }

            // apply custom sorting
            _initialObjectsList.Sort(new FilesSortingClass());

            try {
                // delete any existing buttons
                if (_displayedTypes != null)
                {
                    foreach (var selectorButton in _displayedTypes)
                    {
                        selectorButton.Value.ButtonPressed -= HandleTypeClick;
                        if (Controls.Contains(selectorButton.Value))
                        {
                            Controls.Remove(selectorButton.Value);
                        }
                        selectorButton.Value.Dispose();
                    }
                }

                // get distinct types, create a button for each
                int xPos = 59;
                int yPox = Height - 28;
                _displayedTypes = new Dictionary <FileType, SelectorButton <FileType> >();
                foreach (var type in _initialObjectsList.Select(x => x.Type).Distinct())
                {
                    var but = new SelectorButton <FileType> {
                        BackGrndImage        = Utils.GetImageFromStr(Utils.GetExtensionImage(type.ToString(), true)),
                        Activated            = true,
                        Size                 = new Size(24, 24),
                        TabStop              = false,
                        Location             = new Point(xPos, yPox),
                        Type                 = type,
                        AcceptsRightClick    = true,
                        Anchor               = AnchorStyles.Left | AnchorStyles.Bottom,
                        HideFocusedIndicator = true
                    };
                    but.ButtonPressed += HandleTypeClick;
                    toolTipHtml.SetToolTip(but, "Type of item : <b>" + type + "</b>:<br><br><b>Left click</b> to toggle on/off this filter<br><b>Right click</b> to filter for this type only");
                    _displayedTypes.Add(type, but);
                    Controls.Add(but);
                    xPos += but.Width;
                }

                // label for the number of items
                TotalItems   = _initialObjectsList.Count;
                nbitems.Text = TotalItems + StrItems;
                fastOLV.SetObjects(_initialObjectsList);

                ApplyFilter();
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Error while showing the list of files");
            }
        }
示例#2
0
 /// <summary>
 /// Check/uncheck the menu depending on this form visibility
 /// </summary>
 /// <param name="e"></param>
 protected override void OnVisibleChanged(EventArgs e)
 {
     FileExplorer.UpdateMenuItemChecked();
     base.OnVisibleChanged(e);
 }