Пример #1
0
        public static void BodyContentChangeHandler(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            LogGrid grid = s as LogGrid;

            grid.bodyContent.Content = e.NewValue as UIElement;
        }
Пример #2
0
        private UIElement GetLogControl(List <WorkReportLogEntity> logs, int rowIndex, int columnCount, int logCount,
                                        GridLength length)
        {
            int    margin         = 2;
            string groupName      = Guid.NewGuid().ToString();
            var    userLogControl = new LogGrid
            {
                Header = "LOG质量"
            };


            var gridLog = new Grid
            {
                ShowGridLines = false,

                Background = GetColor(5)
            };

            var logGroup = logs;

            if (logGroup.Count > 0)
            {
                for (int i1 = 0; i1 < columnCount + margin; i1++)
                {
                    if (i1 == 0)
                    {
                        gridLog.ColumnDefinitions.Add(new ColumnDefinition
                        {
                            Width = new GridLength(115),
                        });
                    }
                    else
                    {
                        gridLog.ColumnDefinitions.Add(new ColumnDefinition
                        {
                            Width = new GridLength(100),
                        });
                    }

                    Rectangle rec = CreateVertLine(i1, logGroup.Count + 1);

                    gridLog.Children.Add(rec);
                }

                for (int i1 = 0; i1 < logGroup.Count + 1; i1++)
                {
                    gridLog.RowDefinitions.Add(new RowDefinition
                    {
                        Height    = GridLength.Auto,
                        MinHeight = 40
                    });
                    Rectangle rectSub = CreateHorLine(i1, columnCount + margin);
                    if (i1 == logGroup.Count() && rowIndex != logCount * 2)
                    {
                        rectSub.Height = 2;
                        rectSub.Fill   = new SolidColorBrush(Colors.Black);
                        rectSub.Margin = new Thickness(0, 1, 0, -1);
                    }
                    gridLog.Children.Add(rectSub);
                }

                Rectangle rectlogo = CreateRectangler(2);
                rectlogo.Margin = new Thickness(1);
                Grid.SetColumn(rectlogo, 0);
                Grid.SetColumnSpan(rectlogo, 2);
                Grid.SetRow(rectlogo, 0);
                gridLog.Children.Add(rectlogo);

                var lableLogName = new Border
                {
                    Child = new TextBlock
                    {
                        Text                = "LOG名称",
                        FontSize            = 12,
                        FontWeight          = FontWeights.Bold,
                        VerticalAlignment   = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin              = new Thickness(20, 0, 0, 0)
                    },
                    Margin = new Thickness(1, 0, 1, 1)
                };
                lableLogName.SetValue(Canvas.ZIndexProperty, 10);
                Grid.SetColumn(lableLogName, 0);

                Grid.SetRow(lableLogName, 0);
                lableLogName.HorizontalAlignment = HorizontalAlignment.Stretch;
                lableLogName.VerticalAlignment   = VerticalAlignment.Stretch;
                gridLog.Children.Add(lableLogName);

                var lableLogQuality = new Border
                {
                    Child = new TextBlock
                    {
                        Text                = "Log质量",
                        FontSize            = 12,
                        FontWeight          = FontWeights.Bold,
                        VerticalAlignment   = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin              = new Thickness(20, 0, 0, 0)
                    },
                    Margin = new Thickness(1, 0, 1, 1)
                };
                lableLogName.SetValue(Canvas.ZIndexProperty, 10);
                Grid.SetColumn(lableLogQuality, 1);

                Grid.SetRow(lableLogQuality, 0);
                lableLogName.HorizontalAlignment = HorizontalAlignment.Stretch;
                lableLogName.VerticalAlignment   = VerticalAlignment.Stretch;
                gridLog.Children.Add(lableLogQuality);


                for (int m = 0; m < columnCount; m++)
                {
                    var kpi      = logs[0].Kpis[m];
                    var lableLog = new TextBlock
                    {
                        Text         = kpi.KpiName + (kpi.KpiName.Contains("FTP") ? "" : "(%)"),
                        FontSize     = 12,
                        FontWeight   = FontWeights.Bold,
                        MaxWidth     = 80,
                        TextWrapping = TextWrapping.Wrap
                    };
                    lableLog.SetValue(ToolTipService.ToolTipProperty,
                                      kpi.KpiName + (kpi.KpiName.Contains("FTP") ? "" : "(%)"));
                    Grid.SetColumn(lableLog, m + margin);
                    lableLog.VerticalAlignment   = VerticalAlignment.Center;
                    lableLog.HorizontalAlignment = HorizontalAlignment.Center;
                    Grid.SetRow(lableLog, 0);
                    lableLog.SetValue(Canvas.ZIndexProperty, 10);
                    gridLog.Children.Add(lableLog);
                }

                var countLog = 0;
                for (int i = 0; i < logGroup.Count(); i++)
                {
                    countLog++;
                    StackPanel stackPanelLog = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };

                    var rb = new RadioButton()
                    {
                        Tag = logGroup[i], VerticalAlignment = VerticalAlignment.Center, GroupName = groupName + logGroup[i].LogServertype
                    };
                    rb.SetBinding(RadioButton.IsCheckedProperty,
                                  new Binding()
                    {
                        Source = rb.Tag, Path = new PropertyPath("IsSelected"), Mode = BindingMode.TwoWay
                    });


                    stackPanelLog.Children.Add(rb);
                    var logtxt = new TextBlock
                    {
                        FontSize            = 12,
                        FontWeight          = FontWeights.Bold,
                        VerticalAlignment   = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(20, 0, 0, 0)
                    };
                    var run = new Run
                    {
                        Text = logGroup[i].LogName,
                    };
                    logtxt.Inlines.Add(run);
                    var br = new LineBreak();
                    logtxt.Inlines.Add(br);

                    var dataType = new Underline();

                    dataType.Inlines.Add(new Run
                    {
                        Text = logGroup[i].LogServertype + "(打点图)"
                    });
                    logtxt.Inlines.Add(dataType);
                    stackPanelLog.Children.Add(logtxt);
                    var lableNameLog1 = new Border
                    {
                        Child  = stackPanelLog,
                        Margin = new Thickness(1, 0, 1, 1),
                        Cursor = Cursors.Hand
                    };

                    lableNameLog1.MouseLeftButtonDown +=
                        (s, e) =>
                    {
                    };
                    lableNameLog1.SetValue(Canvas.ZIndexProperty, 10);
                    Grid.SetColumn(lableNameLog1, 0);

                    Grid.SetRow(lableNameLog1, countLog);
                    lableNameLog1.VerticalAlignment   = VerticalAlignment.Stretch;
                    lableNameLog1.HorizontalAlignment = HorizontalAlignment.Stretch;
                    gridLog.Children.Add(lableNameLog1);


                    Rectangle rectbg = CreateGridRowBackground(1, countLog);
                    gridLog.Children.Add(rectbg);

                    TextBlock logQuality = new TextBlock()
                    {
                        Foreground = GetColor(logGroup[i].Result),
                        FontFamily = new FontFamily("Microsoft YaHei"),
                        FontSize   = 14,
                        FontWeight = FontWeights.Bold,
                    };

                    logQuality.Text = GetResult(logGroup[i].Result);
                    Grid.SetColumn(logQuality, 1);
                    Grid.SetRow(logQuality, countLog);
                    logQuality.VerticalAlignment   = VerticalAlignment.Center;
                    logQuality.HorizontalAlignment = HorizontalAlignment.Center;
                    gridLog.Children.Add(logQuality);


                    if (logs[i].Kpis == null)
                    {
                        continue;
                    }
                    for (int m = 0; m < columnCount; m++)
                    {
                        var kpi = logs[i].Kpis[m];


                        Rectangle newrect = CreateRectangler(1);
                        newrect.Margin = new Thickness(1, 1, 1, 1);
                        Grid.SetColumn(newrect, m + margin);
                        Grid.SetRow(newrect, 0);
                        gridLog.Children.Add(newrect);

                        var borderlog = new TextBlock
                        {
                            Text =
                                kpi.KpiName.Contains("FTP")
                                    ? kpi.KpiValue.ToString()
                                    : (kpi.KpiValue.Value * 100).ToString("00.0"),
                            Foreground          = GetColor(logs[i].Result),
                            FontFamily          = new FontFamily("Microsoft YaHei"),
                            FontSize            = 12,
                            VerticalAlignment   = VerticalAlignment.Center,
                            HorizontalAlignment = HorizontalAlignment.Center
                        };

                        borderlog.SetValue(ToolTipService.ToolTipProperty,
                                           kpi.KpiRange);
                        borderlog.SetValue(Canvas.ZIndexProperty, 100);
                        Grid.SetColumn(borderlog, m + margin);
                        Grid.SetRow(borderlog, countLog);
                        gridLog.Children.Add(borderlog);
                    }
                }
            }
            userLogControl.Content = new Border()
            {
                Child = gridLog, BorderBrush = new SolidColorBrush(Colors.Black), BorderThickness = new Thickness(1)
            };;

            return(userLogControl);
        }
