コード例 #1
0
 //0未完成,1是通过,2是错误
 private void Main_TreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Action == TreeViewAction.ByMouse)
     {
         foreach (int key in problems.Keys)
         {
             if (e.Node.Text == ProblemList.GetProblem(key).QuestionName)
             {
                 selectedProblem = ProblemList.GetProblem(key);
                 ShowProblem(ProblemList.GetProblem(key));
                 if (ProblemList.GetProblem(key).Status == 1)
                 {
                     e.Node.ImageIndex = 1;
                 }
                 else if (ProblemList.GetProblem(key).Status == 0)
                 {
                     e.Node.ImageIndex = 0;
                 }
                 else
                 {
                     e.Node.ImageIndex = 2;
                 }
             }
         }
     }
 }
コード例 #2
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            StructureOfProblem pro = null;

            foreach (int key in problems.Keys)
            {
                if (this.Main_TreeView.SelectedNode.Text == ProblemList.GetProblem(key).QuestionName)
                {
                    ProblemList.GetProblem(key).QuestionName        = this.Main_TreeView.SelectedNode.Text;
                    ProblemList.GetProblem(key).QuestionDescription = this.ProDescTextBox.Text;
                    ProblemList.GetProblem(key).OutputSample        = this.OutputsampleText.Text;
                    ProblemList.GetProblem(key).Problemcode         = this.StdAnswerTextBox.Text;
                    ProblemList.GetProblem(key).InputSample         = this.InputSampleText.Text;
                    pro = ProblemList.GetProblem(key);
                }
                if (ProblemList.GetProblem(key).QuestionName == "新练习")
                {
                    ProblemList.GetProblem(key).QuestionName        = this.Main_TreeView.SelectedNode.Text;
                    ProblemList.GetProblem(key).QuestionDescription = this.ProDescTextBox.Text;
                }
            }
            if (pro != null)
            {
                ProblemList.UpdateStatus(pro);
            }
        }
コード例 #3
0
        private void Confirm_Click(object sender, EventArgs e)
        {
            StructureOfProblem problem = new StructureOfProblem();
            //problem.ProblemID = int.Parse(test.Text);
            //ProblemList.Add(problem);
            Boolean isNumber = true;

            foreach (char a in test.Text)
            {
                if (!Char.IsDigit(a))
                {
                    isNumber = false;
                    break;
                }
            }
            if (isNumber)
            {
                ((Form1)(this.ParentForm)).TurnForm(new ProblemStructure(int.Parse(test.Text)));
            }
            else
            {
                MessageBox.Show("请输入题目ID号");
            }
            //StructureOfQuestionbank.problemTitle = test.Text;
            //ProblemStructure problemStructure = new ProblemStructure();
            //problemStructure.Show();
            //this.Hide();
        }
コード例 #4
0
        //private StructureOfQuestionbank structureOfQuestionbank = new StructureOfQuestionbank();
        public ProblemStructure(int ID)
        {
            this.ID            = ID;
            this.Location      = new System.Drawing.Point(500, 500);
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            InitializeComponent();

            try
            {
                structureOfProblem = ProblemList.GetProblem(ID);
                this.questionName.AppendText(structureOfProblem.QuestionName);
                this.timeLimitIndex.AppendText(structureOfProblem.TimeLimitIndex.Length != 0 ? structureOfProblem.TimeLimitIndex : "");
                this.memoryLimitIndex.AppendText(structureOfProblem.MemoryLimitIndex.Length != 0 ? structureOfProblem.MemoryLimitIndex : "");
                //添加+“”,表达int向string的隐式转换
                this.totalAccepts.AppendText(!structureOfProblem.TotalAccepts.Equals(0) ? structureOfProblem.TotalAccepts + "" : "");
                this.totalSubmits.AppendText(!structureOfProblem.TotalSubmits.Equals(0) ? structureOfProblem.TotalSubmits + "" : "");
                this.acceptsRate.AppendText(!structureOfProblem.AcceptsRate.Equals(0) ? structureOfProblem.AcceptsRate : "");
                this.questionDescription.AppendText(structureOfProblem.QuestionDescription.Length != 0 ? structureOfProblem.QuestionDescription : "");
                this.inputDescription.AppendText(structureOfProblem.InputDescription.Length != 0 ? structureOfProblem.InputDescription : "");
                this.outputDescription.AppendText(structureOfProblem.OutputDescription.Length != 0 ? structureOfProblem.OutputDescription : "");
                this.inputSample.AppendText(structureOfProblem.InputSample.Length != 0 ? structureOfProblem.InputSample : "");
                this.outputDescription.AppendText(structureOfProblem.OutputSample.Length != 0 ? structureOfProblem.OutputSample : "");
                this.hint.AppendText(structureOfProblem.Hint.Length != 0 ? structureOfProblem.Hint : "");
                //StructureOfQuestionbank.structureOfProblem = structureOfProblem;
            }
            catch { }
        }
