/// <summary>
        /// Updates the gridlines.
        /// </summary>
        /// <param name="axis">The Relevant Axis</param>
        /// <param name="linesRecycler">The Line Recycler</param>
        /// <param name="requiredLinescount">The Required Lines Count</param>
        /// <param name="isMajor">Check For Marjor Axis</param>
        /// <param name="checkOrginFlag">Check For Origin Flag</param>
        private static void UpdateGridlines(ChartAxis axis, UIElementsRecycler <Line> linesRecycler, int requiredLinescount, bool isMajor, bool checkOrginFlag)
        {
            if (linesRecycler == null || axis == null)
            {
                return;
            }

            foreach (var line in linesRecycler)
            {
                line.ClearValue(FrameworkElement.StyleProperty);
            }

            int totalLinesCount = requiredLinescount;

            if (axis.ShowOrigin && checkOrginFlag)
            {
                totalLinesCount += 1;
            }

            if (!linesRecycler.BindingProvider.Keys.Contains(FrameworkElement.StyleProperty))
            {
                linesRecycler.BindingProvider.Add(FrameworkElement.StyleProperty, GetGridLineBinding(axis, isMajor));
            }

            if (linesRecycler.Count > 0)
            {
                foreach (var line in linesRecycler)
                {
                    line.SetBinding(FrameworkElement.StyleProperty, GetGridLineBinding(axis, isMajor));
                }
            }

            linesRecycler.GenerateElements(totalLinesCount);
            var rangeStyles = axis.RangeStyles;

            if (rangeStyles != null && rangeStyles.Count > 0)
            {
                var values = !isMajor ? axis.SmallTickPoints :
                             (from label in axis.VisibleLabels select label.Position).ToList();

                for (int i = 0; i < values.Count; i++)
                {
                    foreach (var chartAxisRangeStyle in rangeStyles)
                    {
                        var range = chartAxisRangeStyle.Range;
                        var style = isMajor ? chartAxisRangeStyle.MajorGridLineStyle : chartAxisRangeStyle.MinorGridLineStyle;
                        if (range.Start <= values[i] && range.End >= values[i] && style != null)
                        {
                            linesRecycler[i].SetBinding(FrameworkElement.StyleProperty, GetGridLineBinding(chartAxisRangeStyle, isMajor));
                            break;
                        }
                    }
                }
            }

            //StrokeDashArray applied only for the first line element when it is applied through style.
            //It is bug in the framework.
            //And hence manually setting stroke dash array for each and every grid line.
            ChartExtensionUtils.SetStrokeDashArray(linesRecycler);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the tick lines.
        /// </summary>
        private void UpdateTickLines()
        {
            int linesCount = this.Axis.VisibleLabels.Count;

            if (!lineRecycler.BindingProvider.Keys.Contains(Line.StyleProperty))
            {
                Binding binding = new Binding();
                binding.Source = Axis;
                binding.Path   = new PropertyPath("MajorTickLineStyle");
                lineRecycler.BindingProvider.Add(Line.StyleProperty, binding);
            }

            lineRecycler.GenerateElements(linesCount);
        }
        /// <summary>
        /// Updates the tick lines.
        /// </summary>
        /// <param name="linescount">The Tick Lines Count</param>
        /// <param name="lineRecycler">The Tick Lines Recycler</param>
        /// <param name="lineStylePath">The Tick Lines Style</param>
        private void UpdateTicks(int linescount, UIElementsRecycler <Line> lineRecycler, String lineStylePath)
        {
            int linesCount = linescount;

            foreach (var line in lineRecycler)
            {
                line.ClearValue(FrameworkElement.StyleProperty);
            }

            if (!lineRecycler.BindingProvider.Keys.Contains(Line.StyleProperty))
            {
                lineRecycler.BindingProvider.Add(Line.StyleProperty, GetTickLineBinding(Axis, lineStylePath));
                lineRecycler.BindingProvider.Add(Line.VisibilityProperty, GetTickLineBinding(Axis, "Visibility"));
            }

            if (lineRecycler.Count > 0)
            {
                foreach (var line in lineRecycler)
                {
                    line.SetBinding(FrameworkElement.StyleProperty, GetTickLineBinding(Axis, lineStylePath));
                    line.SetBinding(Line.VisibilityProperty, GetTickLineBinding(Axis, "Visibility"));
                }
            }

            lineRecycler.GenerateElements(linesCount);
            var rangeStyles = axis.RangeStyles;

            if (rangeStyles != null && rangeStyles.Count > 0)
            {
                var values = !lineStylePath.Equals("MajorTickLineStyle") ? axis.SmallTickPoints :
                             (from label in axis.VisibleLabels select label.Position).ToList();

                for (int i = 0; i < values.Count; i++)
                {
                    foreach (var chartAxisRangeStyle in rangeStyles)
                    {
                        var range = chartAxisRangeStyle.Range;
                        var style = lineStylePath.Equals("MajorTickLineStyle") ? chartAxisRangeStyle.MajorTickLineStyle : chartAxisRangeStyle.MinorTickLineStyle;
                        if (range.Start <= values[i] && range.End >= values[i] && style != null)
                        {
                            lineRecycler[i].SetBinding(FrameworkElement.StyleProperty, GetTickLineBinding(chartAxisRangeStyle, lineStylePath));
                            lineRecycler[i].SetBinding(Line.VisibilityProperty, GetTickLineBinding(axis, "Visibility"));
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Generates the children of <see cref="MultiLevelLabelsPanel"/>
        /// </summary>
        /// <param name="labelsCount">The Labels Count</param>
        private void GenerateContainer(int labelsCount)
        {
            Binding binding = new Binding();

            binding.Source = Axis;
            binding.Path   = new PropertyPath("Visibility");
            if (!textBlockRecycler.BindingProvider.Keys.Contains(UIElement.VisibilityProperty))
            {
                textBlockRecycler.BindingProvider.Add(UIElement.VisibilityProperty, binding);
            }
            textBlockRecycler.GenerateElements(labelsCount);
            if (Axis.MultiLevelLabelsBorderType != BorderType.Brace)
            {
                if (polylineRecycler != null && polylineRecycler.Count > 0)
                {
                    polylineRecycler.Clear();
                }
                if (!borderRecycler.BindingProvider.Keys.Contains(UIElement.VisibilityProperty))
                {
                    borderRecycler.BindingProvider.Add(UIElement.VisibilityProperty, binding);
                }
                borderRecycler.GenerateElements(labelsCount);
            }
            else
            {
                if (borderRecycler != null && borderRecycler.Count > 0)
                {
                    borderRecycler.Clear();
                }
                if (!polylineRecycler.BindingProvider.Keys.Contains(UIElement.VisibilityProperty))
                {
                    polylineRecycler.BindingProvider.Add(UIElement.VisibilityProperty, binding);
                }
                polylineRecycler.GenerateElements(2 * labelsCount);
            }

            SetLabelProperty();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates the labels.
        /// </summary>
        private void UpdateLabels()
        {
            int pos = 0;

            ObservableCollection <ChartAxisLabel> visibleLabels = this.Axis.VisibleLabels;

            contentControlRecycler.GenerateElements(visibleLabels.Count);
            var prefixLabeltemplate  = this.Axis.PrefixLabelTemplate;
            var postfixLabelTemplate = this.Axis.PostfixLabelTemplate;

            foreach (var item in visibleLabels)
            {
                if (this.Axis is NumericalAxis && pos == Axis.VisibleLabels.Count - 1)
                {
                    return;
                }

                ContentControl control = contentControlRecycler[pos];
                control.Tag = visibleLabels[pos];

                if (this.Axis.LabelTemplate == null)
                {
                    control.ContentTemplate = ChartDictionaries.GenericCommonDictionary["AxisLabelsCustomTemplate"] as DataTemplate;
                    control.ApplyTemplate();
                    item.PrefixLabelTemplate  = prefixLabeltemplate;
                    item.PostfixLabelTemplate = postfixLabelTemplate;
                    if (Axis.LabelStyle != null)
                    {
                        if (Axis.LabelStyle.Foreground != null)
                        {
                            var foregroundBinding = new Binding {
                                Source = Axis.LabelStyle, Path = new PropertyPath("Foreground")
                            };
                            control.SetBinding(Control.ForegroundProperty, foregroundBinding);
                        }
                        if (Axis.LabelStyle.FontSize > 0.0)
                        {
                            var fontSizeBinding = new Binding {
                                Source = Axis.LabelStyle, Path = new PropertyPath("FontSize")
                            };
                            control.SetBinding(Control.FontSizeProperty, fontSizeBinding);
                        }
                        if (Axis.LabelStyle.FontFamily != null)
                        {
                            var fontFamilyBinding = new Binding {
                                Source = Axis.LabelStyle, Path = new PropertyPath("FontFamily")
                            };
                            control.SetBinding(Control.FontFamilyProperty, fontFamilyBinding);
                        }
                    }
                    control.Content = item;
                }
                else
                {
                    control.ContentTemplate = this.Axis.LabelTemplate;
                    control.ApplyTemplate();
                    control.Content = item;
                }

                pos++;
            }
        }