/// <summary> /// </summary> protected override void DoWork(CodeActivityContext context) { PlainText.Set(context, null); Html.Set(context, null); DataTable dataTable = FieldData.Get(context); var format = (MergeFieldUtility.MergeFieldsOutputFormats)OutputFormat.Get(context); IList <IQEnum> columns = Columns.Get(context); if (dataTable.Columns.Count == 0) { PlainText.Set(context, MergeFieldUtility.NO_DATA); return; } // create a new table that contains only the user selected columns var filteredTable = FilterTable(dataTable, columns); var statusList = GetStatusList(dataTable); string result; switch (format) { case MergeFieldUtility.MergeFieldsOutputFormats.Table: case MergeFieldUtility.MergeFieldsOutputFormats.TableNoLines: case MergeFieldUtility.MergeFieldsOutputFormats.TableNoHeader: case MergeFieldUtility.MergeFieldsOutputFormats.TableNoLinesNoHeader: bool showHeader = format == MergeFieldUtility.MergeFieldsOutputFormats.Table || format == MergeFieldUtility.MergeFieldsOutputFormats.TableNoLines; bool showLines = format == MergeFieldUtility.MergeFieldsOutputFormats.Table || format == MergeFieldUtility.MergeFieldsOutputFormats.TableNoHeader; if (filteredTable.Rows.Count == 0 && !showHeader) { PlainText.Set(context, MergeFieldUtility.NO_DATA); } else { result = ConvertToHtml(filteredTable, showHeader, showLines, statusList); Html.Set(context, result); } break; case MergeFieldUtility.MergeFieldsOutputFormats.List: // use html format for the same look and feel (line spacing) result = ConvertToHtmlParagraph(filteredTable, " ", "<br>", statusList); Html.Set(context, result); break; case MergeFieldUtility.MergeFieldsOutputFormats.Paragraph: if (statusList == null || statusList.Count <= 0) { result = ConvertToParagraph(filteredTable, " ", "; "); PlainText.Set(context, result); } else { result = ConvertToHtmlParagraph(filteredTable, " ", "; ", statusList); Html.Set(context, result); } break; } }
private void SetupField(FieldData data, int brickDensity = -1) { int width = data.GetWidth(); int height = data.GetHeight(); cells = new FieldCellArray(width, height); movableCells = new LinkedList <MovableCell>(); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { FieldBlocks block = data.Get(x, y); switch (block) { case FieldBlocks.Blank: { break; } case FieldBlocks.Brick: { if (brickDensity == -1 || MathHelp.NextInt(100) <= brickDensity) { AddCell(new BrickCell(x, y)); } break; } case FieldBlocks.Solid: { AddCell(new SolidCell(x, y)); break; } default: { Debug.Assert(false, "Unsupported cell type: " + block); break; } } } } }
public FieldDataView(FieldData data, Style style) : base(style.width, style.height) { AddView(new RectView(0, 0, width, height, Color.Gray, Color.Black)); float iw = style.iw; float ih = style.ih; RectView rect = new RectView(0.5f * (width - iw), 0.5f * (height - ih), iw, ih, Color.Green, Color.Green); AddView(rect); float cw = iw / data.GetWidth(); float ch = ih / data.GetHeight(); for (int y = 0; y < data.GetHeight(); ++y) { for (int x = 0; x < data.GetWidth(); ++x) { FieldBlocks block = data.Get(x, y); Color color; switch (block) { case FieldBlocks.Brick: color = COLOR_BRICK; break; case FieldBlocks.Solid: color = COLOR_SOLID; break; default: continue; } float cx = x * cw; float cy = y * ch; rect.AddView(new RectView(cx, cy, cw, ch, color, color)); } } }