public FormUserInfo(User user)
        {
            InitializeComponent();
            StyleApply.ForForm(this);

            listBox.DoubleClick += (s, e) =>
            {
                btn_moreInfo.PerformClick();
            };

            if (user == null)
            {
                throw new ArgumentNullException($"{nameof(user)} is null");
            }

            this.User = user;

            Timer moreInfoEnable = new Timer()
            {
                Interval = 100,
                Enabled  = true
            };

            moreInfoEnable.Tick += MoreInfoEnable_Tick;

            lbl_name.Text  = user.Name;
            lbl_class.Text = user.Class;
            int i = 0;

            foreach (var test in user.UserTests)
            {
                listBox.Items.Add($"{i} Время начала: {test.TimeStart}; Оценка {test.Mark}; Кол-во заданий {test.AllMissions?.Count}");
                i++;
            }
        }
Exemple #2
0
 public FormSendTest()
 {
     InitializeComponent();
     StyleApply.ForForm(this);
     this.FormClosing += (s, e) => isOpen = false;
     server            = new NetworkServer(88); // port never changes
     lbl_ip.Text       = $"IP: {server.Ip}";
 }
Exemple #3
0
        public FormMissionSolve(User user, Test test, bool isMistakesCorrection)
        {
            InitializeComponent();
            IsMistakesCorrection    = isMistakesCorrection;
            lbl_isTopMost.ForeColor = Color.Red;
            lbl_isTopMost.Text      = "Монопольный режим выключен";
            if (test.IsTopMost)
            {
                this.WindowState        = FormWindowState.Maximized;
                this.TopMost            = true;
                this.MaximizeBox        = false;
                this.MinimizeBox        = false;
                this.FormBorderStyle    = FormBorderStyle.None;
                lbl_isTopMost.ForeColor = Color.Green;
                lbl_isTopMost.Text      = "Монопольный режим включен";
            }

            test.TimeStart = DateTime.Now;
            CurrentUser    = user;
            this.Test      = test;
            var showType = test.ShowType;

            if (isMistakesCorrection)
            {
                showType = TestShowType.OnOneForm;
            }
            this.Shown += (s, e) =>
            {
                UpdateUI();

                switch (showType)
                {
                case TestShowType.OneByOneBlocks:
                    ShowMissionsBlocksOneByOne(test);
                    break;

                case TestShowType.OneByOneMissions:
                    ShowMissionsOneByOne(test);
                    break;

                case TestShowType.OnOneForm:
                    AddTabsWithMissions(test);
                    break;

                default:
                    throw new Exception("Unknown show type for test");
                }
            };

            System.Windows.Forms.Timer uiUpdater = new System.Windows.Forms.Timer()
            {
                Interval = 100,
                Enabled  = true
            };
            uiUpdater.Tick += (s, e) => UpdateUI();
            StyleApply.ForForm(this);
        }
Exemple #4
0
        public FormTeacher()
        {
            InitializeComponent();
            StyleApply.ForForm(this);

            listbx_users.DoubleClick += (s, e) =>
            {
                btn_info.PerformClick();
            };

            Users = UserCollection.Instance.GetUsers.ToList();
            UpdateUsersList();
        }
        public FormTestResult(Test test, User user)
        {
            InitializeComponent();
            StyleApply.ForForm(this);
            Test = test;
            User = user;

            lbl_name.Click           += lbl_FeatureAnimate;
            lbl_state.Click          += lbl_FeatureAnimate;
            lbl_timeStart.Click      += lbl_FeatureAnimate;
            lbl_timeEnd.Click        += lbl_FeatureAnimate;
            lbl_wasCalcDiabled.Click += lbl_FeatureAnimate;
            lbl_timeSpend.Click      += lbl_FeatureAnimate;
            lbl_topmost.Click        += lbl_FeatureAnimate;

            UpdateUI();
        }
Exemple #6
0
        public FormSelectMissions()
        {
            InitializeComponent();

            int yPosition = 5;

            foreach (var catagory in MissionGeneratorCollection.Categories)
            {
                CategoryControl categoryControl = new CategoryControl(catagory, yPosition, RefreshUITotal, RefreshLabels);
                yPosition = categoryControl.AddToPanel(panel_missions);

                CategoryControls.Add(categoryControl);
                yPosition += 35;
            }

            RefreshUITotal();
            StyleApply.ForForm(this);
        }
