示例#1
0
        private void UpdateChildrenGetter(string columnName)
        {
            TreeListView.ChildrenGetterDelegate DelegateSort;
            switch (columnName)
            {
            case "Initiating":
                DelegateSort = DelegateSortInitiating;
                break;

            case "Planning":
                DelegateSort = DelegateSortPlanning;
                break;

            case "Executing":
                DelegateSort = DelegateSortExecuting;
                break;

            case "Monitoring":
                DelegateSort = DelegateSortMonitoring;
                break;

            case "Closing":
                DelegateSort = DelegateSortClosing;
                break;

            default:
                DelegateSort = DelegateSortDefault;
                break;
            }
            m_treeListView1.ChildrenGetter = DelegateSort;
            m_treeListView1.RebuildAll(false);
            m_treeListView1.ExpandAll();
        }
示例#2
0
        private void RefreshObject(object o, bool exists)
        {
            //or from known descendancy
            var knownDescendancy = _activator.CoreChildProvider.GetDescendancyListIfAnyFor(o);

            //if it is a root object maintained by this tree and it exists
            if (MaintainRootObjects != null && MaintainRootObjects.Contains(o.GetType()) && exists)
            {
                //if tree doesn't yet contain the object
                if (!Tree.Objects.Cast <object>().Contains(o))
                {
                    Tree.AddObject(o); //add it
                    return;
                }
            }

            if (ShouldClearPinFilterOnRefresh(o, exists))
            {
                _pinFilter.UnApplyToTree();
            }

            if (!exists)
            {
                //clear the current selection (if the object to be deleted is selected)
                if (Tree.IsSelected(o))
                {
                    Tree.SelectedObject  = null;
                    Tree.SelectedObjects = null;
                }

                //remove it from tree
                Tree.RemoveObject(o);
            }


            if (!IsHiddenByFilter(o))
            {
                //By preference refresh the parent that way we deal with hierarchy changes
                if (knownDescendancy != null)
                {
                    var lastParent = knownDescendancy.Parents.LastOrDefault(p => Tree.IndexOf(p) != -1);

                    //does tree have parent?
                    if (lastParent != null)
                    {
                        Tree.RefreshObject(lastParent); //refresh parent
                    }
                    else
                    if (Tree.IndexOf(o) != -1)
                    {
                        //Tree has object but not parent, bad times, maybe BetterRouteExists?
                        Tree.RebuildAll(true);
                    }
                }
                else
                //if we have the object
                if (Tree.IndexOf(o) != -1 && exists)
                {
                    Tree.RefreshObject(o);     //it exists so refresh it!
                }
            }
        }
