Пример #1
0
        /// <summary>
        /// for the turns, the sides are rotated to the front
        /// the y-axis points upwards, the x-axis to the right and the z-axis backwards
        /// for the left side, the cube is turned 90 degrees counterclockwise around the y-axis
        /// for the right side, the cube is turned 90 degrees clockwise around the y-axis
        /// for the top side, the cube is turned 90 degrees counterclockwise around the x-axis
        /// for the bottom side, the cube is turned 90 degrees clockwise around the x-axis
        /// for the back side, the cube is turned 180 degrees around the y-axis
        ///
        /// the notations in the method are marked according to this page:
        /// https://rubiks.com/uploads/general_content/Rubiks_cube_3x3_solution-en.pdf
        ///
        /// the rotations need to run in separate threads, because otherwise they would run in the UI thread
        /// but because the events have to await until the storyboard finished, the rotation method's execution continues
        /// so basically there is no way to wait until the rotation is finished in the UI for the rest of the methods to continue
        /// therefore they have to run in a second thread, so that the event also runs in a second thread
        /// the event handler can then synchronously wait for a task executed with the dispatcher to finish
        /// </summary>


        /// <summary>
        /// F
        /// </summary>
        public void RotateFrontCW(bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                raiseBeforeFrontCWRotation();
            }
            var tempRow = top.GetRow(2);

            top.SetRow(2, left.GetColumn(2).Reverse().ToArray());
            left.SetColumn(2, bottom.GetRow(0));
            bottom.SetRow(0, right.GetColumn(0).Reverse().ToArray());
            right.SetColumn(0, tempRow);
            front.RotateCW();
            raiseAfterFrontCWRotation();
        }
Пример #2
0
        /// <summary>
        /// D
        /// </summary>
        public void RotateBottomCW(bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                raiseBeforeBottomCWRotation();
            }
            var tempRow = front.GetRow(2);

            front.SetRow(2, left.GetRow(2));
            left.SetRow(2, back.GetRow(2));
            back.SetRow(2, right.GetRow(2));
            right.SetRow(2, tempRow);
            bottom.RotateCW();
            if (raiseEvents)
            {
                raiseAfterBottomCWRotation();
            }
        }
Пример #3
0
        /// <summary>
        /// U
        /// </summary>
        public void RotateTopCW(bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                raiseBeforeTopCWRotation();
            }
            var tempRow = front.GetRow(0);

            front.SetRow(0, right.GetRow(0));
            right.SetRow(0, back.GetRow(0));
            back.SetRow(0, left.GetRow(0));
            left.SetRow(0, tempRow);
            top.RotateCW();
            if (raiseEvents)
            {
                raiseAfterTopCWRotation();
            }
        }
Пример #4
0
        /// <summary>
        /// R
        /// </summary>
        public void RotateRightCW(bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                raiseBeforeRightCWRotation();
            }
            var tempColumn = top.GetColumn(2);

            top.SetColumn(2, front.GetColumn(2));
            front.SetColumn(2, bottom.GetColumn(2));
            bottom.SetColumn(2, back.GetColumn(0).Reverse().ToArray());
            back.SetColumn(0, tempColumn.Reverse().ToArray());
            right.RotateCW();
            if (raiseEvents)
            {
                raiseAfterRightCWRotation();
            }
        }