public override void Drop(DragEventArgs eventArgs, Point dropPoint) { HeaderColumnSection headerColumnSection = GetHeaderColumnSectionFromDragData(eventArgs.Data); HeaderColumnSection before; HeaderColumnSection after; GetDropBoundsSections(ToWorldPoint(dropPoint), out before, out after); int insertionIndex = 0; if (headerColumnSection.Parent != this || headerColumnSection.Parent.Columns.IndexOf(headerColumnSection.Column) != insertionIndex - 1) { if (headerColumnSection.Parent.ShouldRemoveColumnOnDrop(headerColumnSection.Column)) { headerColumnSection.Parent.Columns.Remove(headerColumnSection.Column); } if (before != null) { insertionIndex = Columns.IndexOf(before.Column) + 1; } int columnIndexFound = Columns.IndexOf(headerColumnSection.Column); if (columnIndexFound != -1) { Columns.RemoveAt(columnIndexFound); if (insertionIndex > columnIndexFound) { insertionIndex--; } } Columns.Insert(insertionIndex, headerColumnSection.Column); } }
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); }
public virtual CellSection CreateCellSection( ISectionHost host, HeaderColumnSection hcs, object item ) { object cellValue = item == null ? null : hcs.Column.ColumnItemAccessor( item ); if( cellValue != null ) { Type type = cellValue.GetType(); foreach( KeyValuePair<Type, CellSectionCreator> kv in _cellSectionFactoryMap ) { if( type == kv.Key || type.IsSubclassOf( kv.Key ) ) { return kv.Value( host, hcs, item ); } } } return new CellSection( host, hcs, item ); }
protected void GetDropBoundsSections(Point pt, out HeaderColumnSection before, out HeaderColumnSection after) { before = null; after = null; foreach (HeaderColumnSection s in Children) { if (pt.X > s.Rectangle.Right && (before == null || s.Rectangle.Right > before.Rectangle.Right)) { before = s; } if (pt.X < s.Rectangle.Right && (after == null || s.Rectangle.Right < after.Rectangle.Right)) { after = s; } } }
public virtual CellSection CreateCellSection(ISectionHost host, HeaderColumnSection hcs, object item) { object cellValue = item == null ? null : hcs.Column.ColumnItemAccessor(item); if (cellValue != null) { Type type = cellValue.GetType(); foreach (KeyValuePair <Type, CellSectionCreator> kv in _cellSectionFactoryMap) { if (type == kv.Key || type.IsSubclassOf(kv.Key)) { return(kv.Value(host, hcs, item)); } } } return(new CellSection(host, hcs, item)); }
protected void SyncSectionsToColumns(HeaderColumnSection.DisplayMode displayModeToCreate) { List <HeaderColumnSection> newHeaderList = new List <HeaderColumnSection>(); Dictionary <Column, HeaderColumnSection> columnToHeaderColumnSection = new Dictionary <Column, HeaderColumnSection>(); foreach (Section s in Children) { HeaderColumnSection headerColumnSection = s as HeaderColumnSection; if (headerColumnSection != null) { columnToHeaderColumnSection[headerColumnSection.Column] = headerColumnSection; } } // // Add additions foreach (Column column in _columns) { HeaderColumnSection headerColumnSection; if (!columnToHeaderColumnSection.TryGetValue(column, out headerColumnSection)) { headerColumnSection = CreateHeaderColumnSection(displayModeToCreate, column); } newHeaderList.Add(headerColumnSection); } // // Remove any ones that doesn't exists any more foreach (Section s in Children) { HeaderColumnSection hcs = s as HeaderColumnSection; if (hcs != null) { if (newHeaderList.IndexOf(hcs) == -1) { hcs.Dispose(); } } } Children.Clear(); Children.AddRange(newHeaderList.ToArray()); }
private static HeaderColumnSection GetHeaderColumnSectionFromDragData(IDataObject dataObject) { string[] formats = dataObject.GetFormats(); foreach (string format in formats) { object[] items = dataObject.GetData(format) as object[]; if (items.Length == 1) { HeaderColumnSection headerColumnSection = items[0] as HeaderColumnSection; if (headerColumnSection != null) { return(headerColumnSection); } } } return(null); }
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]; } } }
protected void SyncSectionsToColumns( HeaderColumnSection.DisplayMode displayModeToCreate ) { List<HeaderColumnSection> newHeaderList = new List<HeaderColumnSection>(); Dictionary<Column, HeaderColumnSection> columnToHeaderColumnSection = new Dictionary<Column, HeaderColumnSection>(); foreach( Section s in Children ) { HeaderColumnSection headerColumnSection = s as HeaderColumnSection; if( headerColumnSection != null ) { columnToHeaderColumnSection[headerColumnSection.Column] = headerColumnSection; } } // // Add additions foreach( Column column in _columns ) { HeaderColumnSection headerColumnSection; if( !columnToHeaderColumnSection.TryGetValue( column, out headerColumnSection ) ) { headerColumnSection = CreateHeaderColumnSection( displayModeToCreate, column ); } newHeaderList.Add( headerColumnSection ); } // // Remove any ones that doesn't exists any more foreach( Section s in Children ) { HeaderColumnSection hcs = s as HeaderColumnSection; if( hcs != null ) { if( newHeaderList.IndexOf( hcs ) == -1 ) { hcs.Dispose(); } } } Children.Clear(); Children.AddRange( newHeaderList.ToArray() ); }
protected void GetDropBoundsSections( Point pt, out HeaderColumnSection before, out HeaderColumnSection after ) { before = null; after = null; foreach( HeaderColumnSection s in Children ) { if( pt.X > s.Rectangle.Right && (before == null || s.Rectangle.Right > before.Rectangle.Right) ) { before = s; } if( pt.X < s.Rectangle.Right && (after == null || s.Rectangle.Right < after.Rectangle.Right) ) { after = s; } } }
protected virtual HeaderColumnSection CreateHeaderColumnSection( HeaderColumnSection.DisplayMode displayModeToCreate, Column column ) { return Host.SectionFactory.CreateHeaderColumnSection( Host, displayModeToCreate, column ); }
public virtual HeaderColumnSection CreateHeaderColumnSection( ISectionHost host, HeaderColumnSection.DisplayMode displayMode, Column column ) { return new HeaderColumnSection( host, displayMode, column ); }
protected override HeaderColumnSection CreateHeaderColumnSection( HeaderColumnSection.DisplayMode displayModeToCreate, Column column ) { return Host.SectionFactory.CreateAvailableColumnSection( Host, column ); }
public CellSectionImage( ISectionHost host, HeaderColumnSection hcs, object item ) : base(host, hcs, item) { }
public CellSectionImage(ISectionHost host, HeaderColumnSection hcs, object item) : base(host, hcs, item) { }
public CellSection( ISectionHost host, HeaderColumnSection hcs, object item ) : base(host) { _hcs = hcs; _item = item; }
public CellSection(ISectionHost host, HeaderColumnSection hcs, object item) : base(host) { _hcs = hcs; _item = item; }