예제 #1
0
파일: Form1.cs 프로젝트: hnjm/VirtualRubik
 private void button4_Click(object sender, EventArgs e)
 {
     if (listBox1.Items.Count > 0)
     {
         rotationTicks     = 25;
         groupBox1.Enabled = false;
         List <LayerMove> lms = new List <LayerMove>();
         for (int i = listBox1.Items.Count - 1; i >= 0; i--)
         {
             String[] commands = listBox1.Items[i].ToString().Split(new Char[] { Convert.ToChar(" ") });
             lms.Add(new LayerMove((Cube3D.RubikPosition)Enum.Parse(typeof(Cube3D.RubikPosition), commands[0]), (commands[1] == "Clockwise")));
         }
         moveStack = new Stack <LayerMove>(lms);
         LayerMove nextMove  = moveStack.Pop();
         bool      direction = nextMove.Direction;
         if (nextMove.Layer == Cube3D.RubikPosition.TopLayer || nextMove.Layer == Cube3D.RubikPosition.LeftSlice || nextMove.Layer == Cube3D.RubikPosition.FrontSlice)
         {
             direction = !direction;
         }
         rubikManager.Rotate90(nextMove.Layer, direction, rotationTicks);
         toolStripStatusLabel1.Text = "Rotating " + nextMove.Layer.ToString() + " " + ((nextMove.Direction) ? "Clockwise" : "Counter-Clockwise");
         listBox1.SelectedIndex     = 0;
         comboBox1.Text             = listBox1.SelectedItem.ToString();
     }
 }
예제 #2
0
 public Algorithm(string moves)
 {
     Moves = new List <LayerMove>();
     foreach (string s in moves.Split(char.Parse(" ")))
     {
         Moves.Add(LayerMove.Parse(s));
     }
 }
예제 #3
0
 private void RotatingFinished(object sender)
 {
     if (moveStack.Count > 0)
     {
         LayerMove nextMove  = moveStack.Pop();
         bool      direction = nextMove.Direction;
         rubikRenderer.RubikManager.Rotate90(nextMove.Layer, direction, rotationTime);
         toolStripStatusLabel1.Text = "Rotating " + nextMove.Layer.ToString() + " " + ((nextMove.Direction) ? "Clockwise" : "Counter-Clockwise");
         if (listBox1.InvokeRequired)
         {
             listBox1.Invoke((MethodInvoker) delegate() { listBox1.SelectedIndex++; });
         }
         if (comboBox1.InvokeRequired)
         {
             comboBox1.Invoke((MethodInvoker) delegate() { comboBox1.Text = listBox1.SelectedItem.ToString(); });
         }
     }
     else
     {
         if (groupBox1.InvokeRequired)
         {
             groupBox1.Invoke((MethodInvoker) delegate() { groupBox1.Enabled = true; });
         }
         if (listBox1.InvokeRequired)
         {
             listBox1.Invoke((MethodInvoker) delegate()
             {
                 if (listBox1.SelectedIndex != listBox1.Items.Count - 1)
                 {
                     listBox1.SelectedIndex++;
                 }
                 else
                 {
                     listBox1.SelectedIndex = -1;
                 }
             });
         }
         toolStripStatusLabel1.Text = "Ready";
     }
 }
예제 #4
0
파일: Form1.cs 프로젝트: hnjm/VirtualRubik
 private void RotatingFinished(object sender)
 {
     if (moveStack.Count > 0)
     {
         LayerMove nextMove  = moveStack.Pop();
         bool      direction = nextMove.Direction;
         if (nextMove.Layer == Cube3D.RubikPosition.TopLayer || nextMove.Layer == Cube3D.RubikPosition.LeftSlice || nextMove.Layer == Cube3D.RubikPosition.FrontSlice)
         {
             direction = !direction;
         }
         rubikManager.Rotate90(nextMove.Layer, direction, rotationTicks);
         toolStripStatusLabel1.Text = "Rotating " + nextMove.Layer.ToString() + " " + ((nextMove.Direction) ? "Clockwise" : "Counter-Clockwise");
         listBox1.SelectedIndex++;
         comboBox1.Text = listBox1.SelectedItem.ToString();
     }
     else
     {
         groupBox1.Enabled          = true;
         listBox1.SelectedIndex     = -1;
         toolStripStatusLabel1.Text = "Ready";
     }
 }