Пример #1
0
        /// <summary>
        /// Adds anova statistics to the gadget
        /// </summary>
        /// <param name="strataValue">The strata value associated with the results</param>
        /// <param name="stats">The descriptive statistics to process</param>
        private void AddAnova(string strataValue, DescriptiveStatistics stats)
        {
            if (stats.crosstabs == 2)
            {
                Expander tTestExpander = new Expander();
                tTestExpander.Margin = (Thickness)this.Resources["expanderMargin"];
                tTestExpander.IsExpanded = true;

                StackPanel pnlT = new StackPanel();

                tTestExpander.Content = pnlT;

                if (this.StrataCount > 1)
                {
                    Expander expander = GetStrataExpander(strataValue);
                    if (expander.Content is StackPanel)
                    {
                        StackPanel sPanel = expander.Content as StackPanel;
                        sPanel.Children.Add(tTestExpander);
                    }
                }
                else
                {
                    panelMain.Children.Add(tTestExpander);
                }

                    KeyValuePair<string, DescriptiveStatistics> TTestStatistics = new KeyValuePair<string, DescriptiveStatistics>(strataValue, stats);
                    pnlT.Tag = TTestStatistics;
                    pnlT.HorizontalAlignment = HorizontalAlignment.Center;
                    pnlT.VerticalAlignment = VerticalAlignment.Center;
                    pnlT.Margin = new Thickness(5);
                    anovaBlocks.Add(pnlT);

                    TextBlock txtT1 = new TextBlock();
                    txtT1.Text = "T-Test";
                    txtT1.HorizontalAlignment = HorizontalAlignment.Center;
                    txtT1.Margin = new Thickness(5);
                    txtT1.FontWeight = FontWeights.Bold;
                    tTestExpander.Header = txtT1;

                    Grid tGrid1 = new Grid();
                    tGrid1.SnapsToDevicePixels = true;
                    tGrid1.HorizontalAlignment = HorizontalAlignment.Center;
                    tGrid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    tGrid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    tGrid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    tGrid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

                    pnlT.Children.Add(tGrid1);

                    for (int y = 0; y < tGrid1.ColumnDefinitions.Count; y++)
                    {
                        Rectangle rctHeader = new Rectangle();
                        rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                        Grid.SetRow(rctHeader, 0);
                        Grid.SetColumn(rctHeader, y);
                        tGrid1.Children.Add(rctHeader);
                    }

                    TextBlock tDiffPooled = new TextBlock();
                    tDiffPooled.Text = "Diff (Group 1 - Group 2)";
                    tDiffPooled.Margin = new Thickness(4, 0, 4, 0);
                    tDiffPooled.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    tDiffPooled.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(tDiffPooled);
                    Grid.SetRow(tDiffPooled, 1);
                    Grid.SetColumn(tDiffPooled, 0);

                    TextBlock tDiffSatterthwaite = new TextBlock();
                    tDiffSatterthwaite.Text = "Diff (Group 1 - Group 2)";
                    tDiffSatterthwaite.Margin = new Thickness(4, 0, 4, 0);
                    tDiffSatterthwaite.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    tDiffSatterthwaite.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(tDiffSatterthwaite);
                    Grid.SetRow(tDiffSatterthwaite, 2);
                    Grid.SetColumn(tDiffSatterthwaite, 0);

                    TextBlock methodHeader = new TextBlock();
                    methodHeader.Text = "Method";
                    methodHeader.Margin = new Thickness(4, 0, 4, 0);
                    methodHeader.FontWeight = FontWeights.Bold;
                    methodHeader.Foreground = Brushes.White;
                    methodHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    methodHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(methodHeader);
                    Grid.SetRow(methodHeader, 0);
                    Grid.SetColumn(methodHeader, 1);

                    TextBlock meanHeader = new TextBlock();
                    meanHeader.Text = "Mean";
                    meanHeader.Margin = new Thickness(4, 0, 4, 0);
                    meanHeader.FontWeight = FontWeights.Bold;
                    meanHeader.Foreground = Brushes.White;
                    meanHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    meanHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(meanHeader);
                    Grid.SetRow(meanHeader, 0);
                    Grid.SetColumn(meanHeader, 2);

                    TextBlock clHeader = new TextBlock();
                    clHeader.Text = "95%";
                    clHeader.Margin = new Thickness(4, 0, 4, 0);
                    clHeader.FontWeight = FontWeights.Bold;
                    clHeader.Foreground = Brushes.White;
                    clHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    clHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(clHeader);
                    Grid.SetRow(clHeader, 0);
                    Grid.SetColumn(clHeader, 3);

                    TextBlock uclHeader = new TextBlock();
                    uclHeader.Text = "CL";
                    uclHeader.Margin = new Thickness(4, 0, 4, 0);
                    uclHeader.FontWeight = FontWeights.Bold;
                    uclHeader.Foreground = Brushes.White;
                    uclHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    uclHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(uclHeader);
                    Grid.SetRow(uclHeader, 0);
                    Grid.SetColumn(uclHeader, 4);

                    TextBlock stdDevHeader = new TextBlock();
                    stdDevHeader.Text = "StdDev";
                    stdDevHeader.Margin = new Thickness(4, 0, 4, 0);
                    stdDevHeader.FontWeight = FontWeights.Bold;
                    stdDevHeader.Foreground = Brushes.White;
                    stdDevHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    stdDevHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(stdDevHeader);
                    Grid.SetRow(stdDevHeader, 0);
                    Grid.SetColumn(stdDevHeader, 5);

                    TextBlock txtMethod = new TextBlock();
                    txtMethod.Text = "Pooled";
                    txtMethod.Margin = new Thickness(4, 0, 4, 0);
                    txtMethod.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    txtMethod.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtMethod);
                    Grid.SetRow(txtMethod, 1);
                    Grid.SetColumn(txtMethod, 1);

                    TextBlock txtMeanP = new TextBlock();
                    txtMeanP.Text = stats.meansDiff.ToString("N4");
                    txtMeanP.Margin = new Thickness(4, 0, 4, 0);
                    txtMeanP.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtMeanP.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtMeanP);
                    Grid.SetRow(txtMeanP, 1);
                    Grid.SetColumn(txtMeanP, 2);

                    TextBlock txtLCLP = new TextBlock();
                    txtLCLP.Text = stats.equalLCLMean.ToString("N4");
                    txtLCLP.Margin = new Thickness(4, 0, 4, 0);
                    txtLCLP.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtLCLP.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtLCLP);
                    Grid.SetRow(txtLCLP, 1);
                    Grid.SetColumn(txtLCLP, 3);

                    TextBlock txtUCLP = new TextBlock();
                    txtUCLP.Text = stats.equalUCLMean.ToString("N4");
                    txtUCLP.Margin = new Thickness(4, 0, 4, 0);
                    txtUCLP.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtUCLP.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtUCLP);
                    Grid.SetRow(txtUCLP, 1);
                    Grid.SetColumn(txtUCLP, 4);

                    TextBlock txtStdDev = new TextBlock();
                    txtStdDev.Text = stats.stdDevDiff.ToString("N4");
                    txtStdDev.Margin = new Thickness(4, 0, 4, 0);
                    txtStdDev.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtStdDev.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtStdDev);
                    Grid.SetRow(txtStdDev, 1);
                    Grid.SetColumn(txtStdDev, 5);

                    TextBlock txtMethodS = new TextBlock();
                    txtMethodS.Text = "Satterthwaite";
                    txtMethodS.Margin = new Thickness(4, 0, 4, 0);
                    txtMethodS.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    txtMethodS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtMethodS);
                    Grid.SetRow(txtMethodS, 21);
                    Grid.SetColumn(txtMethodS, 1);

                    TextBlock txtMeanS = new TextBlock();
                    txtMeanS.Text = stats.meansDiff.ToString("N4");
                    txtMeanS.Margin = new Thickness(4, 0, 4, 0);
                    txtMeanS.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtMeanS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtMeanS);
                    Grid.SetRow(txtMeanS, 2);
                    Grid.SetColumn(txtMeanS, 2);

                    TextBlock txtLCLS = new TextBlock();
                    txtLCLS.Text = stats.unequalLCLMean.ToString("N4");
                    txtLCLS.Margin = new Thickness(4, 0, 4, 0);
                    txtLCLS.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtLCLS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtLCLS);
                    Grid.SetRow(txtLCLS, 2);
                    Grid.SetColumn(txtLCLS, 3);

                    TextBlock txtUCLS = new TextBlock();
                    txtUCLS.Text = stats.unequalUCLMean.ToString("N4");
                    txtUCLS.Margin = new Thickness(4, 0, 4, 0);
                    txtUCLS.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtUCLS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid1.Children.Add(txtUCLS);
                    Grid.SetRow(txtUCLS, 2);
                    Grid.SetColumn(txtUCLS, 4);

                    int rdcountT = 0;
                    foreach (RowDefinition rd in tGrid1.RowDefinitions)
                    {
                        int cdcount = 0;
                        foreach (ColumnDefinition cd in tGrid1.ColumnDefinitions)
                        {
                            Border b = new Border();
                            b.Style = this.Resources["gridCellBorder"] as Style;

                            if (rdcountT == 0)
                            {
                                b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                            }
                            if (cdcount == 0)
                            {
                                b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                            }
                            if (cdcount == 3 && rdcountT == 0)
                            {
                                b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, 0, b.BorderThickness.Bottom);
                            }

                            Grid.SetRow(b, rdcountT);
                            Grid.SetColumn(b, cdcount);
                            tGrid1.Children.Add(b);
                            cdcount++;
                        }
                        rdcountT++;
                    }

                    Grid tGrid2 = new Grid();
                    tGrid2.Margin = new Thickness(5);
                    tGrid2.SnapsToDevicePixels = true;
                    tGrid2.HorizontalAlignment = HorizontalAlignment.Center;
                    tGrid2.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    tGrid2.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    tGrid2.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
                    tGrid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
                    tGrid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

                    pnlT.Children.Add(tGrid2);

                    for (int y = 0; y < tGrid2.ColumnDefinitions.Count; y++)
                    {
                        Rectangle rctHeader = new Rectangle();
                        rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                        Grid.SetRow(rctHeader, 0);
                        Grid.SetColumn(rctHeader, y);
                        tGrid2.Children.Add(rctHeader);
                    }

                    TextBlock methodHeaderG2 = new TextBlock();
                    methodHeaderG2.Text = "Method";
                    methodHeaderG2.Margin = new Thickness(4, 0, 4, 0);
                    methodHeaderG2.FontWeight = FontWeights.Bold;
                    methodHeaderG2.Foreground = Brushes.White;
                    methodHeaderG2.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    methodHeaderG2.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(methodHeaderG2);
                    Grid.SetRow(methodHeaderG2, 0);
                    Grid.SetColumn(methodHeaderG2, 0);

                    TextBlock variancesHeader = new TextBlock();
                    variancesHeader.Text = "Variances";
                    variancesHeader.Margin = new Thickness(4, 0, 4, 0);
                    variancesHeader.FontWeight = FontWeights.Bold;
                    variancesHeader.Foreground = Brushes.White;
                    variancesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    variancesHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(variancesHeader);
                    Grid.SetRow(variancesHeader, 0);
                    Grid.SetColumn(variancesHeader, 1);

                    TextBlock dfHeader = new TextBlock();
                    dfHeader.Text = "DF";
                    dfHeader.Margin = new Thickness(4, 0, 4, 0);
                    dfHeader.FontWeight = FontWeights.Bold;
                    dfHeader.Foreground = Brushes.White;
                    dfHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    dfHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(dfHeader);
                    Grid.SetRow(dfHeader, 0);
                    Grid.SetColumn(dfHeader, 2);

                    TextBlock tValueHeader = new TextBlock();
                    tValueHeader.Text = "t Value";
                    tValueHeader.Margin = new Thickness(4, 0, 4, 0);
                    tValueHeader.FontWeight = FontWeights.Bold;
                    tValueHeader.Foreground = Brushes.White;
                    tValueHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    tValueHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(tValueHeader);
                    Grid.SetRow(tValueHeader, 0);
                    Grid.SetColumn(tValueHeader, 3);

                    TextBlock prHeader = new TextBlock();
                    prHeader.Text = "Pr > |t|";
                    prHeader.Margin = new Thickness(4, 0, 4, 0);
                    prHeader.FontWeight = FontWeights.Bold;
                    prHeader.Foreground = Brushes.White;
                    prHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                    prHeader.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(prHeader);
                    Grid.SetRow(prHeader, 0);
                    Grid.SetColumn(prHeader, 4);

                    TextBlock txtPooled = new TextBlock();
                    txtPooled.Text = "Pooled";
                    txtPooled.Margin = new Thickness(4, 0, 4, 0);
                    txtPooled.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    txtPooled.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtPooled);
                    Grid.SetRow(txtPooled, 1);
                    Grid.SetColumn(txtPooled, 0);

                    TextBlock txtSatterthwaite = new TextBlock();
                    txtSatterthwaite.Text = "Satterthwaite";
                    txtSatterthwaite.Margin = new Thickness(4, 0, 4, 0);
                    txtSatterthwaite.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    txtSatterthwaite.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtSatterthwaite);
                    Grid.SetRow(txtSatterthwaite, 2);
                    Grid.SetColumn(txtSatterthwaite, 0);

                    TextBlock txtEqual = new TextBlock();
                    txtEqual.Text = "Equal";
                    txtEqual.Margin = new Thickness(4, 0, 4, 0);
                    txtEqual.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    txtEqual.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtEqual);
                    Grid.SetRow(txtEqual, 1);
                    Grid.SetColumn(txtEqual, 1);

                    TextBlock txtUnequal = new TextBlock();
                    txtUnequal.Text = "Unequal";
                    txtUnequal.Margin = new Thickness(4, 0, 4, 0);
                    txtUnequal.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    txtUnequal.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtUnequal);
                    Grid.SetRow(txtUnequal, 2);
                    Grid.SetColumn(txtUnequal, 1);

                    TextBlock txtDFP = new TextBlock();
                    txtDFP.Text = stats.df.ToString();
                    txtDFP.Margin = new Thickness(4, 0, 4, 0);
                    txtDFP.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtDFP.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtDFP);
                    Grid.SetRow(txtDFP, 1);
                    Grid.SetColumn(txtDFP, 2);

                    TextBlock txtDFS = new TextBlock();
                    txtDFS.Text = stats.SatterthwaiteDF.ToString("N2");
                    txtDFS.Margin = new Thickness(4, 0, 4, 0);
                    txtDFS.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtDFS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtDFS);
                    Grid.SetRow(txtDFS, 2);
                    Grid.SetColumn(txtDFS, 2);

                    TextBlock txtTStatP = new TextBlock();
                    txtTStatP.Text = stats.tStatistic.ToString("N4");
                    txtTStatP.Margin = new Thickness(4, 0, 4, 0);
                    txtTStatP.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtTStatP.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtTStatP);
                    Grid.SetRow(txtTStatP, 1);
                    Grid.SetColumn(txtTStatP, 3);

                    TextBlock txtTStatS = new TextBlock();
                    txtTStatS.Text = stats.tStatisticUnequal.ToString("N4");
                    txtTStatS.Margin = new Thickness(4, 0, 4, 0);
                    txtTStatS.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtTStatS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtTStatS);
                    Grid.SetRow(txtTStatS, 2);
                    Grid.SetColumn(txtTStatS, 3);

                    TextBlock txtPValueP = new TextBlock();
                    txtPValueP.Text = stats.pEqual.ToString("N4");
                    txtPValueP.Margin = new Thickness(4, 0, 4, 0);
                    txtPValueP.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtPValueP.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtPValueP);
                    Grid.SetRow(txtPValueP, 1);
                    Grid.SetColumn(txtPValueP, 4);

                    TextBlock txtPValueS = new TextBlock();
                    txtPValueS.Text = stats.pUneqal.ToString("N4");
                    txtPValueS.Margin = new Thickness(4, 0, 4, 0);
                    txtPValueS.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    txtPValueS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                    tGrid2.Children.Add(txtPValueS);
                    Grid.SetRow(txtPValueS, 2);
                    Grid.SetColumn(txtPValueS, 4);

                    rdcountT = 0;
                    foreach (RowDefinition rd in tGrid2.RowDefinitions)
                    {
                        int cdcount = 0;
                        foreach (ColumnDefinition cd in tGrid2.ColumnDefinitions)
                        {
                            Border b = new Border();
                            b.Style = this.Resources["gridCellBorder"] as Style;

                            if (rdcountT == 0)
                            {
                                b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                            }
                            if (cdcount == 0)
                            {
                                b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                            }

                            Grid.SetRow(b, rdcountT);
                            Grid.SetColumn(b, cdcount);
                            tGrid2.Children.Add(b);
                            cdcount++;
                        }
                        rdcountT++;
                    }
            }

            Expander anovaExpander = new Expander();
            anovaExpander.Margin = (Thickness)this.Resources["expanderMargin"];
            anovaExpander.IsExpanded = true;

            StackPanel pnl = new StackPanel();

            anovaExpander.Content = pnl;

            if (this.StrataCount > 1)
            {
                Expander expander = GetStrataExpander(strataValue);
                if (expander.Content is StackPanel)
                {
                    StackPanel sPanel = expander.Content as StackPanel;
                    sPanel.Children.Add(anovaExpander);
                }
            }
            else
            {
                panelMain.Children.Add(anovaExpander);
            }

            KeyValuePair<string, DescriptiveStatistics> ANOVAStatistics = new KeyValuePair<string, DescriptiveStatistics>(strataValue, stats);
            pnl.Tag = ANOVAStatistics;
            pnl.HorizontalAlignment = HorizontalAlignment.Center;
            pnl.VerticalAlignment = VerticalAlignment.Center;
            pnl.Margin = new Thickness(5);
            anovaBlocks.Add(pnl);

            TextBlock txt1 = new TextBlock();
            txt1.Text = SharedStrings.ANOVA_DESCRIPTION_FOR_MEANS;
            txt1.HorizontalAlignment = HorizontalAlignment.Center;
            txt1.Margin = new Thickness(5);
            txt1.FontWeight = FontWeights.Bold;
            //pnl.Children.Add(txt1);
            anovaExpander.Header = txt1;

            #region Grid1
            TextBlock txt2 = new TextBlock();
            txt2.Text = SharedStrings.ANOVA_DESCRIPTION_FOR_MEANS_SUBTITLE;
            txt2.HorizontalAlignment = HorizontalAlignment.Center;
            pnl.Children.Add(txt2);

            Grid grid1 = new Grid();
            grid1.SnapsToDevicePixels = true;
            grid1.HorizontalAlignment = HorizontalAlignment.Center;
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            pnl.Children.Add(grid1);

            for (int y = 0; y < grid1.ColumnDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, 0);
                Grid.SetColumn(rctHeader, y);
                grid1.Children.Add(rctHeader);
            }

            for (int y = 1; y < grid1.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid1.Children.Add(rctHeader);
            }

            TextBlock lblVariation = new TextBlock();
            lblVariation.Text = SharedStrings.ANOVA_VARIATION;
            lblVariation.Margin = new Thickness(4, 0, 4, 0);
            lblVariation.FontWeight = FontWeights.Bold;
            lblVariation.Foreground = Brushes.White;
            lblVariation.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblVariation.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(lblVariation);
            Grid.SetRow(lblVariation, 0);
            Grid.SetColumn(lblVariation, 0);

            TextBlock lblBetween = new TextBlock();
            lblBetween.Text = SharedStrings.ANOVA_BETWEEN;
            lblBetween.Margin = new Thickness(4, 0, 4, 0);
            lblBetween.FontWeight = FontWeights.Bold;
            lblBetween.Foreground = Brushes.White;
            lblBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(lblBetween);
            Grid.SetRow(lblBetween, 1);
            Grid.SetColumn(lblBetween, 0);

            TextBlock lblWithin = new TextBlock();
            lblWithin.Text = SharedStrings.ANOVA_WITHIN;
            lblWithin.Margin = new Thickness(4, 0, 4, 0);
            lblWithin.FontWeight = FontWeights.Bold;
            lblWithin.Foreground = Brushes.White;
            lblWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(lblWithin);
            Grid.SetRow(lblWithin, 2);
            Grid.SetColumn(lblWithin, 0);

            TextBlock lblTotal = new TextBlock();
            lblTotal.Text = SharedStrings.ANOVA_TOTAL;
            lblTotal.Margin = new Thickness(4, 0, 4, 0);
            lblTotal.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblTotal.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblTotal.FontWeight = FontWeights.Bold;
            lblTotal.Foreground = Brushes.White;
            grid1.Children.Add(lblTotal);
            Grid.SetRow(lblTotal, 3);
            Grid.SetColumn(lblTotal, 0);

            TextBlock lblSS = new TextBlock();
            lblSS.Text = SharedStrings.ANOVA_SS;
            lblSS.Margin = new Thickness(4, 0, 4, 0);
            lblSS.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblSS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblSS.FontWeight = FontWeights.Bold;
            lblSS.Foreground = Brushes.White;
            grid1.Children.Add(lblSS);
            Grid.SetRow(lblSS, 0);
            Grid.SetColumn(lblSS, 1);

            TextBlock lblDf = new TextBlock();
            lblDf.Text = SharedStrings.ANOVA_DF_SHORT;
            lblDf.Margin = new Thickness(4, 0, 4, 0);
            lblDf.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblDf.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblDf.FontWeight = FontWeights.Bold;
            lblDf.Foreground = Brushes.White;
            grid1.Children.Add(lblDf);
            Grid.SetRow(lblDf, 0);
            Grid.SetColumn(lblDf, 2);

            TextBlock lblMS = new TextBlock();
            lblMS.Text = SharedStrings.ANOVA_MS;
            lblMS.Margin = new Thickness(4, 0, 4, 0);
            lblMS.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblMS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblMS.FontWeight = FontWeights.Bold;
            lblMS.Foreground = Brushes.White;
            grid1.Children.Add(lblMS);
            Grid.SetRow(lblMS, 0);
            Grid.SetColumn(lblMS, 3);

            TextBlock lblF = new TextBlock();
            lblF.Text = SharedStrings.ANOVA_F;
            lblF.Margin = new Thickness(4, 0, 4, 0);
            lblF.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblF.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblF.FontWeight = FontWeights.Bold;
            lblF.Foreground = Brushes.White;
            grid1.Children.Add(lblF);
            Grid.SetRow(lblF, 0);
            Grid.SetColumn(lblF, 4);

            TextBlock txtSSBetween = new TextBlock();
            txtSSBetween.Text = stats.ssBetween.Value.ToString("N4");
            txtSSBetween.Margin = new Thickness(4, 0, 4, 0);
            txtSSBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtSSBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtSSBetween);
            Grid.SetRow(txtSSBetween, 1);
            Grid.SetColumn(txtSSBetween, 1);

            TextBlock txtSSWithin = new TextBlock();
            txtSSWithin.Text = stats.ssWithin.Value.ToString("N4");
            txtSSWithin.Margin = new Thickness(4, 0, 4, 0);
            txtSSWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtSSWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtSSWithin);
            Grid.SetRow(txtSSWithin, 2);
            Grid.SetColumn(txtSSWithin, 1);

            TextBlock txtSSTotal = new TextBlock();
            txtSSTotal.Text = (stats.ssWithin.Value + stats.ssBetween.Value).ToString("N4");
            txtSSTotal.Margin = new Thickness(4, 0, 4, 0);
            txtSSTotal.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtSSTotal.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtSSTotal);
            Grid.SetRow(txtSSTotal, 3);
            Grid.SetColumn(txtSSTotal, 1);

            TextBlock txtDFBetween = new TextBlock();
            txtDFBetween.Text = stats.dfBetween.Value.ToString();
            txtDFBetween.Margin = new Thickness(4, 0, 4, 0);
            txtDFBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtDFBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtDFBetween);
            Grid.SetRow(txtDFBetween, 1);
            Grid.SetColumn(txtDFBetween, 2);

            TextBlock txtDFWithin = new TextBlock();
            txtDFWithin.Text = stats.dfWithin.Value.ToString();
            txtDFWithin.Margin = new Thickness(4, 0, 4, 0);
            txtDFWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtDFWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtDFWithin);
            Grid.SetRow(txtDFWithin, 2);
            Grid.SetColumn(txtDFWithin, 2);

            TextBlock txtDFTotal = new TextBlock();
            txtDFTotal.Text = (stats.dfWithin.Value + stats.dfBetween.Value).ToString();
            txtDFTotal.Margin = new Thickness(4, 0, 4, 0);
            txtDFTotal.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtDFTotal.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtDFTotal);
            Grid.SetRow(txtDFTotal, 3);
            Grid.SetColumn(txtDFTotal, 2);

            TextBlock txtMSBetween = new TextBlock();
            txtMSBetween.Text = stats.msBetween.Value.ToString("N4");
            txtMSBetween.Margin = new Thickness(4, 0, 4, 0);
            txtMSBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtMSBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtMSBetween);
            Grid.SetRow(txtMSBetween, 1);
            Grid.SetColumn(txtMSBetween, 3);

            TextBlock txtMSWithin = new TextBlock();
            txtMSWithin.Text = stats.msWithin.Value.ToString("N4");
            txtMSWithin.Margin = new Thickness(4, 0, 4, 0);
            txtMSWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtMSWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtMSWithin);
            Grid.SetRow(txtMSWithin, 2);
            Grid.SetColumn(txtMSWithin, 3);

            TextBlock txtFStat = new TextBlock();
            txtFStat.Text = stats.fStatistic.Value.ToString("N4");
            txtFStat.Margin = new Thickness(4, 0, 4, 0);
            txtFStat.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            txtFStat.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtFStat);
            Grid.SetRow(txtFStat, 1);
            Grid.SetColumn(txtFStat, 4);

            int rdcount = 0;
            foreach (RowDefinition rd in grid1.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid1.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid1.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }

            #endregion // Grid1

            #region Grid2
            Grid grid2 = new Grid();
            grid2.SnapsToDevicePixels = true;
            grid2.Margin = new Thickness(5);
            grid2.HorizontalAlignment = HorizontalAlignment.Center;
            grid2.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(110) });
            grid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(95) });

            pnl.Children.Add(grid2);

            for (int y = 0; y < grid2.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid2.Children.Add(rctHeader);
            }

            TextBlock lblPValue = new TextBlock();
            lblPValue.Text = SharedStrings.ANOVA_P_VAL;
            lblPValue.HorizontalAlignment = HorizontalAlignment.Center;
            lblPValue.VerticalAlignment = VerticalAlignment.Center;
            lblPValue.FontWeight = FontWeights.Bold;
            lblPValue.Foreground = Brushes.White;
            Grid.SetRow(lblPValue, 0);
            Grid.SetColumn(lblPValue, 0);
            grid2.Children.Add(lblPValue);

            TextBlock txtPValue = new TextBlock();
            txtPValue.Text = stats.anovaPValue.Value.ToString("N4");
            txtPValue.HorizontalAlignment = HorizontalAlignment.Center;
            txtPValue.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtPValue, 0);
            Grid.SetColumn(txtPValue, 1);
            grid2.Children.Add(txtPValue);

            rdcount = 0;
            foreach (RowDefinition rd in grid2.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid2.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid2.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }
            #endregion // Grid2

            #region Grid3
            TextBlock txt3 = new TextBlock();
            txt3.Text = SharedStrings.ANOVA_BARTLETT;
            txt3.HorizontalAlignment = HorizontalAlignment.Center;
            txt3.Margin = new Thickness(5);
            txt3.FontWeight = FontWeights.Bold;
            pnl.Children.Add(txt3);

            Grid grid3 = new Grid();
            grid3.SnapsToDevicePixels = true;
            grid3.Margin = new Thickness(5);
            grid3.HorizontalAlignment = HorizontalAlignment.Center;
            grid3.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid3.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid3.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid3.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(110) });
            grid3.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(95) });

            pnl.Children.Add(grid3);

            for (int y = 0; y < grid3.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid3.Children.Add(rctHeader);
            }

            TextBlock lblBartlettChi = new TextBlock();
            lblBartlettChi.Text = SharedStrings.ANOVA_CHI;
            lblBartlettChi.HorizontalAlignment = HorizontalAlignment.Center;
            lblBartlettChi.VerticalAlignment = VerticalAlignment.Center;
            lblBartlettChi.FontWeight = FontWeights.Bold;
            lblBartlettChi.Foreground = Brushes.White;
            Grid.SetRow(lblBartlettChi, 0);
            Grid.SetColumn(lblBartlettChi, 0);
            grid3.Children.Add(lblBartlettChi);

            TextBlock lblBartlettDf = new TextBlock();
            lblBartlettDf.Text = SharedStrings.ANOVA_DF_LONG;
            lblBartlettDf.HorizontalAlignment = HorizontalAlignment.Center;
            lblBartlettDf.VerticalAlignment = VerticalAlignment.Center;
            lblBartlettDf.FontWeight = FontWeights.Bold;
            lblBartlettDf.Foreground = Brushes.White;
            Grid.SetRow(lblBartlettDf, 1);
            Grid.SetColumn(lblBartlettDf, 0);
            grid3.Children.Add(lblBartlettDf);

            TextBlock lblBartlettP = new TextBlock();
            lblBartlettP.Text = SharedStrings.ANOVA_P_VAL;
            lblBartlettP.HorizontalAlignment = HorizontalAlignment.Center;
            lblBartlettP.VerticalAlignment = VerticalAlignment.Center;
            lblBartlettP.FontWeight = FontWeights.Bold;
            lblBartlettP.Foreground = Brushes.White;
            Grid.SetRow(lblBartlettP, 2);
            Grid.SetColumn(lblBartlettP, 0);
            grid3.Children.Add(lblBartlettP);

            TextBlock txtBartlettChi = new TextBlock();
            txtBartlettChi.Text = stats.chiSquare.Value.ToString("N4");
            txtBartlettChi.HorizontalAlignment = HorizontalAlignment.Center;
            txtBartlettChi.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtBartlettChi, 0);
            Grid.SetColumn(txtBartlettChi, 1);
            grid3.Children.Add(txtBartlettChi);

            TextBlock txtBartlettDf = new TextBlock();
            txtBartlettDf.Text = stats.dfBetween.Value.ToString();
            txtBartlettDf.HorizontalAlignment = HorizontalAlignment.Center;
            txtBartlettDf.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtBartlettDf, 1);
            Grid.SetColumn(txtBartlettDf, 1);
            grid3.Children.Add(txtBartlettDf);

            TextBlock txtBartlettP = new TextBlock();
            txtBartlettP.Text = stats.bartlettPValue.Value.ToString("N4");
            txtBartlettP.HorizontalAlignment = HorizontalAlignment.Center;
            txtBartlettP.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtBartlettP, 2);
            Grid.SetColumn(txtBartlettP, 1);
            grid3.Children.Add(txtBartlettP);

            rdcount = 0;
            foreach (RowDefinition rd in grid3.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid3.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid3.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }

            TextBlock txt4 = new TextBlock();
            txt4.Text = SharedStrings.ANOVA_SMALL_P;
            txt4.HorizontalAlignment = HorizontalAlignment.Center;
            txt4.Margin = new Thickness(5);
            pnl.Children.Add(txt4);

            TextBlock txt5 = new TextBlock();
            txt5.Text = SharedStrings.ANOVA_MWWTST;
            txt5.HorizontalAlignment = HorizontalAlignment.Center;
            txt5.Margin = new Thickness(5);
            txt5.FontWeight = FontWeights.Bold;
            pnl.Children.Add(txt5);

            #endregion // Grid3

            #region Grid4
            Grid grid4 = new Grid();
            grid4.SnapsToDevicePixels = true;
            grid4.Margin = new Thickness(5);
            grid4.HorizontalAlignment = HorizontalAlignment.Center;
            grid4.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid4.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid4.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid4.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(110) });
            grid4.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(95) });

            pnl.Children.Add(grid4);

            for (int y = 0; y < grid4.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid4.Children.Add(rctHeader);
            }

            TextBlock lblKWChi = new TextBlock();
            lblKWChi.Text = SharedStrings.ANOVA_KWH;
            lblKWChi.HorizontalAlignment = HorizontalAlignment.Center;
            lblKWChi.VerticalAlignment = VerticalAlignment.Center;
            lblKWChi.FontWeight = FontWeights.Bold;
            lblKWChi.Foreground = Brushes.White;
            Grid.SetRow(lblKWChi, 0);
            Grid.SetColumn(lblKWChi, 0);
            grid4.Children.Add(lblKWChi);

            TextBlock lblKWDf = new TextBlock();
            lblKWDf.Text = SharedStrings.ANOVA_DF_LONG;
            lblKWDf.HorizontalAlignment = HorizontalAlignment.Center;
            lblKWDf.VerticalAlignment = VerticalAlignment.Center;
            lblKWDf.FontWeight = FontWeights.Bold;
            lblKWDf.Foreground = Brushes.White;
            Grid.SetRow(lblKWDf, 1);
            Grid.SetColumn(lblKWDf, 0);
            grid4.Children.Add(lblKWDf);

            TextBlock lblKWP = new TextBlock();
            lblKWP.Text = SharedStrings.ANOVA_P_VAL;
            lblKWP.HorizontalAlignment = HorizontalAlignment.Center;
            lblKWP.VerticalAlignment = VerticalAlignment.Center;
            lblKWP.FontWeight = FontWeights.Bold;
            lblKWP.Foreground = Brushes.White;
            Grid.SetRow(lblKWP, 2);
            Grid.SetColumn(lblKWP, 0);
            grid4.Children.Add(lblKWP);

            TextBlock txtKWChi = new TextBlock();
            txtKWChi.Text = stats.kruskalWallisH.Value.ToString("N4");
            txtKWChi.HorizontalAlignment = HorizontalAlignment.Center;
            txtKWChi.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtKWChi, 0);
            Grid.SetColumn(txtKWChi, 1);
            grid4.Children.Add(txtKWChi);

            TextBlock txtWKDf = new TextBlock();
            txtWKDf.Text = stats.dfBetween.Value.ToString();
            txtWKDf.HorizontalAlignment = HorizontalAlignment.Center;
            txtWKDf.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtWKDf, 1);
            Grid.SetColumn(txtWKDf, 1);
            grid4.Children.Add(txtWKDf);

            TextBlock txtKWP = new TextBlock();
            txtKWP.Text = stats.kruskalPValue.Value.ToString("N4");
            txtKWP.HorizontalAlignment = HorizontalAlignment.Center;
            txtKWP.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtKWP, 2);
            Grid.SetColumn(txtKWP, 1);
            grid4.Children.Add(txtKWP);

            rdcount = 0;
            foreach (RowDefinition rd in grid4.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid4.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid4.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }

            #endregion // Grid4

            //panelMain.Children.Add(pnl);
        }
        public void RefreshResults()
        {
            if (!loadingCombos &&
                cbxPatientIdField.SelectedIndex >= 0 &&
                cbxPatientId.SelectedIndex >= 0 &&
                cbxGenderField.SelectedIndex >= 0 &&
                cbxMeasurementField.SelectedIndex >= 0)
            {
                if (IsAgeBasedMeasurement && cbxAgeField.SelectedIndex == -1)
                {
                    return;
                }

                txtError.Text = string.Empty;
                txtError.Visibility = Visibility.Collapsed;

                SetGadgetToProcessingState();

                ShowLegend = (bool)checkboxShowLegend.IsChecked;
                ShowTallChart = (bool)checkboxShowTallChart.IsChecked;
                UseCustomCurveColors = (bool)checkboxBlackAndWhite.IsChecked;

                if (UseCustomCurveColors)
                {
                    CustomCurveColor = Color.FromRgb(0, 0, 0);
                }

                if (cbxUnits.SelectedIndex == 0)
                {
                    IsMetric = false;
                }
                else
                {
                    IsMetric = true;
                }

                Thickness margin = pnlChartContainer.Margin;
                margin.Top = 40;
                pnlChartContainer.Margin = margin;

                List<string> columnNames = new List<string>();
                string weightColumnName = string.Empty;
                string heightColumnName = string.Empty;
                string ageColumnName = string.Empty;
                string measurementColumnName = cbxMeasurementField.SelectedItem.ToString();
                if (cbxWeightField.SelectedIndex > -1)
                {
                    weightColumnName = cbxWeightField.SelectedItem.ToString();
                    columnNames.Add(weightColumnName);
                }
                if (cbxAgeField.SelectedIndex > -1)
                {
                    ageColumnName = cbxAgeField.SelectedItem.ToString();
                    columnNames.Add(ageColumnName);
                }
                if (cbxHeightField.SelectedIndex > -1)
                {
                    heightColumnName = cbxHeightField.SelectedItem.ToString();
                    columnNames.Add(heightColumnName);
                }
                string genderColumnName = cbxGenderField.SelectedItem.ToString();
                string patientIdColumnName = cbxPatientIdField.SelectedItem.ToString();

                patientLabel = cbxPatientId.SelectedItem.ToString();

                ChartSubTitle.Content = "ID: " + patientLabel;

                string customFilter = "([" + patientIdColumnName + "] = " + dashboardHelper.FormatValue(cbxPatientId.SelectedItem.ToString(), dashboardHelper.GetColumnType(patientIdColumnName)) + ")";

                columnNames.Add(genderColumnName);
                columnNames.Add(patientIdColumnName);
                columnNames.Add(measurementColumnName);

                gadgetOptions.InputVariableList.Clear();
                gadgetOptions.InputVariableList.Add("showtallchart", ShowTallChart.ToString());
                gadgetOptions.InputVariableList.Add("gendercolumnname", genderColumnName);
                gadgetOptions.InputVariableList.Add("agecolumnname", ageColumnName);
                gadgetOptions.InputVariableList.Add("heightcolumnname", heightColumnName);
                gadgetOptions.InputVariableList.Add("weightcolumnname", weightColumnName);
                gadgetOptions.InputVariableList.Add("measurementcolumnname", measurementColumnName);
                gadgetOptions.InputVariableList.Add("patientidcolumnname", patientIdColumnName);

                KeyValuePair<List<string>, string> inputs = new KeyValuePair<List<string>, string>(columnNames, customFilter);

                worker = new BackgroundWorker();
                worker.DoWork += new System.ComponentModel.DoWorkEventHandler(Execute);
                worker.RunWorkerAsync(inputs);
            }
        }
