Exemplo n.º 1
0
        protected static void OnUseDirect2DChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            PlotPanel plotPanelLocal = ((PlotPanel)obj);

            if (plotPanelLocal.direct2DControl == null && plotPanelLocal.UseDirect2D)
            {
                // Create Direct2DControl:
                try
                {
                    plotPanelLocal.direct2DControl = new Direct2DControl();
                    plotPanelLocal.Children.Add(plotPanelLocal.direct2DControl);
                    plotPanelLocal.direct2DControl.SetValue(Grid.ZIndexProperty, 75);
                }
                catch (Exception)
                {
                    plotPanelLocal.direct2DControl = null;
                    plotPanelLocal.UseDirect2D     = false;
                }
                return;
            }
            if (plotPanelLocal.UseDirect2D)
            {
                plotPanelLocal.Children.Add(plotPanelLocal.direct2DControl);
            }
            else
            {
                plotPanelLocal.Children.Remove(plotPanelLocal.direct2DControl);
            }
            plotPanelLocal.InvalidateMeasure();
        }
Exemplo n.º 2
0
 protected override void OnHostChanged(PlotPanel host)
 {
     base.OnHostChanged(host);
     if (this.host != null)
     {
         try
         {
             host.Canvas.Children.Remove(Rectangle);
             if (colourBar != null)
             {
                 host.Annotations.Remove(colourBar);
             }
         }
         catch (Exception)
         {
             // Just swallow any exception
         }
     }
     this.host = host;
     if (colourBar != null)
     {
         host.Annotations.Add(colourBar);
         colourBar.ColourMapChanged += new RoutedEventHandler(OnColourMapChanged);
     }
     colourMapUpdateTimer.Tick += OnColourMapUpdateTimerElapsed;
     host.Canvas.Children.Add(Rectangle);
 }
Exemplo n.º 3
0
 protected override void OnHostChanged(PlotPanel host)
 {
     base.OnHostChanged(host);
     if (this.host != null)
     {
         try
         {
             RemoveElements((bool)GetValue(UseDirect2DProperty));
             this.host = host;
             BindingOperations.ClearBinding(this, Plot2DCurve.UseDirect2DProperty);
         }
         catch (Exception)
         {
             // Just swallow any exception
         }
     }
     else
     {
         this.host = host;
     }
     if (this.host != null)
     {
         AddElements();
         curve.Transform(xAxis.GraphTransform, yAxis.GraphTransform);
         // Add binding:
         bindingDirect2D = new Binding("UseDirect2D")
         {
             Source = host, Mode = BindingMode.OneWay
         };
         BindingOperations.SetBinding(this, Plot2DCurve.UseDirect2DProperty, bindingDirect2D);
     }
     SetBounds();
 }
Exemplo n.º 4
0
        protected static void OnEqualAxesChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            PlotPanel plotPanelLocal = ((PlotPanel)obj);

            if ((bool)e.NewValue == true)
            {
                plotPanelLocal.Axes.SetAxesEqual();
            }
            else
            {
                plotPanelLocal.Axes.ResetAxesEqual();
            }
            plotPanelLocal.InvalidateMeasure();
        }
Exemplo n.º 5
0
        protected virtual void OnHostChanged(PlotPanel host)
        {
            if (host == null)
            {
                xAxis = null; yAxis = null;
                return;
            }
            // Update axis to default if null or it it does not belong to the new plot.
            if ((xAxis == null) || (!host.Axes.XAxes.Contains(xAxis)))
            {
                xAxis = host.Axes.XAxes.Bottom;
            }

            if ((yAxis == null) || (!host.Axes.YAxes.Contains(yAxis)))
            {
                yAxis = host.Axes.YAxes.Left;
            }
        }
Exemplo n.º 6
0
 public void FindPlotPanelsAndAlignedAxes()
 {
     plotPanelList.Clear();
     alignedAxesList.Clear();
     foreach (UIElement element in Children)
     {
         if (element is Plot2D)
         {
             PlotPanel plotPanel = (element as Plot2D).PlotPanel;
             plotPanelList.Add(plotPanel);
             int column     = (int)element.GetValue(ColumnProperty);
             int columnSpan = (int)element.GetValue(ColumnSpanProperty);
             int row        = (int)element.GetValue(RowProperty);
             int rowSpan    = (int)element.GetValue(RowSpanProperty);
             GetAlignedAxes(AlignmentDirection.Row, row, rowSpan).Axes.AddRange(plotPanel.Axes.YAxes);
             GetAlignedAxes(AlignmentDirection.Column, column, columnSpan).Axes.AddRange(plotPanel.Axes.XAxes);
         }
     }
 }
Exemplo n.º 7
0
 protected override void OnHostChanged(PlotPanel host)
 {
     base.OnHostChanged(host);
     if (this.host != null)
     {
         try
         {
             host.Canvas.Children.Remove(Rectangle);
             if (colourBar != null) host.Annotations.Remove(colourBar);
         }
         catch (Exception) 
         { 
             // Just swallow any exception 
         }
     }
     this.host = host;
     if (colourBar != null)
     {
         host.Annotations.Add(colourBar);
         colourBar.ColourMapChanged += new RoutedEventHandler(OnColourMapChanged);
     }
     colourMapUpdateTimer.Tick += OnColourMapUpdateTimerElapsed;
     host.Canvas.Children.Add(Rectangle);
 }
