Exemplo n.º 1
0
        private void m_treeListView_SelectionChanged(object sender, EventArgs e)
        {
            m_frmMain.myDocViewer1.UnloadMyDoc();
            m_treeListView2.GetColumn(0).Text = "Process Entities";
            Object selObj = m_treeListView1.SelectedObject;

            if (selObj is Process)
            {
                Process process = (Process)selObj;
                m_treeListView2.RemoveObjects((ICollection)m_treeListView2.Objects);
                m_treeListView2.ClearObjects();
                m_treeListView2.AddObject(process.Inputs);
                m_treeListView2.AddObject(process.OutputsCreated);
                //m_treeListView2.AddObject(process.OutputsUpdated);
                if (process.OutputsUpdated.Items.Count > 0)
                {
                    process.OutputsCreated.Name = "Outputs Created";
                    process.OutputsUpdated.Name = "Outputs Updated";
                    m_treeListView2.AddObject(process.OutputsUpdated);
                }
                m_treeListView2.AddObject(process.Tools);
                m_treeListView2.ExpandAll();
                m_frmMain.ClearStatusStrip2();
            }
            else
            {
                m_treeListView2.RemoveObjects((ICollection)m_treeListView2.Objects);
                m_frmMain.ClearStatusStrip2();
            }
        }
Exemplo n.º 2
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>
        /// Configures the tree with appropriate settings to handle plugins, groups, and recordviews.
        /// </summary>
        public void SetupTree()
        {
            // Todo: This whole method is really nasty and pretty hard to even look at. Should really come up with a better way to do this if possible.

            // Which groups can have children
            TlvControl.CanExpandGetter = x => (x is ElderScrollsPlugin || x is Group);

            // What to look at to get the children of an object
            TlvControl.ChildrenGetter = delegate(object x)
            {
                var plugin = x as ElderScrollsPlugin;
                if (plugin != null)
                {
                    return(plugin.TopGroups);
                }

                var group = x as Group;
                if (group != null)
                {
                    if (group.Children.Count == 0)
                    {
                        return(group.ChildRecordViews);
                    }
                    return(group.Children);
                }

                return(new ArrayList());
            };

            // How to fill in column 0 - FormID
            TlvControl.GetColumn(0).AspectGetter = delegate(object x)
            {
                var plugin = x as ElderScrollsPlugin;
                if (plugin != null)
                {
                    return(plugin.FileName);
                }

                var group = x as Group;
                if (group != null)
                {
                    return(group.ToString());
                }

                var recordView = x as RecordView;
                if (recordView != null)
                {
                    return(recordView.FormID);
                }

                return(new ArrayList());
            };

            // How to fill in column 1 - EditorID
            TlvControl.GetColumn(1).AspectGetter = delegate(object x)
            {
                var plugin = x as ElderScrollsPlugin;
                if (plugin != null)
                {
                    return("");
                }

                var group = x as Group;
                if (group != null)
                {
                    if (group is CellGroup)
                    {
                        var r = ElderScrollsPlugin.LoadedRecordViews[((CellGroup)x).Cell.RawValue];
                        return(r?[0].Record.ToString());
                    }
                    if (group is WorldGroup)
                    {
                        var r = ElderScrollsPlugin.LoadedRecordViews[((WorldGroup)group).Worldspace.RawValue];
                        return(r?[0].Record.ToString());
                    }
                    if (group is TopicGroup)
                    {
                        var r = ElderScrollsPlugin.LoadedRecordViews[((TopicGroup)group).Topic.RawValue];
                        return(r?[0].Record.ToString());
                    }
                    return("");
                }

                var recordView = x as RecordView;
                if (recordView != null)
                {
                    return(recordView.Record.ToString());
                }

                return(new ArrayList());
            };

            // How to fill in column 2 - Name
            TlvControl.GetColumn(2).AspectGetter = delegate(object x)
            {
                if (x is ElderScrollsPlugin || x is Group)
                {
                    return("");
                }

                // Todo: Maybe find a better way than reflection to do this
                if (x is RecordView)
                {
                    return(((RecordView)x).Record.TryGetPropertyValue("Name"));
                }

                return(new ArrayList());
            };

            // TODO: implement parent getter once records can see who their parents are
            //TlvControl.ParentGetter = delegate(object x)
            //{


            //};
        }