コード例 #1
0
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            if (OpenDLG.ShowDialog(this) == DialogResult.OK)
            {
                if (OpenDLG.FileName.Length == 0)
                {
                    return;
                }

                FileStream fs = new FileStream(OpenDLG.FileName, FileMode.Open, FileAccess.Read);
                if (fs.Length != 1000021)
                {
                    MessageBox.Show(this, "Invalid File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                PnlGUI.DrawModeSetup = DrawModeSetup.None;
                foreach (ToolStripItem item in ToolStrp.Items)
                {
                    if (item is ToolStripButton)
                    {
                        ((ToolStripButton)item).Checked = false;
                    }
                }

                PnlGUI.Start                     = new Point(fs.ReadByte() << 8 | fs.ReadByte(), fs.ReadByte() << 8 | fs.ReadByte());
                PnlGUI.End                       = new Point(fs.ReadByte() << 8 | fs.ReadByte(), fs.ReadByte() << 8 | fs.ReadByte());
                ChkDiagonals.Checked             = fs.ReadByte() > 0;
                ChkHeavyDiagonals.Checked        = fs.ReadByte() > 0;
                ChkPunishChangeDirection.Checked = fs.ReadByte() > 0;
                ChkReopenCloseNodes.Checked      = fs.ReadByte() > 0;
                NumUpDownHeuristic.Value         = fs.ReadByte();
                CboFormula.SelectedIndex         = fs.ReadByte();
                ChkTieBraker.Checked             = fs.ReadByte() > 0;
                NumSearchLimit.Value             = fs.ReadByte() << 24 | fs.ReadByte() << 16 | fs.ReadByte() << 8 | fs.ReadByte();
                TBarGridSize.Value               = fs.ReadByte();
                PnlGUI.GridSize                  = TBarGridSize.Value;
                TBarSpeed.Value                  = fs.ReadByte();
                mDelay = (int)Math.Pow(TBarSpeed.Value, 2);

                for (int y = 0; y < 1000; y++)
                {
                    for (int x = 0; x < 1000; x++)
                    {
                        PnlGUI.Matrix[x, y] = (byte)fs.ReadByte();
                    }
                }

                fs.Close();
                PnlGUI.Invalidate();
            }
        }
コード例 #2
0
        private void BtnLoad_Click(object sender, EventArgs e)
        {
            if (OpenDLG.ShowDialog(this) == DialogResult.OK)
            {
                if (OpenDLG.FileName.Length == 0)
                {
                    return;
                }

                FileStream fs = new FileStream(OpenDLG.FileName, FileMode.Open, FileAccess.Read);
                if (fs.Length != 1000021)
                {
                    MessageBox.Show(this, "Invalid File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                matrix_Base.DrawModeSetup = DrawModeSetup.None;
                foreach (ToolStripItem item in ToolStrp.Items)
                {
                    if (item is ToolStripButton)
                    {
                        ((ToolStripButton)item).Checked = false;
                    }
                }

                matrix_Base.Start           = new Point(fs.ReadByte() << 8 | fs.ReadByte(), fs.ReadByte() << 8 | fs.ReadByte());
                matrix_Base.End             = new Point(fs.ReadByte() << 8 | fs.ReadByte(), fs.ReadByte() << 8 | fs.ReadByte());
                ChkDiagonals.Checked        = fs.ReadByte() > 0;
                ChkReopenCloseNodes.Checked = fs.ReadByte() > 0;
                NumUpDownHeuristic.Value    = fs.ReadByte();
                CboFormula.SelectedIndex    = fs.ReadByte();

                for (int y = 0; y < 1000; y++)
                {
                    for (int x = 0; x < 1000; x++)
                    {
                        matrix_Base.Matrix[x, y] = (byte)fs.ReadByte();
                    }
                }

                fs.Close();
                matrix_Base.Invalidate();
            }
        }