コード例 #1
0
ファイル: GraphInfo.cs プロジェクト: becerda/JobDB
        /// <summary>
        /// Rotates Independant Axes Text
        /// </summary>
        /// <param name="angle">The Angle To Rotate The Text</param>
        private void RotateText(int angle)
        {
            ControlTemplate ct = new ControlTemplate(typeof(AxisLabel));
            var             tb = new FrameworkElementFactory(typeof(TextBlock));

            tb.SetValue(TextBlock.PaddingProperty, new Thickness(5, 5, 5, 5));
            tb.SetValue(TextBlock.TextProperty, new TemplateBindingExtension(AxisLabel.FormattedContentProperty));
            tb.SetValue(TextBlock.LayoutTransformProperty, new RotateTransform {
                Angle = angle
            });
            ct.VisualTree = tb;

            Style s = new Style(typeof(AxisLabel));

            s.Setters.Add(new Setter(AxisLabel.TemplateProperty, ct));
            CategoryAxis ca = new CategoryAxis {
                Orientation = AxisOrientation.X
            };

            ca.SetValue(CategoryAxis.AxisLabelStyleProperty, s);

            switch (Type)
            {
            case SeriesType.Area:
                Graph.SetValue(AreaSeries.IndependentAxisProperty, ca);
                break;

            case SeriesType.Bar:
                break;

            case SeriesType.Column:
                Graph.SetValue(ColumnSeries.IndependentAxisProperty, ca);
                break;

            case SeriesType.Line:
                Graph.SetValue(LineSeries.IndependentAxisProperty, ca);
                break;

            case SeriesType.Pie:
                break;

            case SeriesType.Scatter:
                Graph.SetValue(ScatterSeries.IndependentAxisProperty, ca);
                break;
            }
        }