Beispiel #1
0
        internal void Refresh()
        {
            if (CurrentSize.Width == 0 || CurrentSize.Height == 0)
            {
                return;
            }

            _ax.Axis = _view.AxisX;
            _ay.Axis = _view.AxisY;
            List <string> list = new List <string>();

            foreach (Axis axis in _axes)
            {
                if ((axis.PositionInternal & AxisPosition.OverData) > AxisPosition.Near)
                {
                    Canvas.SetZIndex(axis, 1);
                }
                else
                {
                    Canvas.SetZIndex(axis, 0);
                }
                ((IAxis)axis).ClearLabels();
                axis.ResetLimits();
                axis.Chart = _view.Chart;
                if (((axis != _ax) && (axis != _ay)) && !string.IsNullOrEmpty(axis.AxisName))
                {
                    list.Add(axis.AxisName);
                }
            }

            if (_view.Renderer != null)
            {
                IView2DRenderer renderer = _view.Renderer as IView2DRenderer;
                if (renderer == null)
                {
                    return;
                }

                _ast = renderer.Axis;
                Size       sz        = new Size(CurrentSize.Width, CurrentSize.Height);
                Renderer2D rendererd = renderer as Renderer2D;
                if (rendererd != null)
                {
                    rendererd.ValidAuxAxes = list.ToArray();
                    if (_plot.Width > 0.0)
                    {
                        sz.Width = _plot.Width;
                    }
                    if (_plot.Height > 0.0)
                    {
                        sz.Height = _plot.Height;
                    }
                }

                Rect rect = renderer.Measure(sz);
                if (rect.Width > 0.0)
                {
                    _ax.SetLimits(rect.X, rect.X + rect.Width);
                }
                if (rect.Height > 0.0)
                {
                    _ay.SetLimits(rect.Y, rect.Y + rect.Height);
                }
            }

            switch (_ast)
            {
            case AxisStyle.None:
                if ((base.Width > 10.0) && (base.Height > 10.0))
                {
                    _plot = new Rect(5.0, 5.0, base.Width - 10.0, base.Height - 10.0);
                }
                using (List <Axis> .Enumerator enumerator3 = _axes.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        enumerator3.Current.Visibility = Utils.VisHidden;
                    }
                }
                break;

            case AxisStyle.Cartesian:
                UpdateLayoutCartesian();
                break;

            case AxisStyle.Radar:
                using (List <Axis> .Enumerator enumerator2 = _axes.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        enumerator2.Current.Visibility = Visibility.Collapsed;
                    }
                }
                UpdateLayoutRadar();
                break;
            }

            Shape plotShape = _view.PlotShape;

            if (plotShape != null)
            {
                Canvas.SetLeft(plotShape, _view.PlotRect.Left);
                Canvas.SetTop(plotShape, _view.PlotRect.Top);
                plotShape.Width  = _view.PlotRect.Width;
                plotShape.Height = _view.PlotRect.Height;
                if (_ast == AxisStyle.None)
                {
                    plotShape.Visibility = Visibility.Collapsed;
                }
                else
                {
                    plotShape.Visibility = Visibility.Visible;
                }
            }

            if (_view.Chart.UpdateCount <= 0 && _view.Renderer != null)
            {
                CreateDataObjects();
                _view.Renderer.Dirty = false;
            }
        }
Beispiel #2
0
        void CreateDataObjects()
        {
            if (_startDataIdx >= 0)
            {
                int num = InternalChildren.Count - _startDataIdx;
                for (int j = 0; j < num; j++)
                {
                    PlotElement sender = InternalChildren[_startDataIdx] as PlotElement;
                    InternalChildren.RemoveAt(_startDataIdx);
                    if (((sender != null) && (sender.DataPoint != null)) && (sender.DataPoint.Series != null))
                    {
                        sender.DataPoint.Series.FirePlotElementUnloaded(sender, EventArgs.Empty);
                    }
                }
            }

            Shape plotShape = _view.PlotShape;

            if ((plotShape != null) && !InternalChildren.Contains(plotShape))
            {
                InternalChildren.Insert(0, plotShape);
            }
            _startDataIdx = InternalChildren.Count;

            IView2DRenderer renderer = _view.Renderer as IView2DRenderer;

            if (renderer != null)
            {
                renderer.CoordConverter = this;
                UIElement[] elementArray = renderer.Generate();

                if (_view.Renderer is BaseRenderer br)
                {
                    br.FireRendered(this, EventArgs.Empty);
                }

                if (elementArray == null)
                {
                    while (Children.Count > 1)
                    {
                        Children.RemoveAt(Children.Count - 1);
                    }
                }
                else
                {
                    int length = elementArray.Length;
                    for (int k = 0; k < length; k++)
                    {
                        var elem = elementArray[k];
                        if (elem == null || InternalChildren.Contains(elem))
                        {
                            continue;
                        }

                        if (elem is FrameworkElement fe && fe.Parent is Panel pnl)
                        {
                            pnl.Children.Remove(elem);
                        }
                        InternalChildren.Add(elem);
                    }

                    while (Children.Count > 1)
                    {
                        Children.RemoveAt(Children.Count - 1);
                    }
                }
            }

            int num5 = _view.Layers.Count;

            for (int i = 0; i < num5; i++)
            {
                FrameworkElement element = _view.Layers[i] as FrameworkElement;
                if (element != null)
                {
                    Canvas.SetLeft(element, PlotRect.X);
                    Canvas.SetTop(element, PlotRect.Y);
                    element.Width  = PlotRect.Width;
                    element.Height = PlotRect.Height;
                    Children.Add(element);
                }
            }

            foreach (UIElement element5 in _view.Children)
            {
                if (!Children.Contains(element5))
                {
                    Children.Add(element5);
                }
            }
        }