예제 #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();
                }
            }
        }
예제 #2
0
        private void New()
        {
            SaveAndClose();
            codeBox.Clear();
            string dir = Application.UserAppDataPath + "\\currentfile";

            codeFileName      = dir + "\\code";
            modifiedinfo.Text = "Untitled - *No Changes*";
            try {
                memView.Close();
                memView.Dispose();
            } catch { }
            try { MPU.CommitMemory(); }  catch (NullReferenceException) { }
            try { Directory.Delete(dir, true); } catch (IOException) { }
            Directory.CreateDirectory(dir);
            MPU.InitMemory(dir + "\\memory");
            memView           = new MemoryViewer();
            codeBox.IsChanged = false;

            codeBox.Visible = true;
        }
예제 #3
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*";
        }