public InferenceWpfControl(AimTemplateTreeInferenceNode inference)
        {
            Inference = inference;
            InitializeComponent();

            _originalBackground = Background;

            // Hide the allowed terms control that is not being used
            if (MaxNumberOfAnswers > 1)
            {
                _comboBox.Visibility = Visibility.Hidden;
                _comboBox.Height     = 0;

                var cardinalityString = String.Empty;

                if (Inference.MinCardinality > 0 && Inference.MaxCardinality >= Inference.AllowedTerms.Count)
                {
                    cardinalityString = "Select at least " + Inference.MinCardinality;
                }
                else if (Inference.MaxCardinality < Inference.AllowedTerms.Count && Inference.MinCardinality <= 0)
                {
                    cardinalityString = "Select less than " + (Inference.MaxCardinality + 1);
                }
                else if (Inference.MinCardinality > 0 && Inference.MaxCardinality < Inference.AllowedTerms.Count)
                {
                    cardinalityString = "Select at least " + Inference.MinCardinality + " and less than " +
                                        (Inference.MaxCardinality + 1);
                }

                if (!String.IsNullOrEmpty(cardinalityString))
                {
                    ((TextBlock)_label.Content).Text += Environment.NewLine + cardinalityString;
                }
            }
            else
            {
                _itemsControl.Visibility = Visibility.Hidden;
                _itemsControl.Height     = 0;
            }

            // Add confidence control
            if (Inference.ShouldDisplay && Inference.HasConfidence)
            {
                NodeConfidenceWpfControl = new NodeConfidenceWpfControl(Inference);
                _stackPanel.Children.Add(NodeConfidenceWpfControl);
            }

            Loaded += InferenceWpfControlLoaded;

            Inference.SelectedAllowedTermsChanged += SelectedAllowedTermsCollectionChanged;
            CheckBoxControls = new Dictionary <AimTemplateTreeAllowedTerm, CheckBox>();

            if (!Inference.ShouldDisplay)
            {
                this.Visibility = Visibility.Hidden;
                this.Height     = 0;
            }
        }
Ejemplo n.º 2
0
        private AimTemplateTreeInferenceNode AimTemplateTreeInferenceNodeFromXsdInference(TemplateComponent component, TemplateComponentInference inference)
        {
            var allowedTerms = new List <AimTemplateTreeAllowedTerm>();

            for (int index = 0; index < component.Items.Length; index++)
            {
                object item = component.Items[index];
                if (item.GetType() == typeof(TemplateComponentAllowedTerm))
                {
                    var term = AllowedTermFromXsdAllowedTerm((TemplateComponentAllowedTerm)item);
                    if (term != null)
                    {
                        term.PresentationIndex = index;
                        allowedTerms.Add(term);
                    }
                }
            }

            int itemNumber;

            int.TryParse(component.itemNumber, out itemNumber);

            int minCardinality;

            int.TryParse(component.minCardinality, out minCardinality);

            int maxCardinality;

            int.TryParse(component.maxCardinality, out maxCardinality);

            string label = component.label;

            if (component.QuestionType != null)
            {
                label = component.QuestionType.codeMeaning;
            }

            var node = new AimTemplateTreeInferenceNode(
                label,
                itemNumber,
                component.explanatoryText,
                minCardinality,
                maxCardinality,
                component.shouldDisplay,
                component.groupLabel,
                ValidTermFromXsdValidTerm(component.QuestionType),
                inference.annotatorConfidence,
                allowedTerms,
                component.id
                );

            return(node);
        }
        private AimTemplateTreeInferenceNode AimTemplateTreeInferenceNodeFromXsdInference(TemplateComponent component, TemplateComponentInference inference)
        {
            var allowedTerms = new List<AimTemplateTreeAllowedTerm>();
            for (int index = 0; index < component.Items.Length; index++)
            {
                object item = component.Items[index];
                if (item.GetType() == typeof(TemplateComponentAllowedTerm))
                {
                    var term = AllowedTermFromXsdAllowedTerm((TemplateComponentAllowedTerm)item);
                    if (term != null)
                    {
                        term.PresentationIndex = index;
                        allowedTerms.Add(term);
                    }
                }
            }

            int itemNumber;
            int.TryParse(component.itemNumber, out itemNumber);

            int minCardinality;
            int.TryParse(component.minCardinality, out minCardinality);

            int maxCardinality;
            int.TryParse(component.maxCardinality, out maxCardinality);

            string label = component.label;
            if (component.QuestionType != null)
                label = component.QuestionType.codeMeaning;

            var node = new AimTemplateTreeInferenceNode(
                label,
                itemNumber,
                component.explanatoryText,
                minCardinality,
                maxCardinality,
                component.shouldDisplay,
                component.groupLabel,
                ValidTermFromXsdValidTerm(component.QuestionType),
                inference.annotatorConfidence,
                allowedTerms,
                component.id
                );
            return node;
        }