protected virtual void CreateRecordBrick(XRDataRecord currentRecord, PanelBrick parentBrick, ref float actualHeight) { if (IsDesignMode || (parentBrick is DataContainerBrick && !((DataContainerBrick)parentBrick).IsHeader)) { CreateBricksForRecord(currentRecord, parentBrick, false, ref actualHeight); } }
protected override void CreateBricksForRecord(XRDataRecord record, PanelBrick parentBrick, bool isHeader, ref float actualHeight) { XRTreeListNode node = record as XRTreeListNode; PrintNodeEventArgs args = new PrintNodeEventArgs(node); if (!isHeader) { TreeList.OnPrintNode(args); } if (args.SuppressType == NodeSuppressType.Leave) { int nodeLevel = node.Level; TreeListNodeBrick nodeBrick = new TreeListNodeBrick(TreeList, (DataContainerBrick)parentBrick, isHeader); nodeBrick.Style = XRControlStyle.Default.Clone() as XRControlStyle; nodeBrick.Separable = false; RecordPrintCache cache = new TreeListNodePrintCache(nodeBrick, node.Level); List <VisualBrick> childBricks = new List <VisualBrick>(); List <XRFieldHeader> visibleHeaders = TreeList.VisibleHeaders; for (int i = 0; i < visibleHeaders.Count; i++) { VisualBrick valueBrick = CreateCellBrick(TreeList, parentBrick, node, i, isHeader); childBricks.Add(valueBrick); } CorrectBrickBounds(nodeBrick, childBricks, nodeLevel * TreeList.NodeIndent, actualHeight); float nodeHeight = nodeBrick.Rect.Height; VisualBrickHelper.SetBrickBounds(nodeBrick, nodeBrick.Rect, TreeList.Dpi); parentBrick.Bricks.Add(nodeBrick); actualHeight += nodeHeight; if (!IsDesignMode) { if (isHeader) { ((DataContainerBrick)parentBrick).PrintCache.HeaderCache = cache; } else { ((DataContainerBrick)parentBrick).PrintCache.RecordsCache.Add(cache); } } } if (args.SuppressType != NodeSuppressType.SuppressWithChildren) { foreach (XRTreeListNode childNode in node.Nodes) { CreateBricksForRecord(childNode, parentBrick, isHeader, ref actualHeight); } } }
public override int Compare(XRDataRecord other) { int sortResult = base.Compare(other); if (sortResult == 0) { sortResult = Comparer.Default.Compare(this.KeyValue, ((XRTreeListNode)other).KeyValue); } return(sortResult); }
protected override void CreateBricksForRecord(XRDataRecord record, PanelBrick parentBrick, bool isHeader, ref float actualHeight) { PrintRecordEventArgs args = new PrintRecordEventArgs(record); if (!isHeader) { Grid.OnPrintRecord(args); } if (!args.Cancel) { GridRecordBrick recordBrick = new GridRecordBrick(Grid, (DataContainerBrick)parentBrick, isHeader); recordBrick.Style = XRControlStyle.Default.Clone() as XRControlStyle; recordBrick.Separable = false; RecordPrintCache cache = new RecordPrintCache(recordBrick); List <VisualBrick> childBricks = new List <VisualBrick>(); List <XRFieldHeader> visibleHeaders = Grid.VisibleHeaders; for (int i = 0; i < visibleHeaders.Count; i++) { VisualBrick valueBrick = CreateCellBrick(Grid, parentBrick, record, i, isHeader); childBricks.Add(valueBrick); } CorrectBrickBounds(recordBrick, childBricks, 0, actualHeight); float recordHeight = recordBrick.Rect.Height; VisualBrickHelper.SetBrickBounds(recordBrick, recordBrick.Rect, Grid.Dpi); parentBrick.Bricks.Add(recordBrick); actualHeight += recordHeight; if (!IsDesignMode) { if (isHeader) { ((DataContainerBrick)parentBrick).PrintCache.HeaderCache = cache; } else { ((DataContainerBrick)parentBrick).PrintCache.RecordsCache.Add(cache); } } } }
protected override void CreateHeaders(PanelBrick parentBrick, ref float actualHeight) { if (IsDesignMode || (parentBrick is DataContainerBrick && ((DataContainerBrick)parentBrick).IsHeader)) { XRDataRecord headerRecord = TableControl.CreateDataRecord(); List <XRFieldHeader> visibleHeaders = TableControl.VisibleHeaders; for (int i = 0; i < visibleHeaders.Count; i++) { headerRecord[i] = visibleHeaders[i].Caption; } CreateBricksForRecord(headerRecord, parentBrick, true, ref actualHeight); } }
protected override void InitializeRecord(XRDataRecord record, object dataItem) { base.InitializeRecord(record, dataItem); XRTreeListNode node = record as XRTreeListNode; node.KeyValue = keyFieldDescriptor == null ? null : keyFieldDescriptor.GetValue(dataItem); node.ParentValue = parentFieldDescriptor == null ? null : parentFieldDescriptor.GetValue(dataItem); if (node.KeyValue != null && !nodeTable.ContainsKey(node.KeyValue)) { nodeTable.Add(node.KeyValue, node); } else { nodeTable.Add(Guid.NewGuid(), node); } }
private void LoadRecords() { IList list = ((ICustomDataContainer)control).GetDataSource(); PropertyDescriptorCollection fields = control.GetAvailableFields(); List <PropertyDescriptor> visibleFields = new List <PropertyDescriptor>(); for (int i = 0; i < control.Headers.Count; i++) { PropertyDescriptor descriptor = GetDescriptorByFieldName(fields, control.Headers[i].FieldName); visibleFields.Add(descriptor); } if (list == null) { return; } foreach (object dataItem in list) { XRDataRecord record = control.CreateDataRecord(); control.Records.Add(record); for (int i = 0; i < control.Headers.Count; i++) { if (visibleFields[i] != null) { record[i] = visibleFields[i].GetValue(dataItem); } else { record[i] = null; } } InitializeRecord(record, dataItem); } }
private XRDataRecordCollection CreateDesignRecords() { XRDataRecordCollection designRecords = new XRDataRecordCollection(); for (int i = 0; i < 3; i++) { XRDataRecord currentRecord = new XRDataRecord(Grid); List <XRFieldHeader> visibleHeaders = Grid.VisibleHeaders; for (int j = 0; j < visibleHeaders.Count; j++) { if (visibleHeaders[j].FieldType != null) { currentRecord[j] = visibleHeaders[j].FieldType.Name; } } designRecords.Add(currentRecord); } return(designRecords); }
public PrintRecordEventArgs(XRDataRecord currentRecord) { this.record = currentRecord; cancel = false; }
protected virtual void InitializeRecord(XRDataRecord record, object data) { }
protected virtual void CreateBricksForRecord(XRDataRecord record, PanelBrick parentBrick, bool isHeader, ref float actualHeight) { }
protected override VisualBrick CreateCellBrick(XRDataContainerControl control, VisualBrick parentBrick, XRDataRecord record, int fieldIndex, bool isHeader) { VisualBrick valueBrick = base.CreateCellBrick(control, parentBrick, record, fieldIndex, isHeader); float columnWidth = ((XRGridColumn)control.VisibleHeaders[fieldIndex]).Width; float columnPos = 0; for (int j = 0; j < fieldIndex; j++) { columnPos += ((XRGridColumn)control.VisibleHeaders[j]).Width; } valueBrick.Style = CreateBrickStyle(control, parentBrick, valueBrick, record, fieldIndex, isHeader); float brickHeight = GetBrickHeight(valueBrick, columnWidth, isHeader); valueBrick.Rect = new RectangleF(columnPos, 0, columnWidth, brickHeight); return(valueBrick); }
protected override BrickStyle CreateBrickStyle(XRDataContainerControl control, VisualBrick parentBrick, VisualBrick valueBrick, XRDataRecord record, int fieldIndex, bool isHeader) { BrickStyle style = base.CreateBrickStyle(control, parentBrick, valueBrick, record, fieldIndex, isHeader); if (!isHeader) { PrintCellEventArgs printCellArgs = new PrintNodeCellEventArgs((XRTreeListNode)record, (XRTreeListColumn)control.VisibleHeaders[fieldIndex], valueBrick, style); TreeList.OnPrintNodeCell((PrintNodeCellEventArgs)printCellArgs); } return(style); }
protected virtual BrickStyle CreateBrickStyle(XRDataContainerControl control, VisualBrick parentBrick, VisualBrick valueBrick, XRDataRecord record, int fieldIndex, bool isHeader) { BrickStyle style = GetActualBrickStyle((DataContainerBrick)parentBrick, isHeader); if (isHeader) { PrintCellEventArgs printCellArgs = new PrintCellEventArgs(control.VisibleHeaders[fieldIndex], valueBrick, style); ContainerControl.OnPrintHeaderCell(printCellArgs); ((IDataCellBrick)valueBrick).CellPosition |= XRDataCellPosition.Header; } else { PrintRecordCellEventArgs printCellArgs = new PrintRecordCellEventArgs(record, control.VisibleHeaders[fieldIndex], valueBrick, style); ContainerControl.OnPrintRecordCell(printCellArgs); } return(style); }
protected override VisualBrick CreateCellBrick(XRDataContainerControl control, VisualBrick parentBrick, XRDataRecord record, int fieldIndex, bool isHeader) { VisualBrick valueBrick = base.CreateCellBrick(control, parentBrick, record, fieldIndex, isHeader); float columnWidth = ((XRTreeListColumn)control.VisibleHeaders[fieldIndex]).Width; float columnPos = 0; if (fieldIndex > 0) { columnPos -= ((XRTreeListNode)record).Level * TreeList.NodeIndent; } for (int j = 0; j < fieldIndex; j++) { columnPos += ((XRTreeListColumn)control.VisibleHeaders[j]).Width; } float curColWidth = fieldIndex == 0 ? columnWidth - ((XRTreeListNode)record).Level * TreeList.NodeIndent : columnWidth; valueBrick.Style = CreateBrickStyle(control, parentBrick, valueBrick, record, fieldIndex, isHeader); float brickHeight = GetBrickHeight(valueBrick, columnWidth, isHeader); valueBrick.Rect = new RectangleF(columnPos, 0, curColWidth, brickHeight); return(valueBrick); }
public PrintRecordCellEventArgs(XRDataRecord currentRecord, XRFieldHeader header, VisualBrick brick, BrickStyle style) : base(header, brick, style) { this.record = currentRecord; }
protected virtual VisualBrick CreateCellBrick(XRDataContainerControl control, VisualBrick parentBrick, XRDataRecord record, int fieldIndex, bool isHeader) { VisualBrick valueBrick; int absoluteIndex = fieldIndex; if (!isHeader && !IsDesignMode) { XRFieldHeader header = control.VisibleHeaders[fieldIndex]; absoluteIndex = control.Headers.IndexOf(header); } object value = record[absoluteIndex]; if (value is bool) { valueBrick = new DataCellCheckBrick(ContainerControl); ((DataCellCheckBrick)valueBrick).Checked = Convert.ToBoolean(value); } else { valueBrick = new DataCellTextBrick(ContainerControl); valueBrick.Text = Convert.ToString(value); } valueBrick.TextValue = value; if (fieldIndex == 0) { ((IDataCellBrick)valueBrick).CellPosition |= XRDataCellPosition.LeftMost; } if (fieldIndex == control.VisibleHeaders.Count - 1) { ((IDataCellBrick)valueBrick).CellPosition |= XRDataCellPosition.RightMost; } return(valueBrick); }