Example #1
0
        private static void OnPlotterChanged(object sender, PlotterChangedEventArgs e)
        {
            ViewportHostPanel owner = (ViewportHostPanel)sender;

            if (owner.plotter != null && e.PreviousPlotter != null)
            {
                owner.viewport.PropertyChanged -= owner.Viewport_PropertyChanged;
                owner.viewport = null;
                owner.plotter  = null;
            }
            if (owner.plotter == null && e.CurrentPlotter != null)
            {
                owner.plotter  = (Plotter2D)e.CurrentPlotter;
                owner.viewport = owner.plotter.Viewport;
                owner.viewport.PropertyChanged += owner.Viewport_PropertyChanged;
            }
        }
Example #2
0
        public void OnPlotterAttached(Plotter plotter)
        {
            if (Parent == null)
            {
                hostPanel = new ViewportHostPanel();
                Viewport2D.SetIsContentBoundsHost(hostPanel, false);
                hostPanel.Children.Add(this);

                plotter.Dispatcher.BeginInvoke(() =>
                {
                    plotter.Children.Add(hostPanel);
                }, DispatcherPriority.Send);
            }
#if !old
            Canvas hostCanvas = (Canvas)hostPanel.FindName(canvasName);
            if (hostCanvas == null)
            {
                hostCanvas = new Canvas {
                    ClipToBounds = true
                };
                Panel.SetZIndex(hostCanvas, 1);

                INameScope nameScope = NameScope.GetNameScope(hostPanel);
                if (nameScope == null)
                {
                    nameScope = new NameScope();
                    NameScope.SetNameScope(hostPanel, nameScope);
                }

                hostPanel.RegisterName(canvasName, hostCanvas);
                hostPanel.Children.Add(hostCanvas);
            }

            hostCanvas.Children.Add(this);
#else
#endif

            Plotter2D plotter2d = (Plotter2D)plotter;
            this.plotter = plotter2d;
            OnPositionChanged(new DependencyPropertyChangedEventArgs());
        }