private void UpdateCurrent() { //Debug.Print("<<< starting UpdateCurrent"); try { this.running = true; LogicalCircuit current = this.diagram.CircuitProject.ProjectSet.Project.LogicalCircuit; int currentVersion = this.diagram.CircuitProject.Version; HashSet <Wire> bad = this.Bad(current); void redraw() { List <Wire> list = this.badWires.Except(bad).ToList(); foreach (Wire wire in list.Where(w => !w.IsDeleted())) { if (this.stopPending) { return; } wire.WireGlyph.Stroke = Symbol.WireStroke; } this.badWires.ExceptWith(list); foreach (Wire wire in bad.Where(w => !this.badWires.Contains(w))) { if (this.stopPending) { return; } this.badWires.Add(wire); wire.WireGlyph.Stroke = Symbol.BadWireStroke; } } if (this.logicalCircuit != current) { this.badWires.Clear(); } if (!this.stopPending && bad != null) { App.Dispatch(redraw); this.logicalCircuit = current; } if (!this.stopPending) { this.version = currentVersion; } } catch (Exception exception) { App.Mainframe.ReportException(exception); } finally { this.running = false; //Debug.Print(">>> ending UpdateCurrent"); } }
private static CircuitProject Create(Mainframe mainframe, string file) { bool useAutoSaveFile = false; string autoSaveFile = Mainframe.AutoSaveFile(file); if (Mainframe.IsFileExists(autoSaveFile)) { App.Dispatch(() => { MessageBoxResult result = DialogMessage.Show( mainframe, Properties.Resources.TitleApplication, Properties.Resources.MessageLoadAutoSavedFile(file), null, MessageBoxImage.Question, MessageBoxButton.YesNo ); if (result == MessageBoxResult.Yes) { useAutoSaveFile = true; } }); if (!useAutoSaveFile) { Mainframe.DeleteFile(autoSaveFile); } } if (!useAutoSaveFile) { autoSaveFile = file; } CircuitProject project = CircuitProject.Create(autoSaveFile); if (useAutoSaveFile) { project.InOmitTransaction(() => {}); } return(project); }