public override void DrawCell(LayoutListDrawArgs e) { var layoutList = e.LayoutList; IGroup gitem = e.Item as IGroup; IGlyph image = e.Item as IGlyph; int level = gitem == null ? -1 : GroupHelper.Level(gitem); e.Context.DrawCell(e.Style, null, e.Bound, e.Bound, e.State); if (layoutList.ListInfo.Tree && gitem != null && gitem.IsCompaund) { var glyphBound = layoutList.GetCellGlyphBound(gitem, level, e.Bound); e.Context.DrawGlyph(gitem.Expand ? GlyphType.CaretDown : GlyphType.CaretRight, glyphBound, e.Style, e.State); } if (layoutList.AllowCheck && e.Item is ICheck) { var checkBound = layoutList.GetCellCheckBound(e.Item, level, e.Bound); e.Context.DrawCheckBox(((ICheck)e.Item).Check ? CheckedState.Checked : CheckedState.Unchecked, checkBound, e.Style.FontBrush.GetColorByState(e.State)); } if (layoutList.AllowImage && image != null) { var imageBound = layoutList.GetCellImageBound(e.Item, level, e.Bound); if (image.Image != null) { e.Context.DrawImage(image.Image, imageBound); } else if (image.Glyph != GlyphType.None) { var color = e.Style.FontBrush.GetColorByState(e.State); if (image is Node && ((Node)image).GlyphColor != CellStyleBrush.ColorEmpty) { color = ((Node)image).GlyphColor; } e.Context.DrawGlyph(image.Glyph, imageBound, color); } } var textBound = layoutList.GetCellTextBound(e); if (e.Formated is string) { e.Context.DrawText((string)e.Formated, textBound, e.Style, e.State); } else if (e.Formated is TextLayout) { e.Context.DrawText((TextLayout)e.Formated, textBound, e.Style, e.State); } }
private void FieldsCellValueChanged(object sender, LayoutValueEventArgs e) { if (ListMode && Status == TableEditorStatus.Adding) { LayoutList flist = (LayoutList)sender; var query = DBList.View.Query; LayoutField ff = (LayoutField)e.Cell; if (e.Data != DBNull.Value) { query.BuildParam(ff.Name, e.Data, QQueryBuildParam.AutoLike | QQueryBuildParam.SplitString); } foreach (LayoutField field in flist.Fields) { object val = flist.ReadValue(field, (LayoutColumn)flist.ListInfo.Columns["Value"]); if (!field.Visible || val == null || val == DBNull.Value || GroupHelper.Level(field) != 0) { continue; } if (field == ff) { continue; } if (string.IsNullOrEmpty(val.ToString())) { continue; } query.BuildParam(field.Name, val, QQueryBuildParam.AutoLike | QQueryBuildParam.SplitString); } if (query.Parameters.Count == 0) { loader.Cancel(); } else if (!Table.IsSynchronized) { loader.LoadAsync(query); } //list.View.UpdateFilter(); } }
public void WriteMapItem(LayoutColumn map, int listIndex, object listItem, int sc, int sr, ref int mr, StringKeyList stringTable, List <Row> prows = null) { int tws = map.GetWithdSpan(); Row row = null; var rows = prows; if (prows == null) { rows = new List <Row>(); mr++; row = GenerateRow(mr, mc, listItem == null, stringTable); WriteCell(row.GetFirstChild <Cell>(), listItem == null ? (object)"#" : (object)(listIndex + 1), stringTable); rows.Add(row); sc = 1; } var nr = mr; foreach (var item in map) { if (item.Visible) { map.GetVisibleIndex(item, out int c, out int r); c += sc; r += sr; if (item.Count > 0) { WriteMapItem(item, listIndex, listItem, c, r, ref mr, stringTable, rows); } else { int rr = nr + r; if (rows.Count <= r) { mr++; row = GenerateRow(rr, mc, listItem == null, stringTable); rows.Add(row); } else { row = rows[r]; } object celldata = ((LayoutColumn)item).Text; if (listIndex == -2) { celldata = list.GetCollectedValue((LayoutColumn)item, group); } if (listItem != null) { object val = list.ReadValue(listItem, (ILayoutCell)item); celldata = list.FormatValue(listItem, val, (ILayoutCell)item); if (val is decimal && ((ILayoutCell)item).Format != "p") { celldata = val; } if (prows == null && c == 1 && listItem is Node) { var s = GroupHelper.Level((Node)listItem) * 4; celldata = celldata.ToString().PadLeft(celldata.ToString().Length + s, '-'); } } var cellc = (Cell)row.ChildElements.GetItem(c); WriteCell(cellc, celldata, stringTable); if (celldata is decimal) { cellc.StyleIndex = 3; } int ws = map.GetRowWidthSpan(item.Row); int hs = map.GetRowHeightSpan(item.Row, true); if (tws > ws && hs > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c + tws - ws, rr + hs - 1).ToString() }); } else if (tws > ws) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c + tws - ws, rr).ToString() }); } else if (hs > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c, rr + hs - 1).ToString() }); } } } } if (prows == null) { if (rows.Count > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(0, nr, 0, nr + rows.Count - 1).ToString() }); } if (listItem is Node) { foreach (var item in rows) { item.OutlineLevel = (byte)(GroupHelper.Level((IGroup)listItem)); if (((IGroup)listItem).IsCompaund) { item.Collapsed = !((IGroup)listItem).Expand; } if (item.OutlineLevel > 0) { item.Hidden = !((IGroup)listItem).IsExpanded; } } } WriteRows(writer, rows); if (listItem is Node && map != null) { var i = 0; foreach (var item in ((Node)listItem).Nodes) { WriteMapItem(map, i++, item, 0, 0, ref mr, stringTable); } } } }