Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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 }
     };
 }
Exemplo n.º 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
         }
     };
 }
Exemplo n.º 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()
     };
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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()
     };
 }
Exemplo n.º 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()
     };
 }
Exemplo n.º 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()
     };
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 12
0
 public MoveTool(SchematicEditor Target, Circuit.Coord At)
     : base(Target)
 {
     x = At;
 }
Exemplo n.º 13
0
 public EditorTool(SchematicEditor Target) : base(Target)
 {
 }
Exemplo n.º 14
0
 private Circuit.Point GetSelectionCenter()
 {
     Circuit.Coord x1 = SchematicEditor.LowerBound(Target.Selected);
     Circuit.Coord x2 = SchematicEditor.UpperBound(Target.Selected);
     return(Target.SnapToGrid((x1 + x2) / 2));
 }
Exemplo n.º 15
0
 public EditorTool(SchematicEditor Target)
     : base(Target)
 {
 }
 public SchematicViewer(SchematicEditor Schematic) : this()
 {
     this.Schematic = Schematic;
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 18
0
 public MoveTool(SchematicEditor Target, Circuit.Coord At)
     : base(Target)
 {
     x = At;
 }
Exemplo n.º 19
0
 public SchematicViewer(SchematicEditor Schematic)
     : this()
 {
     this.Schematic = Schematic;
 }