src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/VirtualTreeControl.cs
/// <summary>
///     Return either a Cell or Column object, depending on the branch settings
/// </summary>
/// <param name="ctl">The parent control</param>
/// <param name="baseRow">The row coordinate</param>
/// <param name="nativeBaseColumn">The column coordinate for the owning branch</param>
/// <param name="localColumn">The native column offset</param>
/// <param name="returnColumn">Return an AccColumn object if this is true, otherwise return the AccPrimaryItem directly</param>
/// <returns>An AccSimpleCell or AccColumn</returns>
Return either a Cell or Column object, depending on the branch settings
Return either a Cell or Column object depending on the branch settings
public static AccessibleObject GetColumnObject(
                VirtualTreeControl ctl, int baseRow, int nativeBaseColumn, int localColumn, bool returnColumn)
            {
                Debug.Assert(localColumn > 0);
                AccessibleObject retVal = null;
                var tree = ctl.Tree;
                var info = tree.GetItemInfo(baseRow, nativeBaseColumn, false);
                var mcBranch = info.Branch as IMultiColumnBranch;
                if (mcBranch != null)
                {
                    var simpleCell = true;
                    var useColInfo = false;
                    var nativeColumn = nativeBaseColumn + localColumn;
                    var displayColumn = nativeColumn;
                    var colPerm = ctl.myColumnPermutation;
                    var settings = AccItemSettings.None;
                    if (colPerm != null)
                    {
                        displayColumn = colPerm.GetPermutedColumn(nativeColumn);
                        if (displayColumn == -1)
                        {
                            displayColumn = 0;
                            settings |= AccItemSettings.HiddenItem;
                        }
                    }
                    var style = mcBranch.ColumnStyles(localColumn);
                    var colInfo = new VirtualTreeItemInfo();
                    style = mcBranch.ColumnStyles(localColumn);
                    switch (style)
                    {
                        case SubItemCellStyles.Expandable:
                            simpleCell = !info.Branch.IsExpandable(info.Row, localColumn);
                            break;
                        case SubItemCellStyles.Mixed:
                        case SubItemCellStyles.Complex:
                            colInfo = tree.GetItemInfo(baseRow, nativeColumn, true);
                            if (colInfo.Column == 0)
                            {
                                var columns = (0 == (info.Branch.Features & BranchFeatures.JaggedColumns))
                                                  ? mcBranch.ColumnCount
                                                  : mcBranch.GetJaggedColumnCount(info.Row);
                                if (!(colInfo.Branch.VisibleItemCount == 1 &&
                                      !colInfo.Branch.IsExpandable(0, 0) &&
                                      (localColumn < columns ||
                                       (null != (colInfo.Branch as IMultiColumnBranch) &&
                                        0 == tree.GetSubItemCount(baseRow, nativeColumn)))))
                                {
                                    simpleCell = false;
                                }
                                useColInfo = true;
                            }
                            else if (style == SubItemCellStyles.Mixed)
                            {
                                goto case SubItemCellStyles.Expandable;
                            }
                            break;
                    }
                    if (simpleCell)
                    {
                        if (useColInfo)
                        {
                            retVal = new AccSimpleCell(ctl, baseRow, displayColumn, nativeColumn, settings, ref colInfo);
                        }
                        else
                        {
                            var cellInfo = tree.GetItemInfo(baseRow, nativeColumn, true);
                            if (!cellInfo.Blank)
                            {
                                retVal = new AccSimpleCell(ctl, baseRow, displayColumn, nativeColumn, settings, ref cellInfo);
                            }
                        }
                    }
                    else if (returnColumn)
                    {
                        if (useColInfo)
                        {
                            retVal = new AccColumn(ctl, baseRow, displayColumn, nativeColumn, settings, ref colInfo);
                        }
                        else
                        {
                            var cellInfo = tree.GetItemInfo(baseRow, nativeBaseColumn + localColumn, true);
                            retVal = new AccColumn(ctl, baseRow, displayColumn, nativeColumn, settings, ref cellInfo);
                        }
                    }
                    else
                    {
                        if (useColInfo)
                        {
                            retVal = new AccPrimaryItem(ctl, baseRow, displayColumn, nativeColumn, settings, ref colInfo);
                        }
                        else
                        {
                            var cellInfo = tree.GetItemInfo(baseRow, nativeBaseColumn + localColumn, true);
                            retVal = new AccPrimaryItem(ctl, baseRow, displayColumn, nativeColumn, settings, ref cellInfo);
                        }
                    }
                }
                return retVal;
            }
