Пример #1
0
        // set up the position given from PostitionBox
        public void SetUpPosition()
        {
            int    num     = 0;
            string text    = PositionBox.Text;
            bool   success = int.TryParse(text, out num);

            if (success == true && num >= 0 && num < Cube.GetNumPositions())
            {
                Cube.SetUpPosition(num);
                SampleCubeView.Refresh();
                PosNum                        = num;
                AlgLabel.Visible              = true;
                AlgorithmBox.Visible          = true;
                ChangeAlgorithmButton.Visible = true;
                AlgLabel.Text                 = num.ToString();

                // get and display the algorithm
                AlgFile   file = new AlgFile(Info.GetAlgFileName(Set), AlgFileMode.Open, AlgFileAccess.Read);
                Algorithm alg  = file.Read(num);
                AlgorithmBox.Text = alg.ToString();
                file.Close();
            }
            else
            {
                MessageBox.Show("Invalid input.  Input must be an integer between 0 and " + Cube.GetNumPositions() + ".", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        // changes the algorithm for the current position
        private void ChangeAlgorithmButton_Click(object sender, EventArgs e)
        {
            Algorithm alg = null;

            try
            {
                alg = new Algorithm(AlgorithmBox.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Not a valid algorithm.", "invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var file = new AlgFile(Info.GetAlgFileName(Set), AlgFileMode.Open, AlgFileAccess.ReadWrite);

            file.Write(PosNum, alg);
            file.Close();
            MessageBox.Show("Algorithm changed.", "success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #3
0
        private void AssertAlgFilesExist()
        {
            try
            {
                foreach (var set in Enum.GetValues(typeof(AlgSet)))
                {
                    if (set.Equals(AlgSet.All))
                    {
                        continue;
                    }
                    var file = new AlgFile(Info.GetAlgFileName((AlgSet)set), AlgFileMode.Open, AlgFileAccess.Read);
                    file.Close();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(@"Algorithm files are missing.
Please make sure 'eg.alg', 'ellcp.alg', 'oll.alg', 'ollcp.alg', 'oneLookLL.alg', 'vls.alg' and 'zbll.alg' are in the working directory.
You can download them from github: https://github.com/fletcher-berry/Cubing.", "missing files", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
        }