コード例 #5
0
        public void EditShow()
        {
            StructureOfProblem problem = new StructureOfProblem();

            problem.ProblemID    = 1;
            problem.QuestionName = "动态规划";
            problem.InputSample  = "1 7 4 9 2 5\r\n1 2 3 4 5 6 7 8 9";
            problem.OutputSample = "6\r\n2";

            ProblemList.GetAll().Clear();
            ProblemList.Add(problem);

            ProblemUpdate problemUpdate = new ProblemUpdate(problem.ProblemID);

            Assert.AreEqual(problemUpdate.QuestionName, problem.QuestionName);
            Assert.AreEqual(problemUpdate.InputSamples, problem.InputSample);
            Assert.AreEqual(problemUpdate.OutputSamples, problem.OutputSample);
            Assert.AreEqual(problemUpdate.QuestionDescription, problem.QuestionDescription);

            //修改题目名字
            string newQuestionName = "贪心";

            problemUpdate.QuestionName = newQuestionName;
            Assert.AreEqual(problemUpdate.QuestionName, newQuestionName);
        }
コード例 #6
0
 public SubmitProblem(StructureOfProblem p)
 {
     InitializeComponent();
     structureOfProblem = p;
     textBox1.Text      = structureOfProblem.ProblemID.ToString();
     textBox2.Text      = structureOfProblem.QuestionName;
 }
コード例 #7
0
 private void ShowProblem(StructureOfProblem problem)
 {
     this.ProblemDec.Text                = problem.QuestionDescription;
     this.StandardAnswer.Text            = problem.Problemcode;
     this.StandarOutputrichTextBox.Text  = problem.OutputSample;
     this.label_Exercise_Name.Text       = problem.QuestionName;
     this.ProblemWebBrowser.DocumentText = problem.QuestionDescription;
     this.InputSamplerichTextBox.Text    = problem.InputSample;
     this.OutputSamplerichTextBox.Text   = problem.OutputSample;
 }
コード例 #8
0
        public void XmlwriteTest()
        {
            XmlOperator        xmlOperator = new XmlOperator();
            StructureOfProblem p           = new StructureOfProblem();

            p.QuestionDescription = "testing";
            p.QuestionName        = "test";
            p.ProblemID           = 1;
            SerializableDictionary <int, StructureOfProblem> problemlist = new SerializableDictionary <int, StructureOfProblem>();

            problemlist.Add(p.ProblemID, p);
            xmlOperator.XMLSerialized("Problem//Problem.xml", problemlist);
            Directory.Exists("Problem//Problem.xml");
        }
コード例 #9
0
 private void Main_TreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Action == TreeViewAction.ByMouse)
     {
         TreeNode selected = e.Node;
         foreach (int key in problems.Keys)
         {
             if (this.Main_TreeView.SelectedNode.Text == ProblemList.GetProblem(key).QuestionName)
             {
                 selectedProblem = ProblemList.GetProblem(key);
                 ShowProblem(ProblemList.GetProblem(key));
             }
         }
     }
 }
コード例 #10
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkProblem())
                {
                    MessageBox.Show("请完善信息");
                    return;
                }

                string[] inputSamples  = this.InputSampleInput.Text.Split(';');
                string[] outputSamples = this.OutputSampleInput.Text.Split(';');
                if (inputSamples.Length != outputSamples.Length)
                {
                    MessageBox.Show("输入及输出样例不匹配");
                    return;
                }
                string             problemName       = this.ProblemNameInput.Text;
                string             timeLimit         = this.TimeLimitInput.Text;
                string             memoryLimit       = this.MemoryLimitInput.Text;
                string             inputDescription  = this.InputDescriptionInput.Text;
                string             outputDesctiption = this.OutputDescriptionInput.Text;
                string             inputSample       = this.InputSampleInput.Text;
                string             outputSample      = this.OutputSampleInput.Text;
                string             hint       = this.hintInput.Text;
                string             decription = this.DescriptionInput.Text;
                StructureOfProblem newProblem = new StructureOfProblem();
                newProblem.ProblemID           = ProblemList.GetAll().Values.Last().ProblemID + 1;
                newProblem.Hint                = hint;
                newProblem.QuestionName        = problemName;
                newProblem.TimeLimitIndex      = timeLimit;
                newProblem.MemoryLimitIndex    = memoryLimit;
                newProblem.InputDescription    = inputDescription;
                newProblem.OutputDescription   = outputDesctiption;
                newProblem.InputSample         = inputSample;
                newProblem.OutputSample        = outputSample;
                newProblem.QuestionDescription = decription;
                ProblemList.Add(newProblem);
                ProblemList.Save();
                MessageBox.Show("添加成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
                return;
            }
            ((Form1)(this.ParentForm)).TurnForm(new Questionbank());
        }
