Esempio n. 1
0
 private void OnLocationChanged()
 {
     EdgePanel.SetEdge((UIElement)this.GetAxisPanel(AxisPresenter.AxisPanelType.AxisAndTickMarks), this.ActualLocation);
     EdgePanel.SetEdge((UIElement)this.GetAxisPanel(AxisPresenter.AxisPanelType.Labels), this.ActualLocation);
     EdgePanel.SetEdge((UIElement)this.GetAxisPanel(AxisPresenter.AxisPanelType.Title), this.ActualLocation);
     EdgePanel.SetEdge((UIElement)this.GetAxisPanel(AxisPresenter.AxisPanelType.DisplayUnit), this.ActualLocation);
     this.OnPropertyChanged("ActualLocation");
 }
Esempio n. 2
0
 public override void OnApplyTemplate()
 {
     if (this.ChartAreaPanel != null)
     {
         this.ChartAreaPanel.ArrangeComplete -= new EventHandler(this.ChartArea_ArrangeComplete);
     }
     base.OnApplyTemplate();
     this.ChartAreaPanel = this.GetTemplateChild("ChartAreaCanvas") as EdgePanel;
     if (this.ChartAreaPanel != null)
     {
         this._chartAreaLayersProvider.ParentPanel = (Panel)this.ChartAreaPanel;
         this.ChartAreaPanel.ChartArea             = this;
         this.ChartAreaPanel.SetBinding(EdgePanel.CenterMarginProperty, (BindingBase) new Binding("PlotAreaMargin")
         {
             Source = (object)this
         });
         this.SetBinding(ChartArea.ActualPlotAreaMarginProperty, (BindingBase) new Binding("ActualCenterMargin")
         {
             Source = (object)this.ChartAreaPanel
         });
         this.PlotAreaPanel = (Grid)this._chartAreaLayersProvider.GetLayer((object)LayerType.PlotArea, 100, (Func <Panel>)(() => (Panel) new Grid()));
         this.PlotAreaPanel.SetBinding(FrameworkElement.StyleProperty, (BindingBase) new Binding("PlotAreaStyle")
         {
             Source = (object)this
         });
         this.PlotAreaPanel.Background = (Brush) new SolidColorBrush(Color.FromArgb((byte)1, byte.MaxValue, byte.MaxValue, byte.MaxValue));
         EdgePanel.SetEdge((UIElement)this.PlotAreaPanel, Edge.Center);
         this._plotAreaLayersProvider.ParentPanel = (Panel)this.PlotAreaPanel;
         this.InitializeWatermark();
         this.ChartAreaPanel.ArrangeComplete     += new EventHandler(this.ChartArea_ArrangeComplete);
         this.ChartAreaPanel.MouseWheel          += new MouseWheelEventHandler(this.ChartAreaPanel_MouseWheel);
         this.ChartAreaPanel.MouseLeftButtonDown += new MouseButtonEventHandler(this.ChartAreaPanel_MouseLeftButtonDown);
         this.ChartAreaPanel.MouseLeftButtonUp   += new MouseButtonEventHandler(this.ChartAreaPanel_MouseLeftButtonUp);
         this.ChartAreaPanel.MouseMove           += new MouseEventHandler(this.ChartAreaPanel_MouseMove);
         this.MouseClickHelper = new MouseClickHelper(new Action <object, MouseButtonEventArgs>(this.OnMouseSingleClick), new Action <object, MouseButtonEventArgs>(this.OnMouseDoubleClick), new TimeSpan?());
         this.MouseClickHelper.Attach((UIElement)this.ChartAreaPanel);
         Grid grid = this.GetTemplateChild("LayoutRoot") as Grid;
         if (grid != null)
         {
             this.SelectionPanel = new SelectionPanel(this);
             grid.Children.Add((UIElement)this.SelectionPanel);
         }
     }
     if (!this._isTemplateApplied)
     {
         this._isTemplateApplied = true;
     }
     this.UpdateSession.DisableUpdates = false;
     this.ResetView();
 }