Exemple #7
0
        void ShowMissionsOneByOne(Test test)
        {
            if (test.RandomOrder)
            {
                test.AllMissions = test.AllMissions.OrderBy(x => rnd.Next()).ToList(); //shuffle list
            }

            new Thread(() =>
            {
                int num = 1;
                for (int i = 0; i < test.AllMissions.Count; i++)
                {
                    object indexOfCurrMission = i;                                                            // номер миссии

                    TabPage tab    = test.AllMissions[i].GetTabPage(showAnswerAtOnce: Test.ShowAnswerAtOnce); // создем tab миссии
                    tab.Text       = num.ToString();
                    tab.AutoScroll = true;
                    num++;
                    this.Invoke(new MethodInvoker(() =>
                    {
                        tabControl.TabPages.Add(tab);
                    }));
                    StyleApply.ForForm(tabControl);
                    while (!test.AllMissions[(int)indexOfCurrMission].IsSolved())
                    {
                        if (Test.Finished)
                        {
                            return;
                        }
                        Thread.Sleep(200);
                    }
                    Thread.Sleep(800);
                    this.Invoke(new MethodInvoker(() =>
                    {
                        tabControl.TabPages.Remove(tab);
                    }));
                }
                ShowResult();
            }).Start();
        }
Exemple #8
0
        public RawControls(MissionGenerator mg, int yPosition)
        {
            this.yPosition   = yPosition;
            MissionGenerator = mg;

            NumOfMission = mg.NumOfMission;

            CheckBox = new CheckBox()
            {
                Location = new Point(25, yPosition),
                Checked  = false,
                Font     = new Font(new FontFamily("Arial"), 16, FontStyle.Regular, GraphicsUnit.Pixel),
                Text     = $"{mg.MissionName}",
                AutoSize = true
            };
#if DEBUG
            this.CheckBox.Text = $"{NumOfMission}. {this.CheckBox.Text}";
#endif
            Numeric = new NumericUpDown()
            {
                Location = new Point(CheckBox.Location.X + 500, CheckBox.Location.Y),
                Maximum  = mg.MaxNumInTest,
                Value    = 1,
                Width    = 50,
                Enabled  = false
            };
            OfMax = new Label()
            {
                Location = new Point(CheckBox.Location.X + 500, CheckBox.Location.Y),
                Text     = $"из {mg.MaxNumInTest}",
                Visible  = true
            };
            string timeToSolve = ((double)mg.TimeToSolveMission / 60.0).ToString("0.#") + " мин";
            TimeToSolve = new Label()
            {
                Location = new Point(CheckBox.Location.X + 600, yPosition),
                Text     = timeToSolve,
                Font     = new Font(new FontFamily("Arial"), 12, FontStyle.Regular, GraphicsUnit.Pixel),
                AutoSize = false
            };
            MissionType = new Label()
            {
                Location = new Point(CheckBox.Location.X + 700, yPosition),
                Text     = GlobalExtentions.GetStringMissionType(mg.TypeOfMission),
                Font     = new Font(new FontFamily("Arial"), 12, FontStyle.Regular, GraphicsUnit.Pixel),
                AutoSize = false
            };
            Preview = new Button()
            {
                //Text = "Предпросмотр",
                Location              = new Point(CheckBox.Location.X + 800, CheckBox.Location.Y),
                Width                 = 30,
                Height                = 15,
                BackgroundImage       = Properties.Resources.view,
                BackgroundImageLayout = ImageLayout.Stretch
            };

            Preview.Click += (s, e) =>
            {
                TabPage tab         = mg.Generate().GetTabPage(true);
                Form    previewForm = new Form()
                {
                    Width         = 900,
                    Height        = 550,
                    Icon          = Properties.Resources.icon,
                    Text          = $"Предпросмотр задания {NumOfMission} \"{mg.MissionName}\"",
                    StartPosition = FormStartPosition.CenterScreen
                };

                TabControl tc = new TabControl()
                {
                    Dock = DockStyle.Fill
                };
                tc.Controls.Add(tab);

                previewForm.Controls.Add(tc);

                StyleApply.ForForm(previewForm, changeHeader: false);

                previewForm.ShowDialog();
            };
            RegisterEventsToControls();
        }
        public FormSelectStartType()
        {
            InitializeComponent();
            TopMost           = true;
            this.DoubleClick += Form_DoubleClick_Feature;
            this.Shown       += (s, e) =>
            {
                new Thread(() =>
                {
                    bool waiting = true;
                    #region wait animation
                    new Thread(() =>
                    {
                        btn_update.Invoke(new MethodInvoker(() =>
                        {
                            btn_update.Visible = true;
                            btn_update.Enabled = false;
                        }));
                        int animatoinStep = 1;
                        do
                        {
                            try
                            {
                                btn_update.Invoke(new MethodInvoker(() =>
                                {
                                    switch (animatoinStep)
                                    {
                                    case 1:
                                        btn_update.Text = @" / / / ";
                                        animatoinStep++;
                                        break;

                                    case 2:
                                        btn_update.Text = @" | | | ";
                                        animatoinStep++;
                                        break;

                                    case 3:
                                        btn_update.Text = @" \ \ \ ";
                                        animatoinStep   = 1;
                                        break;
                                    }
                                }));
                                Thread.Sleep(250);
                            }
                            catch { }
                        } while (waiting);
                    })
                    {
                        IsBackground = true
                    }.Start();
                    #endregion
                    var updater = new GitUpdater();
                    again:
                    bool needUpdate = updater.NeedUpdate;
                    if (needUpdate)
                    {
                        waiting = false;
                        btn_update.Invoke(new MethodInvoker(() =>
                        {
                            btn_update.Visible = true;
                            btn_update.Enabled = true;
                            btn_update.Text    = "Обновить";
                        }));
                    }
                    else
                    {
                        if (!GitUpdater.IsInternetExists())
                        {
                            goto again;
                        }
                        try
                        {
                            waiting = false;
                            btn_update.Invoke(new MethodInvoker(() =>
                            {
                                btn_update.Visible = true;
                                btn_update.Enabled = false;
                                btn_update.Text    = "Обновлений нет";
                            }));
                        }
                        catch { }
                    }
                })
                {
                    IsBackground = true
                }.Start();
                new Thread(() =>
                {
                    try
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(2));
                        Invoke(new MethodInvoker(() =>
                        {
                            TopMost = false;
                        }));
                    }
                    catch { }
                }).Start();
            };

            // for game
            updateFrame = new System.Windows.Forms.Timer()
            {
                Enabled  = false,
                Interval = 200
            };
            updateFrame.Tick += (ss, ee) => UpdateFrame();

            // for combobox style
            foreach (var item in StyleCollection.Styles)
            {
                cb_style.Items.Add((item as StyleNotebook).Name);
            }
            cb_style.SelectedIndexChanged += (s, e) =>
            {
                string selectedStyleName = cb_style.Items[cb_style.SelectedIndex].ToString();
                StyleApply.CurrentStyle = StyleCollection.GetStyleByName(selectedStyleName);
                StyleApply.ForForm(this);

                ConfigCollection.Instance.SelectedFormStyleName = selectedStyleName;
            };
            cb_style.Text = StyleCollection.GetStyleByName(ConfigCollection.Instance.SelectedFormStyleName).Name;

            StyleApply.ForForm(this);
        }
