Esempio n. 1
0
        private void openMI_Click(object sender, EventArgs e)
        {
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                SaveAndClose();
                try {
                    memView.Close();
                    memView.Dispose();
                } catch { }
                MPU.CommitMemory();
                if (OneXFile.ExtractOneXFile(openFile.FileName, "currentfile"))
                {
                    saveFileName = openFile.FileName;
                    string dir = Application.UserAppDataPath + "\\currentfile";
                    codeFileName = dir + "\\code";
                    codeBox.OpenFile(codeFileName, Encoding.UTF8);
                    MPU.InitMemory(dir + "\\memory");
                    memView           = new MemoryViewer();
                    codeBox.IsChanged = false;
                    modifiedinfo.Text = Path.GetFileName(saveFileName) + " - *No Changes*";

                    codeBox.Visible = true;
                }
                else
                {
                    MessageBox.Show("The selected *.onex file is in invalid format!", "Invalid format!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CloseFile();
                }
            }
        }
Esempio n. 2
0
        private void SaveFile(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                saveasMI.PerformClick(); return;
            }
            saveFileName = name;
            string dir = Application.UserAppDataPath + "\\currentfile";

            codeFileName = dir + "\\code";
            codeBox.SaveToFile(codeFileName, Encoding.UTF8);
            try {
                memView.Close();
                memView.Dispose();
            } catch { }
            MPU.CommitMemory();
            OneXFile.RepackOneXFile(name, "currentfile");
            MPU.InitMemory(dir + "\\memory");
            memView = new MemoryViewer();
            // commit changes (reset all dirty flags)
            codeBox.IsChanged = false;
            modifiedinfo.Text = Path.GetFileName(saveFileName) + " - *Changes Saved*";
        }