private Cell MultipleLineFieldToCell(Cell cell, Boolean forCompile, dtoSubmissionValueField item, String emptyItem, String maxCharInfo)
        {
            Chunk chunk = new Chunk((forCompile ? "" : (item.Value == null || String.IsNullOrEmpty(item.Value.Text) ? emptyItem : item.Value.Text)), GetFont(ItemType.Paragraph));

            if (forCompile)
            {
                Table tInput = GetTable(1, 1);
                Cell  cInput = new Cell();
                if (item.Field.MaxLength > 4000)
                {
                    cInput.Rowspan = 15;
                }
                else if (item.Field.MaxLength > 2000)
                {
                    cInput.Rowspan = 10;
                }
                else
                {
                    cInput.Rowspan = 5;
                }
                tInput.AddCell(cInput);
                cell.Add(tInput);
            }
            else
            {
                cell.Add(chunk);
            }
            if (item.Field.MaxLength > 0)
            {
                cell.Add(GetParagraph(String.Format(maxCharInfo, item.Field.MaxLength), GetFont(ItemType.Caption)));
            }
            return(cell);
        }
Exemple #2
0
        private void ManipulatePdf(string dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
            Document    doc    = new Document(pdfDoc, new PageSize(300, 160));

            Table table = new Table(UnitValue.CreatePercentArray(2)).UseAllAvailableWidth();

            table.SetMarginTop(10);

            Cell cell = new Cell();

            cell.Add(new Paragraph("G"));
            cell.Add(new Paragraph("R"));
            cell.Add(new Paragraph("O"));
            cell.Add(new Paragraph("U"));
            cell.Add(new Paragraph("P"));
            table.AddCell(cell);

            Table inner = new Table(UnitValue.CreatePercentArray(1)).UseAllAvailableWidth();

            inner.SetKeepTogether(true);
            inner.AddCell("row 1");
            inner.AddCell("row 2");
            inner.AddCell("row 3");
            inner.AddCell("row 4");
            inner.AddCell("row 5");

            cell = new Cell().Add(inner);
            cell.SetPadding(0);
            table.AddCell(cell);

            doc.Add(table);

            doc.Close();
        }
Exemple #3
0
        private void AddCompanyInfo()
        {
            if (companyName == null && companyInfo == null)
            {
                return;
            }

            Table table = new Table(1);

            table.Offset          = 5;
            table.WidthPercentage = 100;
            table.Cellpadding     = 2;
            table.Border          = Rectangle.NO_BORDER;
            Cell cell = new Cell();

            if (companyName != null)
            {
                cell.Add(new Phrase(defaultLeading + 2, companyName + "\n", companyFontBold));
            }
            if (companyInfo != null)
            {
                cell.Add(new Paragraph(defaultLeading, companyInfo + "\n", companyFont));
            }
            cell.VerticalAlignment = Element.ALIGN_TOP;
            cell.Border            = Rectangle.NO_BORDER;
            table.AddCell(cell);
            document.Add(table);
        }
Exemple #4
0
        private void ProcessSnapshotWithArrays(short snap)
        {
            DebugOut.PrintLine("PROCESSING SNAPSHOT WITH ARRAYS" + snap);
            // using this only if needed
            HsmlReader hsmlReader = new HsmlReader();

            // and make the directory, just to be safe
            try
            {
                Directory.CreateDirectory(GetSnapDir(outPath, snap));
            }
            catch (IOException e)
            {
                System.Console.WriteLine(e.Message);
            }

            int curFile = firstSnapshotFile; // index of current read/write file
            int numFile = 0;
            if (useHsml)
                hsmlReader = new HsmlReader(GetHsmlPath(inPath, snap));

            if (lastSnapshotFile < firstSnapshotFile)
            {
                lastSnapshotFile = firstSnapshotFile;
                numFile = -1;
            }
            while (curFile <= lastSnapshotFile)
            {
                DebugOut.PrintLine("..file " + curFile + "/" + lastSnapshotFile);

                string filename = "";
                try
                {
                    filename = GetSnapFile(inPath, snap, snapshotFilePrefix, curFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    return;
                }
                // now load the file
                SnapFile curSnap = new SnapFile(filename, samplingRate);
                // and open the stream for writing
                using (SqlBinaryWriter binwriter = new SqlBinaryWriter(new FileStream(GetSnapDefault(outPath, snap, snapshotFilePrefix, curFile), FileMode.Create)))
                {
                    Structs[] parts = new Structs[curSnap.numSample];
                    // now write each particle into the array
                    for (int i = 0; i < curSnap.numSample; i++)
                    {
                        parts[i].x = curSnap.pos[i, 0];
                        parts[i].y = curSnap.pos[i, 1];
                        parts[i].z = curSnap.pos[i, 2];
                        parts[i].vx = curSnap.vel[i, 0];
                        parts[i].vy = curSnap.vel[i, 1];
                        parts[i].vz = curSnap.vel[i, 2];
                        parts[i].snapnum = snap;
                        parts[i].id = curSnap.id[i];
                        // add in highest-order bit
                        parts[i].id |= ((UInt64)curSnap.nLargeSims[1]) << 32;
                        // make ph-key
                        parts[i].phkey = GetPHKey(parts[i].x, parts[i].y, parts[i].z);
                        // read hsml, if desired
                        if (useHsml) // TODO fix this part for random sampling
                        {
                            parts[i].hsml = hsmlReader.GetHsml();
                            parts[i].veldisp = hsmlReader.GetVelDisp();
                            parts[i].density = hsmlReader.GetDensity();
                            // and advance read pointer
                            hsmlReader.Next();
                        }
                    }
                    // now sort before writing files
                    // TBD this may not be necessary if the particles
                    // are sorted in the files already.
                    Array.Sort<Structs>(parts, new ParticleComparator());

                    Cell cell = new Cell(snap);
                    int currentPHkey = -1;
                    for (int i = 0; i < curSnap.numSample; i++)
                    {
                        if (parts[i].phkey != currentPHkey)
                        {
                            if(cell.Count > 0)
                                binwriter.Write(cell);
                            currentPHkey = parts[i].phkey;
                            cell.Init(currentPHkey);
                        }
                        cell.Add(parts[i]);
                    }
                    if (cell.Count > 0)
                        binwriter.Write(cell);

                    // and add a bulk insert
                    DebugOut.AddCommand(GetSnapDefault(outPath, snap, snapshotFilePrefix, curFile), snapshotTable);

                    DebugOut.PrintLine("..wrote " + curSnap.numSample + "/" + curSnap.numTotals[1] + " points");
                }

                // and set numFiles
                if (numFile == -1)
                {
                    numFile = (int)curSnap.numSubfiles - firstSnapshotFile + 1;
                    lastSnapshotFile = numFile - 1;
                }

                curFile++;
                // avoid outofmemory errors
                GC.Collect();
                GC.WaitForPendingFinalizers();

            }
        }