diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..419b600 --- /dev/null +++ b/.gitignore @@ -0,0 +1,138 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.svclog +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.azurePubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +packages/ +## TODO: If the tool you use requires repositories.config, also uncomment the next line +!packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +![Ss]tyle[Cc]op.targets +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml + +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +_NCrunch* + +*.vsidx +*.lock +*.testlog +*.manifest diff --git a/SeaAnimalQuiz/.vs/SeaAnimalQuiz/config/applicationhost.config b/SeaAnimalQuiz/.vs/SeaAnimalQuiz/config/applicationhost.config new file mode 100644 index 0000000..600d758 --- /dev/null +++ b/SeaAnimalQuiz/.vs/SeaAnimalQuiz/config/applicationhost.config @@ -0,0 +1,972 @@ + + + + + + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SeaAnimalQuiz/SeaAnimalQuiz.sln b/SeaAnimalQuiz/SeaAnimalQuiz.sln new file mode 100644 index 0000000..62474a3 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32901.215 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SeaAnimalQuiz", "SeaAnimalQuiz\SeaAnimalQuiz.csproj", "{CD03AA00-84A0-479B-85C3-7EF2095B4666}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CD03AA00-84A0-479B-85C3-7EF2095B4666}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD03AA00-84A0-479B-85C3-7EF2095B4666}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD03AA00-84A0-479B-85C3-7EF2095B4666}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD03AA00-84A0-479B-85C3-7EF2095B4666}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4AC2789E-8974-463C-9508-30E9A8F5116C} + EndGlobalSection +EndGlobal diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/App.config b/SeaAnimalQuiz/SeaAnimalQuiz/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Classes/MCQ.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/MCQ.cs new file mode 100644 index 0000000..043bb7d --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/MCQ.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SeaAnimalQuiz.Classes +{ + /// + /// The class represents a multiple choice question in the quiz. + /// It will contain the question and 3 possible answers. + /// + public class MCQ : Question + { + // The first possible answer. + string answer1; + + // The second possible answer. + string answer2; + + // The third possible answer. + string answer3; + + // The fourth possible answer. + string answer4; + + /// + /// constructor for the MCQ class. + /// create a constructor on the basis of the given parameters. + /// + /// + /// + /// + /// + /// + public MCQ(string questionText, string correctAnswer, string answer1, string answer2, string answer3, string answer4) + : base(questionText, correctAnswer, QuestionType.MultipleChoice) + { + this.answer1 = answer1; + this.answer2 = answer2; + this.answer3 = answer3; + this.answer4 = answer4; + } + + /// + /// This method will check the whether the answer is the correct anwer + /// + /// + /// True if the answer is the correct anwer + public override bool CheckAnswer(string answer) + { + return answer == CorrectAnswer; + } + + /// + /// This will return the first possible answer. + /// + public string Answer1 + { + get + { + return answer1; + } + } + + /// + /// This will return the second possible answer. + /// + public string Answer2 + { + get + { + return answer2; + } + } + + /// + /// This will return the third possible answer. + /// + public string Answer3 + { + get + { + return answer3; + } + } + + /// + /// This will return the fourth possible answer. + /// + public string Answer4 + { + get + { + return answer4; + } + } + + /// + /// This method will convert the question into its string representation. + /// + /// String representation of MCQ + public override string ToString() + { + return QuestionText + "," + answer1 + "," + answer2 + "," + answer3 + "," + CorrectAnswer; + } + } +} \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Classes/Question.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/Question.cs new file mode 100644 index 0000000..52b99a8 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/Question.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SeaAnimalQuiz.Classes +{ + public enum QuestionType + { + MultipleChoice, + TrueFalse + } + + /// + /// The class represents a question in the quiz. It will contain the questions of + /// 2 types. The first type will contain the question and 3 possible answers. + /// The second will be fill in the blanks. + /// + public abstract class Question + { + // The question text. + string questionText; + + // The question type. + QuestionType questionType; + + // The correct answer + string correctAnswer; + + public Question(string questionText, string correctAnswer, QuestionType questionType) + { + this.questionText = questionText; + this.correctAnswer = correctAnswer; + this.questionType = questionType; + } + + /// + /// This method returns the question text. + /// + public string QuestionText + { + get + { + return questionText; + } + } + + /// + /// This method returns the correct answer. + /// + public string CorrectAnswer + { + get + { + return correctAnswer; + } + } + + /// + /// The method get the type of the question. + /// + public QuestionType QuestionType + { + get + { + return questionType; + } + } + + /// + /// This method will check if the answer is correct. + /// + /// + public abstract bool CheckAnswer(string answer); + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Classes/Quiz.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/Quiz.cs new file mode 100644 index 0000000..94c1fa4 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/Quiz.cs @@ -0,0 +1,284 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows.Forms; + +namespace SeaAnimalQuiz.Classes +{ + public enum QuizCategory + { + Fish, + Birds, + Reptiles + } + + /// + /// This class represents a in the quiz. It will contain the questions between + /// 10 to 20 regarding sea animals. + /// + public class Quiz + { + // The list of questions in the quiz. + List questions; + + // The current question number. + int currentQuestionNumber; + + // The number of correct answers. + int correctAnswers; + + // The number of incorrect answers. + int incorrectAnswers; + + /// + /// The constructor for the Quiz class. + /// + public Quiz() + { + // Initialize the list of questions. + questions = new List(); + + // Initialize the current question number. + currentQuestionNumber = 0; + + // Initialize the number of correct answers. + correctAnswers = 0; + + // Initialize the number of incorrect answers. + incorrectAnswers = 0; + } + + /// + /// load the questions from the text file. + /// + public void LoadQuestions(QuizCategory category) + { + // load the questions from the FishQuestions.txt file in the Data directory. + string file = ""; + if (category == QuizCategory.Fish) + { + file = "../../Data/FishQuestions.txt"; + } + + try + { + if (File.Exists(file)) + { + // Store each line in array of strings + string[] lines = File.ReadAllLines(file); + + + foreach (string ln in lines) + { + if (!(ln == null || ln == "")) + { + string[] data = ln.Split(','); + if (data[0].Equals(QuestionType.MultipleChoice.ToString())) + { + // create MCQ and load data + MCQ mcq = new MCQ(data[1], data[2], data[3], data[4], data[5], data[6]); + questions.Add(mcq); + } + else if (data[0].Equals(QuestionType.TrueFalse.ToString())) + { + // create True False and load data + TrueFalse trueFalse = new TrueFalse(data[1], data[2], data[3], data[4]); + questions.Add(trueFalse); + } + } + } + } + } + catch (Exception) + { + MessageBox.Show("There was an error loading the questions.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); + } + + // Shuffle the questions. + ShuffleQuestions(); + + // Reset the current question number. + currentQuestionNumber = 0; + + // Reset the number of correct answers. + correctAnswers = 0; + + // Reset the number of incorrect answers. + incorrectAnswers = 0; + } + + /// + /// shuffle the questions in the list and only retain 20 questions. + /// + private void ShuffleQuestions() + { + // Create a new random number generator. + Random random = new Random(); + + // Shuffle the questions in the list. + for (int i = 0; i < questions.Count; i++) + { + // Get a random index. + int randomIndex = random.Next(0, questions.Count); + + // Swap the questions at the current index and the random index. + Question temp = questions[i]; + questions[i] = questions[randomIndex]; + questions[randomIndex] = temp; + } + + try { questions = questions.GetRange(0, 20); } catch (Exception) { } + } + + /// + /// check the answer for the current question. + /// + /// The answer to check. + /// True if the answer is correct, false otherwise. + public bool CheckAnswer(string answer) + { + // Check if the answer is correct. + if (questions[currentQuestionNumber].CheckAnswer(answer)) + { + // Increment the number of correct answers. + correctAnswers++; + + // Return true. + return true; + } + else + { + // Increment the number of incorrect answers. + incorrectAnswers++; + + // Return false. + return false; + } + } + + /// + /// Move to the next question. + /// + public void NextQuestion() + { + // Increment the current question number. + currentQuestionNumber++; + } + + /// + /// Check if end of the quiz. + /// + /// True if end of the quiz, false otherwise. + public bool IsEndOfQuiz() + { + // Check if the current question number is greater than or equal to the number of questions. + if (CurrentQuestionNumber >= questions.Count) + { + // Return true. + return true; + } + else + { + // Return false. + return false; + } + } + + /// + /// Get the current question. + /// + /// The current question. + public Question CurrentQuestion + { + get + { + // Return the current question. + try + { + return questions[currentQuestionNumber]; + } + catch (Exception) + { + return null; + } + } + } + + /// + /// Get the number of correct answers. + /// + /// + /// Question of given index otherwise null + public Question GetQuestion(int index) + { +#pragma warning disable CS0168 // The variable 'e' is declared but never used + try + { + return questions[index]; + } + catch (Exception e) + { + return null; + } +#pragma warning restore CS0168 // The variable 'e' is declared but never used + } + + /// + /// Get the number of correct answers. + /// + /// The number of correct answers. + public int CorrectAnswers + { + get + { + // Return the number of correct answers. + return correctAnswers; + } + } + + /// + /// Get the number of incorrect answers. + /// \ + /// The number of incorrect answers. + public int IncorrectAnswers + { + get + { + // Return the number of incorrect answers. + return incorrectAnswers; + } + } + + /// + /// Get the number of questions. + /// + /// The number of questions. + public int NumberOfQuestions + { + get + { + // Return the number of questions. + return questions.Count; + } + } + + /// + /// Get the current question number. + /// + /// The current question number. + public int CurrentQuestionNumber + { + get + { + // Return the current question number. + return currentQuestionNumber + 1; + } + } + + public int QuestionsRemaining() + { + return questions.Count - CurrentQuestionNumber; + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Classes/TrueFalse.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/TrueFalse.cs new file mode 100644 index 0000000..1400812 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Classes/TrueFalse.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SeaAnimalQuiz.Classes +{ + /// + /// The class represents a true/false question in the quiz. + /// + internal class TrueFalse : Question + { + // first expected answer + string firstAnswer; + + // second expected answer + string secondAnswer; + + public TrueFalse(string questionText, string correctAnswer, string firstAnswer, string secondAnswer) + : base(questionText, correctAnswer, QuestionType.TrueFalse) + { + this.firstAnswer = firstAnswer; + this.secondAnswer = secondAnswer; + } + + /// + /// This method will get the first answer. + /// + public string FirstAnswer + { + get + { + return firstAnswer; + } + } + + /// + /// This method will get the second answer. + /// + public string SecondAnswer + { + get + { + return secondAnswer; + } + } + + /// + /// This method will check the answer with the correct answer. + /// + /// + /// True if the answer is the correct anwer + public override bool CheckAnswer(string answer) + { + return answer == CorrectAnswer; + } + + /// + /// This method will convert the question into its string representation. + /// + /// String representation of TrueFalse + public override string ToString() + { + return QuestionText + "," + CorrectAnswer; + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Data/BirdQuestions.txt b/SeaAnimalQuiz/SeaAnimalQuiz/Data/BirdQuestions.txt new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Data/BirdQuestions.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Data/FishQuestions.txt b/SeaAnimalQuiz/SeaAnimalQuiz/Data/FishQuestions.txt new file mode 100644 index 0000000..e5ddaf4 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Data/FishQuestions.txt @@ -0,0 +1,24 @@ +MultipleChoice,What is the largest sea animal?,Blue Whale,Blue Whale,Whale Shark,Giant Squid,Sperm Whale +MultipleChoice,What is the smallest sea animal?,Sea Slug,Sea Horse,Sea Slug,Sea Squirt,Sea Star +MultipleChoice,What is the fastest sea animal?,Sailfish,Swordfish,Sailfish,Marlin,Tuna +MultipleChoice,What is the slowest sea animal?,Sea Slug,Sea Squirt,Sea Star,Sea Slug,Sea Horse +MultipleChoice,What is the most dangerous sea animal ?,Great White Shark,Sperm Whale,Blue Whale,Giant Squid,Great White Shark +MultipleChoice,What is the most poisonous sea animal ?,Blue Ringed Octopus,Sea Snake,Sea Urchin,Sea Cucumber,Blue Ringed Octopus +MultipleChoice,What is the most venomous sea animal ?,Blue Ringed Octopus,Blue Ringed Octopus,Sea Snake,Sea Urchin,Sea Cucumber +MultipleChoice,What is the most intelligent sea animal ?,Dolphin,Dolphin,Sperm Whale,Blue Whale,Giant Squid +MultipleChoice,What is the most beautiful sea animal ?,Sea Slug,Sea Squirt,Sea Slug,Sea Star,Sea Horse +MultipleChoice,What is the most colorful sea animal ?,Sea Slug,Sea Squirt,Sea Star,Sea Horse,Sea Slug +TrueFalse,The octopus has three hearts.,True,True,False +TrueFalse,The blue whale is the largest animal in the world.,True,True,False +TrueFalse,The whale shark is the largest fish in the world.,True,True,False +TrueFalse,Can a red octopus change colors.,True,True,False +TrueFalse,Can a tuna swim backwards.,True,True,False +TrueFalse,Sawfish is a type of shark.,False,True,False +TrueFalse,Sea urchins,starfish and sea cucumbers belong in the same family.,True,True,False +TrueFalse,All clownfish are born male.,True,True,False +TrueFalse,All starfish have 5 arms.,False,True,False +TrueFalse,Conger eels are the largest species of eel.,True,True,False +TrueFalse,Anemones are capable of locomotion.,True,True,False +TrueFalse,All jellyfish can photosynthesize.,False,True,False +TrueFalse,Corals are plants.,False,True,False +TrueFalse,Seahorses are predators.,True,True,False diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Data/ReptileQuestions.txt b/SeaAnimalQuiz/SeaAnimalQuiz/Data/ReptileQuestions.txt new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Data/ReptileQuestions.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Images/main.jpg b/SeaAnimalQuiz/SeaAnimalQuiz/Images/main.jpg new file mode 100644 index 0000000..8b1fe4b Binary files /dev/null and b/SeaAnimalQuiz/SeaAnimalQuiz/Images/main.jpg differ diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Images/question.jpg b/SeaAnimalQuiz/SeaAnimalQuiz/Images/question.jpg new file mode 100644 index 0000000..d1c99b9 Binary files /dev/null and b/SeaAnimalQuiz/SeaAnimalQuiz/Images/question.jpg differ diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Program.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Program.cs new file mode 100644 index 0000000..802a0ec --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Program.cs @@ -0,0 +1,23 @@ +using SeaAnimalQuiz.UI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SeaAnimalQuiz +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(MainForm.Instance); + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Properties/AssemblyInfo.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c292630 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SeaAnimalQuiz")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SeaAnimalQuiz")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("cd03aa00-84a0-479b-85c3-7ef2095b4666")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Resources.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Resources.Designer.cs new file mode 100644 index 0000000..24d29cc --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Resources.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SeaAnimalQuiz.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SeaAnimalQuiz.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap main { + get { + object obj = ResourceManager.GetObject("main", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap question { + get { + object obj = ResourceManager.GetObject("question", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Resources.resx b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Resources.resx new file mode 100644 index 0000000..030f676 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Resources.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Images\main.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\question.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Settings.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Settings.Designer.cs new file mode 100644 index 0000000..81cf43c --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SeaAnimalQuiz.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Settings.settings b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/SeaAnimalQuiz.csproj b/SeaAnimalQuiz/SeaAnimalQuiz/SeaAnimalQuiz.csproj new file mode 100644 index 0000000..f6aff66 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/SeaAnimalQuiz.csproj @@ -0,0 +1,145 @@ + + + + + Debug + AnyCPU + {CD03AA00-84A0-479B-85C3-7EF2095B4666} + WinExe + SeaAnimalQuiz + SeaAnimalQuiz + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + UserControl + + + ucQuizResult.cs + + + UserControl + + + ucTrueFalse.cs + + + UserControl + + + ucCategories.cs + + + UserControl + + + ucMCQ.cs + + + UserControl + + + ucQuiz.cs + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + ucQuizResult.cs + + + ucTrueFalse.cs + + + ucCategories.cs + + + ucMCQ.cs + + + ucQuiz.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.Designer.cs new file mode 100644 index 0000000..78e8c0d --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.Designer.cs @@ -0,0 +1,235 @@ +namespace SeaAnimalQuiz +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pnlMain = new System.Windows.Forms.Panel(); + this.scMainPage = new System.Windows.Forms.SplitContainer(); + this.tlpMainMenu = new System.Windows.Forms.TableLayoutPanel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btnExit = new System.Windows.Forms.Button(); + this.btnAddQuestions = new System.Windows.Forms.Button(); + this.btnStart = new System.Windows.Forms.Button(); + this.btnHelp = new System.Windows.Forms.Button(); + this.lbTitel = new System.Windows.Forms.Label(); + this.pdBackground = new System.Windows.Forms.PictureBox(); + this.pnlMain.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.scMainPage)).BeginInit(); + this.scMainPage.Panel1.SuspendLayout(); + this.scMainPage.Panel2.SuspendLayout(); + this.scMainPage.SuspendLayout(); + this.tlpMainMenu.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pdBackground)).BeginInit(); + this.SuspendLayout(); + // + // pnlMain + // + this.pnlMain.BackColor = System.Drawing.Color.Transparent; + this.pnlMain.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.pnlMain.Controls.Add(this.scMainPage); + this.pnlMain.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlMain.Location = new System.Drawing.Point(0, 0); + this.pnlMain.Name = "pnlMain"; + this.pnlMain.Size = new System.Drawing.Size(784, 450); + this.pnlMain.TabIndex = 0; + // + // scMainPage + // + this.scMainPage.BackColor = System.Drawing.Color.Orange; + this.scMainPage.Dock = System.Windows.Forms.DockStyle.Fill; + this.scMainPage.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.scMainPage.IsSplitterFixed = true; + this.scMainPage.Location = new System.Drawing.Point(0, 0); + this.scMainPage.Name = "scMainPage"; + // + // scMainPage.Panel1 + // + this.scMainPage.Panel1.Controls.Add(this.tlpMainMenu); + // + // scMainPage.Panel2 + // + this.scMainPage.Panel2.Controls.Add(this.pdBackground); + this.scMainPage.Size = new System.Drawing.Size(784, 450); + this.scMainPage.SplitterDistance = 335; + this.scMainPage.SplitterWidth = 1; + this.scMainPage.TabIndex = 0; + // + // tlpMainMenu + // + this.tlpMainMenu.BackColor = System.Drawing.Color.Orange; + this.tlpMainMenu.ColumnCount = 1; + this.tlpMainMenu.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpMainMenu.Controls.Add(this.panel1, 0, 1); + this.tlpMainMenu.Controls.Add(this.lbTitel, 0, 0); + this.tlpMainMenu.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpMainMenu.Location = new System.Drawing.Point(0, 0); + this.tlpMainMenu.Name = "tlpMainMenu"; + this.tlpMainMenu.RowCount = 2; + this.tlpMainMenu.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 17.77778F)); + this.tlpMainMenu.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 82.22222F)); + this.tlpMainMenu.Size = new System.Drawing.Size(335, 450); + this.tlpMainMenu.TabIndex = 2; + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.btnExit); + this.panel1.Controls.Add(this.btnAddQuestions); + this.panel1.Controls.Add(this.btnStart); + this.panel1.Controls.Add(this.btnHelp); + this.panel1.Location = new System.Drawing.Point(3, 83); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(329, 364); + this.panel1.TabIndex = 2; + // + // btnExit + // + this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnExit.BackColor = System.Drawing.Color.DarkOrange; + this.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnExit.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnExit.ForeColor = System.Drawing.Color.White; + this.btnExit.Location = new System.Drawing.Point(23, 301); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(89, 37); + this.btnExit.TabIndex = 0; + this.btnExit.Text = "Exit"; + this.btnExit.UseVisualStyleBackColor = false; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); + // + // btnAddQuestions + // + this.btnAddQuestions.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btnAddQuestions.BackColor = System.Drawing.Color.DarkOrange; + this.btnAddQuestions.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAddQuestions.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAddQuestions.ForeColor = System.Drawing.Color.White; + this.btnAddQuestions.Location = new System.Drawing.Point(23, 86); + this.btnAddQuestions.Name = "btnAddQuestions"; + this.btnAddQuestions.Size = new System.Drawing.Size(283, 45); + this.btnAddQuestions.TabIndex = 0; + this.btnAddQuestions.Text = "Add Questions"; + this.btnAddQuestions.UseVisualStyleBackColor = false; + this.btnAddQuestions.Click += new System.EventHandler(this.btnAddQuestions_Click); + // + // btnStart + // + this.btnStart.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btnStart.BackColor = System.Drawing.Color.DarkOrange; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnStart.ForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(23, 12); + this.btnStart.Name = "btnStart"; + this.btnStart.Size = new System.Drawing.Size(283, 45); + this.btnStart.TabIndex = 0; + this.btnStart.Text = "Start Quiz"; + this.btnStart.UseVisualStyleBackColor = false; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // + // btnHelp + // + this.btnHelp.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btnHelp.BackColor = System.Drawing.Color.DarkOrange; + this.btnHelp.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnHelp.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnHelp.ForeColor = System.Drawing.Color.White; + this.btnHelp.Location = new System.Drawing.Point(23, 160); + this.btnHelp.Name = "btnHelp"; + this.btnHelp.Size = new System.Drawing.Size(283, 45); + this.btnHelp.TabIndex = 0; + this.btnHelp.Text = "Help"; + this.btnHelp.UseVisualStyleBackColor = false; + this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click); + // + // lbTitel + // + this.lbTitel.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lbTitel.AutoSize = true; + this.lbTitel.Font = new System.Drawing.Font("Century", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbTitel.ForeColor = System.Drawing.Color.White; + this.lbTitel.Location = new System.Drawing.Point(44, 23); + this.lbTitel.Name = "lbTitel"; + this.lbTitel.Size = new System.Drawing.Size(246, 33); + this.lbTitel.TabIndex = 1; + this.lbTitel.Text = "Sea Animal Quiz"; + this.lbTitel.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // pdBackground + // + this.pdBackground.BackgroundImage = global::SeaAnimalQuiz.Properties.Resources.main; + this.pdBackground.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.pdBackground.Dock = System.Windows.Forms.DockStyle.Fill; + this.pdBackground.Location = new System.Drawing.Point(0, 0); + this.pdBackground.Name = "pdBackground"; + this.pdBackground.Size = new System.Drawing.Size(448, 450); + this.pdBackground.TabIndex = 0; + this.pdBackground.TabStop = false; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(784, 450); + this.Controls.Add(this.pnlMain); + this.MinimumSize = new System.Drawing.Size(800, 440); + this.Name = "MainForm"; + this.Text = "Quiz"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.pnlMain.ResumeLayout(false); + this.scMainPage.Panel1.ResumeLayout(false); + this.scMainPage.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.scMainPage)).EndInit(); + this.scMainPage.ResumeLayout(false); + this.tlpMainMenu.ResumeLayout(false); + this.tlpMainMenu.PerformLayout(); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pdBackground)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel pnlMain; + private System.Windows.Forms.SplitContainer scMainPage; + private System.Windows.Forms.Button btnExit; + private System.Windows.Forms.Button btnAddQuestions; + private System.Windows.Forms.PictureBox pdBackground; + private System.Windows.Forms.Button btnStart; + private System.Windows.Forms.Button btnHelp; + private System.Windows.Forms.Label lbTitel; + private System.Windows.Forms.TableLayoutPanel tlpMainMenu; + private System.Windows.Forms.Panel panel1; + } +} + diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.cs new file mode 100644 index 0000000..6dcb96d --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.cs @@ -0,0 +1,107 @@ +using SeaAnimalQuiz.Classes; +using SeaAnimalQuiz.UI; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SeaAnimalQuiz +{ + /// + /// user control for displaying the question of type MCQ to the user. + /// + public partial class MainForm : Form + { + // singleton object for the main form + private static MainForm _instance; + + /// + /// get the singleton object of the MainForm class + /// + public static MainForm Instance + { + get + { + if (_instance == null) + { + _instance = new MainForm(); + } + return _instance; + } + } + + private MainForm() + { + InitializeComponent(); + } + + private void MainForm_Load(object sender, EventArgs e) + { + + } + + private void btnExit_Click(object sender, EventArgs e) + { + // Exit the application when the user clicks the Exit button. + Application.Exit(); + } + + public void SetHomePage() + { + // set the home page as the current user control + scMainPage.BringToFront(); + } + + public void SetHomePageMenu() + { + // set the home page as the current user control + tlpMainMenu.BringToFront(); + } + + public void SetQuizPage() + { + if (pnlMain.Controls.Contains(ucQuiz.Instance)) + { + ucQuiz.Instance.Dock = DockStyle.Fill; + ucQuiz.Instance.RefreshUc(); + ucQuiz.Instance.BringToFront(); + } + else + { + pnlMain.Controls.Add(ucQuiz.Instance); + ucQuiz.Instance.Dock = DockStyle.Fill; + ucQuiz.Instance.BringToFront(); + } + } + + private void btnStart_Click(object sender, EventArgs e) + { + if (scMainPage.Panel1.Controls.Contains(ucCategories.Instance)) + { + ucCategories.Instance.Dock = DockStyle.Fill; + ucCategories.Instance.BringToFront(); + } + else + { + scMainPage.Panel1.Controls.Add(ucCategories.Instance); + ucCategories.Instance.Dock = DockStyle.Fill; + ucCategories.Instance.BringToFront(); + } + } + + private void btnHelp_Click(object sender, EventArgs e) + { + + } + + private void btnAddQuestions_Click(object sender, EventArgs e) + { + + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.resx b/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.Designer.cs new file mode 100644 index 0000000..c892e3a --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.Designer.cs @@ -0,0 +1,170 @@ +namespace SeaAnimalQuiz.UI +{ + partial class ucCategories + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.lbCategory = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btnBack = new System.Windows.Forms.Button(); + this.btnReptiles = new System.Windows.Forms.Button(); + this.btnBirds = new System.Windows.Forms.Button(); + this.btnFish = new System.Windows.Forms.Button(); + this.tableLayoutPanel1.SuspendLayout(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.lbCategory, 0, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 18.26671F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 81.73329F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(329, 450); + this.tableLayoutPanel1.TabIndex = 0; + // + // lbCategory + // + this.lbCategory.Anchor = System.Windows.Forms.AnchorStyles.None; + this.lbCategory.AutoSize = true; + this.lbCategory.Font = new System.Drawing.Font("Century", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbCategory.ForeColor = System.Drawing.Color.White; + this.lbCategory.Location = new System.Drawing.Point(17, 24); + this.lbCategory.Name = "lbCategory"; + this.lbCategory.Size = new System.Drawing.Size(295, 33); + this.lbCategory.TabIndex = 2; + this.lbCategory.Text = "Select Any Category"; + this.lbCategory.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.btnBack); + this.panel1.Controls.Add(this.btnReptiles); + this.panel1.Controls.Add(this.btnBirds); + this.panel1.Controls.Add(this.btnFish); + this.panel1.Location = new System.Drawing.Point(3, 85); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(323, 362); + this.panel1.TabIndex = 3; + // + // btnBack + // + this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnBack.BackColor = System.Drawing.Color.DarkOrange; + this.btnBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnBack.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBack.ForeColor = System.Drawing.Color.White; + this.btnBack.Location = new System.Drawing.Point(23, 291); + this.btnBack.Name = "btnBack"; + this.btnBack.Size = new System.Drawing.Size(89, 45); + this.btnBack.TabIndex = 0; + this.btnBack.Text = "Back"; + this.btnBack.UseVisualStyleBackColor = false; + this.btnBack.Click += new System.EventHandler(this.btnBack_Click); + // + // btnReptiles + // + this.btnReptiles.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btnReptiles.BackColor = System.Drawing.Color.DarkOrange; + this.btnReptiles.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnReptiles.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnReptiles.ForeColor = System.Drawing.Color.White; + this.btnReptiles.Location = new System.Drawing.Point(20, 156); + this.btnReptiles.Name = "btnReptiles"; + this.btnReptiles.Size = new System.Drawing.Size(283, 45); + this.btnReptiles.TabIndex = 0; + this.btnReptiles.Text = "Reptiles"; + this.btnReptiles.UseVisualStyleBackColor = false; + // + // btnBirds + // + this.btnBirds.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btnBirds.BackColor = System.Drawing.Color.DarkOrange; + this.btnBirds.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnBirds.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBirds.ForeColor = System.Drawing.Color.White; + this.btnBirds.Location = new System.Drawing.Point(20, 12); + this.btnBirds.Name = "btnBirds"; + this.btnBirds.Size = new System.Drawing.Size(283, 45); + this.btnBirds.TabIndex = 0; + this.btnBirds.Text = "Birds"; + this.btnBirds.UseVisualStyleBackColor = false; + // + // btnFish + // + this.btnFish.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.btnFish.BackColor = System.Drawing.Color.DarkOrange; + this.btnFish.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnFish.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnFish.ForeColor = System.Drawing.Color.White; + this.btnFish.Location = new System.Drawing.Point(20, 84); + this.btnFish.Name = "btnFish"; + this.btnFish.Size = new System.Drawing.Size(283, 45); + this.btnFish.TabIndex = 0; + this.btnFish.Text = "Fish"; + this.btnFish.UseVisualStyleBackColor = false; + this.btnFish.Click += new System.EventHandler(this.btnFish_Click); + // + // ucCategories + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Orange; + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "ucCategories"; + this.Size = new System.Drawing.Size(329, 450); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label lbCategory; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button btnBack; + private System.Windows.Forms.Button btnReptiles; + private System.Windows.Forms.Button btnBirds; + private System.Windows.Forms.Button btnFish; + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.cs new file mode 100644 index 0000000..c2debcf --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.cs @@ -0,0 +1,48 @@ +using SeaAnimalQuiz.Classes; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SeaAnimalQuiz.UI +{ + public partial class ucCategories : UserControl + { + // singleton object for the categories user control + private static ucCategories _instance; + + /// + /// get the singleton object of the Categories class + /// + public static ucCategories Instance + { + get + { + if (_instance == null) + { + _instance = new ucCategories(); + } + return _instance; + } + } + public ucCategories() + { + InitializeComponent(); + } + + private void btnFish_Click(object sender, EventArgs e) + { + MainForm.Instance.SetQuizPage(); + } + + private void btnBack_Click(object sender, EventArgs e) + { + MainForm.Instance.SetHomePageMenu(); + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.resx b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucCategories.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.Designer.cs new file mode 100644 index 0000000..c1a916c --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.Designer.cs @@ -0,0 +1,193 @@ +namespace SeaAnimalQuiz.UI +{ + partial class ucMCQ + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tlpMcqQuestionAnswers = new System.Windows.Forms.TableLayoutPanel(); + this.tlpMcqAnswers = new System.Windows.Forms.TableLayoutPanel(); + this.btnAnswer1 = new System.Windows.Forms.Button(); + this.btnAnswer2 = new System.Windows.Forms.Button(); + this.btnAnswer3 = new System.Windows.Forms.Button(); + this.btnAnswer4 = new System.Windows.Forms.Button(); + this.tmrNextQuestion = new System.Windows.Forms.Timer(this.components); + this.tbQuestionText = new System.Windows.Forms.TextBox(); + this.tlpMcqQuestionAnswers.SuspendLayout(); + this.tlpMcqAnswers.SuspendLayout(); + this.SuspendLayout(); + // + // tlpMcqQuestionAnswers + // + this.tlpMcqQuestionAnswers.BackColor = System.Drawing.Color.White; + this.tlpMcqQuestionAnswers.ColumnCount = 1; + this.tlpMcqQuestionAnswers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqQuestionAnswers.Controls.Add(this.tlpMcqAnswers, 0, 1); + this.tlpMcqQuestionAnswers.Controls.Add(this.tbQuestionText, 0, 0); + this.tlpMcqQuestionAnswers.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpMcqQuestionAnswers.Location = new System.Drawing.Point(0, 0); + this.tlpMcqQuestionAnswers.Name = "tlpMcqQuestionAnswers"; + this.tlpMcqQuestionAnswers.RowCount = 2; + this.tlpMcqQuestionAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60.16597F)); + this.tlpMcqQuestionAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 39.83403F)); + this.tlpMcqQuestionAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tlpMcqQuestionAnswers.Size = new System.Drawing.Size(528, 241); + this.tlpMcqQuestionAnswers.TabIndex = 2; + // + // tlpMcqAnswers + // + this.tlpMcqAnswers.ColumnCount = 2; + this.tlpMcqAnswers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.Controls.Add(this.btnAnswer1, 0, 0); + this.tlpMcqAnswers.Controls.Add(this.btnAnswer2, 1, 0); + this.tlpMcqAnswers.Controls.Add(this.btnAnswer3, 0, 1); + this.tlpMcqAnswers.Controls.Add(this.btnAnswer4, 1, 1); + this.tlpMcqAnswers.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpMcqAnswers.Location = new System.Drawing.Point(3, 148); + this.tlpMcqAnswers.Name = "tlpMcqAnswers"; + this.tlpMcqAnswers.RowCount = 2; + this.tlpMcqAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.Size = new System.Drawing.Size(522, 90); + this.tlpMcqAnswers.TabIndex = 0; + // + // btnAnswer1 + // + this.btnAnswer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnAnswer1.BackColor = System.Drawing.Color.SlateGray; + this.btnAnswer1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAnswer1.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAnswer1.ForeColor = System.Drawing.Color.White; + this.btnAnswer1.Location = new System.Drawing.Point(3, 3); + this.btnAnswer1.Name = "btnAnswer1"; + this.btnAnswer1.Size = new System.Drawing.Size(255, 39); + this.btnAnswer1.TabIndex = 1; + this.btnAnswer1.Text = "Answer 1"; + this.btnAnswer1.UseVisualStyleBackColor = false; + this.btnAnswer1.Click += new System.EventHandler(this.btnAnswer_Click); + // + // btnAnswer2 + // + this.btnAnswer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnAnswer2.BackColor = System.Drawing.Color.SlateGray; + this.btnAnswer2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAnswer2.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAnswer2.ForeColor = System.Drawing.Color.White; + this.btnAnswer2.Location = new System.Drawing.Point(264, 3); + this.btnAnswer2.Name = "btnAnswer2"; + this.btnAnswer2.Size = new System.Drawing.Size(255, 39); + this.btnAnswer2.TabIndex = 1; + this.btnAnswer2.Text = "Answer 2"; + this.btnAnswer2.UseVisualStyleBackColor = false; + this.btnAnswer2.Click += new System.EventHandler(this.btnAnswer_Click); + // + // btnAnswer3 + // + this.btnAnswer3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnAnswer3.BackColor = System.Drawing.Color.SlateGray; + this.btnAnswer3.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAnswer3.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAnswer3.ForeColor = System.Drawing.Color.White; + this.btnAnswer3.Location = new System.Drawing.Point(3, 48); + this.btnAnswer3.Name = "btnAnswer3"; + this.btnAnswer3.Size = new System.Drawing.Size(255, 39); + this.btnAnswer3.TabIndex = 1; + this.btnAnswer3.Text = "Answer 3"; + this.btnAnswer3.UseVisualStyleBackColor = false; + this.btnAnswer3.Click += new System.EventHandler(this.btnAnswer_Click); + // + // btnAnswer4 + // + this.btnAnswer4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnAnswer4.BackColor = System.Drawing.Color.SlateGray; + this.btnAnswer4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAnswer4.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAnswer4.ForeColor = System.Drawing.Color.White; + this.btnAnswer4.Location = new System.Drawing.Point(264, 48); + this.btnAnswer4.Name = "btnAnswer4"; + this.btnAnswer4.Size = new System.Drawing.Size(255, 39); + this.btnAnswer4.TabIndex = 1; + this.btnAnswer4.Text = "Answer 4"; + this.btnAnswer4.UseVisualStyleBackColor = false; + this.btnAnswer4.Click += new System.EventHandler(this.btnAnswer_Click); + // + // tmrNextQuestion + // + this.tmrNextQuestion.Interval = 800; + this.tmrNextQuestion.Tick += new System.EventHandler(this.tmrNextQuestion_Tick); + // + // tbQuestionText + // + this.tbQuestionText.BackColor = System.Drawing.Color.White; + this.tbQuestionText.Dock = System.Windows.Forms.DockStyle.Fill; + this.tbQuestionText.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbQuestionText.Location = new System.Drawing.Point(3, 3); + this.tbQuestionText.Multiline = true; + this.tbQuestionText.Name = "tbQuestionText"; + this.tbQuestionText.ReadOnly = true; + this.tbQuestionText.ShortcutsEnabled = false; + this.tbQuestionText.Size = new System.Drawing.Size(522, 139); + this.tbQuestionText.TabIndex = 1; + this.tbQuestionText.Text = "Multiple Choice Questions"; + this.tbQuestionText.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // ucMCQ + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.Controls.Add(this.tlpMcqQuestionAnswers); + this.Name = "ucMCQ"; + this.Size = new System.Drawing.Size(528, 241); + this.tlpMcqQuestionAnswers.ResumeLayout(false); + this.tlpMcqQuestionAnswers.PerformLayout(); + this.tlpMcqAnswers.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tlpMcqQuestionAnswers; + private System.Windows.Forms.TableLayoutPanel tlpMcqAnswers; + private System.Windows.Forms.Button btnAnswer1; + private System.Windows.Forms.Button btnAnswer2; + private System.Windows.Forms.Button btnAnswer3; + private System.Windows.Forms.Button btnAnswer4; + private System.Windows.Forms.Timer tmrNextQuestion; + private System.Windows.Forms.TextBox tbQuestionText; + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.cs new file mode 100644 index 0000000..42c841e --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.cs @@ -0,0 +1,126 @@ +using SeaAnimalQuiz.Classes; +using System; +using System.Drawing; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; +using Button = System.Windows.Forms.Button; + +namespace SeaAnimalQuiz.UI +{ + /// + /// user control for displaying the question of type MCQ to the user. + /// + public partial class ucMCQ : UserControl + { + // singleton object for the mcq user control + private static ucMCQ _instance; + + // current question it is displaying + private MCQ _currentQuestion; + + /// + /// get the singleton object of the MCQ class + /// + public static ucMCQ Instance + { + get + { + if (_instance == null) + { + _instance = new ucMCQ(); + } + return _instance; + } + } + + private ucMCQ() + { + InitializeComponent(); + } + + public void DisplayMCQ(Question question) + { + MCQ mcq = (MCQ)question; + _currentQuestion = mcq; + + // set question text + tbQuestionText.Text = mcq.QuestionText; + setTextBox_Scroll(); + + btnAnswer1.Text = mcq.Answer1; + btnAnswer2.Text = mcq.Answer2; + btnAnswer3.Text = mcq.Answer3; + btnAnswer4.Text = mcq.Answer4; + + // set buttons color to default + btnAnswer1.BackColor = Color.SlateGray; + btnAnswer2.BackColor = Color.SlateGray; + btnAnswer3.BackColor = Color.SlateGray; + btnAnswer4.BackColor = Color.SlateGray; + + // set buttons to enabled + btnAnswer1.Enabled = true; + btnAnswer2.Enabled = true; + btnAnswer3.Enabled = true; + btnAnswer4.Enabled = true; + } + + private void setTextBox_Scroll() + { + if (tbQuestionText.Multiline) + { + tbQuestionText.ScrollBars = tbQuestionText.Text.Length > (tbQuestionText.Width + tbQuestionText.Height) / 1.30f ? ScrollBars.Vertical : tbQuestionText.Text.Split('\n').Length > tbQuestionText.Height / tbQuestionText.Font.Size / 1.4f ? ScrollBars.Vertical : ScrollBars.None; + } + } + + private void btnAnswer_Click(object sender, EventArgs e) + { + Button btn = (Button)sender; + if (ucQuiz.Instance.CurrentQuiz.CheckAnswer(btn.Text)) + { + btn.BackColor = Color.LightGreen; + } + else + { + btn.BackColor = Color.MistyRose; + + // set the correct answer button to green + if (btnAnswer1.Text.Equals(_currentQuestion.CorrectAnswer)) + { + btnAnswer1.BackColor = Color.LightGreen; + } + else if (btnAnswer2.Text.Equals(_currentQuestion.CorrectAnswer)) + { + btnAnswer2.BackColor = Color.LightGreen; + } + else if (btnAnswer3.Text.Equals(_currentQuestion.CorrectAnswer)) + { + btnAnswer3.BackColor = Color.LightGreen; + } + else if (btnAnswer4.Text.Equals(_currentQuestion.CorrectAnswer)) + { + btnAnswer4.BackColor = Color.LightGreen; + } + ucQuiz.Instance.IncorrectQuestion.Add(ucQuiz.Instance.CurrentQuiz.CurrentQuestionNumber - 1); + } + + // set buttons to disabled + btnAnswer1.Enabled = false; + btnAnswer2.Enabled = false; + btnAnswer3.Enabled = false; + btnAnswer4.Enabled = false; + + // refresh the score + ucQuiz.Instance.RefreshScore(); + + // start the timer to move to the next question + tmrNextQuestion.Start(); + } + + private void tmrNextQuestion_Tick(object sender, EventArgs e) + { + tmrNextQuestion.Stop(); + ucQuiz.Instance.NextQuestion(); + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.resx b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.resx new file mode 100644 index 0000000..1dec30b --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucMCQ.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 17, 17 + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.Designer.cs new file mode 100644 index 0000000..a64a863 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.Designer.cs @@ -0,0 +1,212 @@ +namespace SeaAnimalQuiz.UI +{ + partial class ucQuiz + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pnlQuestion = new System.Windows.Forms.Panel(); + this.btnBack = new System.Windows.Forms.Button(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.lbCorrectAnswers = new System.Windows.Forms.Label(); + this.lbIncorrectAnswers = new System.Windows.Forms.Label(); + this.lbTotalAnswers = new System.Windows.Forms.Label(); + this.lbCorrectAnswersCount = new System.Windows.Forms.Label(); + this.lbIncorrectAnswersCount = new System.Windows.Forms.Label(); + this.lbTotalAnswersCount = new System.Windows.Forms.Label(); + this.pbQuizBackground = new System.Windows.Forms.PictureBox(); + this.lbLoseFocus = new System.Windows.Forms.Label(); + this.tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbQuizBackground)).BeginInit(); + this.SuspendLayout(); + // + // pnlQuestion + // + this.pnlQuestion.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.pnlQuestion.BackColor = System.Drawing.Color.White; + this.pnlQuestion.Location = new System.Drawing.Point(128, 130); + this.pnlQuestion.Name = "pnlQuestion"; + this.pnlQuestion.Size = new System.Drawing.Size(528, 198); + this.pnlQuestion.TabIndex = 1; + // + // btnBack + // + this.btnBack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnBack.BackColor = System.Drawing.Color.LightSlateGray; + this.btnBack.FlatAppearance.BorderColor = System.Drawing.Color.Gray; + this.btnBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnBack.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnBack.ForeColor = System.Drawing.Color.White; + this.btnBack.Location = new System.Drawing.Point(23, 385); + this.btnBack.Name = "btnBack"; + this.btnBack.Size = new System.Drawing.Size(89, 33); + this.btnBack.TabIndex = 2; + this.btnBack.Text = "Back"; + this.btnBack.UseVisualStyleBackColor = false; + this.btnBack.Click += new System.EventHandler(this.btnBack_Click); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.BackColor = System.Drawing.Color.White; + this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 82.71028F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 17.28972F)); + this.tableLayoutPanel1.Controls.Add(this.lbCorrectAnswers, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.lbIncorrectAnswers, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.lbTotalAnswers, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.lbCorrectAnswersCount, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.lbIncorrectAnswersCount, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.lbTotalAnswersCount, 1, 2); + this.tableLayoutPanel1.Location = new System.Drawing.Point(15, 24); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(179, 58); + this.tableLayoutPanel1.TabIndex = 3; + // + // lbCorrectAnswers + // + this.lbCorrectAnswers.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.lbCorrectAnswers.AutoSize = true; + this.lbCorrectAnswers.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbCorrectAnswers.Location = new System.Drawing.Point(33, 1); + this.lbCorrectAnswers.Name = "lbCorrectAnswers"; + this.lbCorrectAnswers.Size = new System.Drawing.Size(110, 17); + this.lbCorrectAnswers.TabIndex = 0; + this.lbCorrectAnswers.Text = "Correct Answers :"; + // + // lbIncorrectAnswers + // + this.lbIncorrectAnswers.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.lbIncorrectAnswers.AutoSize = true; + this.lbIncorrectAnswers.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbIncorrectAnswers.Location = new System.Drawing.Point(30, 19); + this.lbIncorrectAnswers.Name = "lbIncorrectAnswers"; + this.lbIncorrectAnswers.Size = new System.Drawing.Size(113, 17); + this.lbIncorrectAnswers.TabIndex = 1; + this.lbIncorrectAnswers.Text = "Incorrect Answes :"; + // + // lbTotalAnswers + // + this.lbTotalAnswers.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.lbTotalAnswers.AutoSize = true; + this.lbTotalAnswers.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbTotalAnswers.Location = new System.Drawing.Point(5, 38); + this.lbTotalAnswers.Name = "lbTotalAnswers"; + this.lbTotalAnswers.Size = new System.Drawing.Size(138, 17); + this.lbTotalAnswers.TabIndex = 1; + this.lbTotalAnswers.Text = "Questions Remaining :"; + this.lbTotalAnswers.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lbCorrectAnswersCount + // + this.lbCorrectAnswersCount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lbCorrectAnswersCount.AutoSize = true; + this.lbCorrectAnswersCount.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbCorrectAnswersCount.Location = new System.Drawing.Point(150, 1); + this.lbCorrectAnswersCount.Name = "lbCorrectAnswersCount"; + this.lbCorrectAnswersCount.Size = new System.Drawing.Size(24, 17); + this.lbCorrectAnswersCount.TabIndex = 0; + this.lbCorrectAnswersCount.Text = "Cor"; + // + // lbIncorrectAnswersCount + // + this.lbIncorrectAnswersCount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lbIncorrectAnswersCount.AutoSize = true; + this.lbIncorrectAnswersCount.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbIncorrectAnswersCount.Location = new System.Drawing.Point(150, 19); + this.lbIncorrectAnswersCount.Name = "lbIncorrectAnswersCount"; + this.lbIncorrectAnswersCount.Size = new System.Drawing.Size(24, 17); + this.lbIncorrectAnswersCount.TabIndex = 0; + this.lbIncorrectAnswersCount.Text = "Inc"; + // + // lbTotalAnswersCount + // + this.lbTotalAnswersCount.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lbTotalAnswersCount.AutoSize = true; + this.lbTotalAnswersCount.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbTotalAnswersCount.Location = new System.Drawing.Point(150, 38); + this.lbTotalAnswersCount.Name = "lbTotalAnswersCount"; + this.lbTotalAnswersCount.Size = new System.Drawing.Size(22, 17); + this.lbTotalAnswersCount.TabIndex = 0; + this.lbTotalAnswersCount.Text = "Ttl"; + // + // pbQuizBackground + // + this.pbQuizBackground.BackgroundImage = global::SeaAnimalQuiz.Properties.Resources.question; + this.pbQuizBackground.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.pbQuizBackground.Dock = System.Windows.Forms.DockStyle.Fill; + this.pbQuizBackground.Location = new System.Drawing.Point(0, 0); + this.pbQuizBackground.Name = "pbQuizBackground"; + this.pbQuizBackground.Size = new System.Drawing.Size(784, 450); + this.pbQuizBackground.TabIndex = 0; + this.pbQuizBackground.TabStop = false; + // + // lbLoseFocus + // + this.lbLoseFocus.AutoSize = true; + this.lbLoseFocus.Location = new System.Drawing.Point(766, 13); + this.lbLoseFocus.Name = "lbLoseFocus"; + this.lbLoseFocus.Size = new System.Drawing.Size(0, 13); + this.lbLoseFocus.TabIndex = 4; + // + // ucQuiz + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.tableLayoutPanel1); + this.Controls.Add(this.btnBack); + this.Controls.Add(this.pnlQuestion); + this.Controls.Add(this.pbQuizBackground); + this.Controls.Add(this.lbLoseFocus); + this.Name = "ucQuiz"; + this.Size = new System.Drawing.Size(784, 450); + this.Load += new System.EventHandler(this.ucQuiz_Load); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbQuizBackground)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Panel pnlQuestion; + private System.Windows.Forms.PictureBox pbQuizBackground; + private System.Windows.Forms.Button btnBack; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label lbCorrectAnswers; + private System.Windows.Forms.Label lbIncorrectAnswers; + private System.Windows.Forms.Label lbTotalAnswers; + private System.Windows.Forms.Label lbCorrectAnswersCount; + private System.Windows.Forms.Label lbIncorrectAnswersCount; + private System.Windows.Forms.Label lbTotalAnswersCount; + private System.Windows.Forms.Label lbLoseFocus; + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.cs new file mode 100644 index 0000000..93c852f --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.cs @@ -0,0 +1,164 @@ +using SeaAnimalQuiz.Classes; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SeaAnimalQuiz.UI +{ + + /// + /// user control for displaying the quiz to the user. + /// + public partial class ucQuiz : UserControl + { + // singleton object for the quiz user control + private static ucQuiz _instance; + + // current quiz being undertaken + private Quiz _currentQuiz; + + // incorrect questions + private List _incorrectQuestions = new List(); + + /// + /// get the singleton object of the Quiz class + /// + public static ucQuiz Instance + { + get + { + if (_instance == null) + { + _instance = new ucQuiz(); + } + return _instance; + } + } + + private ucQuiz() + { + InitializeComponent(); + } + + private void ucQuiz_Load(object sender, EventArgs e) + { + _currentQuiz = new Quiz(); + _currentQuiz.LoadQuestions(QuizCategory.Fish); + RefreshScore(); + if (_currentQuiz.CurrentQuestion.QuestionType == QuestionType.MultipleChoice) + { + DisplayMCQ(_currentQuiz.CurrentQuestion); + } + else if (_currentQuiz.CurrentQuestion.QuestionType == QuestionType.TrueFalse) + { + DisplayTrueFalse(_currentQuiz.CurrentQuestion); + } + } + + public void RefreshUc() + { + _currentQuiz = new Quiz(); + _currentQuiz.LoadQuestions(QuizCategory.Fish); + if (_currentQuiz.CurrentQuestion.QuestionType == QuestionType.MultipleChoice) + { + DisplayMCQ(_currentQuiz.CurrentQuestion); + } + else if (_currentQuiz.CurrentQuestion.QuestionType == QuestionType.TrueFalse) + { + DisplayTrueFalse(_currentQuiz.CurrentQuestion); + } + } + + public void RefreshScore() + { + lbCorrectAnswersCount.Text = _currentQuiz.CorrectAnswers.ToString(); + lbIncorrectAnswersCount.Text = _currentQuiz.IncorrectAnswers.ToString(); + lbTotalAnswersCount.Text = _currentQuiz.QuestionsRemaining().ToString(); + } + + // get the current quiz + public Quiz CurrentQuiz + { + get + { + return _currentQuiz; + } + } + + // get the dictionary of the incorrect attempted questions with correct answers + public List IncorrectQuestion + { + get + { + return _incorrectQuestions; + } + } + + public void NextQuestion() + { + + if (_currentQuiz.IsEndOfQuiz()) + { + // string representation of the result + string result = _currentQuiz.CorrectAnswers + "/" + (_currentQuiz.CorrectAnswers + _currentQuiz.IncorrectAnswers); + + if (!pnlQuestion.Controls.Contains(ucQuizResult.Instance)) + { + pnlQuestion.Controls.Add(ucQuizResult.Instance); + } + ucQuizResult.Instance.Dock = DockStyle.Fill; + ucQuizResult.Instance.RefreshUc(_incorrectQuestions, result); + ucQuizResult.Instance.BringToFront(); + }else + { + _currentQuiz.NextQuestion(); + if (_currentQuiz.CurrentQuestion.QuestionType == QuestionType.MultipleChoice) + { + DisplayMCQ(_currentQuiz.CurrentQuestion); + } + else if (_currentQuiz.CurrentQuestion.QuestionType == QuestionType.TrueFalse) + { + DisplayTrueFalse(_currentQuiz.CurrentQuestion); + } + } + } + + public void LoseFocus() + { + lbLoseFocus.Focus(); + } + + private void DisplayTrueFalse(Question question) + { + if (!pnlQuestion.Controls.Contains(ucTrueFalse.Instance)) + { + pnlQuestion.Controls.Add(ucTrueFalse.Instance); + } + ucTrueFalse.Instance.Dock = DockStyle.Fill; + ucTrueFalse.Instance.DisplayTrueFalse(question); + ucTrueFalse.Instance.BringToFront(); + } + + private void DisplayMCQ(Question question) + { + if (!pnlQuestion.Controls.Contains(ucMCQ.Instance)) + { + pnlQuestion.Controls.Add(ucMCQ.Instance); + } + ucMCQ.Instance.Dock = DockStyle.Fill; + ucMCQ.Instance.DisplayMCQ(question); + ucMCQ.Instance.BringToFront(); + } + + private void btnBack_Click(object sender, EventArgs e) + { + MainForm.Instance.SetHomePage(); + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.resx b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuiz.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.Designer.cs new file mode 100644 index 0000000..92e6c5d --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.Designer.cs @@ -0,0 +1,210 @@ +namespace SeaAnimalQuiz.UI +{ + partial class ucQuizResult + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dgvIncorrectQuestions = new System.Windows.Forms.DataGridView(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.label1 = new System.Windows.Forms.Label(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.lbTotalScore = new System.Windows.Forms.Label(); + this.lbObtainedByTotal = new System.Windows.Forms.Label(); + this.cQuestion = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.cCorrectAnswer = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvIncorrectQuestions)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.panel1.SuspendLayout(); + this.tableLayoutPanel3.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + this.SuspendLayout(); + // + // dgvIncorrectQuestions + // + this.dgvIncorrectQuestions.AllowUserToAddRows = false; + this.dgvIncorrectQuestions.AllowUserToDeleteRows = false; + this.dgvIncorrectQuestions.AllowUserToResizeColumns = false; + this.dgvIncorrectQuestions.AllowUserToResizeRows = false; + this.dgvIncorrectQuestions.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dgvIncorrectQuestions.BackgroundColor = System.Drawing.Color.White; + this.dgvIncorrectQuestions.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dgvIncorrectQuestions.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvIncorrectQuestions.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.cQuestion, + this.cCorrectAnswer}); + this.dgvIncorrectQuestions.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgvIncorrectQuestions.GridColor = System.Drawing.Color.LightGray; + this.dgvIncorrectQuestions.Location = new System.Drawing.Point(3, 3); + this.dgvIncorrectQuestions.Name = "dgvIncorrectQuestions"; + this.dgvIncorrectQuestions.ReadOnly = true; + this.dgvIncorrectQuestions.RowHeadersVisible = false; + this.dgvIncorrectQuestions.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.dgvIncorrectQuestions.ShowCellErrors = false; + this.dgvIncorrectQuestions.ShowCellToolTips = false; + this.dgvIncorrectQuestions.ShowEditingIcon = false; + this.dgvIncorrectQuestions.ShowRowErrors = false; + this.dgvIncorrectQuestions.Size = new System.Drawing.Size(522, 197); + this.dgvIncorrectQuestions.TabIndex = 0; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.dgvIncorrectQuestions, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 84.23237F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15.76763F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(528, 241); + this.tableLayoutPanel1.TabIndex = 1; + // + // panel1 + // + this.panel1.Controls.Add(this.tableLayoutPanel3); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(3, 206); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(522, 32); + this.panel1.TabIndex = 1; + // + // tableLayoutPanel3 + // + this.tableLayoutPanel3.ColumnCount = 2; + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.19157F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 49.80843F)); + this.tableLayoutPanel3.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel2, 1, 0); + this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel3.Name = "tableLayoutPanel3"; + this.tableLayoutPanel3.RowCount = 1; + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(522, 32); + this.tableLayoutPanel3.TabIndex = 4; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.ForeColor = System.Drawing.Color.DarkGreen; + this.label1.Location = new System.Drawing.Point(3, 5); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(97, 21); + this.label1.TabIndex = 2; + this.label1.Text = "Completed!"; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel2.ColumnCount = 2; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 59F)); + this.tableLayoutPanel2.Controls.Add(this.lbTotalScore, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.lbObtainedByTotal, 1, 0); + this.tableLayoutPanel2.Location = new System.Drawing.Point(330, 3); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 1; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(189, 26); + this.tableLayoutPanel2.TabIndex = 3; + // + // lbTotalScore + // + this.lbTotalScore.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.lbTotalScore.AutoSize = true; + this.lbTotalScore.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbTotalScore.Location = new System.Drawing.Point(28, 2); + this.lbTotalScore.Name = "lbTotalScore"; + this.lbTotalScore.Size = new System.Drawing.Size(99, 21); + this.lbTotalScore.TabIndex = 2; + this.lbTotalScore.Text = "Total Score :"; + // + // lbObtainedByTotal + // + this.lbObtainedByTotal.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lbObtainedByTotal.AutoSize = true; + this.lbObtainedByTotal.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbObtainedByTotal.Location = new System.Drawing.Point(133, 2); + this.lbObtainedByTotal.Name = "lbObtainedByTotal"; + this.lbObtainedByTotal.Size = new System.Drawing.Size(50, 21); + this.lbObtainedByTotal.TabIndex = 2; + this.lbObtainedByTotal.Text = "score"; + // + // cQuestion + // + this.cQuestion.HeaderText = "Incorrect Quesetion"; + this.cQuestion.Name = "cQuestion"; + this.cQuestion.ReadOnly = true; + // + // cCorrectAnswer + // + this.cCorrectAnswer.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.cCorrectAnswer.HeaderText = "Correct Answer"; + this.cCorrectAnswer.Name = "cCorrectAnswer"; + this.cCorrectAnswer.ReadOnly = true; + this.cCorrectAnswer.Width = 96; + // + // ucQuizResult + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "ucQuizResult"; + this.Size = new System.Drawing.Size(528, 241); + ((System.ComponentModel.ISupportInitialize)(this.dgvIncorrectQuestions)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.tableLayoutPanel3.ResumeLayout(false); + this.tableLayoutPanel3.PerformLayout(); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.DataGridView dgvIncorrectQuestions; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.Label lbTotalScore; + private System.Windows.Forms.Label lbObtainedByTotal; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.DataGridViewTextBoxColumn cQuestion; + private System.Windows.Forms.DataGridViewTextBoxColumn cCorrectAnswer; + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.cs new file mode 100644 index 0000000..c4ba4f1 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.cs @@ -0,0 +1,52 @@ +using SeaAnimalQuiz.Classes; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SeaAnimalQuiz.UI +{ + public partial class ucQuizResult : UserControl + { + // singleton object for the quiz result user control + private static ucQuizResult _instance; + + /// + /// get the singleton object of the Quiz Result class + /// + public static ucQuizResult Instance + { + get + { + if (_instance == null) + { + _instance = new ucQuizResult(); + } + return _instance; + } + } + public ucQuizResult() + { + InitializeComponent(); + } + + public void RefreshUc(List incorrectQuestions, string result) + { + dgvIncorrectQuestions.Rows.Clear(); + + // load the incorrectQuestions key question number, question text and value into the data grid view + foreach (int index in incorrectQuestions) + { + Question question = ucQuiz.Instance.CurrentQuiz.GetQuestion(index); + dgvIncorrectQuestions.Rows.Add(question.QuestionText, question.CorrectAnswer); + } + + lbObtainedByTotal.Text = result; + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.resx b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.resx new file mode 100644 index 0000000..e27281e --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucQuizResult.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + \ No newline at end of file diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.Designer.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.Designer.cs new file mode 100644 index 0000000..3439977 --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.Designer.cs @@ -0,0 +1,167 @@ +namespace SeaAnimalQuiz.UI +{ + partial class ucTrueFalse + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tlpTrueFalseQuestionAnswers = new System.Windows.Forms.TableLayoutPanel(); + this.tlpMcqAnswers = new System.Windows.Forms.TableLayoutPanel(); + this.rbAnswer1 = new System.Windows.Forms.RadioButton(); + this.rbAnswer2 = new System.Windows.Forms.RadioButton(); + this.tmrNextQuestion = new System.Windows.Forms.Timer(this.components); + this.btnSubmit = new System.Windows.Forms.Button(); + this.tbQuestionText = new System.Windows.Forms.TextBox(); + this.tlpTrueFalseQuestionAnswers.SuspendLayout(); + this.tlpMcqAnswers.SuspendLayout(); + this.SuspendLayout(); + // + // tlpTrueFalseQuestionAnswers + // + this.tlpTrueFalseQuestionAnswers.BackColor = System.Drawing.Color.White; + this.tlpTrueFalseQuestionAnswers.ColumnCount = 1; + this.tlpTrueFalseQuestionAnswers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpTrueFalseQuestionAnswers.Controls.Add(this.tbQuestionText, 0, 0); + this.tlpTrueFalseQuestionAnswers.Controls.Add(this.tlpMcqAnswers, 0, 1); + this.tlpTrueFalseQuestionAnswers.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpTrueFalseQuestionAnswers.Location = new System.Drawing.Point(0, 0); + this.tlpTrueFalseQuestionAnswers.Name = "tlpTrueFalseQuestionAnswers"; + this.tlpTrueFalseQuestionAnswers.RowCount = 2; + this.tlpTrueFalseQuestionAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60.16597F)); + this.tlpTrueFalseQuestionAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 39.83403F)); + this.tlpTrueFalseQuestionAnswers.Size = new System.Drawing.Size(528, 241); + this.tlpTrueFalseQuestionAnswers.TabIndex = 3; + // + // tlpMcqAnswers + // + this.tlpMcqAnswers.ColumnCount = 2; + this.tlpMcqAnswers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.Controls.Add(this.rbAnswer1, 0, 0); + this.tlpMcqAnswers.Controls.Add(this.rbAnswer2, 1, 0); + this.tlpMcqAnswers.Controls.Add(this.btnSubmit, 1, 1); + this.tlpMcqAnswers.Dock = System.Windows.Forms.DockStyle.Fill; + this.tlpMcqAnswers.Location = new System.Drawing.Point(3, 147); + this.tlpMcqAnswers.Name = "tlpMcqAnswers"; + this.tlpMcqAnswers.RowCount = 2; + this.tlpMcqAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tlpMcqAnswers.Size = new System.Drawing.Size(522, 91); + this.tlpMcqAnswers.TabIndex = 0; + // + // rbAnswer1 + // + this.rbAnswer1.Anchor = System.Windows.Forms.AnchorStyles.None; + this.rbAnswer1.AutoSize = true; + this.rbAnswer1.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.rbAnswer1.Location = new System.Drawing.Point(90, 12); + this.rbAnswer1.Name = "rbAnswer1"; + this.rbAnswer1.Size = new System.Drawing.Size(80, 21); + this.rbAnswer1.TabIndex = 0; + this.rbAnswer1.TabStop = true; + this.rbAnswer1.Text = "Answer 1"; + this.rbAnswer1.UseVisualStyleBackColor = true; + // + // rbAnswer2 + // + this.rbAnswer2.Anchor = System.Windows.Forms.AnchorStyles.None; + this.rbAnswer2.AutoSize = true; + this.rbAnswer2.BackColor = System.Drawing.Color.White; + this.rbAnswer2.Font = new System.Drawing.Font("Segoe UI Semibold", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.rbAnswer2.Location = new System.Drawing.Point(350, 12); + this.rbAnswer2.Name = "rbAnswer2"; + this.rbAnswer2.Size = new System.Drawing.Size(82, 21); + this.rbAnswer2.TabIndex = 1; + this.rbAnswer2.TabStop = true; + this.rbAnswer2.Text = "Answer 2"; + this.rbAnswer2.UseVisualStyleBackColor = false; + // + // tmrNextQuestion + // + this.tmrNextQuestion.Interval = 800; + this.tmrNextQuestion.Tick += new System.EventHandler(this.tmrNextQuestion_Tick); + // + // btnSubmit + // + this.btnSubmit.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.btnSubmit.BackColor = System.Drawing.Color.SlateGray; + this.btnSubmit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnSubmit.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnSubmit.ForeColor = System.Drawing.Color.White; + this.btnSubmit.Location = new System.Drawing.Point(443, 48); + this.btnSubmit.Name = "btnSubmit"; + this.btnSubmit.Size = new System.Drawing.Size(76, 39); + this.btnSubmit.TabIndex = 2; + this.btnSubmit.Text = "Submit"; + this.btnSubmit.UseVisualStyleBackColor = false; + this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click); + // + // tbQuestionText + // + this.tbQuestionText.BackColor = System.Drawing.Color.White; + this.tbQuestionText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbQuestionText.Cursor = System.Windows.Forms.Cursors.Arrow; + this.tbQuestionText.Dock = System.Windows.Forms.DockStyle.Fill; + this.tbQuestionText.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbQuestionText.Location = new System.Drawing.Point(3, 3); + this.tbQuestionText.Multiline = true; + this.tbQuestionText.Name = "tbQuestionText"; + this.tbQuestionText.ReadOnly = true; + this.tbQuestionText.ShortcutsEnabled = false; + this.tbQuestionText.Size = new System.Drawing.Size(522, 138); + this.tbQuestionText.TabIndex = 2; + this.tbQuestionText.Text = "True False Questions"; + this.tbQuestionText.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.tbQuestionText.Enter += new System.EventHandler(this.tbQuestionText_Enter); + // + // ucTrueFalse + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.Controls.Add(this.tlpTrueFalseQuestionAnswers); + this.Name = "ucTrueFalse"; + this.Size = new System.Drawing.Size(528, 241); + this.tlpTrueFalseQuestionAnswers.ResumeLayout(false); + this.tlpTrueFalseQuestionAnswers.PerformLayout(); + this.tlpMcqAnswers.ResumeLayout(false); + this.tlpMcqAnswers.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tlpTrueFalseQuestionAnswers; + private System.Windows.Forms.TableLayoutPanel tlpMcqAnswers; + private System.Windows.Forms.RadioButton rbAnswer1; + private System.Windows.Forms.RadioButton rbAnswer2; + private System.Windows.Forms.Timer tmrNextQuestion; + private System.Windows.Forms.Button btnSubmit; + private System.Windows.Forms.TextBox tbQuestionText; + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.cs b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.cs new file mode 100644 index 0000000..572fc5a --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.cs @@ -0,0 +1,141 @@ +using SeaAnimalQuiz.Classes; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace SeaAnimalQuiz.UI +{ + public partial class ucTrueFalse : UserControl + { + // singleton object for the true false user control + private static ucTrueFalse _instance; + + // current question it is displaying + private TrueFalse _currentQuestion; + + /// + /// get the singleton object of the TrueFalse class + /// + public static ucTrueFalse Instance + { + get + { + if (_instance == null) + { + _instance = new ucTrueFalse(); + } + return _instance; + } + } + + private ucTrueFalse() + { + InitializeComponent(); + } + + public void DisplayTrueFalse(Question question) + { + TrueFalse trueFalse = (TrueFalse)question; + _currentQuestion = trueFalse; + + // set question text + tbQuestionText.Text = trueFalse.QuestionText; + setTextBox_Scroll(); + + rbAnswer1.Text = trueFalse.FirstAnswer; + rbAnswer2.Text = trueFalse.SecondAnswer; + + // set buttons color to default + rbAnswer1.BackColor = Color.White; + rbAnswer2.BackColor = Color.White; + + // set buttons to enabled + rbAnswer1.Enabled = true; + rbAnswer2.Enabled = true; + btnSubmit.Enabled = true; + + // set buttons to unchecked + rbAnswer1.Checked = false; + rbAnswer2.Checked = false; + } + + private void setTextBox_Scroll() + { + if (tbQuestionText.Multiline) + { + tbQuestionText.ScrollBars = tbQuestionText.Text.Length > (tbQuestionText.Width + tbQuestionText.Height) / 1.30f ? ScrollBars.Vertical : tbQuestionText.Text.Split('\n').Length > tbQuestionText.Height / tbQuestionText.Font.Size / 1.4f ? ScrollBars.Vertical : ScrollBars.None; + } + } + + private void tmrNextQuestion_Tick(object sender, EventArgs e) + { + tmrNextQuestion.Stop(); + ucQuiz.Instance.NextQuestion(); + } + + private void btnSubmit_Click(object sender, EventArgs e) + { + RadioButton radioButton; + if (rbAnswer1.Checked) + { + radioButton = rbAnswer1; + } + else if(rbAnswer2.Checked) + { + radioButton = rbAnswer2; + } + else + { + MessageBox.Show("Please select an answer"); + return; + } + + if (ucQuiz.Instance.CurrentQuiz.CheckAnswer(radioButton.Text)) + { + radioButton.BackColor = Color.LightGreen; + } + else + { + radioButton.BackColor = Color.MistyRose; + + // set the correct answer button to green + if (rbAnswer1.Text.Equals(_currentQuestion.CorrectAnswer)) + { + rbAnswer1.BackColor = Color.LightGreen; + } + else if (rbAnswer2.Text.Equals(_currentQuestion.CorrectAnswer)) + { + rbAnswer2.BackColor = Color.LightGreen; + } + ucQuiz.Instance.IncorrectQuestion.Add(ucQuiz.Instance.CurrentQuiz.CurrentQuestionNumber - 1); + } + + // set buttons to disabled + rbAnswer1.Enabled = false; + rbAnswer2.Enabled = false; + btnSubmit.Enabled = false; + + // lose focus from the text box + ucQuiz.Instance.LoseFocus(); + + // refresh the score + ucQuiz.Instance.RefreshScore(); + + // start the timer to move to the next question + tmrNextQuestion.Start(); + } + + private void tbQuestionText_Enter(object sender, EventArgs e) + { + + } + } +} diff --git a/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.resx b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.resx new file mode 100644 index 0000000..1dec30b --- /dev/null +++ b/SeaAnimalQuiz/SeaAnimalQuiz/UI/ucTrueFalse.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 17, 17 + + \ No newline at end of file