Example #1
0
        private void AddIconFill(Brush color, int allNumber, PieCharItem item)
        {
            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Horizontal;
            stackPanel.Children.Add(new Ellipse()
            {
                Fill   = color,
                Width  = 15,
                Height = 15,
                Margin = new Thickness(10, 0, 5, 0),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            });
            stackPanel.Children.Add(new TextBox()
            {
                Text                       = $"{item.TypeName}({(Math.Round((double)item.TypeNumber / allNumber * 100, 1)).ToString("F1")}%)",
                FontSize                   = 15,
                IsReadOnly                 = true,
                BorderThickness            = new Thickness(0),
                HorizontalContentAlignment = HorizontalAlignment.Left,
                VerticalContentAlignment   = VerticalAlignment.Center,
            });
            // ListViewItem listViewItem = new ListViewItem(stackPanel);
            _legendGridView.Items.Add(stackPanel);
        }
Example #2
0
 /// <summary>
 /// 添加图例
 /// </summary>
 /// <param name="color"></param>
 /// <param name="constString"></param>
 private void AddIconFill(Brush color, int allNumber, PieCharItem item)
 {
     _legendGrid.Children.Add(new Ellipse()
     {
         Fill   = color,
         Width  = 15,
         Height = 15,
         Margin = new Thickness(10, 0, 0, 0),
         HorizontalAlignment = HorizontalAlignment.Center
     });
     _legendGrid.Children.Add(new TextBox()
     {
         Text                       = $"{item.TypeName}({(Math.Round((double)item.TypeNumber / allNumber * 100, 1)).ToString("F1")}%)",
         Foreground                 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF")),
         Width                      = 90,
         Height                     = 20,
         FontSize                   = 11,
         IsReadOnly                 = true,
         BorderThickness            = new Thickness(0),
         HorizontalContentAlignment = HorizontalAlignment.Left,
         VerticalContentAlignment   = VerticalAlignment.Center,
         Background                 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#333333")),
     });
 }