示例#1
0
        private AppState previousState; // may be used in the future, leave here

        #endregion Fields

        #region Constructors

        private MainForm()
        {
            InitializeComponent();

            // Using OneBasedArray to have our answers numbered from 1
            answerPickers = new OneBasedArray<RadioButton>(PersistentData.MAX_ANSWERS);
            answerPickers[1] = answerPicker1;
            answerPickers[2] = answerPicker2;
            answerPickers[3] = answerPicker3;
            answerPickers[4] = answerPicker4;

            loginButton.MouseEnter += new EventHandler(LoginButton_MouseEnter);
            loginButton.MouseLeave += new EventHandler(LoginButton_MouseLeave);
            newQuizButton.MouseEnter += new EventHandler(NewQuizButton_MouseEnter);
            newQuizButton.MouseLeave += new EventHandler(NewQuizButton_MouseLeave);
            statisticsButton.MouseEnter += new EventHandler(StatisticsButton_MouseEnter);
            statisticsButton.MouseLeave += new EventHandler(StatisticsButton_MouseLeave);
            exitButton.MouseEnter += new EventHandler(ExitButton_MouseEnter);
            exitButton.MouseLeave += new EventHandler(ExitButton_MouseLeave);
            nextQuestionButton.MouseEnter += new EventHandler(NextQuestionButton_MouseEnter);
            nextQuestionButton.MouseLeave += new EventHandler(NextQuestionButton_MouseLeave);
            createAccountLink.MouseEnter += new EventHandler(CreateAccountLink_MouseEnter);
            createAccountLink.MouseLeave += new EventHandler(CreateAccountLink_MouseLeave);
            createAccountButton.MouseEnter += new EventHandler(CreateAccountButton_MouseEnter);
            createAccountButton.MouseLeave += new EventHandler(CreateAccountButton_MouseLeave);
            statisticsBackButton.MouseEnter += new EventHandler(StatisticsBackButton_MouseEnter);
            statisticsBackButton.MouseLeave += new EventHandler(StatisticsBackButton_MouseLeave);
            endingBackButton.MouseEnter += new EventHandler(EndingBackButton_MouseEnter);
            endingBackButton.MouseLeave += new EventHandler(EndingBackButton_MouseLeave);
            logoutButton.MouseEnter += new EventHandler(LogOutButton_MouseEnter);
            logoutButton.MouseLeave += new EventHandler(LogOutButton_MouseLeave);
            finnishquizButton.MouseEnter += new EventHandler(FinnishQuizButton_MouseEnter);
            finnishquizButton.MouseLeave += new EventHandler(FinnishQuizButton_MouseLeave);
        }
示例#2
0
    public OneBasedArray <Cup> GetInput(string str)
    {
        int[] input = str.Select(c => (int)char.GetNumericValue(c)).ToArray();
        OneBasedArray <Cup> cups = new OneBasedArray <Cup>(input.Length);

        for (int i = 1; i < input.Length; i++)
        {
            int num = input[i - 1];
            cups[num] = new Cup(num, input[i]);
        }
        cups[input[^ 1]] = new Cup(input[^ 1], input[0]);
示例#3
0
文件: DAL.cs 项目: poseamaria/RomGeo
        public static OneBasedArray<Question> GetQuestions()
        {
            OneBasedArray<Question> questionList = new OneBasedArray<Question>(30);
            int id = 0;
            int difficultyPercent = 0;
            bool isGraphic = false;
            string text = string.Empty;
            Domain domain = Domain.None;
            byte[] imageData;
            Image image = null;

            // Open connection
            if (OpenConnection() == true)
            {
                // Create command and assign the query and connection from the constructor
                try
                {
                        using (var command = new MySqlCommand("GetQuestions", connection) { CommandType = CommandType.StoredProcedure })
                        {
                            command.Parameters.AddWithValue("@user", PersistentData.user);
                            int j = 1;

                            MySqlDataReader myReader = command.ExecuteReader();
                            while (myReader.Read())
                            {
                                id = myReader.GetInt32(0);
                                text = myReader.GetString(1);
                                domain = myReader.GetDomain(2);
                                difficultyPercent = myReader.GetInt32(3);
                                isGraphic = myReader.GetBoolean(4);

                                if (isGraphic)
                                    imageData = (byte[])myReader[5];
                                else imageData = null;
                                image = Utils.Converters.ByteArrayToImage(imageData);
                                Answers answers = new Answers();
                                answers.CorrectAnswer = myReader.GetString(6);

                                int i = 1;
                                while (i <= PersistentData.MAX_ANSWERS)
                                {
                                    answers[i] = myReader.GetString(6 + i);
                                    i++;
                                }

                                if (!isGraphic)
                                    questionList[j] = new Question(id, text, domain, difficultyPercent, answers);
                                else
                                    questionList[j] = new GraphicQuestion(id, text, image, domain, difficultyPercent, answers);
                                j++;
                            }
                        }
                    }
                catch (MySqlException ex)
                {
                    Debug.ExitWithErrorMessage(ex.Message, ex.Number);
                }

                // Close connection
                CloseConnection();
            }
            else Debug.ExitWithErrorMessage("Connection failed to open using DAL method.");
            return questionList;
        }