Esempio n. 1
0
        /// <summary>
        /// 获取标签生成器
        /// </summary>
        protected override TagBuilder GetTagBuilder()
        {
            var builder = new CellBuilder();

            Config(builder);
            return(builder);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a file containing the exported identity information
        /// Encoding is iso-8859-1
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        private byte[] GetIdentityCsv(List <ExportItem> items)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("title,firstName,middleName,lastName,address1,address2,address3,city,state,postalCode,country,company,email,phone,ssn,username,passportNumber,licenseNumber");
            foreach (ExportItem item in items)
            {
                builder.AppendLine(CellBuilder.BuildCells(
                                       item.Object.Identity.Title,
                                       item.Object.Identity.FirstName,
                                       item.Object.Identity.MiddleName,
                                       item.Object.Identity.LastName,
                                       item.Object.Identity.Adress1,
                                       item.Object.Identity.Adress2,
                                       item.Object.Identity.Adress3,
                                       item.Object.Identity.City,
                                       item.Object.Identity.State,
                                       item.Object.Identity.PostalCode,
                                       item.Object.Identity.Country,
                                       item.Object.Identity.Company,
                                       item.Object.Identity.EMail,
                                       item.Object.Identity.Phone,
                                       item.Object.Identity.SSN,
                                       item.Object.Identity.Username,
                                       item.Object.Identity.PassportNumber,
                                       item.Object.Identity.LicenseNumber).Join(","));
            }

            return(Encoding.GetEncoding("iso-8859-1").GetBytes(builder.ToString()));
        }
Esempio n. 3
0
        /// <summary>
        /// 添加单元格配置
        /// </summary>
        private void AddCell(TagBuilder builder)
        {
            if (_autoCreateCell == false)
            {
                return;
            }
            var cellBuilder = new CellBuilder();

            builder.AppendContent(cellBuilder);
            var type   = _config.GetValue <TableColumnType?>(UiConst.Type);
            var column = _config.GetValue(UiConst.Column);

            switch (type)
            {
            case TableColumnType.Bool:
                AddBoolCell(cellBuilder, column);
                return;

            case TableColumnType.Date:
                AddDateCell(cellBuilder, column);
                return;

            default:
                AddDefaultCell(cellBuilder, column);
                return;
            }
        }
Esempio n. 4
0
 public override void Do()
 {
     if (Cell.StoreEnegry > MoveEnergy)
     {
         Cell.StoreEnegry -= MoveEnergy;
         CellBuilder.TryToMove(Cell, GetDirection());
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (!God.Cells.Any())
     {
         var cell = CellBuilder.GetDefaultCell();
         God.Cells.Add(cell);
         Burn(cell);
     }
 }
Esempio n. 6
0
        public void BuildEmptyCube()
        {
            CellBuilder builder = new CellBuilder(new GameMaster(0));

            builder.BuildCells(new Form1(), new Panel());
            int cells = 0;

            Assert.AreEqual(cells, builder.GameMaster.Cells.Count);
        }
Esempio n. 7
0
        /// <summary>
        /// 添加单元格配置
        /// </summary>
        private void AddCell(TagBuilder builder)
        {
            if (_autoCreateCell == false)
            {
                return;
            }
            var cellBuilder = new CellBuilder();

            cellBuilder.AppendContent($"{{{{ row.{_config.GetValue( UiConst.Column )} }}}}");
            builder.AppendContent(cellBuilder);
        }
Esempio n. 8
0
        /// <summary>
        /// 配置单选框单元格
        /// </summary>
        private void ConfigRadioCell(TagBuilder builder)
        {
            var radioBuilder = new RadioButtonBuilder();

            radioBuilder.AddAttribute("(click)", "$event.stopPropagation()");
            radioBuilder.AddAttribute("(change)", $"$event?{_tableId}.checkRow(row):null");
            radioBuilder.AddAttribute("[checked]", $"{_tableId}.checkedSelection.isSelected(row)");
            var cellBuilder = new CellBuilder();

            cellBuilder.AppendContent(radioBuilder);
            builder.AppendContent(cellBuilder);
        }
Esempio n. 9
0
        /// <summary>
        /// 配置复选框单元格
        /// </summary>
        private void ConfigCheckboxCell(TagBuilder builder)
        {
            var checkBoxBuilder = new CheckBoxBuilder();

            checkBoxBuilder.AddAttribute("(click)", "$event.stopPropagation()");
            checkBoxBuilder.AddAttribute("(change)", $"$event?{_tableId}.selection.toggle(row):null");
            checkBoxBuilder.AddAttribute("[checked]", $"{_tableId}.selection.isSelected(row)");
            var cellBuilder = new CellBuilder();

            cellBuilder.AppendContent(checkBoxBuilder);
            builder.AppendContent(cellBuilder);
        }
Esempio n. 10
0
        /// <summary>
        /// Returns a file containing the exported secure notes
        /// Encoding is iso-8859-1
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        private byte[] GetSecureNoteCsv(List <ExportItem> items)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("title,note");
            foreach (ExportItem item in items)
            {
                builder.AppendLine(CellBuilder.BuildCells(
                                       item.Object.Name,
                                       item.Object.Notes).Join(","));
            }

            return(Encoding.GetEncoding("iso-8859-1").GetBytes(builder.ToString()));
        }
