Skip to content

Commit

Permalink
Changed from pixel to centimeter on user interfaces and back to pixel…
Browse files Browse the repository at this point in the history
… on test execution
  • Loading branch information
fabiola-m committed May 24, 2018
1 parent 5f5bc9c commit cf095b4
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 66 deletions.
15 changes: 13 additions & 2 deletions StroopTest/Controllers/ExpositionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ public static void BeginMatchingTest(string programName, string participantName,
}
}

public static PictureBox InitializeImageBox(int stimuliSize, Image image, bool expandImage)
public static PictureBox InitializeImageBox(double stimuliSize, Image image, bool expandImage, Form form)
{
PictureBox newPictureBox = new PictureBox();
int size = CentimeterToPixel(stimuliSize, form);
newPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
newPictureBox.Size = new Size(stimuliSize, stimuliSize);
newPictureBox.Size = new Size(size, size);

newPictureBox.Image = image;
newPictureBox.Enabled = true;
Expand Down Expand Up @@ -229,6 +230,16 @@ public static void formSecondScreen(Form form)

}

public static int CentimeterToPixel(double Centimeter, Form form)
{
double pixel = -1;
using (Graphics g = form.CreateGraphics())
{
pixel = Centimeter * g.DpiY / 2.54d;
}
return (int)pixel;
}


}
}
19 changes: 10 additions & 9 deletions StroopTest/Models/Tests/Reaction/ReactionProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TestPlatform.Models
{
class ReactionProgram : Program
{
private Int32 stimuluSize; // [3]
private double stimuluSize; // [3]
private Boolean isBeeping; // [9]
private Boolean beepingRandom; // [19]
private Int32 beepDuration; // [10]
Expand Down Expand Up @@ -43,7 +43,7 @@ public override string ToString()
/// <summary>
/// This constructor is used to create a reaction program with shapes
/// </summary>
public ReactionProgram(string programName, int expositionTime, int numExpositions, int stimuluSize, int intervalTime,
public ReactionProgram(string programName, int expositionTime, int numExpositions, double stimuluSize, int intervalTime,
bool isBeeping, int beepDuration, string stimulusColor,
string fixPoint, string backgroundColor, string fixPointColor, bool intervalTimeRandom,
string stimuluShape, bool beepRandom, int numberPositions,
Expand Down Expand Up @@ -102,7 +102,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
{
// ReactionProgram properties
this.expositionType = "words";
this.stimuluSize = stimuluSize;
this.fontSize = stimuluSize;
this.isBeeping = isBeeping;
this.beepDuration = beepDuration;
this.FontSize = fontSize;
Expand All @@ -125,10 +125,11 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
this.setColorListFile(colorList);
}

//default configurations for shapes version of ReactionProgram
//default configurations for words version of ReactionProgram
this.setAudioListFile("false");
this.setImageListFile("false");
this.ExpandImage = false;
this.stimuluSize = 10;

// Program properties
this.programName = programName;
Expand All @@ -146,7 +147,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
/// <summary>
/// This constructor is used to create a reaction program with image type
/// </summary>
public ReactionProgram(string programName, int expositionTime, int numExpositions, int stimuluSize, int intervalTime,
public ReactionProgram(string programName, int expositionTime, int numExpositions, double stimuluSize, int intervalTime,
bool isBeeping, int beepDuration,
string fixPoint, string backgroundColor, string fixPointColor, bool intervalTimeRandom,
string imageList, bool beepRandom, int numberPositions,
Expand Down Expand Up @@ -188,7 +189,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
/// <summary>
/// This constructor is used to create a reaction program with image and words
/// </summary>
public ReactionProgram(string programName, int expositionTime, int numExpositions, int stimuluSize, int intervalTime,
public ReactionProgram(string programName, int expositionTime, int numExpositions, double stimuluSize, int intervalTime,
bool isBeeping, int beepDuration,
string fixPoint, string backgroundColor, string fixPointColor, bool intervalTimeRandom,
string imageList, string wordList, string colorList, bool beepRandom, int numberPositions,
Expand Down Expand Up @@ -295,7 +296,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
/// </summary>
public ReactionProgram(string programName, int expositionTime, int numExpositions, int intervalTime,
string fixPoint, string backgroundColor, string fixPointColor, bool intervalTimeRandom, int numberPositions,
string responseType, int stimulusSize, bool isExpositionRandom,string audioListFile, string imageListFile, bool expandImage, bool sstInterval)
string responseType, double stimulusSize, bool isExpositionRandom,string audioListFile, string imageListFile, bool expandImage, bool sstInterval)
{

// ReactionProgram properties
Expand Down Expand Up @@ -331,7 +332,7 @@ public ReactionProgram(string programName, int expositionTime, int numExposition
this.intervalTimeRandom = intervalTimeRandom;
}

public int StimuluSize
public double StimuluSize
{
get
{
Expand Down Expand Up @@ -587,7 +588,7 @@ public void readProgramFile(string filepath)
{
NumExpositions = int.Parse(config[1]);
ExpositionTime = int.Parse(config[2]);
StimuluSize = int.Parse(config[3]);
StimuluSize = double.Parse(config[3]);
IntervalTime = int.Parse(config[4]);
setWordListFile(config[5]);
setColorListFile(config[6]);
Expand Down
4 changes: 2 additions & 2 deletions StroopTest/Views/MatchingPages/MatchingExposition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private void drawModel()
else
{
modelControl = ExpositionController.InitializeImageBox(executingTest.ProgramInUse.StimuluSize,
Image.FromFile(matchingGroups.ElementAt(groupCounter).getModelName()), false);
Image.FromFile(matchingGroups.ElementAt(groupCounter).getModelName()), false, this);
size = modelControl.Size;
}

Expand Down Expand Up @@ -650,7 +650,7 @@ private void drawStimulu()
}
else
{
newStimulu = ExpositionController.InitializeImageBox(executingTest.ProgramInUse.StimuluSize, Image.FromFile(element), false);
newStimulu = ExpositionController.InitializeImageBox(executingTest.ProgramInUse.StimuluSize, Image.FromFile(element), false, this);
newStimulu.Tag = element;
size = modelControl.Size;
}
Expand Down
25 changes: 15 additions & 10 deletions StroopTest/Views/ReactionPages/FormReactExposition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ private void drawWord()
private void drawImage()
{
imgPictureBox = ExpositionController.InitializeImageBox(executingTest.ProgramInUse.StimuluSize, Image.FromFile(imagesList[imageCounter]),
executingTest.ProgramInUse.ExpandImage);
executingTest.ProgramInUse.ExpandImage, this);
Point screenPosition = ScreenPosition(imgPictureBox.Size);
imgPictureBox.Location = screenPosition;

Expand Down Expand Up @@ -888,8 +888,9 @@ private Point randomScreenEightPositions(Size size)
// draw on screen filled square stimulus
private void drawFullSquareShape()
{
float widthSquare = executingTest.ProgramInUse.StimuluSize;
float heightSquare = executingTest.ProgramInUse.StimuluSize;
int size = ExpositionController.CentimeterToPixel(executingTest.ProgramInUse.StimuluSize, this);
float widthSquare = size;
float heightSquare = size;

SolidBrush myBrush = new SolidBrush(ColorTranslator.FromHtml(colorsList[colorCounter]));
Graphics formGraphicsSquare = CreateGraphics();
Expand All @@ -908,8 +909,9 @@ private void drawFullSquareShape()

private void drawSquareShape()
{
float widthSquare = executingTest.ProgramInUse.StimuluSize;
float heightSquare = executingTest.ProgramInUse.StimuluSize;
int size = ExpositionController.CentimeterToPixel(executingTest.ProgramInUse.StimuluSize, this);
float widthSquare = size;
float heightSquare = size;

Pen myPen = new Pen(ColorTranslator.FromHtml(colorsList[colorCounter]));
Graphics formGraphicsSquare = CreateGraphics();
Expand All @@ -928,8 +930,9 @@ private void drawSquareShape()

private void drawFullCircleShape()
{
float widthEllipse = executingTest.ProgramInUse.StimuluSize;
float heightEllipse = executingTest.ProgramInUse.StimuluSize;
int size = ExpositionController.CentimeterToPixel(executingTest.ProgramInUse.StimuluSize, this);
float widthEllipse = size;
float heightEllipse = size;

SolidBrush myBrush = new SolidBrush(ColorTranslator.FromHtml(colorsList[colorCounter]));
Graphics formGraphicsEllipse = CreateGraphics();
Expand All @@ -948,8 +951,9 @@ private void drawFullCircleShape()

private void drawCircleShape()
{
float widthEllipse = executingTest.ProgramInUse.StimuluSize;
float heightEllipse = executingTest.ProgramInUse.StimuluSize;
int size = ExpositionController.CentimeterToPixel(executingTest.ProgramInUse.StimuluSize, this);
float widthEllipse = size;
float heightEllipse = size;

Pen myPen = new Pen(ColorTranslator.FromHtml(colorsList[colorCounter]));
Graphics formGraphicsEllipse = CreateGraphics();
Expand Down Expand Up @@ -1008,7 +1012,8 @@ private void drawFullTriangleShape()
private Point[] createTrianglePoints()
{
int[] clientMiddle = { (ClientSize.Width / 2), (ClientSize.Height / 2) };
int heightTriangle = executingTest.ProgramInUse.StimuluSize;
int size = ExpositionController.CentimeterToPixel(executingTest.ProgramInUse.StimuluSize, this);
int heightTriangle = size;
Point screenPosition = this.ScreenPosition(new Size(heightTriangle, heightTriangle));
screenPosition.X -= heightTriangle / 3;
screenPosition.Y += heightTriangle / 2;
Expand Down
24 changes: 10 additions & 14 deletions StroopTest/Views/ReactionPages/FormTRConfig.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions StroopTest/Views/ReactionPages/FormTRConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void editProgram()
intervalTime.Value = editProgram.IntervalTime;
beepingCheckbox.Checked = editProgram.IsBeeping;
beepDuration.Value = editProgram.BeepDuration;
stimuluSize.Value = editProgram.StimuluSize;
stimuluSize.Value = (decimal) editProgram.StimuluSize;
fontSizeUpDown.Value = editProgram.FontSize;
positionsBox.SelectedIndex = editProgram.NumberPositions - 1;
expandImageCheck.Checked = editProgram.ExpandImage;
Expand Down Expand Up @@ -383,7 +383,7 @@ private ReactionProgram configureNewProgram()
// Program type "shapes"
case 0:
newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value),
Convert.ToInt32(numExpo.Value), Convert.ToInt32(stimuluSize.Value),
Convert.ToInt32(numExpo.Value), Convert.ToDouble(stimuluSize.Value),
Convert.ToInt32(intervalTime.Value),
beepingCheckbox.Checked,
Convert.ToInt32(beepDuration.Value), stimulusColorCheck(),
Expand All @@ -394,7 +394,7 @@ private ReactionProgram configureNewProgram()
// Program type "words"
case 1:
newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value),
Convert.ToInt32(numExpo.Value), Convert.ToInt32(stimuluSize.Value),
Convert.ToInt32(numExpo.Value), Convert.ToInt32(fontSizeUpDown.Value),
Convert.ToInt32(intervalTime.Value),
beepingCheckbox.Checked,
Convert.ToInt32(beepDuration.Value), stimulusColorCheck(),
Expand All @@ -406,7 +406,7 @@ private ReactionProgram configureNewProgram()

// Program type "images"
case 2:
newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(stimuluSize.Value),
newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToDouble(stimuluSize.Value),
Convert.ToInt32(intervalTime.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value),
fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, openImgListButton.Text,
randomBeepCheck.Checked, Convert.ToInt32(positionsBox.Text), responseType(), isRandomExposition.Checked,
Expand All @@ -415,7 +415,7 @@ private ReactionProgram configureNewProgram()

// Program type "imageAndWord"
case 3:
newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(stimuluSize.Value),
newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToDouble(stimuluSize.Value),
Convert.ToInt32(intervalTime.Value), beepingCheckbox.Checked, Convert.ToInt32(beepDuration.Value),
fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked,
openImgListButton.Text, openWordListButton.Text, openColorListButton.Text, randomBeepCheck.Checked,
Expand All @@ -437,7 +437,7 @@ private ReactionProgram configureNewProgram()
case 5:
newProgram = new ReactionProgram(prgNameTextBox.Text, Convert.ToInt32(expoTime.Value), Convert.ToInt32(numExpo.Value), Convert.ToInt32(intervalTime.Value),
fixPointValue(), bgColorButton.Text, fixPointColor(), rndIntervalCheck.Checked, Convert.ToInt32(positionsBox.Text),
responseType(), Convert.ToInt32(stimuluSize.Value), isRandomExposition.Checked, openAudioListButton.Text,
responseType(), Convert.ToDouble(stimuluSize.Value), isRandomExposition.Checked, openAudioListButton.Text,
openImgListButton.Text, expandImageCheck.Checked, sstCheckBox.Checked);
break;

Expand Down
6 changes: 3 additions & 3 deletions StroopTest/Views/ReactionPages/FormTRConfig.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ Color:</value>
<data name="numExpoLabel.Text" xml:space="preserve">
<value>Number of Attempts:</value>
</data>
<data name="wordSizeLabel.Text" xml:space="preserve">
<value>Stimulus size:</value>
<data name="stimulusSizeLabel.Text" xml:space="preserve">
<value>Stimulus size (cm):</value>
</data>
<data name="instructionsLabel.Text" xml:space="preserve">
<value>Instructions:</value>
Expand All @@ -230,7 +230,7 @@ Color:</value>
<value>save</value>
</data>
<data name="fontSizeLabel.Text" xml:space="preserve">
<value>Font Size:</value>
<value>Font Size (pt):</value>
</data>
<data name="fixPointGroupBox.Text" xml:space="preserve">
<value>Fix Point</value>
Expand Down
Loading

0 comments on commit cf095b4

Please sign in to comment.