public ChooseOrCreateNewSolution(Object ob)
 {
     sp = (Solvedproblem)ob;
     InitializeComponent();
     newsolutiontext.IsReadOnly = true;
     oldSolution.IsEnabled      = false;
     oldSolution.ItemsSource    = sp.Solution;
 }
 public CreateNewSolution(Object ob, string text)
 {
     sp = (Solvedproblem)ob;
     InitializeComponent();
     nametextbox.Text = text;
     solutionname     = nametextbox.Text;
     nametextbox.SelectAll();
 }
예제 #3
0
 public bool Chazhao(string name, ObservableCollection <Solvedproblem> sp)
 {
     sps = sp;
     for (int i = 0; i < sps.Count; i++)
     {
         if (sps[i].Name == name)
         {
             problemfound = sps[i];
             return(true);
         }
     }
     return(false);
 }
예제 #4
0
        /// <summary>
        /// 通过类文件加载测试用例
        /// </summary>
        /// <param name="cf"></param>
        private void LoadTest(Classfile cf)
        {
            Solvedproblem problem = cf.Parent.Parent;

            for (int i = 0; i < tk.Count; i++)
            {
                for (int j = 0; j < tk[i].problems.Count; j++)
                {
                    if (problem.Name == tk[i].problems[j].Title && problem.Tiku == tk[i].Name)
                    {
                        LoadTest(tk[i].problems[j]);
                    }
                }
            }
        }
        private void CreateNewProblem_Click(object sender, RoutedEventArgs e)
        {
            Solvedproblem sproblem = new Solvedproblem();
            Chachong      cc       = new Chachong();

            if (cc.Chazhao(nametextbox.Text, sp.Solvedproblem))
            {
                MessageBox.Show("此工作空间下已有此题");
                return;
            }
            sproblem.Name   = nametextbox.Text;
            sproblem.Tiku   = tikutextbox.Text;
            sproblem.Parent = sp;
            sproblem.Path   = sp.Path + "\\" + sproblem.Name;
            System.IO.Directory.CreateDirectory(sproblem.Path);
            sp.Solvedproblem.Add(sproblem);
            this.Close();
        }
 private void Click_ok(object sender, RoutedEventArgs e)
 {
     if (rc.IsChecked == true)
     {
         string   proname = problems[currentproblem].Title;
         Chachong cc      = new Chachong();
         if (cc.Chazhao(proname, sp.Solvedproblem))
         {
             MessageBox.Show("此题已在解决空间中创立");
             return;
         }
         Solvedproblem spro = new Solvedproblem();
         spro.Name = proname;
         string name = spro.Name.Replace(" ", "_");
         spro.Parent = sp;
         spro.Tiku   = currenttiku;
         spro.Path   = sp.Path + "\\" + name + "_" + spro.Tiku;
         System.IO.Directory.CreateDirectory(spro.Path);
         sp.Solvedproblem.Add(spro);
         string            text = "第1个解决方案";
         CreateNewSolution cns  = new CreateNewSolution(spro, text);
         cns.ShowDialog();
         Classfile cf = new Classfile();
         cf.Name   = "Main.cs";
         cf.Parent = spro.Solution[0];
         cf.Path   = spro.Solution[0].Path + "\\" + cf.Name;
         File.Create(cf.Path);
         spro.Solution[0].Classfile.Add(cf);
         Reference rf = new Reference();
         rf.Name   = "引用";
         rf.Parent = cf;
         cf.Reference.Add(rf);
         cff = cf;
         this.Close();
     }
     else if (rcc.IsChecked == true)
     {
         Solvespace spp     = (Solvespace)cb.SelectedItem;
         string     proname = problems[currentproblem].Title;
         Chachong   cc      = new Chachong();
         if (cc.Chazhao(proname, spp.Solvedproblem))
         {
             MessageBox.Show("此题已在解决空间中创立");
             return;
         }
         Solvedproblem spro = new Solvedproblem();
         spro.Name = proname;
         string name = spro.Name.Replace(" ", "_");
         spro.Parent = spp;
         spro.Tiku   = currenttiku;
         spro.Path   = spp.Path + "\\" + name + "_" + spro.Tiku;
         System.IO.Directory.CreateDirectory(spro.Path);
         spp.Solvedproblem.Add(spro);
         string            text = "第1个解决方案";
         CreateNewSolution cns  = new CreateNewSolution(spro, text);
         cns.ShowDialog();
         Classfile cf = new Classfile();
         cf.Name   = "Main.cs";
         cf.Parent = spro.Solution[0];
         cf.Path   = spro.Solution[0].Path + "\\" + cf.Name;
         File.Create(cf.Path);
         spro.Solution[0].Classfile.Add(cf);
         Reference rf = new Reference();
         rf.Name   = "引用";
         rf.Parent = cf;
         cf.Reference.Add(rf);
         cff = cf;
         this.Close();
     }
     else
     {
         MessageBox.Show("请选择解题空间");
     }
 }