Пример #3
0
        /// <summary>
        /// Adds anova statistics to the gadget
        /// </summary>
        /// <param name="strataValue">The strata value associated with the results</param>
        /// <param name="stats">The descriptive statistics to process</param>
        private void AddAnova(string strataValue, DescriptiveStatistics stats)
        {
            Expander anovaExpander = new Expander();
            anovaExpander.Margin = (Thickness)this.Resources["expanderMargin"];
            anovaExpander.IsExpanded = true;

            StackPanel pnl = new StackPanel();

            anovaExpander.Content = pnl;

            if (this.StrataCount > 1)
            {
                Expander expander = GetStrataExpander(strataValue);
                if (expander.Content is StackPanel)
                {
                    StackPanel sPanel = expander.Content as StackPanel;
                    sPanel.Children.Add(anovaExpander);
                }
            }
            else
            {
                panelMain.Children.Add(anovaExpander);
            }

            KeyValuePair<string, DescriptiveStatistics> ANOVAStatistics = new KeyValuePair<string, DescriptiveStatistics>(strataValue, stats);
            pnl.Tag = ANOVAStatistics;
            pnl.HorizontalAlignment = HorizontalAlignment.Center;
            pnl.VerticalAlignment = VerticalAlignment.Center;
            pnl.Margin = new Thickness(5);
            anovaBlocks.Add(pnl);

            TextBlock txt1 = new TextBlock();
            txt1.Text = SharedStrings.ANOVA_DESCRIPTION_FOR_MEANS;
            txt1.HorizontalAlignment = HorizontalAlignment.Center;
            txt1.Margin = new Thickness(5);
            txt1.FontWeight = FontWeights.Bold;
            //pnl.Children.Add(txt1);
            anovaExpander.Header = txt1;

            #region Grid1
            TextBlock txt2 = new TextBlock();
            txt2.Text = SharedStrings.ANOVA_DESCRIPTION_FOR_MEANS_SUBTITLE;
            txt2.HorizontalAlignment = HorizontalAlignment.Center;
            pnl.Children.Add(txt2);

            Grid grid1 = new Grid();
            grid1.SnapsToDevicePixels = true;
            grid1.HorizontalAlignment = HorizontalAlignment.Center;
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            grid1.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });

            pnl.Children.Add(grid1);

            for (int y = 0; y < grid1.ColumnDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, 0);
                Grid.SetColumn(rctHeader, y);
                grid1.Children.Add(rctHeader);
            }

            for (int y = 1; y < grid1.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid1.Children.Add(rctHeader);
            }

            TextBlock lblVariation = new TextBlock();
            lblVariation.Text = SharedStrings.ANOVA_VARIATION;
            lblVariation.Margin = new Thickness(4, 0, 4, 0);
            lblVariation.FontWeight = FontWeights.Bold;
            lblVariation.Foreground = Brushes.White;
            lblVariation.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblVariation.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(lblVariation);
            Grid.SetRow(lblVariation, 0);
            Grid.SetColumn(lblVariation, 0);

            TextBlock lblBetween = new TextBlock();
            lblBetween.Text = SharedStrings.ANOVA_BETWEEN;
            lblBetween.Margin = new Thickness(4, 0, 4, 0);
            lblBetween.FontWeight = FontWeights.Bold;
            lblBetween.Foreground = Brushes.White;
            lblBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(lblBetween);
            Grid.SetRow(lblBetween, 1);
            Grid.SetColumn(lblBetween, 0);

            TextBlock lblWithin = new TextBlock();
            lblWithin.Text = SharedStrings.ANOVA_WITHIN;
            lblWithin.Margin = new Thickness(4, 0, 4, 0);
            lblWithin.FontWeight = FontWeights.Bold;
            lblWithin.Foreground = Brushes.White;
            lblWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(lblWithin);
            Grid.SetRow(lblWithin, 2);
            Grid.SetColumn(lblWithin, 0);

            TextBlock lblTotal = new TextBlock();
            lblTotal.Text = SharedStrings.ANOVA_TOTAL;
            lblTotal.Margin = new Thickness(4, 0, 4, 0);
            lblTotal.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblTotal.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblTotal.FontWeight = FontWeights.Bold;
            lblTotal.Foreground = Brushes.White;
            grid1.Children.Add(lblTotal);
            Grid.SetRow(lblTotal, 3);
            Grid.SetColumn(lblTotal, 0);

            TextBlock lblSS = new TextBlock();
            lblSS.Text = SharedStrings.ANOVA_SS;
            lblSS.Margin = new Thickness(4, 0, 4, 0);
            lblSS.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblSS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblSS.FontWeight = FontWeights.Bold;
            lblSS.Foreground = Brushes.White;
            grid1.Children.Add(lblSS);
            Grid.SetRow(lblSS, 0);
            Grid.SetColumn(lblSS, 1);

            TextBlock lblDf = new TextBlock();
            lblDf.Text = SharedStrings.ANOVA_DF_SHORT;
            lblDf.Margin = new Thickness(4, 0, 4, 0);
            lblDf.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblDf.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblDf.FontWeight = FontWeights.Bold;
            lblDf.Foreground = Brushes.White;
            grid1.Children.Add(lblDf);
            Grid.SetRow(lblDf, 0);
            Grid.SetColumn(lblDf, 2);

            TextBlock lblMS = new TextBlock();
            lblMS.Text = SharedStrings.ANOVA_MS;
            lblMS.Margin = new Thickness(4, 0, 4, 0);
            lblMS.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblMS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblMS.FontWeight = FontWeights.Bold;
            lblMS.Foreground = Brushes.White;
            grid1.Children.Add(lblMS);
            Grid.SetRow(lblMS, 0);
            Grid.SetColumn(lblMS, 3);

            TextBlock lblF = new TextBlock();
            lblF.Text = SharedStrings.ANOVA_F;
            lblF.Margin = new Thickness(4, 0, 4, 0);
            lblF.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            lblF.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            lblF.FontWeight = FontWeights.Bold;
            lblF.Foreground = Brushes.White;
            grid1.Children.Add(lblF);
            Grid.SetRow(lblF, 0);
            Grid.SetColumn(lblF, 4);

            TextBlock txtSSBetween = new TextBlock();
            txtSSBetween.Text = stats.ssBetween.Value.ToString("N4");
            txtSSBetween.Margin = new Thickness(4, 0, 4, 0);
            txtSSBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtSSBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtSSBetween);
            Grid.SetRow(txtSSBetween, 1);
            Grid.SetColumn(txtSSBetween, 1);

            TextBlock txtSSWithin = new TextBlock();
            txtSSWithin.Text = stats.ssWithin.Value.ToString("N4");
            txtSSWithin.Margin = new Thickness(4, 0, 4, 0);
            txtSSWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtSSWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtSSWithin);
            Grid.SetRow(txtSSWithin, 2);
            Grid.SetColumn(txtSSWithin, 1);

            TextBlock txtSSTotal = new TextBlock();
            txtSSTotal.Text = (stats.ssWithin.Value + stats.ssBetween.Value).ToString("N4");
            txtSSTotal.Margin = new Thickness(4, 0, 4, 0);
            txtSSTotal.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtSSTotal.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtSSTotal);
            Grid.SetRow(txtSSTotal, 3);
            Grid.SetColumn(txtSSTotal, 1);

            TextBlock txtDFBetween = new TextBlock();
            txtDFBetween.Text = stats.dfBetween.Value.ToString();
            txtDFBetween.Margin = new Thickness(4, 0, 4, 0);
            txtDFBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtDFBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtDFBetween);
            Grid.SetRow(txtDFBetween, 1);
            Grid.SetColumn(txtDFBetween, 2);

            TextBlock txtDFWithin = new TextBlock();
            txtDFWithin.Text = stats.dfWithin.Value.ToString();
            txtDFWithin.Margin = new Thickness(4, 0, 4, 0);
            txtDFWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtDFWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtDFWithin);
            Grid.SetRow(txtDFWithin, 2);
            Grid.SetColumn(txtDFWithin, 2);

            TextBlock txtDFTotal = new TextBlock();
            txtDFTotal.Text = (stats.dfWithin.Value + stats.dfBetween.Value).ToString();
            txtDFTotal.Margin = new Thickness(4, 0, 4, 0);
            txtDFTotal.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtDFTotal.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtDFTotal);
            Grid.SetRow(txtDFTotal, 3);
            Grid.SetColumn(txtDFTotal, 2);

            TextBlock txtMSBetween = new TextBlock();
            txtMSBetween.Text = stats.msBetween.Value.ToString("N4");
            txtMSBetween.Margin = new Thickness(4, 0, 4, 0);
            txtMSBetween.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtMSBetween.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtMSBetween);
            Grid.SetRow(txtMSBetween, 1);
            Grid.SetColumn(txtMSBetween, 3);

            TextBlock txtMSWithin = new TextBlock();
            txtMSWithin.Text = stats.msWithin.Value.ToString("N4");
            txtMSWithin.Margin = new Thickness(4, 0, 4, 0);
            txtMSWithin.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            txtMSWithin.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtMSWithin);
            Grid.SetRow(txtMSWithin, 2);
            Grid.SetColumn(txtMSWithin, 3);

            TextBlock txtFStat = new TextBlock();
            txtFStat.Text = stats.fStatistic.Value.ToString("N4");
            txtFStat.Margin = new Thickness(4, 0, 4, 0);
            txtFStat.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            txtFStat.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            grid1.Children.Add(txtFStat);
            Grid.SetRow(txtFStat, 1);
            Grid.SetColumn(txtFStat, 4);

            int rdcount = 0;
            foreach (RowDefinition rd in grid1.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid1.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid1.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }

            #endregion // Grid1

            #region Grid2
            Grid grid2 = new Grid();
            grid2.SnapsToDevicePixels = true;
            grid2.Margin = new Thickness(5);
            grid2.HorizontalAlignment = HorizontalAlignment.Center;
            grid2.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(110) });
            grid2.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(95) });

            pnl.Children.Add(grid2);

            for (int y = 0; y < grid2.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid2.Children.Add(rctHeader);
            }

            TextBlock lblPValue = new TextBlock();
            lblPValue.Text = SharedStrings.ANOVA_P_VAL;
            lblPValue.HorizontalAlignment = HorizontalAlignment.Center;
            lblPValue.VerticalAlignment = VerticalAlignment.Center;
            lblPValue.FontWeight = FontWeights.Bold;
            lblPValue.Foreground = Brushes.White;
            Grid.SetRow(lblPValue, 0);
            Grid.SetColumn(lblPValue, 0);
            grid2.Children.Add(lblPValue);

            TextBlock txtPValue = new TextBlock();
            txtPValue.Text = stats.anovaPValue.Value.ToString("N4");
            txtPValue.HorizontalAlignment = HorizontalAlignment.Center;
            txtPValue.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtPValue, 0);
            Grid.SetColumn(txtPValue, 1);
            grid2.Children.Add(txtPValue);

            rdcount = 0;
            foreach (RowDefinition rd in grid2.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid2.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid2.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }
            #endregion // Grid2

            #region Grid3
            TextBlock txt3 = new TextBlock();
            txt3.Text = SharedStrings.ANOVA_BARTLETT;
            txt3.HorizontalAlignment = HorizontalAlignment.Center;
            txt3.Margin = new Thickness(5);
            txt3.FontWeight = FontWeights.Bold;
            pnl.Children.Add(txt3);

            Grid grid3 = new Grid();
            grid3.SnapsToDevicePixels = true;
            grid3.Margin = new Thickness(5);
            grid3.HorizontalAlignment = HorizontalAlignment.Center;
            grid3.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid3.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid3.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid3.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(110) });
            grid3.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(95) });

            pnl.Children.Add(grid3);

            for (int y = 0; y < grid3.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid3.Children.Add(rctHeader);
            }

            TextBlock lblBartlettChi = new TextBlock();
            lblBartlettChi.Text = SharedStrings.ANOVA_CHI;
            lblBartlettChi.HorizontalAlignment = HorizontalAlignment.Center;
            lblBartlettChi.VerticalAlignment = VerticalAlignment.Center;
            lblBartlettChi.FontWeight = FontWeights.Bold;
            lblBartlettChi.Foreground = Brushes.White;
            Grid.SetRow(lblBartlettChi, 0);
            Grid.SetColumn(lblBartlettChi, 0);
            grid3.Children.Add(lblBartlettChi);

            TextBlock lblBartlettDf = new TextBlock();
            lblBartlettDf.Text = SharedStrings.ANOVA_DF_LONG;
            lblBartlettDf.HorizontalAlignment = HorizontalAlignment.Center;
            lblBartlettDf.VerticalAlignment = VerticalAlignment.Center;
            lblBartlettDf.FontWeight = FontWeights.Bold;
            lblBartlettDf.Foreground = Brushes.White;
            Grid.SetRow(lblBartlettDf, 1);
            Grid.SetColumn(lblBartlettDf, 0);
            grid3.Children.Add(lblBartlettDf);

            TextBlock lblBartlettP = new TextBlock();
            lblBartlettP.Text = SharedStrings.ANOVA_P_VAL;
            lblBartlettP.HorizontalAlignment = HorizontalAlignment.Center;
            lblBartlettP.VerticalAlignment = VerticalAlignment.Center;
            lblBartlettP.FontWeight = FontWeights.Bold;
            lblBartlettP.Foreground = Brushes.White;
            Grid.SetRow(lblBartlettP, 2);
            Grid.SetColumn(lblBartlettP, 0);
            grid3.Children.Add(lblBartlettP);

            TextBlock txtBartlettChi = new TextBlock();
            txtBartlettChi.Text = stats.chiSquare.Value.ToString("N4");
            txtBartlettChi.HorizontalAlignment = HorizontalAlignment.Center;
            txtBartlettChi.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtBartlettChi, 0);
            Grid.SetColumn(txtBartlettChi, 1);
            grid3.Children.Add(txtBartlettChi);

            TextBlock txtBartlettDf = new TextBlock();
            txtBartlettDf.Text = stats.dfBetween.Value.ToString();
            txtBartlettDf.HorizontalAlignment = HorizontalAlignment.Center;
            txtBartlettDf.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtBartlettDf, 1);
            Grid.SetColumn(txtBartlettDf, 1);
            grid3.Children.Add(txtBartlettDf);

            TextBlock txtBartlettP = new TextBlock();
            txtBartlettP.Text = stats.bartlettPValue.Value.ToString("N4");
            txtBartlettP.HorizontalAlignment = HorizontalAlignment.Center;
            txtBartlettP.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtBartlettP, 2);
            Grid.SetColumn(txtBartlettP, 1);
            grid3.Children.Add(txtBartlettP);

            rdcount = 0;
            foreach (RowDefinition rd in grid3.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid3.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid3.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }

            TextBlock txt4 = new TextBlock();
            txt4.Text = SharedStrings.ANOVA_SMALL_P;
            txt4.HorizontalAlignment = HorizontalAlignment.Center;
            txt4.Margin = new Thickness(5);
            pnl.Children.Add(txt4);

            TextBlock txt5 = new TextBlock();
            txt5.Text = SharedStrings.ANOVA_MWWTST;
            txt5.HorizontalAlignment = HorizontalAlignment.Center;
            txt5.Margin = new Thickness(5);
            txt5.FontWeight = FontWeights.Bold;
            pnl.Children.Add(txt5);

            #endregion // Grid3

            #region Grid4
            Grid grid4 = new Grid();
            grid4.SnapsToDevicePixels = true;
            grid4.Margin = new Thickness(5);
            grid4.HorizontalAlignment = HorizontalAlignment.Center;
            grid4.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid4.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid4.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(30) });
            grid4.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(110) });
            grid4.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(95) });

            pnl.Children.Add(grid4);

            for (int y = 0; y < grid4.RowDefinitions.Count; y++)
            {
                Rectangle rctHeader = new Rectangle();
                rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                Grid.SetRow(rctHeader, y);
                Grid.SetColumn(rctHeader, 0);
                grid4.Children.Add(rctHeader);
            }

            TextBlock lblKWChi = new TextBlock();
            lblKWChi.Text = SharedStrings.ANOVA_KWH;
            lblKWChi.HorizontalAlignment = HorizontalAlignment.Center;
            lblKWChi.VerticalAlignment = VerticalAlignment.Center;
            lblKWChi.FontWeight = FontWeights.Bold;
            lblKWChi.Foreground = Brushes.White;
            Grid.SetRow(lblKWChi, 0);
            Grid.SetColumn(lblKWChi, 0);
            grid4.Children.Add(lblKWChi);

            TextBlock lblKWDf = new TextBlock();
            lblKWDf.Text = SharedStrings.ANOVA_DF_LONG;
            lblKWDf.HorizontalAlignment = HorizontalAlignment.Center;
            lblKWDf.VerticalAlignment = VerticalAlignment.Center;
            lblKWDf.FontWeight = FontWeights.Bold;
            lblKWDf.Foreground = Brushes.White;
            Grid.SetRow(lblKWDf, 1);
            Grid.SetColumn(lblKWDf, 0);
            grid4.Children.Add(lblKWDf);

            TextBlock lblKWP = new TextBlock();
            lblKWP.Text = SharedStrings.ANOVA_P_VAL;
            lblKWP.HorizontalAlignment = HorizontalAlignment.Center;
            lblKWP.VerticalAlignment = VerticalAlignment.Center;
            lblKWP.FontWeight = FontWeights.Bold;
            lblKWP.Foreground = Brushes.White;
            Grid.SetRow(lblKWP, 2);
            Grid.SetColumn(lblKWP, 0);
            grid4.Children.Add(lblKWP);

            TextBlock txtKWChi = new TextBlock();
            txtKWChi.Text = stats.kruskalWallisH.Value.ToString("N4");
            txtKWChi.HorizontalAlignment = HorizontalAlignment.Center;
            txtKWChi.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtKWChi, 0);
            Grid.SetColumn(txtKWChi, 1);
            grid4.Children.Add(txtKWChi);

            TextBlock txtWKDf = new TextBlock();
            txtWKDf.Text = stats.dfBetween.Value.ToString();
            txtWKDf.HorizontalAlignment = HorizontalAlignment.Center;
            txtWKDf.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtWKDf, 1);
            Grid.SetColumn(txtWKDf, 1);
            grid4.Children.Add(txtWKDf);

            TextBlock txtKWP = new TextBlock();
            txtKWP.Text = stats.kruskalPValue.Value.ToString("N4");
            txtKWP.HorizontalAlignment = HorizontalAlignment.Center;
            txtKWP.VerticalAlignment = VerticalAlignment.Center;
            Grid.SetRow(txtKWP, 2);
            Grid.SetColumn(txtKWP, 1);
            grid4.Children.Add(txtKWP);

            rdcount = 0;
            foreach (RowDefinition rd in grid4.RowDefinitions)
            {
                int cdcount = 0;
                foreach (ColumnDefinition cd in grid4.ColumnDefinitions)
                {
                    Border b = new Border();
                    b.Style = this.Resources["gridCellBorder"] as Style;

                    if (rdcount == 0)
                    {
                        b.BorderThickness = new Thickness(b.BorderThickness.Left, 1, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }
                    if (cdcount == 0)
                    {
                        b.BorderThickness = new Thickness(1, b.BorderThickness.Top, b.BorderThickness.Right, b.BorderThickness.Bottom);
                    }

                    Grid.SetRow(b, rdcount);
                    Grid.SetColumn(b, cdcount);
                    grid4.Children.Add(b);
                    cdcount++;
                }
                rdcount++;
            }

            #endregion // Grid4

            //panelMain.Children.Add(pnl);
        }