예제 #1
0
        private void btn_start_Click(object sender, EventArgs e)
        {
            Cube mycube = new Cube();
            mycube.front[0, 0] = change(pnl_front1);
            mycube.front[0, 1] = change(pnl_front2);
            mycube.front[0, 2] = change(pnl_front3);
            mycube.front[1, 0] = change(pnl_front4);
            mycube.front[1, 1] = 'r';
            mycube.front[1, 2] = change(pnl_front5);
            mycube.front[2, 0] = change(pnl_front6);
            mycube.front[2, 1] = change(pnl_front7);
            mycube.front[2, 2] = change(pnl_front8);

            mycube.back[0, 0] = change(pnl_back1);
            mycube.back[0, 1] = change(pnl_back2);
            mycube.back[0, 2] = change(pnl_back3);
            mycube.back[1, 0] = change(pnl_back4);
            mycube.back[1, 1] = 'o';
            mycube.back[1, 2] = change(pnl_back5);
            mycube.back[2, 0] = change(pnl_back6);
            mycube.back[2, 1] = change(pnl_back7);
            mycube.back[2, 2] = change(pnl_back8);

            mycube.left[0, 0] = change(pnl_left1);
            mycube.left[0, 1] = change(pnl_left2);
            mycube.left[0, 2] = change(pnl_left3);
            mycube.left[1, 0] = change(pnl_left4);
            mycube.left[1, 1] = 'b';
            mycube.left[1, 2] = change(pnl_left5);
            mycube.left[2, 0] = change(pnl_left6);
            mycube.left[2, 1] = change(pnl_left7);
            mycube.left[2, 2] = change(pnl_left8);

            mycube.right[0, 0] = change(pnl_right1);
            mycube.right[0, 1] = change(pnl_right2);
            mycube.right[0, 2] = change(pnl_right3);
            mycube.right[1, 0] = change(pnl_right4);
            mycube.right[1, 1] = 'g';
            mycube.right[1, 2] = change(pnl_right5);
            mycube.right[2, 0] = change(pnl_right6);
            mycube.right[2, 1] = change(pnl_right7);
            mycube.right[2, 2] = change(pnl_right8);

            mycube.up[0, 0] = change(pnl_up1);
            mycube.up[0, 1] = change(pnl_up2);
            mycube.up[0, 2] = change(pnl_up3);
            mycube.up[1, 0] = change(pnl_up4);
            mycube.up[1, 1] = 'y';
            mycube.up[1, 2] = change(pnl_up5);
            mycube.up[2, 0] = change(pnl_up6);
            mycube.up[2, 1] = change(pnl_up7);
            mycube.up[2, 2] = change(pnl_up8);

            mycube.down[0, 0] = change(pnl_down1);
            mycube.down[0, 1] = change(pnl_down2);
            mycube.down[0, 2] = change(pnl_down3);
            mycube.down[1, 0] = change(pnl_down4);
            mycube.down[1, 1] = 'w';
            mycube.down[1, 2] = change(pnl_down5);
            mycube.down[2, 0] = change(pnl_down6);
            mycube.down[2, 1] = change(pnl_down7);
            mycube.down[2, 2] = change(pnl_down8);
            //还原魔方
            listview.Items.Clear();
            mycube.count = 0;
            mycube.sequence[0] = '\0';
            try
            {                
                mycube.Cross(mycube);
                mycube.F2L(mycube);
                mycube.OLL(mycube);
                mycube.PLL(mycube);
                mycube.cut(mycube);

                for (int i = 0;  mycube.str[i] != null; i++)
                {
                    listview.Items.Add((i + 1).ToString());
                    listview.Items[i].SubItems.Add(mycube.str[i]);
                    listview.Items[i].SubItems.Add(mycube.sign[i]);
                }
            }
            catch
            {
                MessageBox.Show("请检查颜色是否填充正确!");
            }         
        }