Пример #3
0
        public static void HeaderChangeHandler(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            LogGrid grid = s as LogGrid;

            grid.headerContent.Content = e.NewValue;
        }
        private UIElement GetLogControl(List<WorkReportLogEntity> logs, int rowIndex, int columnCount, int logCount,
            GridLength length)
        {
            int margin = 2;
            string groupName = Guid.NewGuid().ToString();
            var userLogControl = new LogGrid
            {
                Header = "LOG质量"
            };

            var gridLog = new Grid
            {
                ShowGridLines = false,

                Background = GetColor(5)
            };

            var logGroup = logs;
            if (logGroup.Count > 0)
            {
                for (int i1 = 0; i1 < columnCount + margin; i1++)
                {
                    if (i1==0)
                    {
                       gridLog.ColumnDefinitions.Add(new ColumnDefinition
                       {
                        Width =new GridLength(115),
                       });
                    }
                    else
                    {
                         gridLog.ColumnDefinitions.Add(new ColumnDefinition
                    {
                        Width =new GridLength(100),
                    });
                    }

                    Rectangle rec = CreateVertLine(i1, logGroup.Count + 1);

                    gridLog.Children.Add(rec);
                }

                for (int i1 = 0; i1 < logGroup.Count + 1; i1++)
                {
                    gridLog.RowDefinitions.Add(new RowDefinition
                    {
                        Height = GridLength.Auto,
                        MinHeight = 40
                    });
                    Rectangle rectSub = CreateHorLine(i1, columnCount + margin);
                    if (i1 == logGroup.Count() && rowIndex != logCount  * 2)
                    {
                        rectSub.Height = 2;
                        rectSub.Fill = new SolidColorBrush(Colors.Black);
                        rectSub.Margin = new Thickness(0, 1, 0, -1);
                    }
                    gridLog.Children.Add(rectSub);
                }

                Rectangle rectlogo = CreateRectangler(2);
                rectlogo.Margin = new Thickness(1);
                Grid.SetColumn(rectlogo, 0);
                Grid.SetColumnSpan(rectlogo,2);
                Grid.SetRow(rectlogo, 0);
                gridLog.Children.Add(rectlogo);

                var lableLogName = new Border
                {
                    Child = new TextBlock
                    {
                        Text = "LOG名称",
                        FontSize = 12,
                        FontWeight = FontWeights.Bold,
                        VerticalAlignment = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(20, 0, 0, 0)
                    },
                    Margin = new Thickness(1, 0, 1, 1)
                };
                lableLogName.SetValue(Canvas.ZIndexProperty, 10);
                Grid.SetColumn(lableLogName, 0);

                Grid.SetRow(lableLogName, 0);
                lableLogName.HorizontalAlignment = HorizontalAlignment.Stretch;
                lableLogName.VerticalAlignment = VerticalAlignment.Stretch;
                gridLog.Children.Add(lableLogName);

                var lableLogQuality = new Border
                {
                    Child = new TextBlock
                    {
                        Text = "Log质量",
                        FontSize = 12,
                        FontWeight = FontWeights.Bold,
                        VerticalAlignment = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(20, 0, 0, 0)
                    },
                    Margin = new Thickness(1, 0, 1, 1)
                };
                lableLogName.SetValue(Canvas.ZIndexProperty, 10);
                Grid.SetColumn(lableLogQuality, 1);

                Grid.SetRow(lableLogQuality, 0);
                lableLogName.HorizontalAlignment = HorizontalAlignment.Stretch;
                lableLogName.VerticalAlignment = VerticalAlignment.Stretch;
                gridLog.Children.Add(lableLogQuality);

                for (int m = 0; m < columnCount; m++)
                {
                    var kpi = logs[0].Kpis[m];
                    var lableLog = new TextBlock
                    {
                        Text = kpi.KpiName + (kpi.KpiName.Contains("FTP") ? "" : "(%)"),
                        FontSize = 12,
                        FontWeight = FontWeights.Bold,
                        MaxWidth = 80,
                        TextWrapping = TextWrapping.Wrap
                    };
                    lableLog.SetValue(ToolTipService.ToolTipProperty,
                        kpi.KpiName + (kpi.KpiName.Contains("FTP") ? "" : "(%)"));
                    Grid.SetColumn(lableLog, m + margin);
                    lableLog.VerticalAlignment = VerticalAlignment.Center;
                    lableLog.HorizontalAlignment = HorizontalAlignment.Center;
                    Grid.SetRow(lableLog, 0);
                    lableLog.SetValue(Canvas.ZIndexProperty, 10);
                    gridLog.Children.Add(lableLog);
                }

                var countLog = 0;
                for (int i = 0; i < logGroup.Count(); i++)
                {
                    countLog++;
                    StackPanel stackPanelLog = new StackPanel() {Orientation = Orientation.Horizontal};

                    var rb = new RadioButton() { Tag = logGroup[i], VerticalAlignment = VerticalAlignment.Center, GroupName = groupName+logGroup[i].LogServertype };
                    rb.SetBinding(RadioButton.IsCheckedProperty,
                        new Binding() { Source = rb.Tag, Path = new PropertyPath("IsSelected"), Mode = BindingMode.TwoWay });

                    stackPanelLog.Children.Add(rb);
                    var logtxt = new TextBlock
                    {
                        FontSize = 12,
                        FontWeight = FontWeights.Bold,
                        VerticalAlignment = VerticalAlignment.Center,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(20, 0, 0, 0)
                    };
                    var run = new Run
                    {
                        Text = logGroup[i].LogName,
                    };
                    logtxt.Inlines.Add(run);
                    var br = new LineBreak();
                    logtxt.Inlines.Add(br);

                    var dataType = new Underline();

                    dataType.Inlines.Add(new Run
                    {
                        Text = logGroup[i].LogServertype + "(打点图)"
                    });
                    logtxt.Inlines.Add(dataType);
                    stackPanelLog.Children.Add(logtxt);
                    var lableNameLog1 = new Border
                    {
                        Child = stackPanelLog,
                        Margin = new Thickness(1, 0, 1, 1),
                        Cursor = Cursors.Hand
                    };

                    lableNameLog1.MouseLeftButtonDown +=
                        (s, e) =>
                        {
                        };
                    lableNameLog1.SetValue(Canvas.ZIndexProperty, 10);
                    Grid.SetColumn(lableNameLog1, 0);

                    Grid.SetRow(lableNameLog1, countLog);
                    lableNameLog1.VerticalAlignment = VerticalAlignment.Stretch;
                    lableNameLog1.HorizontalAlignment = HorizontalAlignment.Stretch;
                    gridLog.Children.Add(lableNameLog1);

                    Rectangle rectbg = CreateGridRowBackground(1, countLog);
                    gridLog.Children.Add(rectbg);

                    TextBlock logQuality = new TextBlock()
                    {
                        Foreground = GetColor(logGroup[i].Result),
                        FontFamily = new FontFamily("Microsoft YaHei"),
                        FontSize = 14,
                        FontWeight = FontWeights.Bold,

                    };

                    logQuality.Text = GetResult(logGroup[i].Result);
                    Grid.SetColumn(logQuality, 1);
                    Grid.SetRow(logQuality, countLog);
                    logQuality.VerticalAlignment = VerticalAlignment.Center;
                    logQuality.HorizontalAlignment = HorizontalAlignment.Center;
                    gridLog.Children.Add(logQuality);

                    if (logs[i].Kpis==null)
                    {
                        continue;
                    }
                    for (int m = 0; m < columnCount; m++)
                    {

                        var kpi = logs[i].Kpis[m];

                        Rectangle newrect = CreateRectangler(1);
                        newrect.Margin = new Thickness(1, 1, 1, 1);
                        Grid.SetColumn(newrect, m + margin);
                        Grid.SetRow(newrect, 0);
                        gridLog.Children.Add(newrect);

                        var borderlog = new TextBlock
                        {
                            Text =
                                kpi.KpiName.Contains("FTP")
                                    ? kpi.KpiValue.ToString()
                                    : (kpi.KpiValue.Value * 100).ToString("00.0"),
                            Foreground =GetColor(logs[i].Result),
                            FontFamily = new FontFamily("Microsoft YaHei"),
                            FontSize = 12,
                            VerticalAlignment = VerticalAlignment.Center,
                            HorizontalAlignment = HorizontalAlignment.Center
                        };

                        borderlog.SetValue(ToolTipService.ToolTipProperty,
                            kpi.KpiRange);
                        borderlog.SetValue(Canvas.ZIndexProperty, 100);
                        Grid.SetColumn(borderlog, m + margin);
                        Grid.SetRow(borderlog, countLog);
                        gridLog.Children.Add(borderlog);
                    }
                }
            }
            userLogControl.Content = new Border() { Child = gridLog,BorderBrush = new SolidColorBrush(Colors.Black),BorderThickness = new Thickness(1)}; ;

            return userLogControl;
        }