Esempio n. 3
0
        private bool IsCenterMarginApplies(UIElement child)
        {
            switch (EdgePanel.GetEdge(child))
            {
            case Edge.Left:
            case Edge.Right:
                return(ValueHelper.Width(this.CenterMargin) > 0.0);

            case Edge.Bottom:
            case Edge.Top:
                return(ValueHelper.Height(this.CenterMargin) > 0.0);

            default:
                return(false);
            }
        }
Esempio n. 4
0
        private static void InvalidateParentArrange(DependencyObject d)
        {
            UIElement uiElement = d as UIElement;

            if (uiElement == null)
            {
                return;
            }
            EdgePanel edgePanel = VisualTreeHelper.GetParent((DependencyObject)uiElement) as EdgePanel;

            if (edgePanel == null)
            {
                return;
            }
            edgePanel.InvalidateArrange();
        }
Esempio n. 5
0
        private Size GetChildConstraintSize(UIElement child, Size availableSize, Thickness edgeMargins)
        {
            Size      size1     = availableSize;
            Size      size2     = new Size(Math.Max(0.0, availableSize.Width - ValueHelper.Width(edgeMargins)), Math.Max(0.0, availableSize.Height - ValueHelper.Height(edgeMargins)));
            Thickness thickness = new Thickness(double.PositiveInfinity);

            if (!double.IsPositiveInfinity(availableSize.Width))
            {
                thickness.Left = thickness.Right = availableSize.Width * this.GetMinimumRelativeCenterSpace();
            }
            if (!double.IsPositiveInfinity(availableSize.Height))
            {
                thickness.Top = thickness.Bottom = availableSize.Height * this.GetMinimumRelativeCenterSpace();
            }
            switch (EdgePanel.GetEdge(child))
            {
            case Edge.Left:
                size1 = new Size(thickness.Left, size2.Height);
                break;

            case Edge.Right:
                size1 = new Size(thickness.Right, size2.Height);
                break;

            case Edge.Bottom:
                size1 = new Size(size2.Width, thickness.Bottom);
                break;

            case Edge.Top:
                size1 = new Size(size2.Width, thickness.Top);
                break;

            case Edge.Center:
                size1 = size2;
                break;
            }
            return(size1);
        }
Esempio n. 6
0
 private static void OnEdgePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     EdgePanel.InvalidateParentArrange(d);
 }
Esempio n. 7
0
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            if (!this.IsDirty && !this._previousArrangeSize.IsEmpty && (arrangeSize != this._previousArrangeSize && this._arrangeWitnNoMeasureCount < 2))
            {
                ++this._arrangeWitnNoMeasureCount;
                this._autoMeasure         = true;
                this._previousArrangeSize = arrangeSize;
                this.InvalidateMeasure();
                return(arrangeSize);
            }
            this._measureWitnNoArrangeCount = 0;
            this._arrangeWitnNoMeasureCount = 0;
            this._previousArrangeSize       = arrangeSize;
            if (this.ChartArea.UpdateSession.IsUpdating)
            {
                this.Dispatcher.BeginInvoke((Delegate) new Action(((UIElement)this).InvalidateArrange));
                return(arrangeSize);
            }
            double    num1       = 0.0;
            double    num2       = 0.0;
            double    num3       = 0.0;
            double    num4       = 0.0;
            Thickness thickness  = this._centerMargins;
            Rect      finalRect1 = new Rect(thickness.Left, thickness.Top, Math.Max(0.0, arrangeSize.Width - (thickness.Left + thickness.Right)), Math.Max(0.0, arrangeSize.Height - (thickness.Top + thickness.Bottom)));

            foreach (UIElement element in Enumerable.OfType <UIElement>((IEnumerable)this.Children))
            {
                if (element != null && !(element is AnchorPanel))
                {
                    Size desiredSize = element.DesiredSize;
                    Rect finalRect2  = Rect.Empty;
                    switch (EdgePanel.GetEdge(element))
                    {
                    case Edge.Left:
                        num1      += desiredSize.Width;
                        finalRect2 = new Rect(finalRect1.X - num1, finalRect1.Y, desiredSize.Width, finalRect1.Height);
                        break;

                    case Edge.Right:
                        finalRect2 = new Rect(finalRect1.Right + num3, finalRect1.Y, desiredSize.Width, finalRect1.Height);
                        num3      += desiredSize.Width;
                        break;

                    case Edge.Bottom:
                        finalRect2 = new Rect(finalRect1.X, finalRect1.Bottom + num4, finalRect1.Width, desiredSize.Height);
                        num4      += desiredSize.Height;
                        break;

                    case Edge.Top:
                        num2      += desiredSize.Height;
                        finalRect2 = new Rect(finalRect1.X, finalRect1.Top - num2, finalRect1.Width, desiredSize.Height);
                        break;

                    case Edge.Center:
                        finalRect2 = finalRect1;
                        break;
                    }
                    element.Arrange(finalRect2);
                }
            }
            this.ActualCenterMargin = thickness;
            if (this.IsDirty)
            {
                this.IsDirty = false;
                this.OnArrangeComplete();
            }
            foreach (UIElement uiElement in Enumerable.OfType <UIElement>((IEnumerable)this.Children))
            {
                if (uiElement is AnchorPanel)
                {
                    uiElement.Arrange(finalRect1);
                }
            }
            return(arrangeSize);
        }
