/// <summary> /// Add titles to ChartArea /// </summary> /// <param name="chart">Chart</param> /// <param name="DockInsidePlotArea">DockInsidePlotArea</param> /// <param name="height">Height avilable for title</param> /// <param name="width">Width available for title</param> /// <param name="isHLeftOrRightVCenterTitlesExists">Whether horizontal or vertical titles exists</param> private void AddTitles(Chart chart, Boolean DockInsidePlotArea, Double height, Double width, out Boolean isHLeftOrRightVCenterTitlesExists) { IList<Title> titles; StackPanel topTitlePanel = null; StackPanel bottomTitlePanel = null; StackPanel leftTitlePanel = null; StackPanel rightTitlePanel = null; StackPanel centerPanel = null; isHLeftOrRightVCenterTitlesExists = false; if (DockInsidePlotArea) { // Get the Titles docked outside PlotArea titles = chart.GetTitlesDockedInsidePlotArea(); topTitlePanel = chart._topInnerTitlePanel; bottomTitlePanel = chart._bottomInnerTitlePanel; leftTitlePanel = chart._leftInnerTitlePanel; rightTitlePanel = chart._rightInnerTitlePanel; centerPanel = chart._centerDockInsidePlotAreaPanel; } else { // Get the Titles docked outside PlotArea titles = chart.GetTitlesDockedOutSidePlotArea(); topTitlePanel = chart._topOuterTitlePanel; bottomTitlePanel = chart._bottomOuterTitlePanel; leftTitlePanel = chart._leftOuterTitlePanel; rightTitlePanel = chart._rightOuterTitlePanel; centerPanel = chart._centerDockOutsidePlotAreaPanel; } if (titles.Count == 0) return; // Get Titles on the top of the ChartArea using LINQ var titlesOnTop = from title in titles where (title.InternalVerticalAlignment == VerticalAlignment.Top && title.Enabled == true) select title; // Add Title on the top of the ChartArea foreach (Title title in titlesOnTop) this.AddTitle(chart, title, topTitlePanel, width, height); // Get Titles on the bottom of the ChartArea using LINQ var titlesOnBottom = from title in titles where (title.InternalVerticalAlignment == VerticalAlignment.Bottom && title.Enabled == true) select title; titlesOnBottom.Reverse(); // Add Title on the bottom of the ChartArea foreach (Title title in titlesOnBottom) this.AddTitle(chart, title, bottomTitlePanel, width, height); // Get Titles on the left of the ChartArea using LINQ var titlesAtLeft = from title in titles where ((title.InternalVerticalAlignment == VerticalAlignment.Center || title.InternalVerticalAlignment == VerticalAlignment.Stretch) && title.InternalHorizontalAlignment == HorizontalAlignment.Left && title.Enabled == true) select title; if (titlesAtLeft.Count() > 0) isHLeftOrRightVCenterTitlesExists = true; // Add Title on left of the ChartArea foreach (Title title in titlesAtLeft) this.AddTitle(chart, title, leftTitlePanel, width, height); // Get Titles on the right of the ChartArea using LINQ var titlesAtRight = from title in titles where ((title.InternalVerticalAlignment == VerticalAlignment.Center || title.InternalVerticalAlignment == VerticalAlignment.Stretch) && title.InternalHorizontalAlignment == HorizontalAlignment.Right && title.Enabled == true) select title; if (titlesAtRight.Count() > 0) isHLeftOrRightVCenterTitlesExists = true; titlesAtRight.Reverse(); // Add Title on the right of the ChartArea foreach (Title title in titlesAtRight) this.AddTitle(chart, title, rightTitlePanel, width, height); // Get Titles on the right of the ChartArea using LINQ var titlesOnCenter = from title in titles where ((title.InternalHorizontalAlignment == HorizontalAlignment.Center || title.InternalHorizontalAlignment == HorizontalAlignment.Stretch) && (title.InternalVerticalAlignment == VerticalAlignment.Center || title.InternalVerticalAlignment == VerticalAlignment.Stretch) && title.Enabled == true) select title; // Add Title on the right of the ChartArea centerPanel.Children.Clear(); foreach (Title title in titlesOnCenter) this.AddTitle(chart, title, centerPanel, width, height); }