Exemplo n.º 8
0
        public Axes2D(PlotPanel plotPanel)
        {
            this.plotPanel = plotPanel;
            frame          = new AxesFrame();
            frame.SetValue(Grid.ZIndexProperty, 300);
            // note that individual axes have index of 200
            plotPanel.Children.Add(frame);

            xAxisBottom = new XAxis();
            xAxisBottom.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Bottom);
            xAxisTop = new XAxis();
            xAxisTop.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Top);
            //
            xAxes = new XAxis2DCollection(plotPanel);
            xAxes.Add(xAxisBottom); xAxes.Add(xAxisTop);
            xAxis = xAxisBottom;
            xAxisTop.LabelsVisible        = false;
            xAxisTop.TicksVisible         = true;
            xAxisTop.GridLines.Visibility = Visibility.Collapsed;
            xAxisTop.BindToAxis(xAxisBottom);
            //
            yAxisLeft = new YAxis();
            yAxisLeft.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Left);
            yAxisRight = new YAxis();
            yAxisRight.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Right);
            //
            yAxes = new YAxis2DCollection(plotPanel);
            yAxes.Add(yAxisLeft); yAxes.Add(yAxisRight);
            yAxis = yAxisLeft;
            yAxisRight.LabelsVisible        = false;
            yAxisRight.TicksVisible         = true;
            yAxisRight.GridLines.Visibility = Visibility.Collapsed;
            yAxisRight.BindToAxis(yAxisLeft);
            //
            UpdateTicks();
        }
Exemplo n.º 9
0
 protected override void OnHostChanged(PlotPanel host)
 {
     base.OnHostChanged(host);
     if (this.host != null)
     {
         try
         {
             RemoveElements((bool)GetValue(UseDirect2DProperty));
             this.host = host;
             BindingOperations.ClearBinding(this, Plot2DCurve.UseDirect2DProperty);
         }
         catch (Exception) 
         { 
             // Just swallow any exception 
         }
     }
     else this.host = host;
     if (this.host != null)
     {
         AddElements();
         curve.Transform(xAxis.GraphTransform, yAxis.GraphTransform);
         // Add binding:
         bindingDirect2D = new Binding("UseDirect2D") { Source = host, Mode = BindingMode.OneWay };
         BindingOperations.SetBinding(this, Plot2DCurve.UseDirect2DProperty, bindingDirect2D);
     }
     SetBounds();
 }
Exemplo n.º 10
0
        public Axes2D(PlotPanel plotPanel)
        {
            this.plotPanel = plotPanel;
            frame = new AxesFrame();
            frame.SetValue(Grid.ZIndexProperty, 300);
            // note that individual axes have index of 200
            plotPanel.Children.Add(frame);

            xAxisBottom = new XAxis();
            xAxisBottom.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Bottom);
            //
            xAxes = new XAxis2DCollection(plotPanel);
            xAxes.Add(xAxisBottom); 
            //
            yAxisLeft = new YAxis();
            yAxisLeft.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Left);
            //
            yAxes = new YAxis2DCollection(plotPanel);
            yAxes.Add(yAxisLeft); 
            //
            UpdateTicks();        
        }
Exemplo n.º 11
0
        protected virtual void OnHostChanged(PlotPanel host)
        {
            if (host == null)
            {
                xAxis = null; yAxis = null;
                return;
            }
            // Update axis to default if null or it it does not belong to the new plot.
            if ((xAxis == null) || (!host.Axes.XAxes.Contains(xAxis)))
            {
                xAxis = host.Axes.XAxes.Bottom;
            }

            if ((yAxis == null) || (!host.Axes.YAxes.Contains(yAxis)))
            {
                yAxis = host.Axes.YAxes.Left;
            }
        }
Exemplo n.º 12
0
 public Axis2DCollection(PlotPanel panel)
     : base()
 {
     this.panel = panel;
 }
Exemplo n.º 13
0
 public YAxis2DCollection(PlotPanel panel)
     : base(panel)
 {
 }
Exemplo n.º 14
0
        public Axes2D(PlotPanel plotPanel)
        {
            this.plotPanel = plotPanel;
            frame = new AxesFrame();
            frame.SetValue(Grid.ZIndexProperty, 300);
            // note that individual axes have index of 200
            plotPanel.Children.Add(frame);

            xAxisBottom = new XAxis();
            xAxisBottom.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Bottom);
            xAxisTop = new XAxis();
            xAxisTop.SetValue(XAxis.XAxisPositionProperty, XAxisPosition.Top);
            //
            xAxes = new XAxis2DCollection(plotPanel);
            xAxes.Add(xAxisBottom); xAxes.Add(xAxisTop);
            xAxis = xAxisBottom;
            xAxisTop.LabelsVisible = false;
            xAxisTop.TicksVisible = true;
            xAxisTop.GridLines.Visibility = Visibility.Collapsed;
            xAxisTop.BindToAxis(xAxisBottom);
            //
            yAxisLeft = new YAxis();
            yAxisLeft.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Left);
            yAxisRight = new YAxis();
            yAxisRight.SetValue(YAxis.YAxisPositionProperty, YAxisPosition.Right);
            //
            yAxes = new YAxis2DCollection(plotPanel);
            yAxes.Add(yAxisLeft); yAxes.Add(yAxisRight);
            yAxis = yAxisLeft;
            yAxisRight.LabelsVisible = false;
            yAxisRight.TicksVisible = true;
            yAxisRight.GridLines.Visibility = Visibility.Collapsed;
            yAxisRight.BindToAxis(yAxisLeft);
            //
            UpdateTicks();        
        }