Esempio n. 11
0
        public override void Do()
        {
            if (Cell.StoreEnegry > BiteEnergyCost)
            {
                var cells = CellBuilder.NearCells(Cell);
                //TODO
                if (!cells.Any())
                {
                    return;
                }

                var index = _random.Next(0, cells.Count());
                var enemy = cells[index];
                enemy.LifePoint  -= 3;
                Cell.StoreEnegry += BiteEnergyProfit;
            }
        }
Esempio n. 12
0
        private ICell CreateCellAndLinkItToCellsInItsRowColAndSqr()
        {
            var rowStub = MockRepository.GenerateStub <IRow>();
            var colStub = MockRepository.GenerateStub <ICol>();
            var sqrStub = MockRepository.GenerateStub <ISqr>();

            rowStub.Expect(x => x.Cells).Return(new List <ICell> {
                _otherCellInMyRowStub
            });
            colStub.Expect(x => x.Cells).Return(new List <ICell> {
                _otherCellInMyColStub
            });
            sqrStub.Expect(x => x.Cells).Return(new List <ICell> {
                _otherCellInMySqrStub
            });

            return(CellBuilder.CreateCell(11).LinkedTo(rowStub).LinkedTo(colStub).LinkedTo(sqrStub));
        }
Esempio n. 13
0
        /// <summary>
        /// Returns a file that contains credit card information
        /// Encoding is iso-8859-1
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        private byte[] GetCardCsv(List <ExportItem> items)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("cardholderName,brand,number,expMonth,expYear,code");
            foreach (ExportItem item in items)
            {
                builder.AppendLine(CellBuilder.BuildCells(
                                       item.Object.Card.CardholderName,
                                       item.Object.Card.Brand,
                                       item.Object.Card.Number,
                                       item.Object.Card.ExpiryMonth,
                                       item.Object.Card.ExpiryYear,
                                       item.Object.Card.Code).Join(","));
            }

            return(Encoding.GetEncoding("iso-8859-1").GetBytes(builder.ToString()));
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            var rule    = new Rule();
            var builder = new CellBuilder(rule);
            var cells   = builder.BuildCells(
                rowLength: 20,
                colLength: 20,
                percentOfLivingCells: 30);
            var grid   = new Grid(cells);
            var writer = new StreamWriter(Console.OpenStandardOutput(), Encoding.ASCII);
            var drawer = new ConsoleDrawer(writer);

            while (!Console.KeyAvailable)
            {
                drawer.DrawCells(grid.Cells);
                grid.ToNextGen();
                Thread.Sleep(200);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Returns a file that contains credit card information
        /// Encoding is iso-8859-1
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        private byte[] GetCardCsv(List <ExportItem> items)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("title,card number,expiry date (MM/YYYY),cardholder name,PIN,bank name,CVV,notes");
            foreach (ExportItem item in items)
            {
                builder.AppendLine(CellBuilder.BuildCells(
                                       item.Object.Card.Brand,
                                       item.Object.Card.Number,
                                       new DateTime(int.Parse(item.Object.Card.ExpiryYear), int.Parse(item.Object.Card.ExpiryMonth), 1).ToString("MM/yyyy"),
                                       item.Object.Card.CardholderName,
                                       item.Object.Card.Code,
                                       string.Empty,
                                       string.Empty,
                                       item.Object.Notes).Join(","));
            }

            return(Encoding.GetEncoding("iso-8859-1").GetBytes(builder.ToString()));
        }
Esempio n. 16
0
        public void Cell()
        {
            CellBuilder configBuilder = new CellBuilder(null);
            CellConfig  config        = null;
            TableEntity entity        = new TableEntity();

            _builderFactory.CellBuilder(Arg.Do <CellConfig>(c => config = c)).Returns(configBuilder);

            CellBuilder builder = _builder.Cell(() => entity.Property);

            _builderFactory.Received(1).CellBuilder(Arg.Any <CellConfig>());
            _configs.Should().HaveCount(1);
            _configs.Should().ContainKey("Property");
            CellConfig cellConfig = _configs["Property"];

            cellConfig.Should().BeSameAs(config);
            cellConfig.CssClasses.Should().BeEmpty();
            cellConfig.State.Should().Be(ContextualState.Default);
            builder.Should().BeSameAs(configBuilder);
        }
Esempio n. 17
0
        /// <summary>
        /// Returns a file containing login information
        /// Encoding is iso-8859-1
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        private byte[] GetLoginCsv(List <ExportItem> items)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("folder,favorite,type,name,notes,fields,login_uri,login_username,login_password,login_totp");
            foreach (ExportItem item in items)
            {
                builder.AppendLine(CellBuilder.BuildCells(
                                       item.Folder?.Name,
                                       item.Object.IsFavorite ? 1 : 0,
                                       item.Object.Type.ToString(),
                                       item.Object.Name,
                                       item.Object.Notes,
                                       item.Object.Fields?.Select(x => $"{x.Name}: {x.Value}").Join("; "),
                                       item.Object.Login?.Uris?.Select(x => x.Uri).Join(";"),
                                       item.Object.Login?.Username,
                                       item.Object.Login?.Password,
                                       item.Object.Login?.Totp).Join(","));
            }

            return(Encoding.GetEncoding("iso-8859-1").GetBytes(builder.ToString()));
        }
