Esempio n. 1
0
        private string BuildNumericLine(NumericLayoutVM numericLayout)
        {
            double sidePartLength = 2;
            double midPartLength  = 4;


            int?   length      = numericLayout.Length;
            double totalLength = 30.0; //default 3 cm

            if (length != null && length.HasValue)
            {
                totalLength = length.Value * 10; //Unit conversion: cm->mm
            }

            double midLength = totalLength - sidePartLength * 2;

            string mid       = "";
            double curLength = 0;

            while (curLength < midLength)
            {
                curLength += midPartLength;
                mid       += Resources.WordMidMark;
            }

            return(Resources.WordStartMark + mid + Resources.WordEndMark);
        }
Esempio n. 2
0
        private void WriteNumerResponse(Body body, QuestionVM question)
        {
            ResponseVM      response      = question.Response;
            NumericLayoutVM numericLayout = (NumericLayoutVM)response.Layout;


            Table    table    = CreateFilledTable();
            TableRow tableRow = new TableRow();

            table.Append(tableRow);
            if (numericLayout.MeasurementMethod == NumericLayoutMeasurementMethod.Number)
            {
                //when filling in a number
                int count = CalcNumericColumnCount(response);
                tableRow.Append(CreateNumberInputCells(numericLayout.Style, count));

                if (!string.IsNullOrEmpty(numericLayout.Unit))
                {
                    tableRow.Append(CreateNoBorderCell(numericLayout.Unit));
                }
                tableRow.Append(CreateLastNoBorderCell());
            }
            else
            {
                string leftStatement = ToSideStatement(numericLayout.LeftStatement);
                tableRow.Append(CreateNoBorderCell(leftStatement));

                tableRow.Append(CreateNoBorderCell(BuildNumericLine(numericLayout)));

                string rightStatement = ToSideStatement(numericLayout.RightStatement);
                tableRow.Append(CreateNoBorderCell(rightStatement));

                tableRow.Append(CreateLastNoBorderCell());
            }

            body.Append(table);
        }