Esempio n. 1
0
        Tuple <double, double> CalculateFontSizeAndTextWidthForListedAnswers(double width, double fontSize)
        {
            var maxWidth =
                FontSizeCalculator.GetFontWidth("this is a text which has      already the correct width",
                                                answersListBox.FontFamily,
                                                fontSize);

            var sum = maxWidth * 2;

            return(sum < width
                       ? CalculateFontSizeAndTextWidth(width, fontSize + 0.5)
                       : Tuple.Create(maxWidth, fontSize));
        }
Esempio n. 2
0
        Tuple <double, double> CalculateFontSizeAndTextWidthForLikert(double width, double fontSize)
        {
            var answers = // All answers for current item
                          _questionnairePresenter.CurrentItem.Answers.Values
                          .Select(x => x.Text)
                          .ToList();

            answers.Add("aaaaaa"); // dummy if there is no text

            var maxWidth =
                answers
                .Select(answer => 1.6 * FontSizeCalculator.GetFontWidth(answer, answersListBox.FontFamily, fontSize))
                .Max();
            var sum = maxWidth * 1.3 * answers.Count();

            return(sum < width
                       ? CalculateFontSizeAndTextWidth(width, fontSize + 0.5)
                       : Tuple.Create(maxWidth, fontSize));
        }