/// <summary> /// Register an editor control with this tab. /// <para/>Note: This will add the editor control into the tabpage <seealso cref="Control.ControlCollection"/> /// </summary> /// <param name="editorControl">The <seealso cref="IEditor"/> control to add</param> public IEditor ImplementEditor(FileProcessor.EditorTypes editorControl = FileProcessor.EditorTypes.NULL) { //NOTE: FileProcessor.FileTypes == FileProcessor.EditorTypes //we assume that because no file was specified, we are using an editor that doesnt require a file, you better have manually specified the editorControl param! //NOTE V2: If you actually use the editorControl param, this func uses that regardless of the file type, so be warned! editor = FileProcessor.returnEditorFromType(editorControl == FileProcessor.EditorTypes.NULL ? (FileProcessor.EditorTypes)(int) File.FileType : editorControl); editor.owner = this; //As long as you follow the EditorTemplate(visible in IEditor) your editor should contain an Init() func, for late initialization scenarios editor.Init(File); tabpage.Controls.Add(editor.main); return(editor); }
private void validateSaveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); if (sfd.ShowDialog() == DialogResult.OK) { SessionManager.Report("Writing to save...", SessionManager.RType.DEBUG); SaveFile(TabControl.Tabs[tabControl1.SelectedIndex].File.FilePath); } F_NGN loadedNGN = (F_NGN)TabControl.Tabs[tabControl1.SelectedIndex].File; F_NGN validater = (F_NGN)FileProcessor.ProcessFile(TabControl.Tabs[tabControl1.SelectedIndex].File.FilePath); SessionManager.Report("Validating save file...", SessionManager.RType.DEBUG); for (int i = 0; i < loadedNGN.Schema.NGNFunctions.Count; i++) { bool val = loadedNGN.Schema.NGNFunctions[i].FunctionOffset == validater.Schema.NGNFunctions[i].FunctionOffset; SessionManager.Report(Enum.GetName(typeof(F_NGN.NGNFunction), loadedNGN.Schema.NGNFunctions[i].FunctionType) + ((val) ? " successfully validated" : " did not validate succesfully"), ((val) ? SessionManager.RType.DEBUG : SessionManager.RType.WARN));//, Color.DarkGreen); } }
public void OpenFile(string path = "") { if (path == "") { OpenFileDialog OFD = new OpenFileDialog { Filter = "T2T Files | *.NGN;*.SAV|Level File | *.NGN|Save File | *.SAV|All files (*.*)|*.*" }; if (OFD.ShowDialog() == DialogResult.OK) { path = OFD.FileName; } } if (path != "") { firstOpenPanel1.Visible = false; tabControl1.Visible = true; TabControl.CreateTab(FileProcessor.ProcessFile(path)); } }