Пример #1
0
        private void backToDefaultClick(object sender, EventArgs e)
        {
            if (File.Exists("config.xml"))
            {
                File.Delete("config.xml");
            }

            StyleApplier.Reload();
            StyleApplier.ApplyColors(this);
        }
Пример #2
0
        public QuizCreator()
        {
            InitializeComponent();
            controler    = new QuizCreatorControler();
            filePathInfo = new ToolTip {
                IsBalloon = true
            };
            entries = new List <EntryInterface>();

            StyleApplier.ApplyColors(mainPanel);
        }
Пример #3
0
        private void LoadQuestion()
        {
            foreach (var c in splitContainer.Panel1.Controls)
            {
                if (c is QuestionViewer)
                {
                    (c as QuestionViewer).Clear();
                }
            }

            splitContainer.Panel1.Controls.Clear();

            var q = controler.GetNextQuestion();

            if (q == null)
            {
                var scoreLabel = new Label
                {
                    TextAlign = ContentAlignment.MiddleCenter,
                    Dock      = DockStyle.Fill,
                    Text      = "Your score:\n" + controler.Points + " / " + controler.QuestionsCount,
                    Font      = new Font("Callbri", 20, FontStyle.Bold),
                };
                splitContainer.Panel1.Controls.Add(scoreLabel);
                splitContainer.Panel2.Controls.Clear();

                var quitButton = new Button
                {
                    Dock = DockStyle.Fill,
                    Font = new Font("Callbri", 15, FontStyle.Bold),
                    Text = "Back to menu",
                };

                quitButton.Click += (s, ea) => Close();
                splitContainer.Panel2.Controls.Add(quitButton);
                StyleApplier.ApplyColors(splitContainer.Panel2);

                return;
            }

            splitContainer.Panel1.Controls.Add(new QuestionViewer(q));
            answerAButton.Text = q[0];
            answerBButton.Text = q[1];
            answerCButton.Text = q[2];
            answerDButton.Text = q[3];

            foreach (var b in new Button[] { answerAButton, answerBButton, answerCButton, answerDButton })
            {
                b.Enabled = true;
                StyleApplier.ApplyColors(splitContainer.Panel2);
            }
        }
Пример #4
0
        private void settingsClick(object sender, EventArgs e)
        {
            this.Visible = false;
            var settings = new Settings();

            settings.FormClosed += (s, ea) =>
            {
                StyleApplier.Reload();
                StyleApplier.ApplyColors(this);
                StyleApplier.ApplyName(this);
                this.Visible = true;
            };
            settings.Show();
        }
Пример #5
0
        private void saveButtonClick(object sender, EventArgs e)
        {
            var elements = new List <XElement>();

            elements.Add(new XElement("programName", programNameTextbox.Text));

            var buttonColor = new XElement
                              (
                "buttonColor",
                new XAttribute("red", buttonColorTextboxRed.Text),
                new XAttribute("green", buttonColorTextboxGreen.Text),
                new XAttribute("blue", buttonColorTextboxBlue.Text)
                              );

            elements.Add(buttonColor);

            var backgroundColor = new XElement
                                  (
                "backgroundColor",
                new XAttribute("red", backgroundColorTextboxRed.Text),
                new XAttribute("green", backgroundColorTextboxGreen.Text),
                new XAttribute("blue", backgroundColorTextboxBlue.Text)
                                  );

            elements.Add(backgroundColor);

            var fontColor = new XElement
                            (
                "fontColor",
                new XAttribute("red", fontColorTextboxRed.Text),
                new XAttribute("green", fontColorTextboxGreen.Text),
                new XAttribute("blue", fontColorTextboxBlue.Text)
                            );

            elements.Add(fontColor);

            elements.Add(new XElement("buttonStyle", buttonStyleButton.FlatStyle == FlatStyle.Standard ? "Standard" : "Popup"));

            var document = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("settings", elements));

            document.Save("config.xml");

            StyleApplier.Reload();
            StyleApplier.ApplyColors(this);
        }
