Пример #1
0
        void SelectedAllowedTermsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (var item in e.NewItems)
                {
                    var term = item as CharacteristicQuantificationAllowedTerm;
                    if (term != null && CheckBoxControls.ContainsKey(term))
                    {
                        CheckBoxControls[term].IsChecked = true;
                    }
                }
            }

            if (e.OldItems != null)
            {
                foreach (var item in e.OldItems)
                {
                    var term = item as CharacteristicQuantificationAllowedTerm;
                    if (term != null && CheckBoxControls.ContainsKey(term))
                    {
                        CheckBoxControls[term].IsChecked = false;
                    }
                }
            }

            if (Characteristic.SelectedCharacteristicQuantificationAllowedTerms.Count > 0)
            {
                _comboBox.SelectedItem = Characteristic.SelectedCharacteristicQuantificationAllowedTerms[0];
            }

            ClearQuantificationDetailsControls();

            foreach (var term in Characteristic.SelectedCharacteristicQuantificationAllowedTerms)
            {
                foreach (var quantification in term.CharacteristicQuantifications)
                {
                    var characteristicControl = new CharacteristicQuantificationDetailsWpfControl(quantification);
                    _stackPanel.Children.Add(characteristicControl);
                }
            }
        }
Пример #2
0
        public AnatomicEntityCharacteristicWpfControl(AimTemplateTreeAnatomicEntityCharacteristicNode characteristic)
        {
            Characteristic = characteristic;
            InitializeComponent();

            ChildControls = new List <IValidTreeControl>();

            _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 (Characteristic.MinCardinality > 0 && Characteristic.MaxCardinality >= Characteristic.CharacteristicQuantificationAllowedTerms.Count)
                {
                    cardinalityString = "Select at least " + Characteristic.MinCardinality;
                }
                else if (Characteristic.MaxCardinality < Characteristic.CharacteristicQuantificationAllowedTerms.Count && Characteristic.MinCardinality <= 0)
                {
                    cardinalityString = "Select less than " + (Characteristic.MaxCardinality + 1);
                }
                else if (Characteristic.MinCardinality > 0 && Characteristic.MaxCardinality < Characteristic.CharacteristicQuantificationAllowedTerms.Count)
                {
                    cardinalityString = "Select at least " + Characteristic.MinCardinality + " and less than " +
                                        (Characteristic.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 (Characteristic.ShouldDisplay && Characteristic.HasConfidence)
            {
                NodeConfidenceWpfControl = new NodeConfidenceWpfControl(Characteristic);
                _stackPanel.Children.Add(NodeConfidenceWpfControl);
            }

            foreach (var term in Characteristic.SelectedCharacteristicQuantificationAllowedTerms)
            {
                foreach (var quantification in term.CharacteristicQuantifications)
                {
                    var characteristicControl = new CharacteristicQuantificationDetailsWpfControl(quantification);
                    _stackPanel.Children.Add(characteristicControl);
                    ChildControls.Add(characteristicControl);
                }
            }

            Loaded += AnatomicEntityCharacteristicWpfControlLoaded;

            Characteristic.SelectedAllowedTermsChanged += SelectedAllowedTermsCollectionChanged;
            CheckBoxControls = new Dictionary <CharacteristicQuantificationAllowedTerm, CheckBox>();

            if (!Characteristic.ShouldDisplay)
            {
                _label.Visibility        = Visibility.Hidden;
                _label.Height            = 0;
                _itemsControl.Visibility = Visibility.Hidden;
                _itemsControl.Height     = 0;
                _comboBox.Visibility     = Visibility.Hidden;
                _comboBox.Height         = 0;
                if (Characteristic.SelectedCharacteristicQuantificationAllowedTerms.Count == 0)
                {
                    this.Visibility = Visibility.Hidden;
                    this.Height     = 0;
                }
            }
        }
        public AnatomicEntityCharacteristicWpfControl(AimTemplateTreeAnatomicEntityCharacteristicNode characteristic)
        {
            Characteristic = characteristic;
            InitializeComponent();

            ChildControls = new List<IValidTreeControl>();

            _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 (Characteristic.MinCardinality > 0 && Characteristic.MaxCardinality >= Characteristic.CharacteristicQuantificationAllowedTerms.Count)
                    cardinalityString = "Select at least " + Characteristic.MinCardinality;
                else if (Characteristic.MaxCardinality < Characteristic.CharacteristicQuantificationAllowedTerms.Count && Characteristic.MinCardinality <= 0)
                    cardinalityString = "Select less than " + (Characteristic.MaxCardinality + 1);
                else if (Characteristic.MinCardinality > 0 && Characteristic.MaxCardinality < Characteristic.CharacteristicQuantificationAllowedTerms.Count)
                    cardinalityString = "Select at least " + Characteristic.MinCardinality + " and less than " +
                                        (Characteristic.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 (Characteristic.ShouldDisplay && Characteristic.HasConfidence)
            {
                NodeConfidenceWpfControl = new NodeConfidenceWpfControl(Characteristic);
                _stackPanel.Children.Add(NodeConfidenceWpfControl);
            }

            foreach (var term in Characteristic.SelectedCharacteristicQuantificationAllowedTerms)
            {
                foreach (var quantification in term.CharacteristicQuantifications)
                {
                    var characteristicControl = new CharacteristicQuantificationDetailsWpfControl(quantification);
                    _stackPanel.Children.Add(characteristicControl);
                    ChildControls.Add(characteristicControl);
                }
            }

            Loaded += AnatomicEntityCharacteristicWpfControlLoaded;

            Characteristic.SelectedAllowedTermsChanged += SelectedAllowedTermsCollectionChanged;
            CheckBoxControls = new Dictionary<CharacteristicQuantificationAllowedTerm, CheckBox>();

            if (!Characteristic.ShouldDisplay)
            {
                _label.Visibility = Visibility.Hidden;
                _label.Height = 0;
                _itemsControl.Visibility = Visibility.Hidden;
                _itemsControl.Height = 0;
                _comboBox.Visibility = Visibility.Hidden;
                _comboBox.Height = 0;
                if (Characteristic.SelectedCharacteristicQuantificationAllowedTerms.Count == 0)
                {
                    this.Visibility = Visibility.Hidden;
                    this.Height = 0;
                }
            }
        }
        void SelectedAllowedTermsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (var item in e.NewItems)
                {
                    var term = item as CharacteristicQuantificationAllowedTerm;
                    if (term != null && CheckBoxControls.ContainsKey(term))
                        CheckBoxControls[term].IsChecked = true;
                }
            }

            if (e.OldItems != null)
            {
                foreach (var item in e.OldItems)
                {
                    var term = item as CharacteristicQuantificationAllowedTerm;
                    if (term != null && CheckBoxControls.ContainsKey(term))
                        CheckBoxControls[term].IsChecked = false;
                }
            }

            if (Characteristic.SelectedCharacteristicQuantificationAllowedTerms.Count > 0)
            {
                _comboBox.SelectedItem = Characteristic.SelectedCharacteristicQuantificationAllowedTerms[0];
            }

            ClearQuantificationDetailsControls();

            foreach (var term in Characteristic.SelectedCharacteristicQuantificationAllowedTerms)
            {
                foreach (var quantification in term.CharacteristicQuantifications)
                {
                    var characteristicControl = new CharacteristicQuantificationDetailsWpfControl(quantification);
                    _stackPanel.Children.Add(characteristicControl);
                }
            }
        }