Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Processes the row change.
        /// </summary>
        /// <param name="currRow">The curr row.</param>
        /// ------------------------------------------------------------------------------------
        private void ProcessRowChange(int currRow)
        {
            if (!m_list.IsExpanded(currRow))
            {
                int parentRow;
                m_list.GetParent(currRow, out parentRow);
                currRow = parentRow;
            }

            Rectangle rc;

            if (currRow < 0)
            {
                rc = GetBlockRectangle();
                if (rc != Rectangle.Empty)
                {
                    Invalidate(rc);
                }

                m_firstRowInShadind = -1;
                m_lastRowInShading  = -1;
                return;
            }

            int firstRowInBlock, lastRowInBlock;

            GetRowsInBlock(currRow, out firstRowInBlock, out lastRowInBlock);

            if (firstRowInBlock == m_firstRowInShadind && lastRowInBlock == m_lastRowInShading)
            {
                return;
            }

            rc = GetBlockRectangle();
            if (rc != Rectangle.Empty)
            {
                Invalidate(rc);
            }

            m_firstRowInShadind = -1;
            m_lastRowInShading  = -1;

            if (firstRowInBlock >= 0 && lastRowInBlock > firstRowInBlock)
            {
                m_firstRowInShadind = firstRowInBlock;
                m_lastRowInShading  = lastRowInBlock;
                rc = GetBlockRectangle();
                if (rc != Rectangle.Empty)
                {
                    Invalidate(rc);
                }
            }
        }
Ejemplo n.º 2
0
        ///// ------------------------------------------------------------------------------------
        ///// <summary>
        ///// Handles the KeyPress event of the tstxtSearch control.
        ///// </summary>
        ///// <param name="sender">The source of the event.</param>
        ///// <param name="e">The <see cref="System.Windows.Forms.KeyPressEventArgs"/> instance containing the event data.</param>
        ///// ------------------------------------------------------------------------------------
        //private void tstxtSearch_KeyPress(object sender, KeyPressEventArgs e)
        //{
        //    if (e.KeyChar != (char)Keys.Enter)
        //        return;

        //    Guid guid = new Guid(tstxtSearch.Text.Trim());
        //    int i = m_list.GotoGuid(guid);
        //    if (i >= 0)
        //    {
        //        gridInspector.RowCount = m_list.Count;
        //        gridInspector.Invalidate();
        //        gridInspector.CurrentCell = gridInspector[0, i];
        //    }
        //}

        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Refreshes the view.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void RefreshView()
        {
            // Get the object that's displayed in the first visible row of the grid.
            IInspectorObject firstDisplayedObj =
                m_list[gridInspector.FirstDisplayedScrollingRowIndex];

            // Get the current, selected row in the grid.
            IInspectorObject currSelectedObj = gridInspector.CurrentObject;

            if (currSelectedObj != null && WillObjDisappearOnRefresh != null)
            {
                // Check if the selected object will disappear after refreshing the grid.
                // If so, then save a reference to the selected object's parent object.
                if (WillObjDisappearOnRefresh(this, currSelectedObj))
                {
                    currSelectedObj = m_list.GetParent(gridInspector.CurrentCellAddress.Y);
                }
            }

            int keyFirstDisplayedObj = (firstDisplayedObj != null ? firstDisplayedObj.Key : -1);
            int keyCurrSelectedObj   = (currSelectedObj != null ? currSelectedObj.Key : -1);

            // Save all the expanded objects.
            List <int> expandedObjects = new List <int>();

            for (int i = 0; i < m_list.Count; i++)
            {
                if (m_list.IsExpanded(i))
                {
                    expandedObjects.Add(m_list[i].Key);
                }
            }

            m_list.Initialize(m_list.TopLevelObject);

            // Now that the list is rebuilt, go through the list of objects that
            // were previously expanded and expand them again.
            int firstRow = 0;
            int currRow  = 0;
            int irow     = 0;

            while (++irow < m_list.Count)
            {
                IInspectorObject io = m_list[irow];
                int key             = io.Key;
                int index           = expandedObjects.IndexOf(key);
                if (index >= 0)
                {
                    m_list.ExpandObject(irow);
                    expandedObjects.RemoveAt(index);
                }

                if (key == keyFirstDisplayedObj)
                {
                    firstRow = irow;
                }

                if (key == keyCurrSelectedObj)
                {
                    currRow = irow;
                }
            }

            gridInspector.SuspendLayout();
            gridInspector.List = m_list;
            gridInspector.FirstDisplayedScrollingRowIndex = firstRow;
            gridInspector.CurrentCell = gridInspector[0, currRow];
            gridInspector.ResumeLayout();
        }