Exemple #1
0
        private void OpenFile(string filename)
        {
            if (!System.IO.File.Exists(filename))
            {
                // "An error occured while reading the file:"
                MessageBox.Show(Translation.StringID.ERROR_FILE + Environment.NewLine + "File \"" + filename + "\" does not exist", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                design = new PesFile.PesFile(filename);
            }
            catch (System.IO.IOException ioex)
            {
                // "An error occured while reading the file:"
                MessageBox.Show(Translation.StringID.ERROR_FILE + Environment.NewLine + filename + ":" + Environment.NewLine + ioex.Message, "IOException", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                design = null;
            }
            catch (PesFile.PECFormatException pecex)
            {
                // "This file is either corrupt or not a valid PES file."
                MessageBox.Show(Translation.StringID.ERROR_FILE + Environment.NewLine + filename + ":" + Environment.NewLine + pecex.Message, "PECFormatException", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                design = null;
            }

            loadedFileName = filename;
            if (design != null)
            {
                UpdateDesignImage();

                if (design.GetFormatWarning())
                {
                    toolStripStatusLabel1.Text = translation.GetTranslatedString(Translation.StringID.UNSUPPORTED_FORMAT); // "The format of this file is not completely supported";
                }
                else if (design.GetColorWarning())
                {
                    toolStripStatusLabel1.Text = translation.GetTranslatedString(Translation.StringID.COLOR_WARNING); // "Colors shown for this design may be inaccurate"
                }
                else
                {
                    toolStripStatusLabel1.Text = "";
                }

                copyToolStripMenuItem.Enabled          = true;
                saveDebugInfoToolStripMenuItem.Enabled = true;
                printPreviewToolStripMenuItem.Enabled  = true;
                printToolStripMenuItem.Enabled         = true;
                rotateLeftToolStripMenuItem.Enabled    = true;
                rotateRightToolStripMenuItem.Enabled   = true;
                refreshToolStripMenuItem.Enabled       = true;
                zoomToolStripMenuItem.Enabled          = true;
                showDebugInfoToolStripMenuItem.Enabled = true;
                saveAsBitmapToolStripMenuItem.Enabled  = true;
                panel2.Select();
            }
            else
            {
                copyToolStripMenuItem.Enabled          = false;
                saveDebugInfoToolStripMenuItem.Enabled = false;
                printPreviewToolStripMenuItem.Enabled  = false;
                printToolStripMenuItem.Enabled         = false;
                rotateLeftToolStripMenuItem.Enabled    = false;
                rotateRightToolStripMenuItem.Enabled   = false;
                refreshToolStripMenuItem.Enabled       = false;
                showDebugInfoToolStripMenuItem.Enabled = false;
                saveAsBitmapToolStripMenuItem.Enabled  = false;
            }
        }