示例#3
0
        /// <summary>
        /// Sets up common functionality for an RDMPCollectionUI
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="tree">The main tree in the collection UI</param>
        /// <param name="activator">The current activator, used to launch objects, register for refresh events etc </param>
        /// <param name="iconColumn">The column of tree view which should contain the icon for each row object</param>
        /// <param name="renameableColumn">Nullable field for specifying which column supports renaming on F2</param>
        /// <param name="settings">Customise which common behaviorurs are turned on</param>
        public void SetUp(RDMPCollection collection, TreeListView tree, IActivateItems activator, OLVColumn iconColumn, OLVColumn renameableColumn, RDMPCollectionCommonFunctionalitySettings settings)
        {
            Settings    = settings;
            _collection = collection;
            IsSetup     = true;
            _activator  = activator;
            _activator.RefreshBus.Subscribe(this);

            RepositoryLocator = _activator.RepositoryLocator;

            Tree = tree;
            Tree.FullRowSelect = true;
            Tree.HideSelection = false;
            Tree.KeyPress     += Tree_KeyPress;

            Tree.RevealAfterExpand = true;

            if (!Settings.SuppressChildrenAdder)
            {
                Tree.CanExpandGetter += CanExpandGetter;
                Tree.ChildrenGetter  += ChildrenGetter;
            }

            if (!Settings.SuppressActivate)
            {
                Tree.ItemActivate += CommonItemActivation;
            }

            Tree.CellRightClick   += CommonRightClick;
            Tree.SelectionChanged += (s, e) => RefreshContextMenuStrip();

            if (iconColumn != null)
            {
                iconColumn.ImageGetter += ImageGetter;
            }

            if (Tree.RowHeight != 19)
            {
                Tree.RowHeight = 19;
            }

            //add colour indicator bar
            Tree.Location = new Point(Tree.Location.X, tree.Location.Y + 3);
            Tree.Height  -= 3;

            CreateColorIndicator(Tree, collection);

            //what does this do to performance?
            Tree.UseNotifyPropertyChanged = true;

            ParentFinder = new TreeNodeParentFinder(Tree);

            DragDropProvider = new DragDropProvider(
                _activator.CommandFactory,
                _activator.CommandExecutionFactory,
                tree);

            if (renameableColumn != null)
            {
                RenameProvider = new RenameProvider(_activator, tree, renameableColumn);
                RenameProvider.RegisterEvents();
            }

            if (Settings.AddFavouriteColumn)
            {
                FavouriteColumnProvider = new FavouriteColumnProvider(_activator, tree);
                FavouriteColumn         = FavouriteColumnProvider.CreateColumn();
            }

            if (settings.AddIDColumn)
            {
                IDColumnProvider = new IDColumnProvider(tree);
                IDColumn         = IDColumnProvider.CreateColumn();

                Tree.AllColumns.Add(IDColumn);
                Tree.RebuildColumns();
            }

            if (Settings.AddCheckColumn)
            {
                CheckColumnProvider = new CheckColumnProvider(tree, _activator.CoreIconProvider);
                CheckColumn         = CheckColumnProvider.CreateColumn();

                Tree.AllColumns.Add(CheckColumn);
                Tree.RebuildColumns();
            }
            CoreIconProvider = activator.CoreIconProvider;

            CopyPasteProvider = new CopyPasteProvider();
            CopyPasteProvider.RegisterEvents(tree);

            CoreChildProvider = _activator.CoreChildProvider;

            _activator.Emphasise += _activator_Emphasise;

            Tree.TreeFactory = TreeFactoryGetter;
            Tree.RebuildAll(true);

            Tree.FormatRow         += Tree_FormatRow;
            Tree.CellToolTipGetter += Tree_CellToolTipGetter;

            if (Settings.AllowSorting)
            {
                if (Tree.PrimarySortColumn == null)
                {
                    Tree.PrimarySortColumn = Tree.AllColumns.FirstOrDefault(c => c.IsVisible && c.Sortable);
                }

                //persist user sort orders
                if (TreeGuids.ContainsKey(_collection))
                {
                    //if we know the sort order fo this collection last time
                    var lastSort = UserSettings.GetLastColumnSortForCollection(TreeGuids[_collection]);

                    //reestablish that sort order
                    if (lastSort != null && Tree.AllColumns.Any(c => c.Text == lastSort.Item1))
                    {
                        Tree.PrimarySortColumn = Tree.GetColumn(lastSort.Item1);
                        Tree.PrimarySortOrder  = lastSort.Item2 ? SortOrder.Ascending : SortOrder.Descending;
                    }

                    //and track changes to the sort order
                    Tree.AfterSorting += TreeOnAfterSorting;
                }
            }
            else
            {
                foreach (OLVColumn c in Tree.AllColumns)
                {
                    c.Sortable = false;
                }
            }
        }
 public static void InvokeRebuildAll(this TreeListView control, bool preserveState)
 {
     control.Invoke(() => control.RebuildAll(preserveState));
 }
        /// <summary>
        /// Sets up common functionality for an RDMPCollectionUI
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="tree">The main tree in the collection UI</param>
        /// <param name="activator">The current activator, used to launch objects, register for refresh events etc </param>
        /// <param name="iconColumn">The column of tree view which should contain the icon for each row object</param>
        /// <param name="renameableColumn">Nullable field for specifying which column supports renaming on F2</param>
        /// <param name="settings">Customise which common behaviorurs are turned on</param>
        public void SetUp(RDMPCollection collection, TreeListView tree, IActivateItems activator, OLVColumn iconColumn, OLVColumn renameableColumn, RDMPCollectionCommonFunctionalitySettings settings)
        {
            Settings    = settings;
            _collection = collection;
            IsSetup     = true;
            _activator  = activator;
            _activator.RefreshBus.Subscribe(this);

            RepositoryLocator = _activator.RepositoryLocator;

            Tree = tree;
            Tree.FullRowSelect = true;
            Tree.HideSelection = false;
            Tree.KeyPress     += Tree_KeyPress;

            Tree.CellToolTip.InitialDelay = UserSettings.TooltipAppearDelay;
            Tree.CellToolTipShowing      += Tree_CellToolTipShowing;

            Tree.RevealAfterExpand = true;

            if (!Settings.SuppressChildrenAdder)
            {
                Tree.CanExpandGetter += CanExpandGetter;
                Tree.ChildrenGetter  += ChildrenGetter;
            }

            if (!Settings.SuppressActivate)
            {
                Tree.ItemActivate += CommonItemActivation;
            }

            Tree.CellRightClick += CommonRightClick;
            Tree.KeyUp          += CommonKeyPress;

            if (iconColumn != null)
            {
                iconColumn.ImageGetter += ImageGetter;
            }

            if (Tree.RowHeight != 19)
            {
                Tree.RowHeight = 19;
            }

            //add colour indicator bar
            Tree.Location = new Point(Tree.Location.X, tree.Location.Y + 3);
            Tree.Height  -= 3;

            CreateColorIndicator(Tree, collection);

            //what does this do to performance?
            Tree.UseNotifyPropertyChanged = true;

            ParentFinder = new TreeNodeParentFinder(Tree);

            DragDropProvider = new DragDropProvider(
                _activator.CommandFactory,
                _activator.CommandExecutionFactory,
                tree);

            if (renameableColumn != null)
            {
                RenameProvider = new RenameProvider(_activator, tree, renameableColumn);
                RenameProvider.RegisterEvents();
            }

            if (Settings.AddFavouriteColumn)
            {
                FavouriteColumnProvider = new FavouriteColumnProvider(_activator, tree);
                FavouriteColumn         = FavouriteColumnProvider.CreateColumn();

                SetupColumnTracking(FavouriteColumn, new Guid("ab25aa56-957c-4d1b-b395-48299be8e467"));
            }

            if (settings.AddIDColumn)
            {
                IDColumnProvider = new IDColumnProvider(tree);
                IDColumn         = IDColumnProvider.CreateColumn();

                Tree.AllColumns.Add(IDColumn);
                SetupColumnTracking(IDColumn, new Guid("9d567d9c-06f5-41b6-9f0d-e630a0e23f3a"));
                Tree.RebuildColumns();
            }

            if (Settings.AddCheckColumn)
            {
                CheckColumnProvider = new CheckColumnProvider(tree, _activator.CoreIconProvider);
                CheckColumn         = CheckColumnProvider.CreateColumn();

                SetupColumnTracking(CheckColumn, new Guid("8d9c6a0f-82a8-4f4e-b058-e3017d8d60e0"));

                Tree.AllColumns.Add(CheckColumn);
                Tree.RebuildColumns();
            }
            CoreIconProvider = activator.CoreIconProvider;

            CopyPasteProvider = new CopyPasteProvider();
            CopyPasteProvider.RegisterEvents(tree);

            CoreChildProvider = _activator.CoreChildProvider;

            _activator.Emphasise += _activator_Emphasise;

            Tree.TreeFactory = TreeFactoryGetter;
            Tree.RebuildAll(true);

            Tree.FormatRow += Tree_FormatRow;
            Tree.KeyDown   += Tree_KeyDown;

            if (Settings.AllowSorting)
            {
                SetupColumnSortTracking(Tree, TreeGuids.ContainsKey(collection) ? TreeGuids[collection] : Guid.Empty);
            }
            else
            {
                foreach (OLVColumn c in Tree.AllColumns)
                {
                    c.Sortable = false;
                }
            }
        }