private void _OkButton_Click(object sender, EventArgs e) { var x = ((int)_XNumericUpDown.Value).ToString(); var y = ((int)_YNumericUpDown.Value).ToString(); var sb = new StringBuilder(); for (int i = y.Length - 1; i >= 0; i--) { sb.Append(y[i]); } y = sb.ToString(); sb.Clear(); var random = new UtilityRandom(); sb.Append(random.Next(1, 9)); sb.Append(_Mode); sb.Append(random.Next(1, 9)); sb.Append(x.Length); sb.Append(random.Next(1, 9)); sb.Append(y.Length); sb.Append(random.Next(1, 9)); sb.Append(x.PadRight(4, random.Next(1, 9).ToString()[0])); sb.Append(random.Next(1, 9)); sb.Append(y.PadLeft(4, random.Next(1, 9).ToString()[0])); sb.Append('`'); Command = sb.ToString(); DialogResult = DialogResult.OK; }
private string GetCommand(int c) { var sb = new StringBuilder(); sb.Append(_Random.Next(1, 9)); sb.Append(c); sb.Append(_Random.Next(1, 9)); sb.Append(_Random.Next(1, 3)); sb.Append(_Random.Next(1, 9)); sb.Append(_Random.Next(1, 3)); sb.Append(_Random.Next(10000, 99999)); sb.Append(_Random.Next(10000, 99999)); sb.Append("`"); string command = sb.ToString(); return(command); }
private void RandomButtonClick(object sender, EventArgs e) { _RandomStepTextbox.Text = string.Empty; _CubePaper.Initialize(); for (int i = 0; i < _RandomStepNumber.Value; i++) { var m = _Random.Next(1, 13); switch (m) { case 1: _CubePaper.BackCCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "B'"); break; case 2: _CubePaper.BackCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "B"); break; case 3: _CubePaper.DownCCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "D'"); break; case 4: _CubePaper.DownCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "D"); break; case 5: _CubePaper.FrontCCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "F'"); break; case 6: _CubePaper.FrontCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "F'"); break; case 7: _CubePaper.UpCCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "U'"); break; case 8: _CubePaper.UpCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "U"); break; case 9: _CubePaper.LeftCCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "L'"); break; case 10: _CubePaper.LeftCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "L"); break; case 11: _CubePaper.RightCCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "R'"); break; case 12: _CubePaper.RightCW90(); _RandomStepTextbox.Text = string.Format("{0}{1}", _RandomStepTextbox.Text, "R"); break; default: break; } _RandomStepTextbox.Refresh(); } }
public static void DoTimeTest() { UtilityRandom random = new UtilityRandom(); random.Next(); IDGenerator geanIdg = new IDGenerator(); geanIdg.Generate(); int count = 500 * 10000; Stopwatch sw = new Stopwatch(); Console.WriteLine("Start......"); //Gean.Data的Id生成器----------------------- long geanIdTime; sw.Reset(); sw.Start(); for (int i = 0; i < count; i++) { string id = geanIdg.Generate(); } sw.Stop(); geanIdTime = sw.ElapsedMilliseconds; //随机数字----------------------- long randNumTime; sw.Reset(); sw.Start(); for (int i = 0; i < count; i++) { string id = random.Next(1, count).ToString(); } sw.Stop(); randNumTime = sw.ElapsedMilliseconds; //随机4位小写字母----------------------- long randTime; sw.Reset(); sw.Start(); for (int i = 0; i < count; i++) { string id = random.GetString(4, UtilityRandom.RandomCharType.Lowercased); } sw.Stop(); randTime = sw.ElapsedMilliseconds; //数字累计----------------------- long gerTime; sw.Reset(); sw.Start(); for (int i = 0; i < count; i++) { string id = (i + i + i).ToString(); } sw.Stop(); gerTime = sw.ElapsedMilliseconds; //IDGenerator生成----------------------- long idgTime; sw.Reset(); sw.Start(); UUIDGenerator idg = new UUIDGenerator(); for (int i = 0; i < count; i++) { string id = idg.Generate(); } sw.Stop(); idgTime = sw.ElapsedMilliseconds; //Guid----------------------- long guidTime; sw.Reset(); sw.Start(); for (int i = 0; i < count; i++) { string id = Guid.NewGuid().ToString(); } sw.Stop(); guidTime = sw.ElapsedMilliseconds; Console.WriteLine("Gean.Data的Id生成器: " + geanIdTime.ToString() + Sudu(geanIdTime, count)); Console.WriteLine("随机数字: " + randNumTime.ToString() + Sudu(randNumTime, count)); Console.WriteLine("随机4位小写字母: " + randTime.ToString() + Sudu(randTime, count)); Console.WriteLine("数字累计: " + gerTime.ToString() + Sudu(gerTime, count)); Console.WriteLine("IDGenerator生成: " + idgTime.ToString() + Sudu(idgTime, count)); Console.WriteLine("Guid: " + guidTime.ToString() + Sudu(guidTime, count)); }