public SchematicViewer()
        {
            InitializeComponent();

            CommandBindings.Add(new CommandBinding(NavigationCommands.Zoom, (o, e) => Zoom         *= 1.5));
            CommandBindings.Add(new CommandBinding(NavigationCommands.DecreaseZoom, (o, e) => Zoom *= 1 / 1.5));
            CommandBindings.Add(new CommandBinding(Commands.ZoomFit, (o, e) => FocusCenter()));

            scroll.PreviewMouseWheel += (o, e) =>
            {
                Zoom     *= e.Delta > 0 ? 1.1 : (1 / 1.1);
                e.Handled = true;
            };
            scroll.PreviewMouseMove += (o, e) => mouse = e.GetPosition(this);
            scroll.MouseLeave       += (o, e) => mouse = null;

            SizeChanged += SchematicViewer_SizeChanged;

            Schematic = new SchematicControl(new Circuit.Schematic());
        }
        public SchematicViewer()
        {
            InitializeComponent();

            CommandBindings.Add(new CommandBinding(NavigationCommands.Zoom, (o, e) => Zoom *= 2));
            CommandBindings.Add(new CommandBinding(NavigationCommands.DecreaseZoom, (o, e) => Zoom *= 0.5));
            CommandBindings.Add(new CommandBinding(Commands.ZoomFit, (o, e) => FocusCenter()));

            scroll.PreviewMouseWheel += (o, e) =>
            {
                Zoom = LogFloor(Zoom * (e.Delta > 0 ? 2 : 0.5));
                e.Handled = true;
            };
            scroll.PreviewMouseMove += (o, e) => mouse = e.GetPosition(this);
            scroll.MouseLeave += (o, e) => mouse = null;

            SizeChanged += SchematicViewer_SizeChanged;

            Schematic = new SchematicControl(new Circuit.Schematic());
        }
        public void FocusCenter()
        {
            Point a, b;

            if (Schematic.Selected.Any())
            {
                a = Schematic.ToPoint(SchematicControl.LowerBound(Schematic.Selected));
                b = Schematic.ToPoint(SchematicControl.UpperBound(Schematic.Selected));
            }
            else if (Schematic.Elements.Any())
            {
                a = Schematic.ToPoint(Schematic.LowerBound() - 40);
                b = Schematic.ToPoint(Schematic.UpperBound() + 40);
            }
            else
            {
                a = Schematic.ToPoint(new Circuit.Coord(-100, -100));
                b = Schematic.ToPoint(new Circuit.Coord(100, 100));
            }
            FocusRect(a, b, true);
        }
 public FindRelevantTool(SchematicControl Target)
     : base(Target)
 {
 }
Exemple #5
0
 public SchematicTool(SchematicControl Target)
 {
     target = Target;
 }
 public SchematicTool(SchematicControl Target)
 {
     target = Target;
 }
 public FindRelevantTool(SchematicControl Target)
     : base(Target)
 {
 }