Пример #6
0
        public QuizWindow(string filePath)
        {
            InitializeComponent();

            controler = new QuizWindowControler(filePath);

            answerAButton.Click += (s, ea) => AnswerButtonClick(0);
            answerBButton.Click += (s, ea) => AnswerButtonClick(1);
            answerCButton.Click += (s, ea) => AnswerButtonClick(2);
            answerDButton.Click += (s, ea) => AnswerButtonClick(3);

            timer          = new Timer();
            timer.Interval = 1000;
            timer.Tick    += AnswerShowEnd;

            StyleApplier.ApplyName(this);
            StyleApplier.ApplyColors(splitContainer);
            StyleApplier.ApplyColors(splitContainer.Panel1);
            StyleApplier.ApplyColors(splitContainer.Panel2);

            LoadQuestion();
        }
Пример #7
0
        public QuestionViewer(Question q)
        {
            question = q;
            text     = question.GetQuestion();
            Dock     = DockStyle.Fill;
            StyleApplier.ApplyColors(this);

            textLabel = new Label
            {
                TextAlign = ContentAlignment.MiddleCenter,
                Dock      = DockStyle.Fill,
                Text      = text,
                Font      = new Font("Callbri", 11, FontStyle.Bold),
            };

            if (question is ImageQuestion)
            {
                var splitContainer = new SplitContainer {
                    IsSplitterFixed = true
                };
                splitContainer.Orientation  = Orientation.Horizontal;
                splitContainer.Dock         = DockStyle.Fill;
                splitContainer.SizeChanged += (s, ea) => splitContainer.SplitterDistance = 100;
                splitContainer.Panel1.Controls.Add(textLabel);
                splitContainer.Panel1.Controls.Add(new Button {
                    Text = ""
                });                                                            //now the spliter does not catch focus
                splitContainer.Panel1.AutoScroll = true;
                splitContainer.Panel2.Controls.Add(new PictureBox {
                    Image = (question as ImageQuestion).Image, Dock = DockStyle.Fill, SizeMode = PictureBoxSizeMode.Zoom
                });
                this.Controls.Add(splitContainer);
            }
            else if (question is SoundQuestion)
            {
                var playButton = new Button
                {
                    Width     = 120,
                    Height    = 40,
                    Text      = "Play sound",
                    BackColor = Color.Green,
                    Font      = new Font("Callbri", 12, FontStyle.Bold),
                    FlatStyle = FlatStyle.Popup,
                    ForeColor = Color.Black
                };

                var stopButton = new Button
                {
                    Width     = 120,
                    Height    = 40,
                    Text      = "Stop",
                    BackColor = Color.Red,
                    Font      = new Font("Callbri", 12, FontStyle.Bold),
                    FlatStyle = FlatStyle.Popup,
                    ForeColor = Color.Black
                };

                playButton.Click += (s, ea) => (question as SoundQuestion).Play();
                stopButton.Click += (s, ea) => (question as SoundQuestion).Stop();

                var splitContainer = new SplitContainer {
                    IsSplitterFixed = true
                };
                splitContainer.Orientation  = Orientation.Horizontal;
                splitContainer.Dock         = DockStyle.Fill;
                splitContainer.SizeChanged += (s, ea) => splitContainer.SplitterDistance = 80;
                splitContainer.Panel1.Controls.Add(playButton);
                splitContainer.Panel1.Controls.Add(stopButton);

                splitContainer.Panel1.SizeChanged += (s, ea) =>
                {
                    playButton.Left = (splitContainer.Panel1.Width) / 2 - playButton.Width - 10;
                    playButton.Top  = (splitContainer.Panel1.Height - playButton.Height) / 2;

                    stopButton.Left = (splitContainer.Panel1.Width) / 2 + 10;
                    stopButton.Top  = (splitContainer.Panel1.Height - stopButton.Height) / 2;
                };

                splitContainer.Panel2.Controls.Add(textLabel);
                splitContainer.Panel2.AutoScroll = true;
                this.Controls.Add(splitContainer);
            }
            else
            {
                this.Controls.Add(textLabel);
            }
        }
Пример #8
0
 public Settings()
 {
     InitializeComponent();
     StyleApplier.ApplyColors(this);
     LoadValues();
 }
Пример #9
0
 public Menu()
 {
     InitializeComponent();
     StyleApplier.ApplyName(this);
     StyleApplier.ApplyColors(this);
 }