public CrosstabProperties(
            DashboardHelper dashboardHelper,
            IGadget gadget,
            CrosstabParameters parameters,
            List <Grid> strataGridList
            )
        {
            InitializeComponent();
            this.DashboardHelper = dashboardHelper;
            this.Gadget          = gadget;
            this.Parameters      = parameters;
            this.StrataGridList  = strataGridList;

            List <string> fields       = new List <string>();
            List <string> weightFields = new List <string>();
            List <string> strataItems  = new List <string>();

            //Variable fields
            fields.Add(String.Empty);
            ColumnDataType columnDataType = ColumnDataType.Boolean | ColumnDataType.DateTime | ColumnDataType.Numeric | ColumnDataType.Text | ColumnDataType.UserDefined;

            foreach (string fieldName in DashboardHelper.GetFieldsAsList(columnDataType))
            {
                if (DashboardHelper.IsUsingEpiProject)
                {
                    if (!(fieldName == "RecStatus"))
                    {
                        fields.Add(fieldName);
                    }
                }
                else
                {
                    fields.Add(fieldName);
                }
            }

            if (fields.Contains("SYSTEMDATE"))
            {
                fields.Remove("SYSTEMDATE");
            }

            //Weight Fields
            weightFields.Add(String.Empty);
            columnDataType = ColumnDataType.Numeric | ColumnDataType.UserDefined;
            foreach (string fieldName in DashboardHelper.GetFieldsAsList(columnDataType))
            {
                if (DashboardHelper.IsUsingEpiProject)
                {
                    if (!(fieldName == "RecStatus"))
                    {
                        weightFields.Add(fieldName);
                    }
                }
                else
                {
                    weightFields.Add(fieldName);
                }
            }
            weightFields.Sort();

            //Strata Fields
            strataItems.Add(String.Empty);
            columnDataType = ColumnDataType.Numeric | ColumnDataType.Boolean | ColumnDataType.Text | ColumnDataType.UserDefined;
            foreach (string fieldName in DashboardHelper.GetFieldsAsList(columnDataType))
            {
                if (DashboardHelper.IsUsingEpiProject)
                {
                    if (!(fieldName == "RecStatus" || fieldName == "FKEY" || fieldName == "GlobalRecordId"))
                    {
                        strataItems.Add(fieldName);
                    }
                }
                else
                {
                    strataItems.Add(fieldName);
                }
            }

            if (DashboardHelper.IsUsingEpiProject)
            {
                if (fields.Contains("RecStatus"))
                {
                    fields.Remove("RecStatus");
                }
                if (weightFields.Contains("RecStatus"))
                {
                    weightFields.Remove("RecStatus");
                }

                if (strataItems.Contains("RecStatus"))
                {
                    strataItems.Remove("RecStatus");
                }
                if (strataItems.Contains("FKEY"))
                {
                    strataItems.Remove("FKEY");
                }
                if (strataItems.Contains("GlobalRecordId"))
                {
                    strataItems.Remove("GlobalRecordId");
                }
            }

            List <string> allFieldNames = new List <string>();

            allFieldNames.AddRange(fields);
            allFieldNames.AddRange(DashboardHelper.GetAllGroupsAsList());

            cbxExposureField.ItemsSource = allFieldNames;
            cbxOutcomeField.ItemsSource  = fields;
            cbxFieldWeight.ItemsSource   = weightFields;
            lbxFieldStrata.ItemsSource   = strataItems;

            if (cbxExposureField.Items.Count > 0)
            {
                cbxExposureField.SelectedIndex = -1;
                cbxOutcomeField.SelectedIndex  = -1;
            }

            if (cbxFieldWeight.Items.Count > 0)
            {
                cbxFieldWeight.SelectedIndex = -1;
            }

            CollectionView           view             = (CollectionView)CollectionViewSource.GetDefaultView(cbxExposureField.ItemsSource);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription("VariableCategory");

            view.GroupDescriptions.Add(groupDescription);

            RowFilterControl = new RowFilterControl(this.DashboardHelper, Dialogs.FilterDialogMode.ConditionalMode, (gadget as CrosstabControl).DataFilters, true);
            RowFilterControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            panelFilters.Children.Add(RowFilterControl);

            txtMaxColumnLength.PreviewKeyDown += new KeyEventHandler(txtInput_PositiveIntegerOnly_PreviewKeyDown);

            #region Translation

            lblConfigExpandedTitleTxt.Text = DashboardSharedStrings.GADGET_CONFIG_TITLE_CROSSTABULATION;

            tbtnVariables.Title          = DashboardSharedStrings.GADGET_TABBUTTON_VARIABLES;
            tbtnVariables.Description    = DashboardSharedStrings.GADGET_TABDESC_EXPOSURE_OUTCOME;
            tbtnValueMapping.Title       = DashboardSharedStrings.GADGET_22_VALUE_MAPPING;
            tbtnValueMapping.Description = DashboardSharedStrings.GADGET_SPECIFY_EXPOSURE_OUTCOME;
            tbtnDisplay.Title            = DashboardSharedStrings.GADGET_TABBUTTON_DISPLAY;
            tbtnDisplay.Description      = DashboardSharedStrings.GADGET_TABDESC_DISPLAY;
            tbtnDisplas.Title            = DashboardSharedStrings.GADGET_TAB_COLORS_STYLES;
            tbtnDisplas.Description      = DashboardSharedStrings.GADGET_TABDESC_COLORS_STYLES;
            tbtnFilters.Title            = DashboardSharedStrings.GADGET_TABBUTTON_FILTERS;
            tbtnFilters.Description      = DashboardSharedStrings.GADGET_TABDESC_FILTERS;

            tblockPanelVariablesTxt.Text      = DashboardSharedStrings.GADGET_PANELHEADER_VARIABLES;
            tblockPanelValueMappingTxt.Text   = DashboardSharedStrings.GADGET_VALUE_MAPPING;
            tblockPanelDisplayTxt.Text        = DashboardSharedStrings.GADGET_PANELHEADER_DISPLAY;
            tblockPanelColorStyleTxt.Text     = DashboardSharedStrings.GADGET_PANEL_COLORS_STYLES;
            tblockPanelDataFilterTxt.Text     = DashboardSharedStrings.GADGET_PANELHEADER_DATA_FILTER;
            tblockExposureField.Text          = DashboardSharedStrings.GADGET_EXPOSURE_VARIABLE;
            tblockOutcomeField.Text           = DashboardSharedStrings.GADGET_OUTCOME_VARIABLE;
            tblockWeightVariable.Text         = DashboardSharedStrings.GADGET_WEIGHT_VARIABLE;
            tblockStrataVariable.Text         = DashboardSharedStrings.GADGET_STRATA_VARIABLE;
            tblockAllValues.Text              = DashboardSharedStrings.GADGET_ALL_VALUES;
            tblockYesValues.Text              = DashboardSharedStrings.GADGET_YES_VALUES;
            tblockNoValues.Text               = DashboardSharedStrings.GADGET_NO_VALUES;
            tblockTitleNDescSubheaderTxt.Text = DashboardSharedStrings.GADGET_PANELSUBHEADER_TITLENDESC;
            tblockTitleTxt.Text               = DashboardSharedStrings.GADGET_GADET_TITLE;
            tblockDescTxt.Text           = DashboardSharedStrings.GADGET_DESCRIPTION;
            tblockPanelOutputOptTxt.Text = DashboardSharedStrings.GADGET_OUTPUT_OPTIONS;

            checkboxAllValuesTxt.Text          = DashboardSharedStrings.GADGET_DISPLAY_LIST_VALUE;
            checkboxCommentLegalLabelsTxt.Text = DashboardSharedStrings.GADGET_LIST_LABELS;
            checkboxUsePromptsTxt.Text         = DashboardSharedStrings.GADGET_USE_FIELD_PROMPTS;
            checkboxIncludeMissingTxt.Text     = DashboardSharedStrings.GADGET_INCLUDE_MISSING;
            checkboxOutcomeContinuousTxt.Text  = DashboardSharedStrings.GADGET_OUTCOME_CONTINUOUS;
            checkboxSmartTableTxt.Text         = DashboardSharedStrings.GADGET_SMART_2X2;
            checkboxStrataSummaryOnlyTxt.Text  = DashboardSharedStrings.GADGET_STRATA_SUMMARY_ONLY;
            checkboxDisplayChiSqTxt.Text       = DashboardSharedStrings.GADGET_DISPLAY_CHISQUARE;
            checkboxRowColPercentsTxt.Text     = DashboardSharedStrings.GADGET_ROW_COL_PERCENTS;
            checkboxHorizontalTxt.Text         = DashboardSharedStrings.GADGET_DISPLAY_2X2_SUMMARY_HORIZONTALLY;

            tblockMaxColumnLength.Text         = DashboardSharedStrings.GADGET_MAX_COL_NAME_LENGTH;
            checkboxConditionalShadingTxt.Text = DashboardSharedStrings.GADGET_USE_CONDITIONAL_CELL_SHADING;
            tblockColorGradient.Text           = DashboardSharedStrings.GADGET_COLOR_GRADIENT;
            tblockTooltipLowColor.Content      = DashboardSharedStrings.GADGET_LOW_VALUE_COLOR;
            tblockTooltipHighColor.Content     = DashboardSharedStrings.GADGET_HIGH_VALUE_COLOR;
            tblockBreakType.Text = DashboardSharedStrings.GADGET_BREAK_TYPE;
            tblockBreak1.Text    = DashboardSharedStrings.GADGET_BREAK1;
            tblockBreak2.Text    = DashboardSharedStrings.GADGET_BREAK2;
            tblockBreak3.Text    = DashboardSharedStrings.GADGET_BREAK3;
            tblockBreak4.Text    = DashboardSharedStrings.GADGET_BREAK4;
            tblockBreak5.Text    = DashboardSharedStrings.GADGET_BREAK5;
            tblockAnyFilterGadgetOnlyTxt.Text = DashboardSharedStrings.GADGET_FILTER_GADGET_ONLY;
            btnOKTxt.Text                 = DashboardSharedStrings.BUTTON_OK;
            btnCancelTxt.Text             = DashboardSharedStrings.BUTTON_CANCEL;
            tblockColorsSubheaderTxt.Text = DashboardSharedStrings.GADGET_PANELSUBHEADER_COLORS;
            tblockStylesSubheaderTxt.Text = DashboardSharedStrings.GADGET_PANELSUBHEADER_STYLES;
            ////expanderAdvancedOptions.Header = DashboardSharedStrings.GADGET_ADVANCED_OPTIONS;
            ////expanderDisplayOptions.Header = DashboardSharedStrings.GADGET_DISPLAY_OPTIONS;
            //tblockMainVariable.Text = DashboardSharedStrings.GADGET_FREQUENCY_VARIABLE;
            //tblockStrataVariable.Text = DashboardSharedStrings.GADGET_STRATA_VARIABLE;
            //tblockWeightVariable.Text = DashboardSharedStrings.GADGET_WEIGHT_VARIABLE;

            ////checkboxAllValues.Content = DashboardSharedStrings.GADGET_ALL_LIST_VALUES;
            ////checkboxCommentLegalLabels.Content = DashboardSharedStrings.GADGET_LIST_LABELS;
            //checkboxIncludeMissing.Content = DashboardSharedStrings.GADGET_INCLUDE_MISSING;

            //checkboxSortHighLow.Content = DashboardSharedStrings.GADGET_SORT_HI_LOW;
            //checkboxUsePrompts.Content = DashboardSharedStrings.GADGET_USE_FIELD_PROMPTS;
            ////tblockOutputColumns.Text = DashboardSharedStrings.GADGET_OUTPUT_COLUMNS_DISPLAY;
            ////tblockPrecision.Text = DashboardSharedStrings.GADGET_DECIMALS_TO_DISPLAY;

            //tblockRows.Text = DashboardSharedStrings.GADGET_MAX_ROWS_TO_DISPLAY;
            //tblockBarWidth.Text = DashboardSharedStrings.GADGET_MAX_PERCENT_BAR_WIDTH;

            ////btnRun.Content = DashboardSharedStrings.GADGET_RUN_BUTTON;
            #endregion // Translation
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.DashboardHelper = DashboardHelper;
            CrosstabParameters crosstabParameters = (CrosstabParameters)Parameters;

            rctLowColor.Fill  = crosstabParameters.LoColorFill;
            rctHighColor.Fill = crosstabParameters.HiColorFill;

            //Variables settings
            if (Parameters.ColumnNames.Count > 0)
            {
                cbxExposureField.SelectedItem = Parameters.ColumnNames[0];
            }
            cbxOutcomeField.SelectedItem        = Parameters.CrosstabVariableName;
            cbxFieldWeight.SelectedItem         = Parameters.WeightVariableName;
            lbxFieldStrata.MaxHeight            = lbxFieldStrata.MaxHeight + (System.Windows.SystemParameters.PrimaryScreenHeight - 868.0);
            scrollViewerStrataProperties.Height = scrollViewerStrataProperties.Height + (Math.Max(0, System.Windows.SystemParameters.PrimaryScreenHeight - 768.0));
            if (Parameters.StrataVariableNames.Count > 0)
            {
                foreach (string s in Parameters.StrataVariableNames)
                {
                    //lbxFieldStrata.SelectedItem = s;
                    lbxFieldStrata.SelectedItems.Add(s.ToString());
                }
            }

            //2 x 2 Value mapping settings
            Update2x2ValueMappings();
            if (crosstabParameters.ColumnNames.Count > 0)
            {
                //foreach (string s in yesValues)
                foreach (string s in crosstabParameters.YesValues)
                {
                    if (lbxAllValues.Items.Contains(s))
                    {
                        lbxYesValues.Items.Add(s);
                        lbxAllValues.Items.Remove(s);
                    }
                }

                foreach (string s in crosstabParameters.NoValues)
                {
                    if (lbxAllValues.Items.Contains(s))
                    {
                        lbxNoValues.Items.Add(s);
                        lbxAllValues.Items.Remove(s);
                    }
                }
            }

            //Display settings
            txtTitle.Text = Parameters.GadgetTitle;
            txtDesc.Text  = Parameters.GadgetDescription;
            checkboxAllValues.IsChecked          = Parameters.ShowAllListValues;
            checkboxUsePrompts.IsChecked         = Parameters.UsePromptsForColumnNames; //Ei-83
            checkboxCommentLegalLabels.IsChecked = Parameters.ShowCommentLegalLabels;
            checkboxIncludeMissing.IsChecked     = Parameters.IncludeMissing;
            checkboxOutcomeContinuous.IsChecked  = crosstabParameters.TreatOutcomeAsContinuous;
            checkboxSmartTable.IsChecked         = crosstabParameters.SmartTable;
            checkboxStrataSummaryOnly.IsChecked  = crosstabParameters.StrataSummaryOnly;
            checkboxDisplayChiSq.IsChecked       = crosstabParameters.DisplayChiSq; //EI-146
            checkboxRowColPercents.IsChecked     = crosstabParameters.ShowPercents;
            checkboxHorizontal.IsChecked         = crosstabParameters.HorizontalDisplayMode;
            txtMaxColumnLength.Text = crosstabParameters.MaxColumnNameLength;

            //Color and style settings
            checkboxConditionalShading.IsChecked = crosstabParameters.ConditionalShading;

            //color gradient
            cmbBreakType.SelectedIndex = int.Parse(crosstabParameters.BreakType.ToString());
            if (!String.IsNullOrEmpty(crosstabParameters.Break1))
            {
                txtPct1.Text = crosstabParameters.Break1;
            }
            else
            {
                txtPct1.Text = "0";
            }
            if (!String.IsNullOrEmpty(crosstabParameters.Break2))
            {
                txtPct2.Text = crosstabParameters.Break2;
            }
            else
            {
                txtPct2.Text = "20";
            }
            if (!String.IsNullOrEmpty(crosstabParameters.Break3))
            {
                txtPct3.Text = crosstabParameters.Break3;
            }
            else
            {
                txtPct3.Text = "40";
            }
            if (!String.IsNullOrEmpty(crosstabParameters.Break4))
            {
                txtPct4.Text = crosstabParameters.Break4;
            }
            else
            {
                txtPct4.Text = "60";
            }
            if (!String.IsNullOrEmpty(crosstabParameters.Break5))
            {
                txtPct5.Text = crosstabParameters.Break5;
            }
            else
            {
                txtPct5.Text = "80";
            }

            CheckVariables();
        }