Esempio n. 18
0
        /// <summary>
        /// Returns a file containing login information
        /// Encoding is iso-8859-1
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        private byte[] GetLoginCsv(List <ExportItem> items)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("title,website,username,password,notes");
            foreach (ExportItem item in items)
            {
                List <string> lstCells = new List <string>()
                {
                    item.Object.Name,
                    item.Object.Login?.Uris?.Select(x => x.Uri).Join(";"),
                    item.Object.Login?.Username,
                    item.Object.Login?.Password,
                    item.Object.Notes
                };

                lstCells.AddRangeIfNotNull(item.Object.Fields?.Select(x => $"{x.Name}:{x.Value}"));

                builder.AppendLine(CellBuilder.BuildCells(lstCells.ToArray()).Join(","));
            }

            return(Encoding.GetEncoding("iso-8859-1").GetBytes(builder.ToString()));
        }
Esempio n. 19
0
    public static void SetTemplate(Stream templateStream)
    {
        Template = templateStream.ReadAllBytes();

        MemoryStream memoryStream = new MemoryStream();

        memoryStream.WriteAllBytes(Template);

        using (SpreadsheetDocument document = SpreadsheetDocument.Open(memoryStream, true))
        {
            document.PackageProperties.Creator        = "";
            document.PackageProperties.LastModifiedBy = "";

            WorkbookPart workbookPart = document.WorkbookPart !;

            WorksheetPart worksheetPart = document.GetWorksheetPartById("rId1");
            Worksheet     worksheet     = worksheetPart.Worksheet;

            CellBuilder = new CellBuilder()
            {
                CellFormatCount = document.WorkbookPart !.WorkbookStylesPart !.Stylesheet.CellFormats !.Count !,
                DefaultStyles   = new Dictionary <DefaultStyle, UInt32Value>
                {
                    { DefaultStyle.Title, worksheet.FindCell("A1").StyleIndex ! },
Esempio n. 20
0
    public static void WriteDataInExcelFile(ResultTable results, Stream stream)
    {
        if (results == null)
        {
            throw new ApplicationException(ExcelMessage.ThereAreNoResultsToWrite.NiceToString());
        }

        using (SpreadsheetDocument document = SpreadsheetDocument.Open(stream, true))
        {
            document.PackageProperties.Creator        = "";
            document.PackageProperties.LastModifiedBy = "";

            WorkbookPart workbookPart = document.WorkbookPart !;

            if (workbookPart.CalculationChainPart != null)
            {
                workbookPart.Workbook.CalculationProperties !.ForceFullCalculation  = true;
                workbookPart.Workbook.CalculationProperties !.FullCalculationOnLoad = true;
            }

            WorksheetPart worksheetPart = document.GetWorksheetPartBySheetName(ExcelMessage.Data.NiceToString());

            CellBuilder cb = PlainExcelGenerator.CellBuilder;

            SheetData sheetData = worksheetPart.Worksheet.Descendants <SheetData>().SingleEx();

            List <ColumnData> columnEquivalences = GetColumnsEquivalences(document, sheetData, results);

            UInt32Value headerStyleIndex = worksheetPart.Worksheet.FindCell("A1").StyleIndex !;

            //Clear sheetData from the template sample data
            sheetData.InnerXml = "";

            sheetData.Append(new Sequence <Row>()
            {
                (from columnData in columnEquivalences
                 select cb.Cell(columnData.Column.Column.DisplayName, headerStyleIndex)).ToRow(),

                from r in results.Rows
                select(from columnData in columnEquivalences
                       select cb.Cell(r[columnData.Column], cb.GetDefaultStyle(columnData.Column.Column.Type), columnData.StyleIndex)).ToRow()
            }.Cast <OpenXmlElement>());

            var pivotTableParts = workbookPart.PivotTableCacheDefinitionParts
                                  .Where(ptpart => ptpart.PivotCacheDefinition.Descendants <WorksheetSource>()
                                         .Any(wss => wss.Sheet !.Value == ExcelMessage.Data.NiceToString()));

            foreach (PivotTableCacheDefinitionPart ptpart in pivotTableParts)
            {
                PivotCacheDefinition pcd = ptpart.PivotCacheDefinition;
                WorksheetSource      wss = pcd.Descendants <WorksheetSource>().FirstEx();
                wss.Reference !.Value = "A1:" + GetExcelColumn(columnEquivalences.Count(ce => !ce.IsNew) - 1) + (results.Rows.Count() + 1).ToString();

                pcd.RefreshOnLoad = true;
                pcd.SaveData      = false;
                pcd.Save();
            }

            workbookPart.Workbook.Save();
            document.Close();
        }
    }