示例#1
0
        /// <summary>
        /// Handles the Activated event for any AttributeSimilarityCriterion control.  This event
        /// is fired when a AttributeSimilarityCriterion is made active, which mean that the input
        /// controls should be activated and a new (inactive) control should be created.
        /// However, if a control is not valid, a new control can't be added.
        /// </summary>
        /// <param name="sender">The specific AttributeSimilarityCriterion instance that fired the event</param>
        /// <param name="e">Event arguments for the event</param>
        private void AttributeSimilarityCriterion_Activated(object sender, EventArgs e)
        {
            bool addNew = true;
            AttributeSimilarityCriterionViewModel sourceCriterion = sender as AttributeSimilarityCriterionViewModel;

            // Check how many AttributeSimilarityCriterion controls we currently have
            if (SimilarityCriteria.Count > 1)
            {
                // Loop through all AttributeSimilarityCriterion view models in our list
                foreach (AttributeSimilarityCriterionViewModel criterion in SimilarityCriteria)
                {
                    // If this criterion control is the one that fired the Activate
                    // event, just skip it
                    if (criterion == sourceCriterion)
                    {
                        continue;
                    }

                    // Check if the AttributeSimilarityCriterion is currently active
                    if (criterion.IsActive)
                    {
                        // Validate the Criterion
                        criterion.Validate();

                        if (!criterion.IsValid)
                        {
                            // Set a flag that we don't actually want to create
                            // a new Criterion because this one was invalid.
                            addNew            = false;
                            SelectedCriterion = criterion;
                        }
                    }
                }
            }

            // Check if we are actually adding a new AttributeSimilarityCriterion control
            if (addNew)
            {
                // Set the IsActive property to true which will trigger the
                // underlying StoryBoard to enable the input controls.
                sourceCriterion.IsActive   = true;
                sourceCriterion.IsSelected = true;

                // Add the new AttributeSimilarityCriterion control
                SetupCriteria();

                ClusteringEnabled = true;
            }
            else
            {
                sourceCriterion.IsActive = false;
            }
        }
示例#2
0
        /// <summary>
        /// Setup the criteria collection and the initial
        /// Criterion control
        /// </summary>
        private void SetupCriteria()
        {
            // Create initial clustering criterion and add it to the collection
            AttributeSimilarityCriterionViewModel newClusteringCriterion = new AttributeSimilarityCriterionViewModel(this)
            {
                IsEnabled = true, IsActive = false, IsSelected = true
            };

            SimilarityCriteria.Add(newClusteringCriterion);

            // Wire up event handlers for the Activated and Deactivated events of
            // the newly created clusdtering criterion control
            newClusteringCriterion.Activated   += new EventHandler <EventArgs>(AttributeSimilarityCriterion_Activated);
            newClusteringCriterion.Deactivated += new EventHandler <EventArgs>(AttributeSimilarityCriterion_Deactivated);
        }
示例#3
0
        /// <summary>
        /// Handles the Deactivated event for any AttributeSimilarityCriterion control.  This event
        /// is fired when an AttributeSimilarityCriterion is made inactive, which means it should be
        /// removed.
        /// </summary>
        /// <param name="sender">The specific AttributeSimilarityCriterion instance that fired the event</param>
        /// <param name="e">Event arguments for the event</param>
        private void AttributeSimilarityCriterion_Deactivated(object sender, EventArgs e)
        {
            AttributeSimilarityCriterionViewModel criterion = sender as AttributeSimilarityCriterionViewModel;

            // Check if we have more than one AttributeSimilarityCriterion control
            if (SimilarityCriteria.Count > 1)
            {
                // Remove the AttributeSimilarityCriterion from the collection
                SimilarityCriteria.Remove(criterion);

                // Remove event handlers
                criterion.Activated   -= new EventHandler <EventArgs>(AttributeSimilarityCriterion_Activated);
                criterion.Deactivated -= new EventHandler <EventArgs>(AttributeSimilarityCriterion_Deactivated);
            }
            else
            {
                // Disable clustering
                ClusteringEnabled = false;

                // Set the IsActive property to false which will trigger the
                // underlying StoryBoard to disable the input controls.
                criterion.IsActive = false;
            }
        }
        /// <summary>
        /// Setup the criteria collection and the initial
        /// Criterion control
        /// </summary>
        private void SetupCriteria()
        {
            // Create initial clustering criterion and add it to the collection
            AttributeSimilarityCriterionViewModel newClusteringCriterion = new AttributeSimilarityCriterionViewModel(this) { IsEnabled = true, IsActive = false, IsSelected = true };
            SimilarityCriteria.Add(newClusteringCriterion);

            // Wire up event handlers for the Activated and Deactivated events of
            // the newly created clusdtering criterion control
            newClusteringCriterion.Activated += new EventHandler<EventArgs>(AttributeSimilarityCriterion_Activated);
            newClusteringCriterion.Deactivated += new EventHandler<EventArgs>(AttributeSimilarityCriterion_Deactivated);
        }