Beispiel #1
0
 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);
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 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 }
     };
 }
Beispiel #4
0
 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
         }
     };
 }
Beispiel #5
0
 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()
     };
 }
Beispiel #6
0
 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;
     }
 }
Beispiel #7
0
 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()
     };
 }
Beispiel #8
0
 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()
     };
 }
Beispiel #9
0
 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()
     };
 }
Beispiel #10
0
        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);
        }
Beispiel #11
0
        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;
        }
Beispiel #12
0
 public MoveTool(SchematicEditor Target, Circuit.Coord At)
     : base(Target)
 {
     x = At;
 }
Beispiel #13
0
 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));
 }
Beispiel #15
0
 public EditorTool(SchematicEditor Target)
     : base(Target)
 {
 }
 public SchematicViewer(SchematicEditor Schematic) : this()
 {
     this.Schematic = Schematic;
 }
Beispiel #17
0
 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;
     }
 }
Beispiel #18
0
 public MoveTool(SchematicEditor Target, Circuit.Coord At)
     : base(Target)
 {
     x = At;
 }
 public SchematicViewer(SchematicEditor Schematic)
     : this()
 {
     this.Schematic = Schematic;
 }