Exemple #10
0
        void AddTabsWithMissions(Test test)
        {
            List <int> numOfMissionsAdded = new List <int>(); // уже  добавленные миссии
            int        indexOfTab         = 0;                // текущий индекс "maintab"
            int        num = 1;

            for (int i = 0; i < test.AllMissions.Count; i++)
            {
                if (numOfMissionsAdded.Contains(test.AllMissions[i].NumOfMission))
                {
                    continue;                                            // если миссия уже добавлена
                }
                int currNumOfMission = test.AllMissions[i].NumOfMission; // номер миссии
                numOfMissionsAdded.Add(currNumOfMission);                // добавить номер миссии в список
                // создаем subTab чтобы потом довить в maintab
                TabControl subTab = new TabControl()
                {
                    Width    = 880,
                    Height   = 430,
                    Location = new Point(5, 5),
                    Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                    Dock     = DockStyle.Fill
                };

                // заполняем subtab
                for (int j = i; j < test.AllMissions.Count; j++)
                {
                    if (test.AllMissions[j].NumOfMission == currNumOfMission)                                  // выбираем только миссии с текущим номером
                    {
                        TabPage tab = test.AllMissions[j].GetTabPage(showAnswerAtOnce: Test.ShowAnswerAtOnce); // создем tab миссии
                        tab.Text = num.ToString();
                        num++;
                        subTab.TabPages.Add(tab); // добавляем tab
                    }
                }
                tabControl.TabPages.Add(new TabPage()
                {
                    Text = test.AllMissions[i].ToString()
                });                                                   // добавляем tab в maintab чтобы в него добавить subtab
                tabControl.TabPages[indexOfTab].Controls.Add(subTab); // добавляем subtab в tabpage под индексом indexOfTab

                object currIndex = indexOfTab;
                StyleApply.ForForm(tabControl);
                new Task(() => // изменить Text mainTab, когда все subTab решены
                {
                    while (true)
                    {
                        bool allAnswersGiven = true;
                        for (int j = 0; j < test.AllMissions.Count; j++)
                        {
                            if (test.AllMissions[j].NumOfMission == currNumOfMission) // выбираем только миссии с текущим номером
                            {
                                if (!test.AllMissions[j].IsSolved())
                                {
                                    allAnswersGiven = false;
                                }
                            }
                        }
                        if (allAnswersGiven)
                        {
                            try
                            {
                                tabControl.Invoke(new MethodInvoker(() =>
                                {
                                    tabControl.TabPages[(int)currIndex].Text = "*";
                                }));
                                break;
                            }
                            catch { }
                        }
                        Thread.Sleep(250);
                    }
                }).Start();

                indexOfTab++; // увеличиваем текущий индекс
            }
        }
