Пример #1
0
        public void Resulttest()
        {
            var ListViewController = new ListViewController();

            try {
                var form        = new Form();
                var groupBox    = new CxFlatGroupBox();
                var groupButton = new CxFlatButton();
                groupBox.Controls.Add(groupButton);
                form.Controls.Add(groupBox);
                ListViewController.CheckShouldEnableSubmitButton(form);
                ListViewController.AddSelectedOptionForAnswer(groupButton, new EventArgs());
            } catch (Exception ex) {
                throw ex;
            }

            Assert.IsInstanceOfType(ListViewController, typeof(ListViewController));

            if (ListViewController != null)
            {
                Assert.IsInstanceOfType(ListViewController, typeof(ListViewController));
            }
        }
Пример #2
0
        // TODO: Make those responsive https://www.codeproject.com/Articles/1140717/A-Responsive-Design-Technique-for-WinForms
        public void RenderInitialView(Form view)
        {
            var groupBoxWidth  = view.ClientSize.Width / 2;
            var groupBoxHeight = view.ClientSize.Height / 2;

            var randomTake   = new Random();
            var dbConnection = new Questions();
            var questions    = dbConnection.Fragens.ToList();

            for (var i = 0; i < 15; i++)
            {
                Fragen currentQuestion;
                do
                {
                    currentQuestion = questions.ElementAt(randomTake.Next(0, 99));
                } while (currentQuestion == null || ChosenQuestions.Any(q => q == currentQuestion));
                ChosenQuestions.Add(currentQuestion);
                AllAnswersToCurrentQuestions.AddRange(currentQuestion.Antwortens);

                var groupBox = new CxFlatGroupBox(new Font("Segoe UI", 1))
                {
                    Name       = $"groupox{i}",
                    Text       = currentQuestion.Frage,
                    Size       = new Size(groupBoxWidth, groupBoxHeight),
                    Left       = (view.ClientSize.Width - groupBoxWidth) / 2,
                    Top        = ((view.ClientSize.Height - groupBoxHeight) / 2),
                    ShowText   = true,
                    ThemeColor = ThemeColors.DarkPrimary, // This isn't working but I'll extend it in my free time probably
                    BackColor  = this.DarkStuff,
                    ////Font = new Font("Segoe UI", 6),
                    HeaderStyle = new HeaderStyle(new CustomDrawLine(new Pen(ThemeColors.OneLevelBorder, 1), 0, 70, groupBoxWidth, 70), new CustomRectangleF(15, 0, groupBoxWidth, 50), new Font("arial", 9F), new SolidBrush(Color.White), StringAlign.Center)
                };

                // Sets up the initial objects in the CheckedListBox.
                var answers = currentQuestion.Antwortens.ToArray();
                for (var j = 1; j <= answers.Length; j++)
                {
                    var questionItem = new CxFlatButton {
                        Name       = $"button{j + i - 1}",
                        Text       = answers[j - 1].Antwort,
                        Size       = new Size(250, 100),
                        Font       = new Font("Arial", 10),
                        ButtonType = ButtonType.Success
                    };

                    // TODO: Make this more reasonable
                    if (j == 1)
                    {
                        questionItem.Location = new Point(groupBox.Width / 2 - 265, groupBox.Height / 2 + 50);
                    }
                    else if (j == 2)
                    {
                        questionItem.Location = new Point(groupBox.Width / 2 + 15, groupBox.Height / 2 + 50);
                    }
                    else if (j == 3)
                    {
                        questionItem.Location = new Point(groupBox.Width / 2 - 265, groupBox.Height / 2 - 60);
                    }
                    else if (j == 4)
                    {
                        questionItem.Location = new Point(groupBox.Width / 2 + 15, groupBox.Height / 2 - 60);
                    }

                    questionItem.Click += this.AddSelectedOptionForAnswer;
                    groupBox.Controls.Add(questionItem);
                }

                view.Controls.Add(groupBox);
            }
        }