public static AccessibleObject GetColumnObject ( VirtualTreeControl ctl , int baseRow , int nativeBaseColumn , int localColumn , bool returnColumn ) { Debug . Assert ( localColumn > 0 ) ; AccessibleObject retVal = null ; var tree = ctl . Tree ; var info = tree . GetItemInfo ( baseRow , nativeBaseColumn , false ) ; var mcBranch = info . Branch as IMultiColumnBranch ; if ( mcBranch != null ) { var simpleCell = true ; var useColInfo = false ; var nativeColumn = nativeBaseColumn + localColumn ; var displayColumn = nativeColumn ; var colPerm = ctl . myColumnPermutation ; var settings = AccItemSettings . None ; if ( colPerm != null ) { displayColumn = colPerm . GetPermutedColumn ( nativeColumn ) ; if ( displayColumn == - 1 ) { displayColumn = 0 ; settings |= AccItemSettings . HiddenItem ; } } var style = mcBranch . ColumnStyles ( localColumn ) ; var colInfo = new VirtualTreeItemInfo ( ) ; style = mcBranch . ColumnStyles ( localColumn ) ; switch ( style ) { case SubItemCellStyles . Expandable : simpleCell = ! info . Branch . IsExpandable ( info . Row , localColumn ) ; break ; case SubItemCellStyles . Mixed : case SubItemCellStyles . Complex : colInfo = tree . GetItemInfo ( baseRow , nativeColumn , true ) ; if ( colInfo . Column == 0 ) { var columns = ( 0 == ( info . Branch . Features & BranchFeatures . JaggedColumns ) ) ? mcBranch . ColumnCount : mcBranch . GetJaggedColumnCount ( info . Row ) ; if ( ! ( colInfo . Branch . VisibleItemCount == 1 && ! colInfo . Branch . IsExpandable ( 0 , 0 ) && ( localColumn < columns || ( null != ( colInfo . Branch as IMultiColumnBranch ) && 0 == tree . GetSubItemCount ( baseRow , nativeColumn ) ) ) ) ) { simpleCell = false ; } useColInfo = true ; } else if ( style == SubItemCellStyles . Mixed ) { goto case SubItemCellStyles . Expandable ; } break ; } if ( simpleCell ) { if ( useColInfo ) { retVal = new AccSimpleCell ( ctl , baseRow , displayColumn , nativeColumn , settings , ref colInfo ) ; } else { var cellInfo = tree . GetItemInfo ( baseRow , nativeColumn , true ) ; if ( ! cellInfo . Blank ) { retVal = new AccSimpleCell ( ctl , baseRow , displayColumn , nativeColumn , settings , ref cellInfo ) ; } } } else if ( returnColumn ) { if ( useColInfo ) { retVal = new AccColumn ( ctl , baseRow , displayColumn , nativeColumn , settings , ref colInfo ) ; } else { var cellInfo = tree . GetItemInfo ( baseRow , nativeBaseColumn + localColumn , true ) ; retVal = new AccColumn ( ctl , baseRow , displayColumn , nativeColumn , settings , ref cellInfo ) ; } } else { if ( useColInfo ) { retVal = new AccPrimaryItem ( ctl , baseRow , displayColumn , nativeColumn , settings , ref colInfo ) ; } else { var cellInfo = tree . GetItemInfo ( baseRow , nativeBaseColumn + localColumn , true ) ; retVal = new AccPrimaryItem ( ctl , baseRow , displayColumn , nativeColumn , settings , ref cellInfo ) ; } } } return retVal ; }
Return either a Cell or Column object, depending on the branch settings
Return either a Cell or Column object depending on the branch settings
// Note:  if this logic changes, corresponding change should be made to IsSimpleItem below. // Use a simple cell unless the item is expandable. An item // in an expandable column cannot have subitems, so // we will not need a column object for this purpose. // The data is provided by a different branch. The item is simple only // if the branch has one unexpandable item and no sub items.
An AccSimpleCell or AccColumn
An AccSimpleCell or AccColumn
ctl
VirtualTreeControl
The parent control
The parent control
baseRow
int
The row coordinate
The row coordinate
nativeBaseColumn
int
The column coordinate for the owning branch
The column coordinate for the owning branch
localColumn
int
The native column offset
The native column offset
returnColumn
bool
Return an AccColumn object if this is true, otherwise return the AccPrimaryItem directly
Return an AccColumn object if this is true otherwise return the AccPrimaryItem directly