/// <summary> /// Show a dialog prompting the user regarding a list of schematics. /// </summary> /// <param name="Owner"></param> /// <param name="Editors"></param> /// <returns></returns> public static IEnumerable <SchematicEditor> Show(Window Owner, string Message, MessageBoxButton Buttons, IEnumerable <SchematicEditor> Editors) { if (!Editors.Any()) { return new SchematicEditor[] { } } ; EditorListDialog dlg = new EditorListDialog(Message, Buttons, Editors) { Owner = Owner }; dlg.ShowDialog(); switch (dlg.result) { case MessageBoxResult.Yes: case MessageBoxResult.OK: return(dlg.Selected.ToList()); case MessageBoxResult.No: return(new SchematicEditor[] { }); default: return(null); } }
private void OnActivated(object sender, EventArgs e) { if (activating) { return; } activating = true; // Find the schematics that have been modified outside the editor. IEnumerable <SchematicEditor> modified = EditorListDialog.Show( this, "The following schematics were modified outside LiveSPICE, do you want to reload them?", MessageBoxButton.YesNo, Editors.Where(i => i.CheckForModifications()).ToList()); if (modified != null) { foreach (SchematicEditor i in modified) { i.Touch(); } foreach (SchematicEditor i in modified) { Open(i.FilePath, true); } } activating = false; }
private void OnClosing(object sender, CancelEventArgs e) { // Find the schematics that have pending edits. IEnumerable <SchematicEditor> save = EditorListDialog.Show( this, "Save the following schematics?", MessageBoxButton.YesNoCancel, Editors.Where(i => i.Edits.Dirty)); if (save != null) { foreach (SchematicEditor i in save) { if (!i.Save()) { e.Cancel = true; return; } } } else { e.Cancel = true; } }
/// <summary> /// Show a dialog prompting the user regarding a list of schematics. /// </summary> /// <param name="Owner"></param> /// <param name="Editors"></param> /// <returns></returns> public static IEnumerable<SchematicEditor> Show(Window Owner, string Message, MessageBoxButton Buttons, IEnumerable<SchematicEditor> Editors) { if (!Editors.Any()) return new SchematicEditor[] { }; EditorListDialog dlg = new EditorListDialog(Message, Buttons, Editors) { Owner = Owner }; dlg.ShowDialog(); switch (dlg.result) { case MessageBoxResult.Yes: case MessageBoxResult.OK: return dlg.Selected.ToList(); case MessageBoxResult.No: return new SchematicEditor[] { }; default: return null; } }