Esempio n. 8
0
        protected override Size MeasureOverride(Size constraint)
        {
            this.IsDirty = true;
            Size availableSize1 = constraint;

            if (double.IsNaN(this.Height) && availableSize1.Height == 0.0)
            {
                availableSize1.Height = double.PositiveInfinity;
            }
            if (double.IsNaN(this.Width) && availableSize1.Width == 0.0)
            {
                availableSize1.Width = double.PositiveInfinity;
            }
            ++this._measureWitnNoArrangeCount;
            if (this._measureWitnNoArrangeCount > 6)
            {
                return(this._lastMeasuredResult);
            }
            if (this._autoMeasure)
            {
                if (!this._previousArrangeSize.IsEmpty)
                {
                    availableSize1.Height = !double.IsInfinity(availableSize1.Height) ? Math.Max(availableSize1.Height, this._previousArrangeSize.Height) : this._previousArrangeSize.Height;
                    availableSize1.Width  = !double.IsInfinity(availableSize1.Width) ? Math.Max(availableSize1.Width, this._previousArrangeSize.Width) : this._previousArrangeSize.Width;
                }
                this._autoMeasure = false;
            }
            foreach (Series series in this.ChartArea.GetSeries())
            {
                series.SeriesPresenter.EnsureRootPanelsCreated();
            }
            IEnumerable <IGrouping <Edge, UIElement> > enumerable = Enumerable.Select <IGrouping <Edge, UIElement>, IGrouping <Edge, UIElement> >(Enumerable.GroupBy <UIElement, Edge>((IEnumerable <UIElement>)Enumerable.OrderBy <UIElement, Edge>(Enumerable.Where <UIElement>(Enumerable.OfType <UIElement>((IEnumerable)this.Children), (Func <UIElement, bool>)(child => child != null)), (Func <UIElement, Edge>)(child => EdgePanel.GetEdge(child))), (Func <UIElement, Edge>)(child => EdgePanel.GetEdge(child))), (Func <IGrouping <Edge, UIElement>, IGrouping <Edge, UIElement> >)(edgeGroups => edgeGroups));

            this._centerMargins = new Thickness(0.0);
            int       num1               = 0;
            Thickness edgeMargins        = new Thickness(availableSize1.Width, availableSize1.Height, availableSize1.Width, availableSize1.Height);
            bool      resetScrollingInfo = this._previousMeasureConstraint != constraint;
            int       num2               = Enumerable.Count <IRequireMarginOnEdges>(Enumerable.OfType <IRequireMarginOnEdges>((IEnumerable)this.Children));

            foreach (IRequireMarginOnEdges requireMarginOnEdges in Enumerable.OfType <IRequireMarginOnEdges>((IEnumerable)this.Children))
            {
                requireMarginOnEdges.ResetRequiredMargin(resetScrollingInfo);
            }
            this._previousMeasureConstraint = constraint;
            double width;
            double height;

            do
            {
                this.ChartArea.OnMeasureIterationStarts();
                Thickness margin1 = new Thickness(0.0);
                Size      size    = new Size(0.0, 0.0);
                Thickness margin2 = new Thickness(0.0);
                foreach (IEnumerable <UIElement> source in enumerable)
                {
                    foreach (UIElement uiElement in Enumerable.ToList <UIElement>((IEnumerable <UIElement>)Enumerable.OrderBy <UIElement, int>(source, (Func <UIElement, int>)(element => !(element is XYAxisBasePanel) ? 1 : 0))))
                    {
                        Size availableSize2 = num1 != 0 ? this.GetChildConstraintSize(uiElement, availableSize1, edgeMargins) : new Size(Math.Max(0.0, availableSize1.Width - ValueHelper.Width(margin1)), Math.Max(0.0, availableSize1.Height - ValueHelper.Height(margin1)));
                        IRequireMarginOnEdges requireMarginOnEdges1 = uiElement as IRequireMarginOnEdges;
                        if (requireMarginOnEdges1 != null && num1 > 0 && resetScrollingInfo)
                        {
                            requireMarginOnEdges1.ScheduleUpdate();
                        }
                        uiElement.Measure(availableSize2);
                        Size desiredSize = uiElement.DesiredSize;
                        if (EdgePanel.GetEdge(uiElement) != Edge.Center && !this.IsCenterMarginApplies(uiElement) && this.IsTakeSpace(uiElement))
                        {
                            IRequireMarginOnEdges requireMarginOnEdges2 = uiElement as IRequireMarginOnEdges;
                            if (requireMarginOnEdges2 != null)
                            {
                                margin2 = ValueHelper.Inflate(margin2, requireMarginOnEdges2.RequiredMargin);
                            }
                            switch (EdgePanel.GetEdge(uiElement))
                            {
                            case Edge.Left:
                                margin1.Left += desiredSize.Width;
                                size.Height   = Math.Max(size.Height, ValueHelper.Height(margin1) + desiredSize.Height);
                                continue;

                            case Edge.Right:
                                margin1.Right += desiredSize.Width;
                                size.Height    = Math.Max(size.Height, ValueHelper.Height(margin1) + desiredSize.Height);
                                continue;

                            case Edge.Bottom:
                                margin1.Bottom += desiredSize.Height;
                                size.Width      = Math.Max(size.Width, ValueHelper.Width(margin1) + desiredSize.Width);
                                continue;

                            case Edge.Top:
                                margin1.Top += desiredSize.Height;
                                size.Width   = Math.Max(size.Width, ValueHelper.Width(margin1) + desiredSize.Width);
                                continue;

                            default:
                                continue;
                            }
                        }
                    }
                }
                margin1             = this.ApplyCenterMargins(ValueHelper.Union(margin1, margin2));
                size.Width          = Math.Max(size.Width, ValueHelper.Width(margin1));
                size.Height         = Math.Max(size.Height, ValueHelper.Height(margin1));
                width               = size.Width;
                height              = size.Height;
                this._centerMargins = margin1;
                if (!(edgeMargins == this._centerMargins) && !this.IsCenterMarginSet() && num2 > 1)
                {
                    edgeMargins = this._centerMargins;
                }
                else
                {
                    break;
                }
            }while (++num1 <= 3);
            this._lastMeasuredResult = new Size(Math.Max(16.0, width), Math.Max(16.0, height));
            return(this._lastMeasuredResult);
        }