public StartWindow(IDictionary <string, double> CommonAttributes) { InitializeComponent(); this.CommonAttributes = CommonAttributes; BindingCriterion = new ObservableCollection <CheckedListItem <BindingCriteria> >(); foreach (KeyValuePair <string, double> attribute in this.CommonAttributes) { BindingCriteria bc = new BindingCriteria(attribute.Key); BindingCriterion.Add(new CheckedListItem <BindingCriteria>(bc)); } // Disable run button if no common attribute RunBtn.IsEnabled = CommonAttributes.Count != 0; this.weightCombo.ItemsSource = CommonAttributes.Keys; DataContext = this; }
private void RunBtn_Click(object sender, RoutedEventArgs e) { HashSet <ICriterion> criteria = new HashSet <ICriterion>(); foreach (CheckedListItem <BindingCriteria> checkbox in CommonAttrList.Items) { if (checkbox.IsChecked) { BindingCriteria criterion = checkbox.Item; switch (criterion.SelectedIndex) { case 0: criteria.Add(new GreaterThanCriterion(criterion.Attribute, criterion.Value1)); break; case 1: criteria.Add(new LessThanCriterion(criterion.Attribute, criterion.Value1)); break; case 2: criteria.Add(new EqualCriterion(criterion.Attribute, criterion.Value1)); break; case 3: criteria.Add(new RangeCriterion(criterion.Attribute, criterion.Value1, criterion.Value2)); break; } } } Constraint <IEdge> constraint = new Constraint <IEdge>(criteria); returnValue = Tuple.Create(weightCombo.SelectedItem.ToString(), constraint); DialogResult = true; }
private void CommonAttrList_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectionCriterion = ((CheckedListItem <BindingCriteria>)CommonAttrList.SelectedItem).Item; this.EditPanel.DataContext = SelectionCriterion; ToggleInputVisiblity(SelectionCriterion.SelectedIndex); }