public bool Chazhao(string name, ObservableCollection <Classfile> cf)
 {
     cfs = cf;
     for (int i = 0; i < cfs.Count; i++)
     {
         if (cfs[i].Name == name)
         {
             classfilefound = cfs[i];
             return(true);
         }
     }
     return(false);
 }
Example #2
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]);
                    }
                }
            }
        }
Example #3
0
 private void Solve1_Click(object sender, RoutedEventArgs e)
 {
     if (cff != null)
     {
         sll = cff.Parent;
     }
     for (int i = 0; i < sll.Classfile.Count; i++)
     {
         Classfile cf = sll.Classfile[i];
         if (cf.Name == "Main.cs")
         {
             exepath = cf.Path.Replace(".cs", ".exe");
             break;
         }
     }
     this.Close();
 }
Example #4
0
        private void Current_Checked(object sender, RoutedEventArgs e)
        {
            LoadTest(cff);

            Solution sl = cff.Parent;

            for (int i = 0; i < sl.Classfile.Count; i++)
            {
                Classfile cf = sl.Classfile[i];
                if (cf.Name == "Main.cs")
                {
                    exepath = cf.Path.Replace(".cs", ".exe");
                    break;
                }
            }
            solve1.IsEnabled = true;
            solve2.IsEnabled = true;
        }
Example #5
0
        public Syntax(Object ob)
        {
            cf = (Classfile)ob;
            InitializeComponent();
            projectAssembly = new CSharpProjectAssembly("SampleBrowser");
            //projectAssembly.AssemblyReferences.ItemAdded += OnAssemblyReferencesChanged;
            //projectAssembly.AssemblyReferences.ItemRemoved += OnAssemblyReferencesChanged;
            var assemblyLoader = new BackgroundWorker();

            assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader;
            assemblyLoader.RunWorkerAsync();

            // Load the .NET Languages Add-on C# language and register the project assembly on it
            var language = new CSharpSyntaxLanguage();

            language.RegisterProjectAssembly(projectAssembly);
            codeEditor.Document.Language = language;
        }
Example #6
0
        public bool dianjiguanbi;                   //用来标示是否是点击关闭按钮关闭的
        public ChooseTestProblem(Object ob, Object Oc, Object Od)
        {
            tk  = (ObservableCollection <Tiku>)Oc;
            cff = (Classfile)ob;
            ss  = (ObservableCollection <Solvespace>)Od;
            InitializeComponent();
            if (cff == null)
            {
                current.Content   = "当前编辑的不是题目";
                current.IsEnabled = false;
                other.Content     = "选择其他题目";

                if (tk.Count == 0)
                {
                    other.IsEnabled = false;
                }
                else
                {
                    other.IsEnabled = true;
                }

                pr.IsEnabled = false;
                sl.IsEnabled = false;
            }
            else
            {
                current.Content   = cff.Parent.Parent.Name + "(当前的解题方法)";
                current.IsEnabled = true;
                other.Content     = "选择其他题目";

                if (tk.Count == 0)
                {
                    other.IsEnabled = false;
                }
                else
                {
                    other.IsEnabled = true;
                }
                pr.IsEnabled = false;
                sl.IsEnabled = false;
            }
            solve1.IsEnabled = false;
            solve2.IsEnabled = false;
        }
        private void CreateNewClass_Click(object sender, RoutedEventArgs e)
        {
            Classfile cf = new Classfile();
            Reference rf = new Reference();
            Chachong  cc = new Chachong();

            if (cc.Chazhao(createclasstextbox.Text, sl.Classfile))
            {
                MessageBox.Show("当前解题方法中已有此类");
                return;
            }
            rf.Name   = "引用";
            cf.Parent = sl;
            cf.Reference.Add(rf);
            cf.Name = createclasstextbox.Text + ".cs";
            cf.Path = sl.Path + "\\" + cf.Name;
            using (File.Create(cf.Path))
            {
            }
            sl.Classfile.Add(cf);
            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("请选择解题空间");
     }
 }
 public MyTabItem(Object ob, Object oc)
 {
     cf       = (Classfile)oc;
     m_Parent = (TabControl)ob;
     InitializeComponent();
 }
Example #10
0
        public Rename(object df)
        {
            cf = (Classfile)df;

            InitializeComponent();
        }