Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Logic.RemoveButtons(Logic.Lcontrol);
            Logic.RemoveLabels(Logic.Lcontrol);
            Logic.ClearSolutionAndAnswer();
            Logic.Return = false;
            Logic.RemoveCongratulationsLabel(Logic.Lcontrol);

            CreateLogic.RemoveButtons(Logic.Lcontrol);
            CreateLogic.RemoveLabels(Logic.Lcontrol);
            CreateLogic.ClearSolution();
            CreateLogic.Return = false;
            CreateLogic.RemoveUserControl(Logic.Lcontrol);


            FileStream fileStream = new FileStream(ChooseLogic.Files[listView1.Items.IndexOf(listView1.SelectedItems[0])],
                                                   FileMode.Open,
                                                   FileAccess.Read,
                                                   FileShare.ReadWrite);
            XmlSerializer     s   = new XmlSerializer(typeof(SaveLogicStruct_t));
            SaveLogicStruct_t tmp = (SaveLogicStruct_t)s.Deserialize(fileStream);

            Logic.LoadLogic(tmp.SizeX, tmp.SizeY, tmp.Solution, Logic.Lcontrol);
            this.Close();
        }
Beispiel #2
0
        private void createPuzzleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();

            f3.ShowDialog();
            if (CreateLogic.Return)
            {
                Logic.RemoveButtons(Logic.Lcontrol);
                Logic.RemoveLabels(Logic.Lcontrol);
                Logic.ClearSolutionAndAnswer();
                Logic.Return = false;
                Logic.RemoveCongratulationsLabel(Logic.Lcontrol);

                CreateLogic.RemoveButtons(CreateLogic.CLcontrol);
                CreateLogic.RemoveLabels(CreateLogic.CLcontrol);
                CreateLogic.ClearSolution();
                CreateLogic.Return = false;
                CreateLogic.RemoveUserControl(CreateLogic.CLcontrol);


                CreateLogic.CreateButtons(CreateLogic.CLcontrol);
                CreateLogic.CreateLabels(CreateLogic.CLcontrol);
                CreateLogic.CreateUserControl(CreateLogic.CLcontrol);
            }
        }
Beispiel #3
0
        private void loadPuzzleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title  = "Load Puzzle";
            openFileDialog.Filter = "XML Save File|*.xml";
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (!openFileDialog.FileName.Equals(""))
                {
                    FileStream fileStream = null;
                    try
                    {
                        using (fileStream = new FileStream($"{openFileDialog.FileName}", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            Logic.RemoveButtons(Logic.Lcontrol);
                            Logic.RemoveLabels(Logic.Lcontrol);
                            Logic.ClearSolutionAndAnswer();
                            Logic.Return = false;
                            Logic.RemoveCongratulationsLabel(Logic.Lcontrol);

                            CreateLogic.RemoveButtons(CreateLogic.CLcontrol);
                            CreateLogic.RemoveLabels(CreateLogic.CLcontrol);
                            CreateLogic.ClearSolution();
                            CreateLogic.Return = false;
                            CreateLogic.RemoveUserControl(CreateLogic.CLcontrol);


                            XmlSerializer     s   = new XmlSerializer(typeof(SaveLogicStruct_t));
                            SaveLogicStruct_t tmp = (SaveLogicStruct_t)s.Deserialize(fileStream);
                            Logic.LoadLogic(tmp.SizeX, tmp.SizeY, tmp.Solution, Logic.Lcontrol);
                        }
                    }
                    finally
                    {
                        if (fileStream != null)
                        {
                            fileStream.Dispose();
                        }
                    }
                }
            }
        }