コード例 #11
0
        private void export_status_Click_1(object sender, EventArgs e)
        {
            SerializableDictionary <int, StructureOfProblem> problems    = ProblemList.GetAll();
            SerializableDictionary <int, StructureOfProblem> problemlist = new SerializableDictionary <int, StructureOfProblem>();
            XmlOperator xmlOperator = new XmlOperator();

            foreach (int key in problems.Keys)
            {
                StructureOfProblem p = new StructureOfProblem();
                p.AcceptsRate  = ProblemList.GetProblem(key).AcceptsRate;
                p.QuestionName = ProblemList.GetProblem(key).QuestionName;
                p.ProblemID    = ProblemList.GetProblem(key).ProblemID;
                problemlist.Add(p.ProblemID, p);
            }
            xmlOperator.XMLSerialized("Problem//ProblemStatus.xml", problemlist);
            //MessageBox.Show("导出成功");
        }
コード例 #12
0
 private void Problem_Add_Click(object sender, EventArgs e)
 {
     if (this.Main_TreeView.Nodes.Count == 0 || this.Main_TreeView.SelectedNode == null)
     {
         this.Main_TreeView.Nodes.Add(NewProblemName);
         StructureOfProblem problem = new StructureOfProblem();
         problem.QuestionName = NewProblemName;
         ProblemList.Add(problem);
     }
     else
     {
         this.Main_TreeView.SelectedNode.Nodes.Add(NewProblemName);
         StructureOfProblem problem = new StructureOfProblem();
         problem.QuestionName = NewProblemName;
         ProblemList.Add(problem);
     }
 }
コード例 #13
0
        public void AddTest()
        {
            ProblemList.Init();
            int size = ProblemList.GetAll().Values.Count;
            StructureOfProblem newProblem = new StructureOfProblem();

            newProblem.ProblemID           = 9;
            newProblem.Hint                = "test";
            newProblem.QuestionName        = "test";
            newProblem.TimeLimitIndex      = "test";
            newProblem.MemoryLimitIndex    = "test";
            newProblem.InputDescription    = "test";
            newProblem.OutputDescription   = "test";
            newProblem.InputSample         = "test";
            newProblem.OutputSample        = "test";
            newProblem.QuestionDescription = "test";
            ProblemList.Add(newProblem);
            Assert.AreEqual(ProblemList.GetAll().Values.Count, size + 1);
        }
コード例 #14
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            StructureOfProblem structureOfProblem = new StructureOfProblem();

            structureOfProblem.QuestionName        = this.questionName.Text;
            structureOfProblem.TimeLimitIndex      = this.timeLimitIndex.Text;
            structureOfProblem.MemoryLimitIndex    = this.memoryLimitIndex.Text;
            structureOfProblem.TotalSubmits        = this.totalSubmits.Text;
            structureOfProblem.TotalAccepts        = this.totalAccepts.Text;
            structureOfProblem.AcceptsRate         = this.acceptsRate.Text;
            structureOfProblem.QuestionDescription = this.questionDescription.Text;
            structureOfProblem.InputDescription    = this.inputDescription.Text;
            structureOfProblem.OutputDescription   = this.outputDescription.Text;
            structureOfProblem.InputSample         = this.inputSample.Text;
            structureOfProblem.OutputSample        = this.outputSample.Text;
            structureOfProblem.Hint      = this.hint.Text;
            structureOfProblem.ProblemID = ID;
            ProblemList.Add(structureOfProblem);
        }
コード例 #15
0
        public void ShowStatus()
        {
            ProblemList.GetAll().Clear();
            StructureOfProblem problem = new StructureOfProblem();

            problem.AcceptsRate  = "Accept";
            problem.ProblemID    = 1;
            problem.QuestionName = "test";
            ProblemList.Add(problem);

            Questionbank bank = new Questionbank();
            //bank.Show();


            ListViewItem temp = bank.Show_question.TopItem;

            Assert.AreEqual(temp.SubItems[1].Text, "1");
            Assert.AreEqual(temp.SubItems[2].Text, "test");
            Assert.AreEqual(temp.Text, "Accept");
        }
コード例 #16
0
        private void ExportStatusBtn_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog path = new FolderBrowserDialog();

            if (path.ShowDialog() == DialogResult.OK)
            {
                // MessageBox.Show(path.SelectedPath);
                SerializableDictionary <int, StructureOfProblem> problemsStatus = new SerializableDictionary <int, StructureOfProblem>();
                foreach (int key in problems.Keys)
                {
                    StructureOfProblem problem = new StructureOfProblem();
                    problem.ProblemID = ProblemList.GetProblem(key).ProblemID;
                    if (this.Main_TreeView.SelectedNode.Text == ProblemList.GetProblem(key).QuestionName)
                    {
                        problem.Problemcode = this.problemcode.Text;
                    }
                    problem.QuestionName = ProblemList.GetProblem(key).QuestionName;
                    problem.AcceptsRate  = ProblemList.GetProblem(key).AcceptsRate;
                    problemsStatus.Add(problem.ProblemID, problem);
                }
                XmlOperator xmlOperator = new XmlOperator();
                xmlOperator.XMLSerialized(path.SelectedPath + "//ProblemStatus.xml", problemsStatus);
            }
        }
コード例 #17
0
 //读取问题内容详情
 private void readProblem()
 {
     problem = ProblemList.GetProblem(problemID);
 }