private void Open(string FileName, bool CanClose) { try { SchematicViewer open = FindViewer(FileName); if (open != null) { ((LayoutDocument)open.Tag).IsSelected = true; // If this schematic is already open, prompt for re-open if necessary. if (CanClose || ((SchematicEditor)open.Schematic).CanClose(true)) { open.Schematic = SchematicEditor.Open(FileName); } } else { // Just make a new one. AddViewer(SchematicEditor.Open(FileName)); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private SchematicViewer AddViewer(SchematicEditor Schematic) { Schematic.SelectionChanged += schematic_SelectionChanged; Schematic.EditSelection += schematic_EditSelection; SchematicViewer sv = new SchematicViewer(Schematic); LayoutDocument doc = new LayoutDocument() { Content = sv, Title = Schematic.Title, ToolTip = Schematic.FilePath, IsActive = true }; doc.Closing += (o, e) => e.Cancel = !Schematic.CanClose(); Schematic.PropertyChanged += (o, e) => { if (e.PropertyName == "FilePath") { doc.Title = Schematic.Title; doc.ToolTip = Schematic.FilePath; } }; sv.Tag = doc; schematics.Children.Add(doc); dock.UpdateLayout(); sv.FocusCenter(); return(sv); }
private SchematicViewer AddViewer(SchematicEditor Schematic) { Schematic.SelectionChanged += schematic_SelectionChanged; Schematic.EditSelection += schematic_EditSelection; SchematicViewer sv = new SchematicViewer(Schematic); LayoutDocument doc = new LayoutDocument() { Content = sv, Title = Schematic.Title, ToolTip = Schematic.FilePath, IsActive = true }; doc.Closing += (o, e) => e.Cancel = !Schematic.CanClose(); Schematic.PropertyChanged += (o, e) => { if (e.PropertyName == "FilePath") { doc.Title = Schematic.Title; doc.ToolTip = Schematic.FilePath; } }; sv.Tag = doc; schematics.Children.Add(doc); dock.UpdateLayout(); sv.FocusCenter(); return sv; }