/// <summary> /// /// </summary> /// <returns></returns> public PdfPCell RenderingCell(CellAttributes attributes) { var numColumns = 10; var salePrice = attributes.RowData.TableRowData .GetSafeStringValueOf <Transaction>(x => x.SalePrice, nullValue: "0") .PadLeft(numColumns, ' '); var table = new PdfGrid(numColumns) { RunDirection = PdfWriter.RUN_DIRECTION_LTR, WidthPercentage = 100 }; for (int i = 0; i < numColumns; i++) { var character = salePrice[i].ToString(); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(character)) { HorizontalAlignment = Element.ALIGN_CENTER, BorderColor = BaseColor.GRAY, UseAscender = true, UseDescender = true, VerticalAlignment = Element.ALIGN_MIDDLE, BorderWidth = 1 }); } return(new PdfPCell(table)); }
/// <summary> /// Custom cell's content template as a PdfPCell /// </summary> /// <returns>Content as a PdfPCell</returns> public PdfPCell RenderingCell(CellAttributes attributes) { if (OnPrintAnnotation == null) { throw new InvalidOperationException("Please set the OnPrintAnnotation formula."); } var data = OnPrintAnnotation.Invoke(attributes.RowData.TableRowData); if (data == null) { return(new PdfPCell()); } var defaultFont = attributes.BasicProperties.PdfFont.Fonts[0]; var chunk = new Chunk(".", defaultFont); chunk.SetAnnotation( PdfAnnotation.CreateText( attributes.SharedData.PdfWriter, new Rectangle(100, 100), data.Title, data.Text, false, _annotationIcon[data.Icon])); return(new PdfPCell(new Phrase(chunk))); }
/// <summary> /// Adds a SummaryRow to an existing PdfGrid /// </summary> /// <param name="table">An existing PdfGrid</param> /// <param name="pdfColumnsDefinitions">List of the PdfColumnAttributes</param> /// <param name="summaryProperty">Sets the location of summary cell's data</param> /// <param name="labelProperty">Sets the location of summary cell's label</param> /// <param name="summaryCell">SummaryCell's Attributes</param> /// <param name="labelCell">LabelCell's Attributes</param> /// <param name="emptyCell">The other not in use cell's Attributes</param> /// <param name="itemsTemplate">Default ItemsTemplate</param> public static void AddSummaryRow(this PdfGrid table, IList <ColumnAttributes> pdfColumnsDefinitions, string summaryProperty, string labelProperty, CellAttributes summaryCell, CellAttributes labelCell, CellAttributes emptyCell, IColumnItemsTemplate itemsTemplate) { foreach (var col in pdfColumnsDefinitions) { if (col.PropertyName == summaryProperty) { table.AddCell(summaryCell.CreateSafePdfPCell(itemsTemplate)); } else if (col.PropertyName == labelProperty) { table.AddCell(labelCell.CreateSafePdfPCell(itemsTemplate)); } else { table.AddCell(emptyCell.CreateSafePdfPCell(itemsTemplate)); } } }
/// <summary> /// /// </summary> /// <returns></returns> public PdfPCell RenderingCell(CellAttributes attributes) { var pdfCell = new PdfPCell(); var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR }; var fileName = $"{_rnd.Next(1, 5):00}.png"; var photo = PdfImageHelper.GetITextSharpImageFromImageFile(TestUtils.GetImagePath(fileName)); table.AddCell(new PdfPCell(photo) { Border = 0, MinimumHeight = photo.Height, VerticalAlignment = Element.ALIGN_BOTTOM }); var name = attributes.RowData.TableRowData.GetSafeStringValueOf <User>(x => x.Name); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name)) { Border = 0 }); var lastName = attributes.RowData.TableRowData.GetSafeStringValueOf <User>(x => x.LastName); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(lastName)) { Border = 0 }); pdfCell.AddElement(table); return(pdfCell); }
public static void ShiftCells(Vector3 startingPoint, Vector3 direction, Organism organism) { Vector3 currentPos = startingPoint; CellAttributes currentCell = organism.cells.RemoveCell(currentPos); while (currentCell != null) { Vector3 shiftedPosition = currentPos + direction; currentCell.relativePosition = shiftedPosition; if (currentCell.instance != null) { var newPositionAndRotation = CellsCreator.RealPositionAndRotation(currentCell, organism.transform); currentCell.instance.transform.position = newPositionAndRotation.Key; currentCell.instance.transform.rotation = newPositionAndRotation.Value; } CellAttributes nextCell = organism.cells.RemoveCell(shiftedPosition); currentPos = shiftedPosition; organism.cells.AddCell(currentCell); currentCell = nextCell; } }
public static void SetNeuralNetwork(Organism organism) { organism.neuralNetwork = new NeuralNetwork(); List <Neuron> outputNeurons = new List <Neuron>(); List <Neuron> inputNeurons = new List <Neuron>(); organism.bias = new Neuron(Organism.GetInputOrganismNeuronsNumbers()[0]); organism.bias.Value = 1; organism.damageNeuron = new Neuron(Organism.GetInputOrganismNeuronsNumbers()[1]); organism.energyNeuron = new Neuron(Organism.GetInputOrganismNeuronsNumbers()[2]); organism.mitosisNeuron = new Neuron(Organism.GetOutputOrganismNeuronsNumbers()[0]); organism.sexualReproductionNeuron = new Neuron(Organism.GetOutputOrganismNeuronsNumbers()[1]); inputNeurons.Add(organism.bias); inputNeurons.Add(organism.damageNeuron); inputNeurons.Add(organism.energyNeuron); outputNeurons.Add(organism.mitosisNeuron); outputNeurons.Add(organism.sexualReproductionNeuron); foreach (var pair in organism.orderOfGrowth) { CellAttributes cell = pair.Value; cell.inputNeurons = Organism.CreateNeuronsFromNumbers(cell.type.GetComponent <Cell>().GetInputNeuronsNumbers(cell.number)); cell.outputNeurons = Organism.CreateNeuronsFromNumbers(cell.type.GetComponent <Cell>().GetOutputNeuronsNumbers(cell.number)); inputNeurons.AddRange(cell.inputNeurons); outputNeurons.AddRange(cell.outputNeurons); } organism.neuralNetwork.BuildFromChromosome(organism.chromosome.neuralChromosome, inputNeurons.ToArray(), outputNeurons.ToArray()); }
private void updateAggregates(ColumnAttributes col, CellAttributes cell) { if (cell == null || col.AggregateFunction == null) { return; } col.AggregateFunction.CellAdded(cell.RowData.Value, CurrentRowInfoData.IsNewGroupStarted); var columnRowSummary = new SummaryCellData { CellData = new CellData { PropertyName = col.PropertyName, PropertyValue = cell.RowData.Value, PropertyType = cell.RowData.PropertyType }, GroupAggregateValue = col.AggregateFunction.GroupValue, GroupRowNumber = CurrentRowInfoData.LastGroupRowNumber, OverallAggregateValue = col.AggregateFunction.OverallValue, OverallRowNumber = CurrentRowInfoData.LastOverallDataRowNumber, GroupNumber = CurrentRowInfoData.LastGroupNumber }; SharedData.ColumnCellsSummaryData.Add(columnRowSummary); }
private static void addSimpleRowCell(PdfGrid table, Action <CellRowData, CellBasicProperties> cellDataItem) { var cellBasicProperties = new CellBasicProperties { BorderColor = BaseColor.BLACK, HorizontalAlignment = HorizontalAlignment.Center, RunDirection = PdfRunDirection.LeftToRight, FontColor = new BaseColor(Color.Black.ToArgb()), BackgroundColor = BaseColor.WHITE, PdfFontStyle = DocumentFontStyle.Normal }; var cellData = new CellRowData { Value = string.Empty, FormattedValue = string.Empty }; if (cellDataItem != null) { cellDataItem(cellData, cellBasicProperties); } if (cellData.CellTemplate == null) { cellData.CellTemplate = new TextBlockField(); } var cellAttributes = new CellAttributes { BasicProperties = cellBasicProperties, RowData = cellData }; table.AddCell(cellAttributes.CreateSafePdfPCell(cellData.CellTemplate)); }
private static PdfPCell runOnItemsTemplate(CellAttributes pdfRptTableCellDefinition, IColumnItemsTemplate defaultItemTemplate) { return (pdfRptTableCellDefinition.ItemTemplate == null? defaultItemTemplate.RenderingCell(pdfRptTableCellDefinition) : pdfRptTableCellDefinition.ItemTemplate.RenderingCell(pdfRptTableCellDefinition)); }
private void ComputeEfficiency() { CellsStructure cells = GetComponentInParent <Organism>().cells; efficiency = 1; for (int i = 0; i <= 2; i++) { for (int j = -1; j <= 1; j++) { Vector3 vect = attributes.angle * -(new Vector3(j, -i)); vect = new Vector3((float)Math.Round(vect.x, 3), (float)Math.Round(vect.y, 3)); CellAttributes cell = cells.GetCell(attributes.relativePosition + vect); if (cell != null && cell.alive && !(cell.type.GetComponent <Cell>() is FlagelloCell)) { Vector3 v = new Vector3(j * 7f, -i); efficiency -= 1 / (v.magnitude); } } } if (efficiency < 0) { efficiency = 0; } }
/// <summary> /// /// </summary> /// <returns></returns> public PdfPCell RenderingCell(CellAttributes attributes) { var pdfCell = new PdfPCell(); var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR }; var photo = PdfImageHelper.GetITextSharpImageFromImageFile(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\" + _rnd.Next(1, 5).ToString("00") + ".png")); table.AddCell(new PdfPCell(photo) { Border = 0, MinimumHeight = photo.Height, VerticalAlignment = Element.ALIGN_BOTTOM }); var name = attributes.RowData.TableRowData.GetSafeStringValueOf <User>(x => x.Name); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name)) { Border = 0 }); var lastName = attributes.RowData.TableRowData.GetSafeStringValueOf <User>(x => x.LastName); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(lastName)) { Border = 0 }); pdfCell.AddElement(table); return(pdfCell); }
/// <summary> /// /// </summary> /// <returns></returns> public PdfPCell RenderingCell(CellAttributes attributes) { var pdfCell = new PdfPCell(); var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR }; // Please note that All columns and properties of an object will create a single cell here. var idx = attributes.RowData.ColumnNumber; var data = attributes.RowData.TableRowData; var character = data.GetSafeStringValueOf <CharacterInfo>(x => x.Character, propertyIndex: idx); table.AddCell(new PdfPCell(_customFont.FontSelector.Process(character)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER }); var characterCode = data.GetSafeStringValueOf <CharacterInfo>(x => x.CharacterCode, propertyIndex: idx); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(characterCode)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER }); pdfCell.AddElement(table); return(pdfCell); }
/// <summary> /// /// </summary> /// <returns></returns> public PdfPCell RenderingCell(CellAttributes attributes) { var data = attributes.RowData.TableRowData; var id = data.GetSafeStringValueOf <Question>(x => x.Id); var questionText = data.GetSafeStringValueOf <Question>(x => x.QuestionText); var answer1 = data.GetSafeStringValueOf <Question>(x => x.Answer1); var answer2 = data.GetSafeStringValueOf <Question>(x => x.Answer2); var answer3 = data.GetSafeStringValueOf <Question>(x => x.Answer3); var answer4 = data.GetSafeStringValueOf <Question>(x => x.Answer4); var picturePath = data.GetSafeStringValueOf <Question>(x => x.PicturePath); var font = attributes.BasicProperties.PdfFont; var relativeWidths = getRelativeWidths(); var mainTable = new PdfGrid(relativeWidths) { RunDirection = (int)_pdfRunDirection, WidthPercentage = 100, SpacingBefore = 5, SpacingAfter = 5 }; addQuestionText(id, questionText, font, mainTable); addOptions(answer1, answer2, answer3, answer4, font, mainTable); addImageCell(picturePath, mainTable); return(new PdfPCell(mainTable)); }
public PdfPCell RenderingCell(CellAttributes attributes) { var pdfCell = new PdfPCell(); var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR }; var filePath = System.IO.Path.Combine(TestUtils.GetBaseDir(), "Images", $"{_rnd.Next(1, 5):00}.png"); var photo = PdfImageHelper.GetITextSharpImageFromImageFile(filePath); table.AddCell(new PdfPCell(photo, fit: true) { Border = 0, VerticalAlignment = Element.ALIGN_BOTTOM, HorizontalAlignment = Element.ALIGN_CENTER }); var name = attributes.RowData.TableRowData.GetSafeStringValueOf("User"); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER }); pdfCell.AddElement(table); return(pdfCell); }
public static void GrowCell(CellAttributes cellToGrow, Organism organism) { organism.cells.AddCell(cellToGrow); CellsCreator.InstantiateCell(cellToGrow, organism.transform); organism.orderOfGrowth.RemoveFirst(); SubtractEnergyForGrowth(cellToGrow.type.GetComponent <Cell>().bodyEnergy, organism.organismEnergy); organism.SetTotalEnergyStorage(); int freeEnergyStorage = organism.organismEnergy.TotalEnergyStorage - organism.organismEnergy.Value; if (organism.organismEnergy.EggEnergy > freeEnergyStorage) { organism.organismEnergy.Value += freeEnergyStorage; organism.organismEnergy.EggEnergy -= freeEnergyStorage; } else { organism.organismEnergy.Value += organism.organismEnergy.EggEnergy; organism.organismEnergy.EggEnergy = 0; } }
/// <summary> /// Custom cell's content template as a PdfPCell /// </summary> /// <returns>Content as a PdfPCell</returns> public PdfPCell RenderingCell(CellAttributes attributes) { var font = setFontStyles(attributes); var anchor = getAnchor(font, attributes); return(new PdfPCell(anchor)); }
public void Set(int x, int y, char c, Color fg, Color bg, CellAttributes attr) { if (render == null) { throw new Exception("Not initialized"); } render.Set(x, y, c, fg, bg, attr); }
private static void mapBasicProperties(CellAttributes pdfRptTableCellDefinition) { if (pdfRptTableCellDefinition.ItemTemplate != null && pdfRptTableCellDefinition.ItemTemplate.BasicProperties != null) { pdfRptTableCellDefinition.ItemTemplate.BasicProperties.MapBasicPropertiesTo(pdfRptTableCellDefinition.BasicProperties); } applyTemplateColors(pdfRptTableCellDefinition.BasicProperties, pdfRptTableCellDefinition.BasicProperties); }
/// <summary> /// /// </summary> /// <returns></returns> public PdfPCell RenderingCell(CellAttributes attributes) { PdfPCell pdfCell = new PdfPCell(); PdfGrid table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR }; iTextSharp.text.Image photo = PdfImageHelper.GetITextSharpImageFromByteArray(SharksLogo); photo.WidthPercentage = 60; table.AddCell(new PdfPCell(photo, true) { Border = 0 }); string coachName = attributes.RowData.TableRowData[0].PropertyValue.ToSafeString(); string coachPhone = attributes.RowData.TableRowData[1].PropertyValue.ToSafeString(); List <string> players = attributes.RowData.TableRowData[2].PropertyValue as List <string>; foreach (string p in players) { table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(p)) { Border = 0, Padding = 0 }); } table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process("")) { Border = 0 }); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process("")) { Border = 0 }); if (!string.IsNullOrWhiteSpace(coachName)) { table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process("Head Coach")) { Border = 0 }); table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(coachName + " " + coachPhone)) { Border = 1 }); } pdfCell.AddElement(table); return(pdfCell); }
public static void InstantiateCell(CellAttributes cell, Transform parentTransform) { var realPostionAndRotation = RealPositionAndRotation(cell, parentTransform); GameObject c = UnityEngine.Object.Instantiate(cell.type, realPostionAndRotation.Key, realPostionAndRotation.Value); c.transform.parent = parentTransform; c.name = cell.name; c.GetComponent <Cell>().SetAttributes(cell); }
/// <summary> /// Sets attributes and neurons /// </summary> /// <param name="attributes"></param> public void SetAttributes(CellAttributes attributes) { this.attributes = attributes; attributes.instance = this; if (attributes.outputNeurons != null) { SetOutputNeurons(attributes.outputNeurons); SetInputNeurons(attributes.inputNeurons); } }
/// <summary> /// Create a PdfPCell based on the PdfCell Attributes. /// </summary> /// <param name="pdfRptTableCellDefinition">PdfCell Attributes</param> /// <param name="defaultItemTemplate">Default ItemTemplate</param> /// <returns>A PdfPCell</returns> public static PdfPCell CreateSafePdfPCell(this CellAttributes pdfRptTableCellDefinition, IColumnItemsTemplate defaultItemTemplate) { mapBasicProperties(pdfRptTableCellDefinition); runConditionalFormatFormula(pdfRptTableCellDefinition); var pdfPCell = runOnItemsTemplate(pdfRptTableCellDefinition, defaultItemTemplate); pdfPCell.ApplyStyles(pdfRptTableCellDefinition); return(pdfPCell); }
private string getUrl(CellAttributes attributes) { var url = attributes.RowData.Value.ToSafeString(); if (!string.IsNullOrEmpty(NavigationUrlPropertyName)) { url = attributes.RowData.TableRowData.GetSafeStringValueOf(NavigationUrlPropertyName); } return(url); }
/// <summary> /// Custom cell's content template as a PdfPCell /// </summary> /// <returns>Content as a PdfPCell</returns> public PdfPCell RenderingCell(CellAttributes attributes) { if (shouldUseCachedImage) { return(new PdfPCell(_image, true)); } createImageFromImportedPage(attributes); return(new PdfPCell(_image, true)); }
private string getText(CellAttributes attributes) { var text = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value); if (!string.IsNullOrEmpty(TextPropertyName)) { text = attributes.RowData.TableRowData.GetSafeStringValueOf(TextPropertyName); } attributes.RowData.FormattedValue = text; return(text); }
private Anchor getAnchor(FontSelector fontSelector, CellAttributes attributes) { var text = getText(attributes); var url = getUrl(attributes); var anchor = new Anchor(fontSelector.Process(text.ToSafeString())) { Reference = url }; return(anchor); }
/// <summary> /// Custom cell's content template as a PdfPCell. /// </summary> /// <returns>Content as a PdfPCell</returns> public PdfPCell RenderingCell(CellAttributes attributes) { var data = FuncHelper.ApplyFormula(attributes.BasicProperties.DisplayFormatFormula, attributes.RowData.Value); attributes.RowData.FormattedValue = data; var img = _barcode.GetBarcodeImage(data, attributes.SharedData.PdfWriter.DirectContent); return(new PdfPCell(img) { PaddingTop = 5, }); }
/// <summary> /// Custom cell's content template as a PdfPCell /// </summary> /// <returns>Content as a PdfPCell</returns> public PdfPCell RenderingCell(CellAttributes attributes) { if (OnSelectSymbol == null) { throw new InvalidOperationException("Please set the OnSelectSymbol formula."); } var font = FontFactory.GetFont(WingdingsFontPath, BaseFont.IDENTITY_H, true, attributes.BasicProperties.PdfFont.Size, Font.NORMAL, attributes.BasicProperties.FontColor); var symbol = (int)OnSelectSymbol.Invoke(attributes.RowData.TableRowData); return(new PdfPCell(new Phrase(new Chunk((char)symbol, font)))); }
private FontSelector setFontStyles(CellAttributes attributes) { foreach (var font in attributes.BasicProperties.PdfFont.Fonts) { font.Color = _foreColor; if (_fontUnderline) { font.SetStyle(Font.UNDERLINE); } } return(attributes.BasicProperties.PdfFont.FontSelector); }
private static void runConditionalFormatFormula(CellAttributes pdfRptTableCellDefinition) { if (pdfRptTableCellDefinition.ItemTemplate != null && pdfRptTableCellDefinition.ItemTemplate.ConditionalFormatFormula != null) { var conditionalPdfCellAttributes = pdfRptTableCellDefinition.ItemTemplate.ConditionalFormatFormula(pdfRptTableCellDefinition.RowData.TableRowData); if (conditionalPdfCellAttributes != null) { conditionalPdfCellAttributes.MapBasicPropertiesTo(pdfRptTableCellDefinition.BasicProperties); applyTemplateColors(conditionalPdfCellAttributes, pdfRptTableCellDefinition.BasicProperties); } } }
/// <summary> /// Determines if the cell has the specified attribute. /// </summary> /// <param name="attribute">The attribute to check</param> /// <returns><c>true</c> if the cell has the specified attribute; otherwise, <c>false</c>.</returns> public bool HasAttribute(CellAttributes attribute) { return (Attribute & (uint)attribute) != 0; }