Exemple #11
0
        void ShowMissionsBlocksOneByOne(Test test)
        {
            if (test.RandomOrder)
            {
                test.AllMissions = test.AllMissions.OrderBy(x => rnd.Next()).ToList(); //shuffle list
            }

            new Thread(() =>
            {
                int num = 1;
                List <int> numOfMissionsAdded = new List <int>(); // уже  добавленные миссии

                for (int i = 0; i < test.AllMissions.Count; i++)
                {
                    if (numOfMissionsAdded.Contains(test.AllMissions[i].NumOfMission))
                    {
                        continue; // если миссия уже добавлена
                    }

                    int currNumOfMission = test.AllMissions[i].NumOfMission; // номер миссии
                    numOfMissionsAdded.Add(currNumOfMission);                // добавить номер миссии в список
                                                                             // создаем subTab чтобы потом довить в maintab


                    List <MissionBase> missionsOnCurrentForm = new List <MissionBase>();
                    List <TabPage> tabs          = new List <TabPage>();
                    List <int> indexesOfMissions = new List <int>();
                    // заполняем subtab
                    for (int j = i; j < test.AllMissions.Count; j++)
                    {
                        if (test.AllMissions[j].NumOfMission == currNumOfMission)                                  // выбираем только миссии с текущим номером
                        {
                            TabPage tab = test.AllMissions[j].GetTabPage(showAnswerAtOnce: Test.ShowAnswerAtOnce); // создем tab миссии
                            tab.Text    = num.ToString();
                            num++;
                            missionsOnCurrentForm.Add(test.AllMissions[j]);
                            indexesOfMissions.Add(j);
                            tabs.Add(tab); // добавляем tab
                        }
                    }

                    this.Invoke(new MethodInvoker(() =>
                    {
                        tabControl.TabPages.AddRange(tabs.ToArray());
                    }));
                    StyleApply.ForForm(tabControl);
                    while (true)
                    {
                        bool allSolved = true;
                        for (int j = 0; j < indexesOfMissions.Count; j++)
                        {
                            if (!test.AllMissions[indexesOfMissions[j]].IsSolved())
                            {
                                allSolved = false;
                                break;
                            }
                        }
                        if (allSolved)
                        {
                            break;
                        }
                        if (Test.Finished)
                        {
                            return;
                        }
                        Thread.Sleep(200);
                    }
                    Thread.Sleep(800);
                    this.Invoke(new MethodInvoker(() =>
                    {
                        tabs.ForEach(x => tabControl.TabPages.Remove(x));
                    }));
                }

                ShowResult();
            }).Start();
        }
Exemple #12
0
 public FormStatistics()
 {
     InitializeComponent();
     RefreshUI();
     StyleApply.ForForm(this);
 }