コード例 #1
0
        public override void PopulateRecordBar(RecordList recList)
        {
            CheckDisposed();

            // The ListBar has a problem in that when it is populated for the first time the horizonal
            // scroll scrolls over a little ways over hiding the left most + or -. I (Rand) sent some
            // time searching this out and found that it is a bug in the ListView control.  It is not
            // our bug.  The scrolling happens when EnsureVisible() is called on the listview.  I found
            // a way around it. By calling this method twice the bug goes away, it looks like the list
            // must be populated, cleared, then repopulated before the bug is bypassed. There are also
            // other things that have an effect on it, such as ClearListBar() must be before
            // BeginUpdate().  Also selection must be made before ExpandAll() or CollapseAll() is called.

            // JohnT: no, the problem is when we EnsureVisible of a node that is wider than the window.
            // EnsureVisble tries to show as much as possible of the label; since it won't fit, it scrolls
            // horizontally and hides the plus/minus.
            // To avoid this if it is desired to EnsureVisible, use the EnsureSelectedNodeVisible routine
            // (which temporarily makes the label short while calling EnsureVisible).
            // (I'm not sure why Rand's comment is in this exact location, so I'm not deleting it.)

            if (this.IsShowing)
            {
                m_fOutOfDate = false;
            }
            else
            {
                m_fOutOfDate = true;
                return;
            }

            XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window");

            window.TreeBarControl.IsFlatList = true;
            window.Cursor = Cursors.WaitCursor;
            ListView list = (ListView)window.ListStyleRecordList;

            list.BeginUpdate();
            window.ClearRecordBarList();                //don't want to directly clear the nodes, because that causes an event to be fired as every single note is removed!
            m_hvoToListViewItemTable.Clear();

            AddListViewItems(recList.SortedObjects, list);
            try
            {
                list.Font = new System.Drawing.Font(recList.FontName, recList.TypeSize);
            }
            catch (Exception error)
            {
                ErrorReporter.ReportException(error, null, false);
            }


            UpdateSelection(recList.CurrentObject);
            list.EndUpdate();

            if (list.SelectedItems.Count > 0)
            {
            }             //list.s .EnsureVisible();

            window.Cursor = Cursors.Default;
        }
コード例 #2
0
        public override void PopulateRecordBar(RecordList list)
        {
            CheckDisposed();

            if (this.IsShowing)
            {
                m_fOutOfDate = false;
            }
            else
            {
                m_fOutOfDate = true;
                return;
            }

            m_list = list;

            XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window");

            using (new WaitCursor(window))
            {
                window.TreeBarControl.IsFlatList = false;
                TreeView  tree          = (TreeView)window.TreeStyleRecordList;
                Set <int> expandedItems = new Set <int>();
                if (m_tree != null && !m_expand)
                {
                    GetExpandedItems(m_tree.Nodes, expandedItems);
                }
                m_tree = tree;

                // Removing the handlers first seems to be necessary because multiple tree handlers are
                // working with one treeview. Only this active one should have handlers connected.
                // If we fail to do this, switching to a different list causes drag and drop to stop working.
                ReleaseRecordBar();

                tree.NodeMouseClick              += new TreeNodeMouseClickEventHandler(tree_NodeMouseClick);
                tree.MouseDown                   += new MouseEventHandler(tree_MouseDown);
                tree.MouseMove                   += new MouseEventHandler(tree_MouseMove);
                tree.DragDrop                    += new DragEventHandler(tree_DragDrop);
                tree.DragOver                    += new DragEventHandler(tree_DragOver);
                tree.GiveFeedback                += new GiveFeedbackEventHandler(tree_GiveFeedback);
                tree.ContextMenuStrip             = CreateTreebarContextMenuStrip();
                tree.ContextMenuStrip.MouseClick += new MouseEventHandler(tree_MouseClicked);
                tree.AllowDrop                    = true;
                tree.BeginUpdate();
                window.ClearRecordBarList();                    //don't want to directly clear the nodes, because that causes an event to be fired as every single note is removed!
                m_hvoToTreeNodeTable.Clear();

                // type size must be set before AddTreeNodes is called
                m_typeSize = list.TypeSize;
                AddTreeNodes(list.SortedObjects, tree);

                tree.Font          = new System.Drawing.Font(list.FontName, m_typeSize);
                tree.ShowRootLines = m_hierarchical;

                if (m_expand)
                {
                    tree.ExpandAll();
                }
                else
                {
                    tree.CollapseAll();
                    ExpandItems(tree.Nodes, expandedItems);
                }
                // Set the selection after expanding/collapsing the tree.  This allows the true
                // selection to be visible even when the tree is collapsed but the selection is
                // an internal node.  (See LT-4508.)
                UpdateSelection(list.CurrentObject);
                tree.EndUpdate();

                EnsureSelectedNodeVisible(tree);
            }
        }