예제 #1
0
        public override void Layout(GraphicsSettings gs, Size maximumSize)
        {
            DeleteChildren();

            int bottom = Location.Y;

            foreach (Section s in _headerSection.Children)
            {
                HeaderColumnSection hcs = s as HeaderColumnSection;

                if (hcs != null)
                {
                    CellSection cellSection = Host.SectionFactory.CreateCellSection(Host, hcs, Item);

                    Children.Add(cellSection);

                    //
                    //	We position the cell aligned to its corresponding HeaderColumnSection. We nudge it to right here
                    //	based on any difference between the column size and the headers columns actual size. The only time there
                    //	will be a different currently is when we have multiple groups reserving initial space on the first column.
                    cellSection.Location = new Point(hcs.Location.X + hcs.Rectangle.Width - hcs.Column.Width, Location.Y);
                    cellSection.Layout(gs, new Size(hcs.Column.Width, maximumSize.Height));
                    bottom = Math.Max(bottom, cellSection.Rectangle.Bottom);
                }
            }
            int newHeigt = MinimumHeight;

            if (bottom - Rectangle.Top > MinimumHeight)
            {
                newHeigt = bottom - Rectangle.Top;
            }
            Size = new Size(HeaderSection.Rectangle.Width, newHeigt);
        }
예제 #2
0
 public CellSection CellSectionFromPoint(Point pt)
 {
     pt.X += GetAbsoluteScrollCoordinates().X;
     pt.Y += GetAbsoluteScrollCoordinates().Y;
     foreach (Section s in Children)
     {
         CellSection cs = s as CellSection;
         if (cs != null)
         {
             Section sectionFromPoint = cs.SectionFromPoint(pt);
             if (sectionFromPoint != null)
             {
                 return(cs);
             }
         }
     }
     return(null);
 }
예제 #3
0
        public void SizeColumnsToFit( params Column[] columns )
        {
            using( Graphics grfx = Host.CreateGraphics() )
            {
                GraphicsSettings grfxSettings = new GraphicsSettings( grfx );
                int[] columnWidths = new int[Columns.Count];
                int position = 0;

                HeaderColumnSection[] hcsSections = new HeaderColumnSection[columns.Length];
                for( int iColumn = 0; iColumn < columns.Length; iColumn++ )
                {
                    HeaderColumnSection hcs = Host.SectionFactory.CreateHeaderColumnSection( Host, HeaderColumnSection.DisplayMode.Customise, columns[iColumn] );
                    hcs.Layout( grfxSettings, new Size( int.MaxValue, int.MaxValue ) );
                    hcsSections[iColumn] = hcs;
                }

                Type[] lastColumnTypes = new Type[columns.Length];
                CellSection[] columnCellSections = new CellSection[columns.Length];

                //
                //	Pick the widest cell to be the width of the column.
                foreach( object rowItem in ItemList.ToArray() )
                {
                    for( int iColumn = 0; iColumn < columns.Length; iColumn++ )
                    {
                        Column column = columns[iColumn];
                        CellSection cs = columnCellSections[iColumn];
                        object columnItem = column.ColumnItemAccessor( rowItem );
                        Type lastColumnType = lastColumnTypes[iColumn] == null ? null : lastColumnTypes[iColumn].GetType();
                        if( lastColumnType == null || columnItem.GetType() != lastColumnType )
                        {
                            cs = columnCellSections[iColumn] = Host.SectionFactory.CreateCellSection( Host, hcsSections[iColumn], rowItem );
                            lastColumnTypes[iColumn] = columnItem.GetType();
                        }
                        cs.Item = rowItem;
                        Size size = cs.GetIdealSize( grfxSettings );
                        if( columnWidths[iColumn] < size.Width )
                        {
                            columnWidths[iColumn] = size.Width;
                        }
                    }
                    position++;
                }

                //
                //	Set columns widths...
                for( int iColumn = 0; iColumn < columns.Length; iColumn++ )
                {
                    columns[iColumn].Width = columnWidths[iColumn] == 0 ? hcsSections[iColumn].Size.Width : columnWidths[iColumn];
                }
            }
        }
예제 #4
0
 public CellEventArgs( CellSection cell )
 {
     Cell = cell;
 }