private void toolStripButton1_Click(object sender, EventArgs e) { #region 构造函数 //connectionControl = new ConnectionControl(); //connectionControl.Visible = true; //pnlControles.Controls.Add(connectionControl); //tableControl = new TableControl(); //tableControl.Visible = false; //pnlControles.Controls.Add(tableControl); configControl = new ConfigurationControl(); configControl.Visible = false; pnlControles.Controls.Add(configControl); solutionControl = new SolutionControl(); solutionControl.Visible = false; pnlControles.Controls.Add(solutionControl); showControl(NewProjectStep.CONNECTION); #endregion }
public void Initialize(ScreenManager screenManager) { this.screenManager = screenManager; this.GraphicsDevice = screenManager.GraphicsDevice; _content = new ContentManager(screenManager.ServiceProvider, Constants.CONTENT_DIRECTORY); Color[] repColors = new Color[6]; for (int i = 0; i < repColors.Length; i++) { repColors[i] = Settings.Instance.RubiksCube.GetVisualColor(i); } rubiksSolver = new RubiksBeginnerSolver(); try { solutionMoves = rubiksSolver.Solve(cube, repColors).Split(); solutionMoves = ConvertAndShortenSolution(solutionMoves); } catch (RubiksCubeUnsolvableException) { Console.WriteLine("Unsolvable"); } viewer = new SolutionViewer(solutionMoves, _content); control = new SolutionControl(_content); control.OnPlay += new EventHandler((s, e) => { if (moveIdx >= solutionMoves.Length) { control.Play = false; } }); control.OnForward += new EventHandler((s, e) => { if (moveIdx <= solutionMoves.Length) { viewer.Increment(); if (moveIdx < solutionMoves.Length) { cube.ResetMove(); CubeRotate(0); cube.Update(); moveIdx++; } control.Play = false; } }); control.OnBackward += new EventHandler((s, e) => { if (moveIdx > 0) { viewer.Decrement(); moveIdx--; cube.ResetMove(); CubeRotateBackward(0); cube.Update(); control.Play = false; } }); control.OnFastBackward += new EventHandler((s, e) => { if (moveIdx > 0) { int times = moveIdx > 4 ? 5 : moveIdx; Console.WriteLine(times); cube.ResetMove(); for (int i = 0; i < times; i++) { viewer.Decrement(); moveIdx--; CubeRotateBackward(0); cube.Update(); } control.Play = false; } }); control.OnFastForward += new EventHandler((s, e) => { if (moveIdx <= solutionMoves.Length) { int times = (solutionMoves.Length - moveIdx) > 4 ? 5 : solutionMoves.Length - moveIdx; Console.WriteLine(times); cube.ResetMove(); for (int i = 0; i < times; i++) { viewer.Increment(); if (moveIdx < solutionMoves.Length) { CubeRotate(0); cube.Update(); moveIdx++; } } control.Play = false; } }); }