/// <summary> /// Creates a new AttributeSimilarityCriterionViewModel instance /// using the provided parent instance /// </summary> /// <param name="_parent">The ClusteringToolPanelItemExtensionViewModel instance /// that owns this criterion</param> public AttributeSimilarityCriterionViewModel(ClusteringToolPanelItemExtensionViewModel _parent) : base(_parent) { IsValid = true; this.currentMode = _parent.Mode; _parent.ClusteringFinished += new EventHandler <ClusteringEventArgs>(ClusteringFinishedHandler); }
/// <summary> /// Updates the weight values, stored in the AttributeSimilarityManager, depending /// on the current mode of the parent clusterting tool /// </summary> private void UpdateAttributeWeights(ClusteringToolMode currentMode) { // Ensure this panel is active if (IsActive) { // Check if the tool is in 'Simple' mode if (currentMode == ClusteringToolMode.Simple) { // Set the weight for this attribute to the default // value of 100% Clustering.AttributeSimilarityManager.Instance.SetAttributeWeight(this.AttributeName, 100d / 100d); } // Check if the tool is in 'Advanced' mode else if (currentMode == ClusteringToolMode.Advanced) { // Set the weight for this attribute to the user- // defined attribute weight value Clustering.AttributeSimilarityManager.Instance.SetAttributeWeight(this.AttributeName, this.attributeWeight / 100d); } } }
/// <summary> /// Handles property changes in the parent Clustering Tool /// </summary> /// <param name="sender">The object that fired the event</param> /// <param name="e">The arguments for the event</param> protected override void ParentPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { // Check if the "Mode" property was changed if (e.PropertyName == "Mode") { //Change the controls state if (Parent.Mode == ClusteringToolMode.Simple && currentMode != ClusteringToolMode.Simple) { currentMode = ClusteringToolMode.Simple; } else if (Parent.Mode == ClusteringToolMode.Advanced && currentMode != ClusteringToolMode.Advanced) { currentMode = ClusteringToolMode.Advanced; } else // Should never happen { } // Ensure the state is updated UpdateState(); } }