public void WriteLine(object text, ConsoleColor color = ConsoleColor.Black, bool invoke = false) { if (invoke) { Invoke(new Action(() => { WriteLine(text, color, false); })); return; } EConsole.WriteLine(text, color); }
private void btnSaveArgs_Click(object sender, EventArgs e) { System.Windows.Forms.SaveFileDialog saveDialog = new System.Windows.Forms.SaveFileDialog(); saveDialog.Title = "Save UIEditor project as..."; saveDialog.Filter = "Memcall Project (*.memcall)|*.memcall|All Files (*.*)|*.*"; if (saveDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string f = saveDialog.FileName; escript.Cmd.Process("SetStatus Memcall - Save Project||Saving Project: " + f); try { ProjectClass sClass = new ProjectClass(); sClass.Arguments = Arguments.ToList(); sClass.Addresses = LastAddresses.ToList(); if (SelectedProcess != null) { sClass.ProcessName = SelectedProcess.ProcessName; } XmlSerializer xml = new XmlSerializer(typeof(ProjectClass)); if (File.Exists(f)) { File.Delete(f); } using (FileStream fs = new FileStream(f, FileMode.OpenOrCreate)) { xml.Serialize(fs, sClass); EConsole.WriteLine("Serialization completed!", ConsoleColor.Green); } } catch (Exception ex) { Program.ShowError(ex.ToString(), "Save Project Error"); } escript.Cmd.Process("HideStatus"); } else { return; } }
public void LoadProject(string f) { escript.Cmd.Process("SetStatus Memcall - Open Project||Loading Project: " + f); try { SelectedItem = -1; XmlSerializer xml = new XmlSerializer(typeof(ProjectClass)); using (FileStream fs = new FileStream(f, FileMode.OpenOrCreate)) { ProjectClass ser = (ProjectClass)xml.Deserialize(fs); if (SelectedProcess == null && ser.ProcessName.Length >= 1) { foreach (var p in Process.GetProcessesByName(ser.ProcessName)) { SelectedProcess = p; } } Arguments = ser.Arguments.ToList(); LastAddresses = ser.Addresses.ToList(); foreach (var adr in LastAddresses) { cbAddress.AutoCompleteCustomSource.Add(adr); cbAddress.Items.Add(adr); } RefreshArgsList(); } EConsole.WriteLine("Project loaded"); } catch (Exception ex) { Program.ShowError(ex.ToString(), "Load Project Error"); } escript.Cmd.Process("HideStatus"); }