void MaxTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (ClassBreakConfigItems == null) { return; } ClassBreakConfigControl classBreakConfigControl = ClassBreakConfigItems.SelectedItem as ClassBreakConfigControl; if (classBreakConfigControl == null || classBreakConfigControl.ClassBreak == null) { return; } double d; if (double.TryParse(MaxTextBox.Text, out d)) { classBreakConfigControl.UpdateMaxValue(d); } OnClassBreakRendererModified(EventArgs.Empty); }
void classBreakConfigControl_ClassBreakChanged(object sender, ClassBreakModificationEventArgs e) { // Auto adjust adjacent class breaks if (e.ClassBreakModificationType == ClassBreakModificationType.MinValueChanged) { ClassBreakConfigControl control = sender as ClassBreakConfigControl; if (control != null) { int indexOfClassBreak = -1; ClassBreakInfo classBreak = control.ClassBreak; indexOfClassBreak = ClassBreaksRenderer.Classes.IndexOf(classBreak); if (indexOfClassBreak > 0) { // Update the previous class break in the collection if (ClassBreakConfigItems != null && ClassBreakConfigItems.Items != null) { int indexOfControl = ClassBreakConfigItems.Items.IndexOf(control); if (indexOfControl > 0)// array bounds check { ClassBreakConfigControl prevControl = ClassBreakConfigItems.Items[indexOfControl - 1] as ClassBreakConfigControl; if (prevControl != null) { ClassBreakInfo prevClassBreak = prevControl.ClassBreak; double incr = 1.0; double delta = 2 * incr; double diff = prevClassBreak.MaximumValue - prevClassBreak.MinimumValue; if (Math.Round(diff, 0) != Math.Round(diff, 4)) // dealing with precision of less than 1 integer { incr = 0.01; delta = 2 * incr; } double newValue = classBreak.MinimumValue - incr; if (classBreak.MinimumValue <= prevClassBreak.MinimumValue + delta) { // don't allow min value to drop below previous class break value // Auto audjust the class breaks newValue = prevClassBreak.MinimumValue + delta; control.UpdateMinValue(newValue); prevControl.UpdateMaxValue(newValue - incr); } else { prevControl.UpdateMaxValue(newValue); } } } } } } } else if (e.ClassBreakModificationType == ClassBreakModificationType.MaxValueChanged) { ClassBreakConfigControl control = sender as ClassBreakConfigControl; if (control != null) { int indexOfClassBreak = -1; ClassBreakInfo classBreak = control.ClassBreak; indexOfClassBreak = ClassBreaksRenderer.Classes.IndexOf(classBreak); if (indexOfClassBreak > -1 && indexOfClassBreak < ClassBreaksRenderer.Classes.Count - 1) { // Update following class break if (ClassBreakConfigItems != null && ClassBreakConfigItems.Items != null) { int indexOfControl = ClassBreakConfigItems.Items.IndexOf(control); if (indexOfControl > -1 && indexOfControl < ClassBreakConfigItems.Items.Count - 1)// array bounds check { ClassBreakConfigControl nextControl = ClassBreakConfigItems.Items[indexOfControl + 1] as ClassBreakConfigControl; if (nextControl != null) { ClassBreakInfo nextClassBreak = nextControl.ClassBreak; double incr = 1.0; double delta = 2 * incr; double diff = nextClassBreak.MaximumValue - nextClassBreak.MinimumValue; if (Math.Round(diff, 0) != Math.Round(diff, 4)) // dealing with precision of less than 1 integer { incr = 0.01; delta = 2 * incr; } double newValue = classBreak.MaximumValue + incr; // check if the max value is greater than max of next classbreak (minus the minimum spacing) if (classBreak.MaximumValue >= (nextClassBreak.MaximumValue - delta)) { // don't allow max value to go above next class break value // Auto audjust the class breaks newValue = nextClassBreak.MaximumValue - delta; control.UpdateMaxValue(newValue); nextControl.UpdateMinValue(newValue + incr); } else { nextControl.UpdateMinValue(newValue); } } } } } } } SelectedClassBreakModificationEventArgs args = new SelectedClassBreakModificationEventArgs() { ClassBreakModificationType = e.ClassBreakModificationType, IsSelectedItem = ClassBreakConfigItems.SelectedItem == sender, }; OnClassBreakRendererModified(args); }