Esempio n. 1
0
        private void InitializeCharQuantificationControls()
        {
            // NOTE:
            // All values are displayed in a single DropDown for now (single selection only)
            // Will need to account for cardinality and have complex logic to show/hide/enable various controls depending on the cardinality values

            var selectionItems = new List <ComparableListItem>();

            ComparableListItem selectedItem = null;
            ComparableListItem defaultItem  = null;

            if (CharacteristicQuantification.NonQuantifiables != null && CharacteristicQuantification.NonQuantifiables.Count > 0)
            {
                // Hide blank list box item
                //selectionItems.Add(new CodeSequenceListItem(null));

                foreach (var nonQuantifiable in CharacteristicQuantification.NonQuantifiables)
                {
                    var listItem = new CodeSequenceListItem(
                        new StandardCodedTerm(
                            nonQuantifiable.DefaultAnswer,
                            nonQuantifiable.NextId,
                            nonQuantifiable.NoMoreQuestions,
                            nonQuantifiable.CodeValue,
                            nonQuantifiable.CodeMeaning,
                            nonQuantifiable.CodingSchemeDesignator,
                            nonQuantifiable.CodingSchemeVersion));
                    selectionItems.Add(listItem);

                    if (CharacteristicQuantification.SelectedNonQuantifiable != null && listItem.Value.Equals(CharacteristicQuantification.SelectedNonQuantifiable))
                    {
                        selectedItem = listItem;
                    }
                    else if (nonQuantifiable.DefaultAnswer)
                    {
                        defaultItem = listItem;
                    }
                }
            }

            switch (CharacteristicQuantificationType)
            {
            case CharacteristicQuantificationTypes.Numerical:
            {
                var numericalQuantification =
                    CharacteristicQuantification as
                    AimTemplateTreeNumericalQuantification;
                foreach (var numerical in numericalQuantification.Numericals)
                {
                    var listItem = new NumericalListItem(numerical);
                    selectionItems.Add(listItem);
                    if (numericalQuantification.SelectedNumerical != null && numericalQuantification.SelectedNumerical.Value.Equals(numerical))
                    {
                        selectedItem = listItem;
                    }
                    else if (numerical.DefaultAnswer)
                    {
                        defaultItem = listItem;
                    }
                }
            }
            break;

            case CharacteristicQuantificationTypes.Quantile:
            {
                var quantileQuantification =
                    CharacteristicQuantification as AimTemplateTreeQuantileQuantification;
                for (int i = 0; i < quantileQuantification.Quantile.Bins; i++)
                {
                    var listItem = new QuantileListItem(i);
                    selectionItems.Add(listItem);
                    if (quantileQuantification.SelectedBin != null && quantileQuantification.SelectedBin == i)
                    {
                        selectedItem = listItem;
                    }
                    else if (quantileQuantification.Quantile.DefaultBin != null && quantileQuantification.Quantile.DefaultBin.Value == i)
                    {
                        defaultItem = listItem;
                    }
                }
            }
            break;

            case CharacteristicQuantificationTypes.Scale:
            {
                var scale =
                    CharacteristicQuantification as AimTemplateTreeScaleQuantification;

                foreach (var scaleLevel in scale.Scale.ScaleLevels)
                {
                    var listItem = new ScaleListItem(scaleLevel);
                    selectionItems.Add(listItem);
                    if (scale.SelectedScaleLevel != null && scale.SelectedScaleLevel.Equals(scaleLevel))
                    {
                        selectedItem = listItem;
                    }
                    else if (scaleLevel.DefaultAnswer)
                    {
                        defaultItem = listItem;
                    }
                }
            }
            break;

            case CharacteristicQuantificationTypes.Interval:
            {
                var intervalQuantification =
                    CharacteristicQuantification as AimTemplateTreeIntervalQuantification;
                foreach (var interval in intervalQuantification.Intervals)
                {
                    var listItem = new IntervalListItem(interval);
                    selectionItems.Add(listItem);
                    if (intervalQuantification.SelectedInterval != null && intervalQuantification.SelectedInterval.Equals(interval))
                    {
                        selectedItem = listItem;
                    }
                    else if (interval.DefaultAnswer)
                    {
                        defaultItem = listItem;
                    }
                }
            }
            break;

            case CharacteristicQuantificationTypes.NonQuantifiable:
                break;     // all done
            }

            // FIXME
            // A single DropDown for now for all items
            //

            var ddlQuantificationItems = new ComboBox();


            foreach (object item in selectionItems)
            {
                ddlQuantificationItems.Items.Add(item);
            }

            if (selectedItem != null)
            {
                ddlQuantificationItems.SelectedItem = selectedItem;
            }

            ddlQuantificationItems.SelectionChanged += QuantificationItemsSelectionChanged;

            if (selectedItem == null && ddlQuantificationItems.Items.Count == 1)
            {
                defaultItem         = (ComparableListItem)ddlQuantificationItems.Items[0];
                defaultItem.Default = true;
            }

            // Add control
            _stackPanel.Children.Add(ddlQuantificationItems);
            _quantificationControl = ddlQuantificationItems;
        }
        private void InitializeCharQuantificationControls()
        {
            // NOTE:
            // All values are displayed in a single DropDown for now (single selection only)
            // Will need to account for cardinality and have complex logic to show/hide/enable various controls depending on the cardinality values

            var selectionItems = new List<ComparableListItem>();

            ComparableListItem selectedItem = null;
            ComparableListItem defaultItem = null;

            if (CharacteristicQuantification.NonQuantifiables != null && CharacteristicQuantification.NonQuantifiables.Count > 0)
            {
                // Hide blank list box item
                //selectionItems.Add(new CodeSequenceListItem(null));

                foreach (var nonQuantifiable in CharacteristicQuantification.NonQuantifiables)
                {
                    var listItem = new CodeSequenceListItem(
                        new StandardCodedTerm(
                            nonQuantifiable.DefaultAnswer,
                            nonQuantifiable.NextId,
                            nonQuantifiable.NoMoreQuestions,
                            nonQuantifiable.CodeValue,
                            nonQuantifiable.CodeMeaning,
                            nonQuantifiable.CodingSchemeDesignator,
                            nonQuantifiable.CodingSchemeVersion));
                    selectionItems.Add(listItem);

                    if (CharacteristicQuantification.SelectedNonQuantifiable != null && listItem.Value.Equals(CharacteristicQuantification.SelectedNonQuantifiable))
                        selectedItem = listItem;
                    else if (nonQuantifiable.DefaultAnswer)
                        defaultItem = listItem;
                }
            }

            switch (CharacteristicQuantificationType)
            {
                case CharacteristicQuantificationTypes.Numerical:
                    {
                        var numericalQuantification =
                            CharacteristicQuantification as
                            AimTemplateTreeNumericalQuantification;
                        foreach (var numerical in numericalQuantification.Numericals)
                        {
                            var listItem = new NumericalListItem(numerical);
                            selectionItems.Add(listItem);
                            if (numericalQuantification.SelectedNumerical != null && numericalQuantification.SelectedNumerical.Value.Equals(numerical))
                                selectedItem = listItem;
                            else if (numerical.DefaultAnswer)
                                defaultItem = listItem;
                        }
                    }
                    break;
                case CharacteristicQuantificationTypes.Quantile:
                    {
                        var quantileQuantification =
                            CharacteristicQuantification as AimTemplateTreeQuantileQuantification;
                        for (int i = 0; i < quantileQuantification.Quantile.Bins; i++)
                        {
                            var listItem = new QuantileListItem(i);
                            selectionItems.Add(listItem);
                            if (quantileQuantification.SelectedBin != null && quantileQuantification.SelectedBin == i)
                                selectedItem = listItem;
                            else if (quantileQuantification.Quantile.DefaultBin != null && quantileQuantification.Quantile.DefaultBin.Value == i)
                                defaultItem = listItem;
                        }
                    }
                    break;
                case CharacteristicQuantificationTypes.Scale:
                    {
                        var scale =
                            CharacteristicQuantification as AimTemplateTreeScaleQuantification;

                        foreach (var scaleLevel in scale.Scale.ScaleLevels)
                        {
                            var listItem = new ScaleListItem(scaleLevel);
                            selectionItems.Add(listItem);
                            if (scale.SelectedScaleLevel != null && scale.SelectedScaleLevel.Equals(scaleLevel))
                                selectedItem = listItem;
                            else if (scaleLevel.DefaultAnswer)
                                defaultItem = listItem;
                        }
                    }
                    break;
                case CharacteristicQuantificationTypes.Interval:
                    {
                        var intervalQuantification =
                            CharacteristicQuantification as AimTemplateTreeIntervalQuantification;
                        foreach (var interval in intervalQuantification.Intervals)
                        {
                            var listItem = new IntervalListItem(interval);
                            selectionItems.Add(listItem);
                            if (intervalQuantification.SelectedInterval != null && intervalQuantification.SelectedInterval.Equals(interval))
                                selectedItem = listItem;
                            else if (interval.DefaultAnswer)
                                defaultItem = listItem;
                        }
                    }
                    break;
                case CharacteristicQuantificationTypes.NonQuantifiable:
                    break; // all done
            }

            // FIXME
            // A single DropDown for now for all items
            //

            var ddlQuantificationItems = new ComboBox();

            foreach (object item in selectionItems)
            {
                ddlQuantificationItems.Items.Add(item);
            }

            if (selectedItem != null)
                ddlQuantificationItems.SelectedItem = selectedItem;

            ddlQuantificationItems.SelectionChanged += QuantificationItemsSelectionChanged;

            if (selectedItem == null && ddlQuantificationItems.Items.Count == 1)
            {
                defaultItem = (ComparableListItem)ddlQuantificationItems.Items[0];
                defaultItem.Default = true;
            }

            // Add control
            _stackPanel.Children.Add(ddlQuantificationItems);
            _quantificationControl = ddlQuantificationItems;
        }