示例#1
0
        /// <summary>
        /// Constructs the gadget
        /// </summary>
        protected virtual void Construct()
        {
            strataGridList     = new List <Grid>();
            strataPanelList    = new List <StackPanel>();
            strataExpanderList = new List <Expander>();
            strataCount        = 0;

            GadgetOptions = new GadgetParameters();
            GadgetOptions.InputVariableList = new Dictionary <string, string>();
            GadgetOptions.ShouldIncludeFullSummaryStatistics = false;
            GadgetOptions.ShouldIncludeMissing       = false;
            GadgetOptions.ShouldSortHighToLow        = false;
            GadgetOptions.ShouldUseAllPossibleValues = false;
            GadgetOptions.StrataVariableNames        = new List <string>();
            GadgetOptions.PSUVariableName            = string.Empty;
            GadgetOptions.CustomFilter = string.Empty;

            if (this.DashboardHelper != null)
            {
                this.dataFilters = new Epi.WPF.Dashboard.DataFilters(this.DashboardHelper);
            }

            object el = this.FindName("headerPanel");

            if (el != null)
            {
                Controls.GadgetHeaderPanel headerPanel = el as Controls.GadgetHeaderPanel;
                headerPanel.GadgetCloseButtonClicked          += new GadgetCloseButtonHandler(CloseGadget);
                headerPanel.GadgetOutputCollapseButtonClicked += new GadgetOutputCollapseButtonHandler(CollapseOutput);
                headerPanel.GadgetOutputExpandButtonClicked   += new GadgetOutputExpandButtonHandler(ExpandOutput);
                headerPanel.GadgetConfigButtonClicked         += new GadgetConfigButtonHandler(ShowHideConfigPanel);
                headerPanel.GadgetDescriptionButtonClicked    += new GadgetDescriptionButtonHandler(ShowHideDescriptionPanel);
                headerPanel.GadgetFilterButtonClicked         += new GadgetFilterButtonHandler(ShowCustomFilterDialog);
            }

            el = this.FindName("messagePanel");
            if (el != null)
            {
                Controls.GadgetMessagePanel messagePanel = el as Controls.GadgetMessagePanel;
                messagePanel.MessagePanelType = Controls.MessagePanelType.StatusPanel;
                messagePanel.Text             = string.Empty;
                messagePanel.Visibility       = System.Windows.Visibility.Collapsed;
            }

            el = this.FindName("descriptionPanel");
            if (el != null)
            {
                Controls.GadgetDescriptionPanel descriptionPanel = el as Controls.GadgetDescriptionPanel;
                if (!string.IsNullOrEmpty(CustomOutputDescription) && !CustomOutputHeading.Equals("(none)"))
                {
                    descriptionPanel.Text      = CustomOutputDescription;
                    descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.DisplayMode;
                }
                else
                {
                    descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.Collapsed;
                }
            }
        }
        protected override void Construct()
        {
            if (!string.IsNullOrEmpty(CustomOutputHeading) && !CustomOutputHeading.Equals("(none)"))
            {
                headerPanel.Text = CustomOutputHeading;
            }

            strataGridList = new List <Grid>();
            gridLabelsList = new List <TextBlock>();

            FillComboboxes();

            mnuCopyData.Click       += new RoutedEventHandler(mnuCopyData_Click);
            mnuSendDataToHTML.Click += new RoutedEventHandler(mnuSendDataToHTML_Click);

#if LINUX_BUILD
            mnuSendDataToExcel.Visibility = Visibility.Collapsed;
#else
            mnuSendDataToExcel.Visibility = Visibility.Visible;
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.ClassesRoot; Microsoft.Win32.RegistryKey excelKey = key.OpenSubKey("Excel.Application"); bool excelInstalled = excelKey == null ? false : true; key = Microsoft.Win32.Registry.ClassesRoot;
            excelKey       = key.OpenSubKey("Excel.Application");
            excelInstalled = excelKey == null ? false : true;

            if (!excelInstalled)
            {
                mnuSendDataToExcel.Visibility = Visibility.Collapsed;
            }
            else
            {
                mnuSendDataToExcel.Click += new RoutedEventHandler(mnuSendDataToExcel_Click);
            }
#endif

            mnuSendToBack.Click += new RoutedEventHandler(mnuSendToBack_Click);
            mnuClose.Click      += new RoutedEventHandler(mnuClose_Click);

            this.IsProcessing = false;

            base.Construct();

            #region Translation
            ConfigExpandedTitle.Text        = DashboardSharedStrings.GADGET_CONFIG_TITLE_COMBINED_FREQUENCY;
            tblockGroupField.Text           = DashboardSharedStrings.GADGET_GROUP_VARIABLE;
            expanderAdvancedOptions.Header  = DashboardSharedStrings.GADGET_ADVANCED_OPTIONS;
            checkboxSortHighLow.Content     = DashboardSharedStrings.GADGET_SORT_HI_LOW;
            checkboxShowDenominator.Content = DashboardSharedStrings.GADGET_SHOW_DENOMINATOR;
            #endregion // Translation
        }
        protected override void Construct()
        {
            this.Parameters = new AberrationDetectionChartParameters();

            if (!string.IsNullOrEmpty(CustomOutputHeading) && !CustomOutputHeading.Equals("(none)"))
            {
                headerPanel.Text = CustomOutputHeading;
            }

            StrataGridList     = new List <Grid>();
            StrataExpanderList = new List <Expander>();

            mnuCopy.Click           += new RoutedEventHandler(mnuCopy_Click);
            mnuSendDataToHTML.Click += new RoutedEventHandler(mnuSendDataToHTML_Click);

#if LINUX_BUILD
            mnuSendDataToExcel.Visibility = Visibility.Collapsed;
#else
            mnuSendDataToExcel.Visibility = Visibility.Visible;
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.ClassesRoot; Microsoft.Win32.RegistryKey excelKey = key.OpenSubKey("Excel.Application"); bool excelInstalled = excelKey == null ? false : true; key = Microsoft.Win32.Registry.ClassesRoot;
            excelKey       = key.OpenSubKey("Excel.Application");
            excelInstalled = excelKey == null ? false : true;

            if (!excelInstalled)
            {
                mnuSendDataToExcel.Visibility = Visibility.Collapsed;
            }
            else
            {
                mnuSendDataToExcel.Click += new RoutedEventHandler(mnuSendDataToExcel_Click);
            }
#endif

            mnuSendToBack.Click             += new RoutedEventHandler(mnuSendToBack_Click);
            mnuClose.Click                  += new RoutedEventHandler(mnuClose_Click);
            this.IsProcessing                = false;
            this.GadgetStatusUpdate         += new GadgetStatusUpdateHandler(RequestUpdateStatusMessage);
            this.GadgetCheckForCancellation += new GadgetCheckForCancellationHandler(IsCancelled);

            base.Construct();
        }
        /// <summary>
        /// Construct
        /// </summary>
        protected override void Construct()
        {
            if (!string.IsNullOrEmpty(CustomOutputHeading) && !CustomOutputHeading.Equals("(none)"))
            {
                headerPanel.Text = CustomOutputHeading;
            }

            mnuCopyData.Click       += new RoutedEventHandler(mnuCopyData_Click);
            mnuSendDataToHTML.Click += new RoutedEventHandler(mnuSendDataToHTML_Click);

#if LINUX_BUILD
            mnuSendDataToExcel.Visibility = Visibility.Collapsed;
#else
            mnuSendDataToExcel.Visibility = Visibility.Visible;
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.ClassesRoot; Microsoft.Win32.RegistryKey excelKey = key.OpenSubKey("Excel.Application"); bool excelInstalled = excelKey == null ? false : true; key = Microsoft.Win32.Registry.ClassesRoot;
            excelKey       = key.OpenSubKey("Excel.Application");
            excelInstalled = excelKey == null ? false : true;

            if (!excelInstalled)
            {
                mnuSendDataToExcel.Visibility = Visibility.Collapsed;
            }
            else
            {
                mnuSendDataToExcel.Click += new RoutedEventHandler(mnuSendDataToExcel_Click);
            }
#endif

            mnuSendToBack.Click += new RoutedEventHandler(mnuSendToBack_Click);
            mnuClose.Click      += new RoutedEventHandler(mnuClose_Click);

            this.IsProcessing = false;

            base.Construct();
            this.Parameters = new CombinedFrequencyParameters();
        }
        /// <summary>
        /// Creates the frequency gadget from an Xml element loaded from a canvas saved in 7.1.1.14 or earlier.
        /// </summary>
        /// <param name="element">The element from which to create the gadget</param>
        private void CreateFromLegacyXml(XmlElement element)
        {
            this.LoadingCombos = true;

            foreach (XmlElement child in element.ChildNodes)
            {
                switch (child.Name.ToLowerInvariant())
                {
                case "mainvariable":
                    if (this.Parameters.ColumnNames.Count > 0)
                    {
                        ((AberrationDetectionChartParameters)Parameters).ColumnNames[0] = child.InnerText.Replace("&lt;", "<");
                    }
                    else
                    {
                        ((AberrationDetectionChartParameters)Parameters).ColumnNames.Add(child.InnerText.Replace("&lt;", "<"));
                    }
                    break;

                case "stratavariable":
                    if (((AberrationDetectionChartParameters)Parameters).StrataVariableNames.Count > 0)
                    {
                        ((AberrationDetectionChartParameters)Parameters).StrataVariableNames[0] = child.InnerText.Replace("&lt;", "<");
                    }
                    else
                    {
                        ((AberrationDetectionChartParameters)Parameters).StrataVariableNames.Add(child.InnerText.Replace("&lt;", "<"));
                    }
                    break;

                case "weightvariable":
                    ((AberrationDetectionChartParameters)Parameters).WeightVariableName = child.InnerText.Replace("&lt;", "<");
                    break;

                case "lagtime":
                    ((AberrationDetectionChartParameters)Parameters).LagTime = child.InnerText.Replace("&lt;", "<");
                    break;

                case "deviations":
                    ((AberrationDetectionChartParameters)Parameters).Deviations = child.InnerText.Replace("&lt;", "<");
                    break;

                case "timeperiod":
                    ((AberrationDetectionChartParameters)Parameters).TimePeriod = child.InnerText.Replace("&lt;", "<");
                    break;

                case "datafilters":
                    this.DataFilters = new DataFilters(this.DashboardHelper);
                    this.DataFilters.CreateFromXml(child);
                    break;

                case "customheading":
                    if (!child.InnerText.Equals("(none)"))
                    {
                        this.Parameters.GadgetTitle = child.InnerText.Replace("&lt;", "<");
                        this.CustomOutputHeading    = child.InnerText.Replace("&lt;", "<");
                    }
                    else
                    {
                        this.CustomOutputHeading    = string.Empty;
                        this.Parameters.GadgetTitle = string.Empty;
                    }
                    break;

                case "customdescription":
                    if (!child.InnerText.Equals("(none)"))
                    {
                        this.CustomOutputDescription      = child.InnerText.Replace("&lt;", "<");
                        this.Parameters.GadgetDescription = child.InnerText.Replace("&lt;", "<");
                        if (!string.IsNullOrEmpty(CustomOutputDescription) && !CustomOutputHeading.Equals("(none)"))
                        {
                            descriptionPanel.Text      = CustomOutputDescription;
                            descriptionPanel.PanelMode = EpiDashboard.Controls.GadgetDescriptionPanel.DescriptionPanelMode.DisplayMode;
                        }
                        else
                        {
                            descriptionPanel.PanelMode = EpiDashboard.Controls.GadgetDescriptionPanel.DescriptionPanelMode.Collapsed;
                        }
                    }
                    break;
                }
            }

            base.CreateFromXml(element);

            this.LoadingCombos = false;

            RefreshResults();
            HideConfigPanel();
        }
        public override void CreateFromXml(XmlElement element)
        {
            this.LoadingCombos      = true;
            infoPanel.Visibility    = System.Windows.Visibility.Collapsed;
            messagePanel.Visibility = System.Windows.Visibility.Collapsed;

            if (element.Name.Equals("aberrationGadget") || element.Name.Equals("AberrationControl"))
            {
                CreateFromLegacyXml(element);
            }
            else
            {
                foreach (XmlElement child in element.ChildNodes)
                {
                    if (!string.IsNullOrEmpty(child.InnerText))
                    {
                        switch (child.Name.ToLowerInvariant())
                        {
                        case "mainvariable":
                            if (this.Parameters.ColumnNames.Count > 0)
                            {
                                ((AberrationDetectionChartParameters)Parameters).ColumnNames[0] = child.InnerText.Replace("&lt;", "<");
                            }
                            else
                            {
                                ((AberrationDetectionChartParameters)Parameters).ColumnNames.Add(child.InnerText.Replace("&lt;", "<"));
                            }
                            break;

                        case "stratavariable":
                            if (((AberrationDetectionChartParameters)Parameters).StrataVariableNames.Count > 0)
                            {
                                ((AberrationDetectionChartParameters)Parameters).StrataVariableNames[0] = child.InnerText.Replace("&lt;", "<");
                            }
                            else
                            {
                                ((AberrationDetectionChartParameters)Parameters).StrataVariableNames.Add(child.InnerText.Replace("&lt;", "<"));
                            }
                            break;

                        case "stratavariables":
                            foreach (XmlElement field in child.ChildNodes)
                            {
                                List <string> fields = new List <string>();
                                if (field.Name.ToLowerInvariant().Equals("stratavariable"))
                                {
                                    ((AberrationDetectionChartParameters)Parameters).StrataVariableNames.Add(field.InnerText.Replace("&lt;", "<"));
                                }
                            }
                            break;

                        case "weightvariable":
                            ((AberrationDetectionChartParameters)Parameters).WeightVariableName = child.InnerText.Replace("&lt;", "<");
                            break;

                        case "customheading":
                            if (!child.InnerText.Equals("(none)"))
                            {
                                this.Parameters.GadgetTitle = child.InnerText.Replace("&lt;", "<");
                                this.CustomOutputHeading    = child.InnerText.Replace("&lt;", "<");
                            }
                            else
                            {
                                this.CustomOutputHeading    = string.Empty;
                                this.Parameters.GadgetTitle = string.Empty;
                            }
                            break;

                        case "customdescription":
                            if (!child.InnerText.Equals("(none)"))
                            {
                                this.CustomOutputDescription      = child.InnerText.Replace("&lt;", "<");
                                this.Parameters.GadgetDescription = child.InnerText.Replace("&lt;", "<");
                                if (!string.IsNullOrEmpty(CustomOutputDescription) && !CustomOutputHeading.Equals("(none)"))
                                {
                                    descriptionPanel.Text      = CustomOutputDescription;
                                    descriptionPanel.PanelMode = EpiDashboard.Controls.GadgetDescriptionPanel.DescriptionPanelMode.DisplayMode;
                                }
                                else
                                {
                                    descriptionPanel.PanelMode = EpiDashboard.Controls.GadgetDescriptionPanel.DescriptionPanelMode.Collapsed;
                                }
                            }
                            break;

                        case "customcaption":
                            this.CustomOutputCaption = child.InnerText;
                            break;

                        case "datafilters":
                            this.DataFilters = new DataFilters(this.DashboardHelper);
                            this.DataFilters.CreateFromXml(child);
                            break;

                        case "width":
                            ((AberrationDetectionChartParameters)Parameters).ChartWidth = int.Parse(child.InnerText.Replace("&lt;", "<"));
                            break;

                        case "height":
                            ((AberrationDetectionChartParameters)Parameters).ChartHeight = int.Parse(child.InnerText.Replace("&lt;", "<"));
                            break;

                        case "charttitle":
                            ((AberrationDetectionChartParameters)Parameters).ChartTitle = child.InnerText.Replace("&lt;", "<");
                            break;

                        case "lagtime":
                            ((AberrationDetectionChartParameters)Parameters).LagTime = child.InnerText.Replace("&lt;", "<");
                            break;

                        case "deviations":
                            ((AberrationDetectionChartParameters)Parameters).Deviations = child.InnerText.Replace("&lt;", "<");
                            break;

                        case "timeperiod":
                            ((AberrationDetectionChartParameters)Parameters).TimePeriod = child.InnerText.Replace("&lt;", "<");
                            break;

                        case "yaxislabel":
                            ((AberrationDetectionChartParameters)Parameters).YAxisLabel = child.InnerText.Replace("&lt;", "<");
                            break;

                        case "xaxislabeltype":
                            ((AberrationDetectionChartParameters)Parameters).XAxisLabelType = int.Parse(child.InnerText);
                            break;

                        case "xaxislabel":
                            ((AberrationDetectionChartParameters)Parameters).XAxisLabel = child.InnerText;
                            break;

                        //EI-98
                        case "yaxislabelfontsize":
                            ((AberrationDetectionChartParameters)Parameters).YAxisLabelFontSize = double.Parse(child.InnerText);
                            break;

                        case "xaxislabelfontsize":
                            ((AberrationDetectionChartParameters)Parameters).XAxisLabelFontSize = double.Parse(child.InnerText);
                            break;

                        case "yaxisfontsize":
                            ((AberrationDetectionChartParameters)Parameters).YAxisFontSize = double.Parse(child.InnerText);
                            break;

                        case "xaxisfontsize":
                            ((AberrationDetectionChartParameters)Parameters).XAxisFontSize = double.Parse(child.InnerText);
                            break;
                        }
                    }
                }
            }

            base.CreateFromXml(element);

            this.LoadingCombos = false;
            RefreshResults();
            HideConfigPanel();
        }
        /// <summary>
        /// Converts the gadget's output to Html
        /// </summary>
        /// <returns></returns>
        public override string ToHTML(string htmlFileName = "", int count = 0)
        {
            StringBuilder htmlBuilder = new StringBuilder();

            CustomOutputHeading     = headerPanel.Text;
            CustomOutputDescription = descriptionPanel.Text;

            if (CustomOutputHeading == null || (string.IsNullOrEmpty(CustomOutputHeading) && !CustomOutputHeading.Equals("(none)")))
            {
                htmlBuilder.AppendLine("<h2 class=\"gadgetHeading\">Combined Frequency</h2>");
            }
            else if (CustomOutputHeading != "(none)")
            {
                htmlBuilder.AppendLine("<h2 class=\"gadgetHeading\">" + CustomOutputHeading + "</h2>");
            }

            htmlBuilder.AppendLine("<p class=\"gadgetOptions\"><small>");
            htmlBuilder.AppendLine("<em>Group variable:</em> <strong>" + cbxField.Text + "</strong>");
            htmlBuilder.AppendLine("<br />");

            if (cmbFieldStrata.SelectedIndex >= 0)
            {
                htmlBuilder.AppendLine("<em>Strata variable:</em> <strong>" + cmbFieldStrata.Text + "</strong>");
                htmlBuilder.AppendLine("<br />");
            }

            htmlBuilder.AppendLine("<em>Combine mode:</em> <strong>" + cmbCombineMode.Text + "</strong>");
            htmlBuilder.AppendLine("<br />");

            //htmlBuilder.AppendLine("<em>Include missing:</em> <strong>" + checkboxIncludeMissing.IsChecked.ToString() + "</strong>");
            //htmlBuilder.AppendLine("<br />");
            htmlBuilder.AppendLine("</small></p>");

            if (!string.IsNullOrEmpty(CustomOutputDescription))
            {
                htmlBuilder.AppendLine("<p class=\"gadgetsummary\">" + CustomOutputDescription + "</p>");
            }

            if (!string.IsNullOrEmpty(messagePanel.Text) && messagePanel.Visibility == System.Windows.Visibility.Visible)
            {
                htmlBuilder.AppendLine("<p><small><strong>" + messagePanel.Text + "</strong></small></p>");
            }

            if (!string.IsNullOrEmpty(infoPanel.Text) && infoPanel.Visibility == Visibility.Visible)
            {
                htmlBuilder.AppendLine("<p><small><strong>" + infoPanel.Text + "</strong></small></p>");
            }

            foreach (Grid grid in this.strataGridList)
            {
                string gridName = grid.Tag.ToString();

                htmlBuilder.AppendLine("<div style=\"height: 7px;\"></div>");
                htmlBuilder.AppendLine("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
                htmlBuilder.AppendLine("<caption>" + gridName + "</caption>");

                foreach (UIElement control in grid.Children)
                {
                    if (control is TextBlock)
                    {
                        int rowNumber    = Grid.GetRow(control);
                        int columnNumber = Grid.GetColumn(control);

                        string tableDataTagOpen  = "<td>";
                        string tableDataTagClose = "</td>";

                        if (rowNumber == 0)
                        {
                            tableDataTagOpen  = "<th>";
                            tableDataTagClose = "</th>";
                        }

                        if (columnNumber == 0)
                        {
                            if (((double)rowNumber) % 2.0 == 1)
                            {
                                htmlBuilder.AppendLine("<tr class=\"altcolor\">");
                            }
                            else
                            {
                                htmlBuilder.AppendLine("<tr>");
                            }
                        }
                        if (columnNumber == 0 && rowNumber > 0)
                        {
                            tableDataTagOpen = "<td class=\"value\">";
                        }

                        string value          = ((TextBlock)control).Text;
                        string formattedValue = value;

                        htmlBuilder.AppendLine(tableDataTagOpen + formattedValue + tableDataTagClose);

                        if (columnNumber >= grid.ColumnDefinitions.Count - 1)
                        {
                            htmlBuilder.AppendLine("</tr>");
                        }
                    }
                }

                htmlBuilder.AppendLine("</table>");
            }

            // TODO: Update if this gadget ever implements stratas
            foreach (UIElement element in panelMain.Children)
            {
                if (element is TextBlock)
                {
                    TextBlock tblock = element as TextBlock;
                    htmlBuilder.AppendLine("<p>");
                    htmlBuilder.AppendLine(tblock.Text);
                    htmlBuilder.AppendLine("</p>");
                }
            }

            return(htmlBuilder.ToString());
        }
        /// <summary>
        /// Creates the frequency gadget from an Xml element
        /// </summary>
        /// <param name="element">The element from which to create the gadget</param>
        public override void CreateFromXml(XmlElement element)
        {
            this.loadingCombos = true;

            foreach (XmlElement child in element.ChildNodes)
            {
                switch (child.Name.ToLower())
                {
                case "mainvariable":
                    cbxField.Text = child.InnerText;
                    break;

                case "stratavariable":
                    cmbFieldStrata.Text = child.InnerText;
                    break;

                case "truevalue":
                    txtTrueValue.Text = child.InnerText;
                    break;

                case "combinemode":
                    switch (child.InnerText.ToLower())
                    {
                    case "boolean":
                    case "bool":
                        cmbCombineMode.SelectedIndex = 1;
                        break;

                    case "categorical":
                        cmbCombineMode.SelectedIndex = 2;
                        break;

                    case "automatic":
                    case "auto":
                    default:
                        cmbCombineMode.SelectedIndex = 0;
                        break;
                    }
                    break;

                case "sort":
                    if (child.InnerText.ToLower().Equals("hightolow") || child.InnerText.ToLower().Equals("highlow"))
                    {
                        checkboxSortHighLow.IsChecked = true;
                    }
                    else
                    {
                        checkboxSortHighLow.IsChecked = false;
                    }
                    break;

                case "customheading":
                    if (!string.IsNullOrEmpty(child.InnerText) && !child.InnerText.Equals("(none)"))
                    {
                        this.CustomOutputHeading = child.InnerText.Replace("&lt;", "<");;
                    }
                    break;

                case "customdescription":
                    if (!string.IsNullOrEmpty(child.InnerText) && !child.InnerText.Equals("(none)"))
                    {
                        this.CustomOutputDescription = child.InnerText.Replace("&lt;", "<");

                        if (!string.IsNullOrEmpty(CustomOutputDescription) && !CustomOutputHeading.Equals("(none)"))
                        {
                            descriptionPanel.Text      = CustomOutputDescription;
                            descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.DisplayMode;
                        }
                        else
                        {
                            descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.Collapsed;
                        }
                    }
                    break;

                case "showdenominator":
                    bool showDenom = false;
                    bool.TryParse(child.InnerText, out showDenom);
                    checkboxShowDenominator.IsChecked = showDenom;
                    break;

                case "datafilters":
                    this.dataFilters = new DataFilters(this.dashboardHelper);
                    this.DataFilters.CreateFromXml(child);
                    break;
                }
            }

            SetPositionFromXml(element);

            this.loadingCombos = false;

            RefreshResults();
            HideConfigPanel();
        }
        /// <summary>
        /// Converts the gadget's output to Html
        /// </summary>
        /// <returns></returns>
        public override string ToHTML(string htmlFileName = "", int count = 0, bool useAlternatingColors = false)
        {
            if (IsCollapsed)
            {
                return(string.Empty);
            }

            StringBuilder htmlBuilder = new StringBuilder();

            CustomOutputHeading     = headerPanel.Text;
            CustomOutputDescription = descriptionPanel.Text;

            if (CustomOutputHeading == null || (string.IsNullOrEmpty(CustomOutputHeading) && !CustomOutputHeading.Equals("(none)")))
            {
                htmlBuilder.AppendLine("<h2 class=\"gadgetHeading\">Combined Frequency</h2>");
            }
            else if (CustomOutputHeading != "(none)")
            {
                htmlBuilder.AppendLine("<h2 class=\"gadgetHeading\">" + CustomOutputHeading + "</h2>");
            }

            htmlBuilder.AppendLine("<p class=\"gadgetOptions\"><small>");
            // TODO: Update this with columns selected
            //htmlBuilder.AppendLine("<em>Group variable:</em> <strong>" + GadgetOptions.MainVariableName + "</strong>");
            htmlBuilder.AppendLine("<br />");

            //if (cmbFieldStrata.SelectedIndex >= 0)
            //{
            //    htmlBuilder.AppendLine("<em>Strata variable:</em> <strong>" + cmbFieldStrata.Text + "</strong>");
            //    htmlBuilder.AppendLine("<br />");
            //}

            //htmlBuilder.AppendLine("<em>Combine mode:</em> <strong>" + cmbCombineMode.Text + "</strong>");
            htmlBuilder.AppendLine("<br />");
            htmlBuilder.AppendLine("</small></p>");

            if (!string.IsNullOrEmpty(CustomOutputDescription))
            {
                htmlBuilder.AppendLine("<p class=\"gadgetsummary\">" + CustomOutputDescription + "</p>");
            }

            if (!string.IsNullOrEmpty(messagePanel.Text) && messagePanel.Visibility == System.Windows.Visibility.Visible)
            {
                htmlBuilder.AppendLine("<p><small><strong>" + messagePanel.Text + "</strong></small></p>");
            }

            if (!string.IsNullOrEmpty(infoPanel.Text) && infoPanel.Visibility == Visibility.Visible)
            {
                htmlBuilder.AppendLine("<p><small><strong>" + infoPanel.Text + "</strong></small></p>");
            }

            DataGrid dg = GetDataGrid();

            if (dg != null && dg.ItemsSource != null)
            {
                htmlBuilder.AppendLine("<div style=\"height: 7px;\"></div>");
                htmlBuilder.AppendLine("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");

                htmlBuilder.AppendLine(Common.ConvertDataViewToHtmlString(dg.ItemsSource as DataView, useAlternatingColors));

                htmlBuilder.AppendLine("</table>");
            }
            // TODO: Update if this gadget ever implements stratas
            foreach (UIElement element in panelMain.Children)
            {
                if (element is TextBlock)
                {
                    TextBlock tblock = element as TextBlock;
                    htmlBuilder.AppendLine("<p>");
                    htmlBuilder.AppendLine(tblock.Text);
                    htmlBuilder.AppendLine("</p>");
                }
            }

            return(htmlBuilder.ToString());
        }
        /// <summary>
        /// Creates the frequency gadget from an Xml element
        /// </summary>
        /// <param name="element">The element from which to create the gadget</param>
        public override void CreateFromXml(XmlElement element)
        {
            this.LoadingCombos = true;
            this.Parameters    = new CombinedFrequencyParameters();

            HideConfigPanel();

            infoPanel.Visibility    = System.Windows.Visibility.Collapsed;
            messagePanel.Visibility = System.Windows.Visibility.Collapsed;

            foreach (XmlElement child in element.ChildNodes)
            {
                switch (child.Name.ToLowerInvariant())
                {
                case "mainvariable":
                    ((CombinedFrequencyParameters)Parameters).ColumnNames.Add(child.InnerText.Replace("&lt;", "<"));
                    break;

                case "groupfields":
                    foreach (XmlElement field in child.ChildNodes)
                    {
                        List <string> fields = new List <string>();
                        if (field.Name.ToLowerInvariant().Equals("groupfield"))
                        {
                            ((CombinedFrequencyParameters)Parameters).ColumnNames.Add(field.InnerText.Replace("&lt;", "<"));
                        }
                    }
                    break;

                case "combinemode":
                    if (!String.IsNullOrEmpty(child.InnerText.Trim()))
                    {
                        switch (child.InnerText.ToString().ToLowerInvariant())
                        {
                        case "boolean":
                            ((CombinedFrequencyParameters)Parameters).CombineMode = CombineModeTypes.Boolean;
                            break;

                        case "categorical":
                            ((CombinedFrequencyParameters)Parameters).CombineMode = CombineModeTypes.Categorical;
                            break;

                        case "automatic":
                        default:
                            ((CombinedFrequencyParameters)Parameters).CombineMode = CombineModeTypes.Automatic;
                            break;
                        }
                    }
                    break;

                case "truevalue":
                    //txtTrueValue.Text = child.InnerText;
                    if (!String.IsNullOrEmpty(child.InnerText.Trim()))
                    {
                        ((CombinedFrequencyParameters)Parameters).TrueValue = child.InnerText.Replace("&lt;", "<").ToString();
                    }
                    break;

                case "sort":
                    if (child.InnerText.ToLowerInvariant().Equals("hightolow") || child.InnerText.ToLowerInvariant().Equals("highlow"))
                    {
                        ((CombinedFrequencyParameters)Parameters).SortHighToLow = true;
                    }
                    else
                    {
                        ((CombinedFrequencyParameters)Parameters).SortHighToLow = false;
                    }
                    break;

                case "customheading":
                    if (!string.IsNullOrEmpty(child.InnerText) && !child.InnerText.Equals("(none)"))
                    {
                        this.CustomOutputHeading = child.InnerText.Replace("&lt;", "<");
                        Parameters.GadgetTitle   = CustomOutputHeading;
                    }
                    break;

                case "customdescription":
                    if (!string.IsNullOrEmpty(child.InnerText) && !child.InnerText.Equals("(none)"))
                    {
                        this.CustomOutputDescription = child.InnerText.Replace("&lt;", "<");
                        Parameters.GadgetDescription = CustomOutputDescription;
                        if (!string.IsNullOrEmpty(CustomOutputDescription) && !CustomOutputHeading.Equals("(none)"))
                        {
                            descriptionPanel.Text      = CustomOutputDescription;
                            descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.DisplayMode;
                        }
                        else
                        {
                            descriptionPanel.PanelMode = Controls.GadgetDescriptionPanel.DescriptionPanelMode.Collapsed;
                        }
                    }
                    break;

                case "showdenominator":
                    bool showDenom = false;
                    bool.TryParse(child.InnerText, out showDenom);
                    ((CombinedFrequencyParameters)Parameters).ShowDenominator = showDenom;
                    break;

                case "datafilters":
                    this.DataFilters = new DataFilters(this.DashboardHelper);
                    this.DataFilters.CreateFromXml(child);
                    break;
                }
            }

            base.CreateFromXml(element);

            this.LoadingCombos = false;

            RefreshResults();
            HideConfigPanel();
        }
        /// <summary>
        /// Converts the gadget's output to Html
        /// </summary>
        /// <returns></returns>
        public override string ToHTML(string htmlFileName = "", int count = 0, bool useAlternatingColors = false, bool ForWeb = false)
        {
            if (IsCollapsed)
            {
                return(string.Empty);
            }

            StringBuilder htmlBuilder = new StringBuilder();

            CustomOutputHeading     = headerPanel.Text;
            CustomOutputDescription = descriptionPanel.Text;

            if (CustomOutputHeading == null || (string.IsNullOrEmpty(CustomOutputHeading) && !CustomOutputHeading.Equals("(none)")))
            {
                htmlBuilder.AppendLine("<h2 class=\"gadgetHeading\">Combined Frequency</h2>");
            }
            else if (CustomOutputHeading != "(none)")
            {
                htmlBuilder.AppendLine("<h2 class=\"gadgetHeading\">" + CustomOutputHeading + "</h2>");
            }

            htmlBuilder.AppendLine("<p class=\"gadgetOptions\"><small>");
            // TODO: Update this with columns selected
            //htmlBuilder.AppendLine("<em>Group variable:</em> <strong>" + GadgetOptions.MainVariableName + "</strong>");
            htmlBuilder.AppendLine("<br />");

            //if (cmbFieldStrata.SelectedIndex >= 0)
            //{
            //    htmlBuilder.AppendLine("<em>Strata variable:</em> <strong>" + cmbFieldStrata.Text + "</strong>");
            //    htmlBuilder.AppendLine("<br />");
            //}

            //htmlBuilder.AppendLine("<em>Combine mode:</em> <strong>" + cmbCombineMode.Text + "</strong>");
            htmlBuilder.AppendLine("<br />");
            htmlBuilder.AppendLine("</small></p>");

            if (!string.IsNullOrEmpty(CustomOutputDescription))
            {
                htmlBuilder.AppendLine("<p class=\"gadgetsummary\">" + CustomOutputDescription + "</p>");
            }

            if (!string.IsNullOrEmpty(messagePanel.Text) && messagePanel.Visibility == System.Windows.Visibility.Visible)
            {
                htmlBuilder.AppendLine("<p><small><strong>" + messagePanel.Text + "</strong></small></p>");
            }

            if (!string.IsNullOrEmpty(infoPanel.Text) && infoPanel.Visibility == Visibility.Visible)
            {
                htmlBuilder.AppendLine("<p><small><strong>" + infoPanel.Text + "</strong></small></p>");
            }

            DataGrid dg = GetDataGrid();

            if (dg != null && dg.ItemsSource != null)
            {
                htmlBuilder.AppendLine("<div style=\"height: 7px;\"></div>");
                htmlBuilder.AppendLine("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");

                System.Data.DataTable sddt = ((System.Data.DataView)dg.ItemsSource).Table.Copy();
                System.Data.DataView  sddv = new System.Data.DataView(sddt);
                foreach (System.Data.DataRowView drv in sddv)
                {
                    try
                    {
                        double proportion = (double)drv.Row["Percent"];
                        drv.Row[2] = Math.Round(100.0 * proportion, 2);
                    }
                    catch (InvalidCastException excep) { continue; }
                    try
                    {
                        double llccll = (double)drv.Row["LCL"];
                        drv.Row[3] = Math.Round(100.0 * llccll, 2);
                    }
                    catch (InvalidCastException excep) { }
                    try
                    {
                        double uuccll = (double)drv.Row["UCL"];
                        drv.Row[4] = Math.Round(100.0 * uuccll, 2);
                    }
                    catch (InvalidCastException excep) { }
                }
                htmlBuilder.AppendLine(Common.ConvertDataViewToHtmlString(sddv as DataView, useAlternatingColors));

                htmlBuilder.AppendLine("</table>");
            }
            // TODO: Update if this gadget ever implements stratas
            foreach (UIElement element in panelMain.Children)
            {
                if (element is TextBlock)
                {
                    TextBlock tblock = element as TextBlock;
                    htmlBuilder.AppendLine("<p>");
                    htmlBuilder.AppendLine(tblock.Text);
                    htmlBuilder.AppendLine("</p>");
                }
            }

            return(htmlBuilder.ToString());
        }