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); }
public SymbolTool(SchematicEditor Target, Circuit.Component C) : base(Target) { overlay = new SymbolControl(C) { Visibility = Visibility.Hidden, ShowText = false, Highlighted = true, Pen = new Pen(Brushes.Gray, 1.0) { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round } }; }
public WireTool(SchematicEditor Target) : base(Target) { path = new Path() { Fill = null, Stroke = ElementControl.HighlightPen.Brush, StrokeThickness = 1, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Visibility = Visibility.Hidden, SnapsToDevicePixels = true, Data = new PathGeometry() }; }
public static SchematicEditor Open(string FileName) { try { SchematicEditor editor = new SchematicEditor(FileName); App.Current.Settings.Used(FileName); return(editor); } catch (Exception) { App.Current.Settings.RemoveFromMru(FileName); throw; } }
public WireTool(SchematicEditor Target) : base(Target) { path = new Path() { Fill = null, Stroke = ElementControl.HighlightPen.Brush, StrokeThickness = 1, StrokeStartLineCap = PenLineCap.Round, StrokeEndLineCap = PenLineCap.Round, StrokeLineJoin = PenLineJoin.Round, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Visibility = Visibility.Hidden, Data = new PathGeometry() }; }
public SelectionTool(SchematicEditor Target) : base(Target) { path = new Path() { Fill = null, Stroke = Brushes.Blue, StrokeThickness = 1, StrokeDashArray = new DoubleCollection() { 2, 1 }, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Visibility = Visibility.Hidden, Data = new RectangleGeometry() }; }
private void component_Click(Circuit.Component C) { SchematicEditor active = ActiveEditor; if (active == null) { active = (SchematicEditor)New().Schematic; } if (C is Circuit.Conductor) { active.Tool = new WireTool(active); } else { active.Tool = new SymbolTool(active, C.Clone()); } active.Focus(); Keyboard.Focus(active); }
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; }
public MoveTool(SchematicEditor Target, Circuit.Coord At) : base(Target) { x = At; }
public EditorTool(SchematicEditor Target) : base(Target) { }
private Circuit.Point GetSelectionCenter() { Circuit.Coord x1 = SchematicEditor.LowerBound(Target.Selected); Circuit.Coord x2 = SchematicEditor.UpperBound(Target.Selected); return(Target.SnapToGrid((x1 + x2) / 2)); }
public SchematicViewer(SchematicEditor Schematic) : this() { this.Schematic = Schematic; }
public static SchematicEditor Open(string FileName) { try { SchematicEditor editor = new SchematicEditor(FileName); App.Current.Settings.Used(FileName); return editor; } catch (Exception) { App.Current.Settings.RemoveFromMru(FileName); throw; } }