Esempio n. 1
0
        public void CheckCheckables()
        {
            if (checkingTask != null && !checkingTask.IsCompleted)
            {
                MessageBox.Show("Checking is already happening");
                return;
            }

            //reset the dictionary
            lock (ocheckResultsDictionaryLock)
            {
                checkResultsDictionary = new Dictionary <ICheckable, CheckResult>();
            }

            checkingTask = new Task(() =>
            {
                //only check the items that are visible int he listview
                foreach (var checkable in GetCheckables())//make copy to prevent synchronization issues
                {
                    var notifier = new ToMemoryCheckNotifier();
                    checkable.Check(notifier);

                    lock (ocheckResultsDictionaryLock)
                        checkResultsDictionary.Add(checkable, notifier.GetWorst());
                }
            });

            EnsureChecksColumnVisible();
            checkingTask.ContinueWith(
                //now load images to UI
                (t) => _tree.RebuildColumns(), TaskScheduler.FromCurrentSynchronizationContext());

            checkingTask.Start();
        }
Esempio n. 2
0
        public OLVColumn CreateColumn()
        {
            _olvFavourite              = new OLVColumn("Favourite", null);
            _olvFavourite.Text         = "Favourite";
            _olvFavourite.ImageGetter += FavouriteImageGetter;
            _olvFavourite.IsEditable   = false;
            _olvFavourite.Sortable     = false;
            _tlv.CellClick            += OnCellClick;

            _tlv.AllColumns.Add(_olvFavourite);
            _tlv.RebuildColumns();

            _olvFavourite.IsVisible          = UserSettings.ShowColumnFavourite;
            _olvFavourite.VisibilityChanged += (s, e) => UserSettings.ShowColumnFavourite = ((OLVColumn)s).IsVisible;

            return(_olvFavourite);
        }
        public OLVColumn CreateColumn()
        {
            _olvFavourite              = new OLVColumn("Favourite", null);
            _olvFavourite.Text         = "Favourite";
            _olvFavourite.ImageGetter += FavouriteImageGetter;
            _olvFavourite.IsEditable   = false;
            _olvFavourite.Sortable     = true;

            // setup value of column as 1 (favourite) or 0 (not favourite)
            _olvFavourite.AspectGetter = FavouriteAspectGetter;
            // but don't actually write that value when rendering (just use for sort etc)
            _olvFavourite.AspectToStringConverter = (st) => "";

            _tlv.CellClick += OnCellClick;

            _tlv.AllColumns.Add(_olvFavourite);
            _tlv.RebuildColumns();

            return(_olvFavourite);
        }
Esempio n. 4
0
 private void GenerateColumns(TreeListView olv, List <OLVColumn> Cols)
 {
     olv.AllColumns.Clear();
     olv.AllColumns.AddRange(Cols);
     olv.RebuildColumns();
 }
Esempio n. 5
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;
                }
            }
        }
        /// <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;
                }
            }
        }