Skip to content

Commit 1cafbaa

Browse files
committed
Fixed layout
1 parent b85b669 commit 1cafbaa

File tree

11 files changed

+66
-21
lines changed

11 files changed

+66
-21
lines changed

AskMeItems.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{C28B
1010
ProjectSection(SolutionItems) = preProject
1111
samples\ADS-K.txt = samples\ADS-K.txt
1212
samples\Coded1.txt = samples\Coded1.txt
13+
samples\HADS.txt = samples\HADS.txt
1314
samples\Likert.txt = samples\Likert.txt
1415
samples\Simple1.txt = samples\Simple1.txt
1516
EndProjectSection

packages/repositories.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<repositories>
33
<repository path="..\src\test\AskMeItems.Model.Specs\packages.config" />
4-
<repository path="..\src\test\AskMeItems.TextParser.Specs\packages.config" />
54
</repositories>

samples/HADS.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Instruction: Dieser Frageborgen bezieht sich auf die vergangene Woche. blabub
2+
HADS_A_1: Ich f�hle mich merkw�rdig.
3+
A) meistens - 3
4+
B) oft - 2
5+
C) von Zeit zu Zeit - 1
6+
D) �berhaupt nicht - 0
7+
HADS_D_10: Ich habe das Interesse an Pizza verloren.
8+
A) ja, das stimmt genau - 3
9+
B) ich k�mmere mich nicht so darum, wie ich sollte - 2
10+
C) eventuell k�mmere ich mich zu wenig darum - 1
11+
D) ich k�mmere mich so viel darum wie immer - 0

src/app/AskMeItems.Model/AskMeItems.Model.crunchproject.local.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
33
<RunPreBuildEvents>false</RunPreBuildEvents>
44
<RunPostBuildEvents>false</RunPostBuildEvents>
5+
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
56
<InstrumentAssembly>true</InstrumentAssembly>
67
<BuildOutputPath></BuildOutputPath>
78
<DefaultTestTimeout>60000</DefaultTestTimeout>

src/app/AskMeItems.WPF/AnswerItemPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@
7373
TextWrapping="Wrap"
7474
Name="itemTextBlock" />
7575
</Label>
76-
<ListBox Height="220"
76+
<ListBox Height="454"
7777
Margin="12,424,12,0"
7878
Name="answersListBox"
7979
FontSize="28"
8080
ScrollViewer.VerticalScrollBarVisibility="Disabled"
8181
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
8282
VerticalAlignment="Top"
8383
BorderBrush="{x:Null}"
84-
Background="{x:Null}">
84+
Background="{x:Null}" VerticalContentAlignment="Top">
8585
<ListBoxItem>Never</ListBoxItem>
8686
<ListBoxItem>Hardly ever</ListBoxItem>
8787
<ListBoxItem>Sometimes</ListBoxItem>

src/app/AskMeItems.WPF/AnswerItemPage.xaml.cs

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,37 @@ void SetListBoxStyle(QuestionnairePresenter questionnairePresenter)
5555

5656
public Tuple<double, double> CalculateFontSizeAndTextWidth(double width, double fontSize)
5757
{
58-
var answers = _questionnairePresenter.CurrentItem.Answers.Values.Select(x => x.Text).ToList();
58+
var answers = // All answers for current item
59+
_questionnairePresenter.CurrentItem.Answers.Values
60+
.Select(x => x.Text)
61+
.ToList();
62+
63+
if (_questionnairePresenter.Questionnaire.Type == QuestionnaireType.ListedAnswers)
64+
answers = // All answers for all items
65+
_questionnairePresenter.Questionnaire.Items
66+
.SelectMany(item => item.Answers)
67+
.Select(answer => answer.Value.Text)
68+
.ToList();
69+
5970
var maxWidth =
6071
answers
61-
.Select(answer => 1.6 * FontSizeCalculator.GetFontWidth(answer, answersListBox.FontFamily, fontSize))
72+
.Select(answer => FontSizeCalculator.GetFontWidth(answer, answersListBox.FontFamily, fontSize))
6273
.Max();
6374

64-
var sum = maxWidth * 1.3 * answers.Count();
75+
if (_questionnairePresenter.Questionnaire.Type == QuestionnaireType.Likert)
76+
maxWidth = 1.6 * maxWidth;
77+
else
78+
maxWidth = 1.2 * maxWidth;
79+
80+
var sum = maxWidth * 1.3;
81+
if (_questionnairePresenter.Questionnaire.Type == QuestionnaireType.Likert)
82+
sum = sum * answers.Count();
83+
if (_questionnairePresenter.Questionnaire.Type == QuestionnaireType.ListedAnswers)
84+
sum = sum * 1.5;
85+
6586
return sum < width
6687
? CalculateFontSizeAndTextWidth(width, fontSize + 0.5)
67-
: Tuple.Create(fontSize, maxWidth);
88+
: Tuple.Create(maxWidth, fontSize);
6889
}
6990

