コード例 #1
0
ファイル: BaseDemoMethod.cs プロジェクト: xknife-erian/nknife
        private static void MarkRecords(Records records)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            records = new Records();
            MyDemoDialog.Clear();
            PgnReader reader = new PgnReader();

            //reader.Filename = Program.PGNFile_CHS_Game;
            reader.Filename = Program.PGNFile_Test_2_Game;
            //reader.Filename = @"e:\ChessBase\Bases\08a.pgn";
            reader.AddEvents(records);
            reader.Parse();
            watch.Stop();
            double rTime = watch.ElapsedMilliseconds;//总时间
            double fTIme = rTime / records.Count;

            MyDemoDialog.StatusText1 = string.Format("记录个数:{2}, 总时间:{0},每个记录的解析时间为:{1}", rTime, fTIme, records.Count);

            MyDemoDialog.RecordTree.BeginUpdate();
            foreach (Record record in records)
            {
                TreeNode node = new TreeNode();
                node.Text = (string)record.Tags.Get("Event");
                node.Tag  = record;
                MyDemoDialog.RecordTree.Nodes.Add(node);
            }
            MyDemoDialog.RecordTree.EndUpdate();
        }
コード例 #2
0
ファイル: BaseDemoForm.cs プロジェクト: xknife-erian/nknife
 public MyDemoDialog()
 {
     InitializeComponent();
     _form       = this;
     StatusText2 = "";
     this.Method = new BaseDemoMethod();
     this.UpdateListBox();
     this._RecordTree.NodeMouseClick += new TreeNodeMouseClickEventHandler(_RecordTree_NodeMouseClick);
 }
コード例 #3
0
 public MyDemoDialog()
 {
     InitializeComponent();
     _form = this;
     StatusText2 = "";
     this.Method = new DemoMethod();
     this.UpdateListBox();
     this._RecordTree.NodeMouseClick += new TreeNodeMouseClickEventHandler(_RecordTree_NodeMouseClick);
 }
コード例 #4
0
ファイル: BaseDemoMethod.cs プロジェクト: xknife-erian/nknife
        /// <summary>
        /// 生成一些测试用的Step用例
        /// </summary>
        private static void MarkSteps()
        {
            MyDemoDialog.FormCursor = Cursors.WaitCursor;

            List <string> step2  = new List <string>();
            List <string> step3  = new List <string>();
            List <string> step4  = new List <string>();
            List <string> step5  = new List <string>();
            List <string> step6  = new List <string>();
            List <string> step7  = new List <string>();
            List <string> step8  = new List <string>();
            List <string> stepPr = new List <string>();

            string regex = @"\d+\.";
            string file  = @"DemoFile\largeness,game.pgn";

            string[] lines = File.ReadAllLines(file);
            MyDemoDialog.ProgressBar.Maximum = lines.Length + 20;
            MyDemoDialog.ProgressBar.Value   = 0;

            MyDemoDialog.StatusText1 = "File read complate. Line count: " + lines.Length.ToString() + ".";
            Application.DoEvents();

            foreach (string line in lines)
            {
                #region line
                MyDemoDialog.ProgressBar.PerformStep();
                MyDemoDialog.ProgressBar.Invalidate();
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                string v = line.Trim();
                if (v.StartsWith("["))
                {
                    continue;
                }
                string[] step = (new Regex(regex)).Split(v);
                foreach (string str in step)
                {
                    string s = str.Trim();
                    if (string.IsNullOrEmpty(s))
                    {
                        continue;
                    }
                    string[] lei = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in lei)
                    {
                        if (item.IndexOf('-') > 0)
                        {
                            continue;
                        }
                        if (item.IndexOf('=') > 0)
                        {
                            stepPr.Add(item);
                            continue;
                        }
                        switch (item.Length)
                        {
                            #region case
                        case 2:
                            step2.Add(item);
                            break;

                        case 3:
                            step3.Add(item);
                            break;

                        case 4:
                            step4.Add(item);
                            break;

                        case 5:
                            step5.Add(item);
                            break;

                        case 6:
                            step6.Add(item);
                            break;

                        case 7:
                            step7.Add(item);
                            break;

                        case 8:
                            step8.Add(item);
                            break;

                        default:
                            break;
                            #endregion
                        }
                    }
                }
                #endregion
            }
            stepPr.Sort();
            StringBuilder sbAll = new StringBuilder();
            StringBuilder sb1   = new StringBuilder();
            StringBuilder sb2   = new StringBuilder();

            MarkStringBuilder(sbAll, sb1, sb2, stepPr, step6, step5, step4, step3, step2);

            File.Delete("stepsAll.txt");
            File.Delete("steps1.txt");
            File.Delete("steps2.txt");
            File.AppendAllText("stepsAll.txt", sbAll.ToString());
            File.AppendAllText("steps1.txt", sb1.ToString());
            File.AppendAllText("steps2.txt", sb2.ToString());

            MyDemoDialog.Clear();
            MyDemoDialog.TextBox3 = "Complated!";

            MyDemoDialog.FormCursor = Cursors.Default;
        }