private void CopyDataIntoBuffer(object sender, RoutedEventArgs e) { string[] values = FilteredData.Select(info => info.ToString(ExportSettings.ExportCountry, ExportSettings.ExportProxyType)) .ToArray(); Clipboard.SetDataObject(string.Join(Environment.NewLine, values)); }
protected override void OnRender(DrawingContext drawingContext) { visualContext = new HorizontalBarChartVisualContext(); PART_bars.Rows = FilteredData.Count; PART_yaxis.Rows = FilteredData.Count; PART_bars.Children.Clear(); PART_yaxis.Children.Clear(); if (FilteredData.Count < 1) { base.OnRender(drawingContext); return; } var effeectiveTargetRenderingMax = CommonFixedRangeMax > 0 ? CommonFixedRangeMax : FilteredData.MaxValue(); var context = new ProviderContext(FilteredData.Count); MaterialProvider.Reset(context); double YAxisRenderingWidth; if (CommonYAxisWidth <= 0) { var maxYAxisTextLength = FilteredData.Select(d => RenderingExtensions.EstimateLabelRenderSize( YAxisFontFamily, YAxisFontSize, d.CategoryName)) .Select(renderSize => renderSize.Width).Concat(new[] { 0.0 }).Max(); YAxisRenderingWidth = maxYAxisTextLength; } else { YAxisRenderingWidth = CommonYAxisWidth; } PART_yaxis.Width = YAxisRenderingWidth; var maxValueTextLength = FilteredData.Select(d => RenderingExtensions.EstimateLabelRenderSize( BarTotalFontFamily, BarTotalFontSize, new Thickness(10, 5, 10, 5), d.Value.ToString(CultureInfo.InvariantCulture))) .Select(renderSize => renderSize.Width).Concat(new[] { 0.0 }).Max(); var totalAvailableVerticalSpace = 0.0; if (CommonFixedRowHeight > 0) { totalAvailableVerticalSpace = CommonFixedRowHeight; } else { totalAvailableVerticalSpace = PART_bars.ActualHeight / FilteredData.Count; } var totalAvailableHorizontalExpanse = PART_bars.ActualWidth; var totalAvailableHorizontalSpace = totalAvailableHorizontalExpanse - maxValueTextLength; var actualBarHeight = totalAvailableVerticalSpace * SegmentWidthPercentage; foreach (var d in FilteredData) { var barContext = new HorizontalBarChartSegmentVisualContext(); var barWidth = d.Value.Map(0, effeectiveTargetRenderingMax, 0, totalAvailableHorizontalSpace); var materialSet = MaterialProvider.ProvideNext(context); var barGrid = new Grid(); var bar = new Rectangle { Fill = SegmentForeground.GetMaterial(materialSet), Height = actualBarHeight, Width = barWidth, HorizontalAlignment = HorizontalAlignment.Left }; barGrid.Children.Add(bar); barContext.ActiveBar = bar; var barSpaceBackground = new Rectangle { Fill = SegmentSpaceBackground.GetMaterial(materialSet), Height = actualBarHeight, Width = totalAvailableHorizontalExpanse, HorizontalAlignment = HorizontalAlignment.Left }; barGrid.Children.Add(barSpaceBackground); barContext.InactiveBar = barSpaceBackground; var barLabel = new Label { Content = d.Value, IsHitTestVisible = false, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, //VerticalAlignment = VerticalAlignment.Center , Width = maxValueTextLength, Padding = new Thickness(10, 5, 10, 5), Foreground = BarTotalForeground.GetMaterial(materialSet), Margin = new Thickness(barWidth, 0, 0, 0), }; barLabel.BindTextualPrimitive <BarTotalPrimitive>(this); barGrid.Children.Add(barLabel); barContext.BarLabel = barLabel; PART_bars.Children.Add(barGrid); var yaxisLabel = new Label { Content = TextRenderingStrategy.ProvideText(d.CategoryName, YAxisRenderingWidth, YAxisFontFamily, YAxisFontSize, YAxisPadding), IsHitTestVisible = false, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center, ToolTip = d.CategoryName, //HorizontalAlignment = HorizontalAlignment.Left, //VerticalAlignment = VerticalAlignment.Center, Width = YAxisRenderingWidth, Foreground = YAxisForeground.GetMaterial(materialSet), Margin = new Thickness(0, 0, 0, 0), Padding = YAxisPadding }; yaxisLabel.BindTextualPrimitive <YAxisPrimitive>(this); PART_yaxis.Children.Add(yaxisLabel); visualContext.BarVisuals.Add(barContext); } base.OnRender(drawingContext); }