7091
void DisplayQuestion(double width, double height)
@@ -73,8 +94,8 @@ void DisplayQuestion(double width, double height)
7394
return;
7495

7596
var tuple = CalculateFontSizeAndTextWidth(width, 1);
76-
var buttonWidth = tuple.Item2;
77-
var fontSize = tuple.Item1;
97+
var checkboxWidth = tuple.Item1;
98+
var fontSize = tuple.Item2;
7899

79100
itemTextBlock.Text = _questionnairePresenter.CurrentItem.Text;
80101

@@ -90,20 +111,19 @@ void DisplayQuestion(double width, double height)
90111
answers.Values
91112
.Select(answer =>
92113
{
93-
var textBlock = new TextBlock
94-
{
95-
Text = answer.ToString(),
96-
FontSize = fontSize,
97-
TextAlignment = TextAlignment.Center
98-
};
99-
var item = new ListBoxItem
114+
var listBoxItem = new ListBoxItem
100115
{
101-
Content = textBlock,
102-
Width = buttonWidth,
116+
Content = new TextBlock
117+
{
118+
Text = answer.ToString(),
119+
FontSize = fontSize,
120+
TextAlignment = TextAlignment.Center
121+
},
122+
Width = checkboxWidth,
103123
HorizontalContentAlignment = HorizontalAlignment.Center
104124
};
105-
_itemsDict.Add(item, answer);
106-
return item;
125+
_itemsDict.Add(listBoxItem, answer);
126+
return listBoxItem;
107127
});
108128

109129
foreach (var listBoxItem in items)

src/app/AskMeItems.WPF/AskMeItems.WPF.crunchproject.local.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
33
<RunPreBuildEvents>false</RunPreBuildEvents>
44
<RunPostBuildEvents>false</RunPostBuildEvents>
5+
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
56
<InstrumentAssembly>false</InstrumentAssembly>
67
<BuildOutputPath></BuildOutputPath>
78
<DefaultTestTimeout>60000</DefaultTestTimeout>

src/app/AskMeItems.WPF/app.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<value>..\..\..\..\..\..\samples\</value>
1212
</setting>
1313
<setting name="Questionnaire" serializeAs="String">
14-
<value>ADS-K.txt</value>
14+
<value>HADS.txt</value>
1515
</setting>
1616
<setting name="ResultsPath" serializeAs="String">
1717
<value>..\..\..\..\..\..\results\</value>

src/test/AskMeItems.Model.Specs/AskMeItems.Model.Specs.crunchproject.local.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
33
<RunPreBuildEvents>false</RunPreBuildEvents>
44
<RunPostBuildEvents>false</RunPostBuildEvents>
5+
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
56
<InstrumentAssembly>true</InstrumentAssembly>
67
<BuildOutputPath></BuildOutputPath>
78
<DefaultTestTimeout>60000</DefaultTestTimeout>

src/test/AskMeItems.Model.Specs/AskMeItems.Model.Specs.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
<Link>Data\ADS-K.txt</Link>
9090
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
9191
</Content>
92+
<Content Include="..\..\..\samples\HADS.txt">
93+
<Link>Data\HADS.txt</Link>
94+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
95+
</Content>
9296
<Content Include="..\..\..\samples\Likert.txt">
9397
<Link>Data\Likert.txt</Link>
9498
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

0 commit comments

Comments
 (0)