//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DarkWynter.Engine.Globals;
using DarkWynter.App.Surveys;
using DarkWynter.Engine.Utilities;
namespace DarkWynter.App.Surveys
{
public partial class SurveyForm : Form
{
public string fileName = "";
public GroupBox radioButtonGB;
private Button startSurvey;
private Button PreviousButton;
private Button NextButton;
private Button FinishedButton;
private RichTextBox QuestionBox;
private Label questionsLabel;
private Label participantLabelInstructions;
private TextBox participantNumberBox;
private Label partNum;
private Label surveyIncomplete;
string participantNumberInstructions = @"Please enter your participant number in the box.
If you do not know your participant number, please ask your study proctor for assistance.
Also, please note that you must enter your number before you will be allowed to continue.";
public static int questionNumber;
///
/// Creates the form for the Surveys
///
public SurveyForm()
{
// Set up components
InitializeComponent();
// Hide all components
radioButtonGB.Hide();
PreviousButton.Hide();
NextButton.Hide();
FinishedButton.Hide();
questionsLabel.Hide();
QuestionBox.Hide();
surveyIncomplete.Hide();
if (Survey.surveyName == "PostTest")
{
SetUpSurvey();
}
}
///
/// Starts the survey
///
/// mouse click (forms parameter)
/// event args (forms parameter)
private void startSurvey_Click(object sender, EventArgs e)
{
try
{
Statics_Engine.PlayerSettings.studentIDNumber = int.Parse(participantNumberBox.Text);
SetUpSurvey();
}
catch
{
// If the Participant Number box is empty/not valid, do not launch.
// Statics_Engine.PlayerSettings.studentIDNumber = Logging.CreateFileName();
}
}
///
/// Sets up the survey form and controls on the form
///
private void SetUpSurvey()
{
// Hide Intro Panel
startSurvey.Hide();
participantNumberBox.Hide();
participantLabelInstructions.Hide();
partNum.Hide();
// Init first problem
questionNumber = 0;
LoadQuestion();
QuestionBox.Show();
questionsLabel.Show();
// Survey display
radioButtonGB.Show();
// Iterators
PreviousButton.Show();
NextButton.Show();
// Save and exit survey
FinishedButton.Show();
}
///
/// Loads the question onto the form
///
private void LoadQuestion()
{
int labelNumber = questionNumber + 1;
// Label for the answer box
radioButtonGB.Text = "Question " + labelNumber + " Answers";
// Label for the question box
questionsLabel.Text = "Question " + labelNumber;
// Question Text
QuestionBox.Text = Survey.questionList[questionNumber].problem;
Survey.questionList[questionNumber].Load(this);
}
///
/// Loads the next question
///
/// mouse click (forms parameter)
/// event args (forms parameter)
private void NextButton_Click(object sender, EventArgs e)
{
// looping back to begining when finished
if (++questionNumber == Survey.questionList.Count)
{
questionNumber = 0;
}
LoadQuestion();
}
///
/// Loads the previous question
///
/// mouse click (forms parameter)
/// event args (forms parameter)
private void PreviousButton_Click(object sender, EventArgs e)
{
// Go back a question, looping back to end when finished
if (--questionNumber == -1)
{
questionNumber = Survey.questionList.Count - 1;
}
LoadQuestion();
}
///
/// Click the button if finished - checks for completion, writes the logs and exits the form
///
/// mouse click (forms parameter)
/// event args (forms parameter)
private void FinishedButton_Click(object sender, EventArgs e)
{
// Validate that Survey has been completed.
surveyIncomplete.Text = SurveyControl.surveyList[0].Validate();
// If errors reported, skip
if (surveyIncomplete.Text != "")
{
surveyIncomplete.Show();
return;
}
surveyIncomplete.BackColor = Color.Green;
surveyIncomplete.Text = "Thank You For Your Participation. \n Saving Your Survey to Server...";
surveyIncomplete.Invalidate();
surveyIncomplete.Show();
// Save file
SurveyControl.surveyList[0].Save();
Logging.writeG2LLog(
DarkWynter.Engine.Globals.Statics_Engine.PlayerSettings.studentIDNumber + "-" + Survey.surveyName + ".txt",
DarkWynter.Engine.Utilities.Logging.G2LSurveyLog
);
// Exit
this.Hide();
}
///
/// Creates the form
///
private void InitializeComponent()
{
this.radioButtonGB = new System.Windows.Forms.GroupBox();
this.startSurvey = new System.Windows.Forms.Button();
this.PreviousButton = new System.Windows.Forms.Button();
this.NextButton = new System.Windows.Forms.Button();
this.FinishedButton = new System.Windows.Forms.Button();
this.QuestionBox = new System.Windows.Forms.RichTextBox();
this.questionsLabel = new System.Windows.Forms.Label();
this.participantLabelInstructions = new System.Windows.Forms.Label();
this.participantNumberBox = new System.Windows.Forms.TextBox();
this.partNum = new System.Windows.Forms.Label();
this.surveyIncomplete = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// radioButtonGB
//
this.radioButtonGB.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.radioButtonGB.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.radioButtonGB.Location = new System.Drawing.Point(10, 313);
this.radioButtonGB.Name = "radioButtonGB";
this.radioButtonGB.Size = new System.Drawing.Size(559, 276);
this.radioButtonGB.TabIndex = 0;
this.radioButtonGB.ForeColor = Color.Purple;
this.radioButtonGB.TabStop = false;
this.radioButtonGB.Text = "AnswerBox";
//
// startSurvey
//
this.startSurvey.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.startSurvey.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.startSurvey.Location = new System.Drawing.Point(50, 360);
this.startSurvey.Name = "startSurvey";
this.startSurvey.Size = new System.Drawing.Size(119, 24);
this.startSurvey.TabIndex = 1;
this.startSurvey.Text = "Start Survey";
this.startSurvey.UseVisualStyleBackColor = false;
this.startSurvey.Click += new System.EventHandler(this.startSurvey_Click);
//
// PreviousButton
//
this.PreviousButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.PreviousButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.PreviousButton.Location = new System.Drawing.Point(158, 550);
this.PreviousButton.Name = "PreviousButton";
this.PreviousButton.Size = new System.Drawing.Size(119, 24);
this.PreviousButton.TabIndex = 2;
this.PreviousButton.Text = "Previous";
this.PreviousButton.UseVisualStyleBackColor = false;
this.PreviousButton.Click += new System.EventHandler(this.PreviousButton_Click);
//
// NextButton
//
this.NextButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.NextButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.NextButton.Location = new System.Drawing.Point(283, 550);
this.NextButton.Name = "NextButton";
this.NextButton.Size = new System.Drawing.Size(119, 24);
this.NextButton.TabIndex = 3;
this.NextButton.Text = "Next";
this.NextButton.UseVisualStyleBackColor = false;
this.NextButton.Click += new System.EventHandler(this.NextButton_Click);
//
// FinishedButton
//
this.FinishedButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.FinishedButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FinishedButton.Location = new System.Drawing.Point(408, 550);
this.FinishedButton.Name = "FinishedButton";
this.FinishedButton.Size = new System.Drawing.Size(119, 24);
this.FinishedButton.TabIndex = 4;
this.FinishedButton.Text = "Finished";
this.FinishedButton.UseVisualStyleBackColor = false;
this.FinishedButton.Click += new System.EventHandler(this.FinishedButton_Click);
//
// QuestionBox
//
this.QuestionBox.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.QuestionBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.QuestionBox.Location = new System.Drawing.Point(7, 31);
this.QuestionBox.Name = "QuestionBox";
this.QuestionBox.ReadOnly = true;
this.QuestionBox.Size = new System.Drawing.Size(559, 276);
this.QuestionBox.TabIndex = 5;
this.QuestionBox.ForeColor = Color.Red;
this.QuestionBox.Text = "";
//
// questionsLabel
//
this.questionsLabel.AutoSize = true;
this.questionsLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.questionsLabel.Location = new System.Drawing.Point(12, 9);
this.questionsLabel.Name = "questionsLabel";
this.questionsLabel.Size = new System.Drawing.Size(68, 18);
this.questionsLabel.TabIndex = 6;
this.questionsLabel.ForeColor = Color.Orange;
this.questionsLabel.Text = "Question";
//
// participantInstructionsLabel
//
this.participantLabelInstructions.AutoSize = true;
this.participantLabelInstructions.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.participantLabelInstructions.Location = new System.Drawing.Point(50, 140);
this.participantLabelInstructions.Name = "participantInstructionsLabel";
this.participantLabelInstructions.Size = new System.Drawing.Size(35, 13);
this.participantLabelInstructions.TabIndex = 6;
this.participantLabelInstructions.BackColor = Color.SkyBlue;
this.participantLabelInstructions.Text = participantNumberInstructions;
//
// participantNumberBox
//
this.participantNumberBox.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.participantNumberBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.participantNumberBox.Location = new System.Drawing.Point(50, 280);
this.participantNumberBox.Name = "participantNumberBox";
this.participantNumberBox.ReadOnly = false;
this.participantNumberBox.Size = new System.Drawing.Size(100, 20);
this.participantNumberBox.BackColor = Color.PaleGreen;
this.participantNumberBox.TabIndex = 5;
this.participantNumberBox.Text = "";
//
// partNum
//
this.partNum.AutoSize = true;
this.partNum.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.partNum.Location = new System.Drawing.Point(200, 280);
this.partNum.Name = "participantInstructionsLabel";
this.partNum.Size = new System.Drawing.Size(35, 13);
this.partNum.TabIndex = 6;
this.partNum.BackColor = Color.PaleGreen;
this.partNum.Text = "Participant Number";
//
// surveyIncomplete
//
this.surveyIncomplete.AutoSize = true;
this.surveyIncomplete.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.surveyIncomplete.Location = new System.Drawing.Point(700, 280);
this.surveyIncomplete.Name = "participantInstructionsLabel";
this.surveyIncomplete.Size = new System.Drawing.Size(35, 13);
this.surveyIncomplete.TabIndex = 6;
this.surveyIncomplete.BackColor = Color.Red;
this.surveyIncomplete.ForeColor = Color.Black;
this.surveyIncomplete.Text = "";
//
// SurveyForm
//
this.ClientSize = new System.Drawing.Size(578, 527);
this.Controls.Add(this.questionsLabel);
this.Controls.Add(this.QuestionBox);
this.Controls.Add(this.FinishedButton);
this.Controls.Add(this.NextButton);
this.Controls.Add(this.PreviousButton);
this.Controls.Add(this.startSurvey);
this.Controls.Add(this.radioButtonGB);
this.Controls.Add(this.participantLabelInstructions);
this.Controls.Add(this.participantNumberBox);
this.Controls.Add(this.partNum);
this.Controls.Add(this.surveyIncomplete);
this.Name = "SurveyForm";
this.ResumeLayout(false);
this.PerformLayout();
}
//private void InitializeComponent()
//{
// this.SuspendLayout();
// //
// // SurveyForm
// //
// this.ClientSize = new System.Drawing.Size(654, 558);
// this.Name = "SurveyForm";
// this.ResumeLayout(false);
//}
}
}