public static void OnColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { // Force a re-render of the object if a visual-related property changes WheelSelector ctl = (obj as WheelSelector); ctl.InvalidateVisual(); //TODO: Figure out how to handle circular dependencies properly. // Currently I'm using propUpdateFlag to prevent infinite loops here. // Ideally there should be a way to update the local values without calling // this callback again (but still notifying other users) if (!propUpdateFlag) { propUpdateFlag = true; if (args.Property == WheelSelector.ThetaProperty || args.Property == WheelSelector.RadProperty) { ctl.RGBValue = ctl.wheel.ColourMapping(ctl.Rad, CircularMath.Mod(ctl.Theta), 1.0); } if (args.Property == WheelSelector.RGBValueProperty) { var rgb = (RGBColor)args.NewValue; var pt = ctl.wheel.InverseColourMapping(rgb); ctl.SetCurrentValue(ThetaProperty, pt.X); ctl.SetCurrentValue(RadProperty, pt.Y); } propUpdateFlag = false; } }
private static void OnHSPropertyAnimated(DependencyObject obj, DependencyPropertyChangedEventArgs args) { WheelSelector ctl = (obj as WheelSelector); ctl.Theta = (args.NewValue as Point?).Value.X; ctl.Rad = (args.NewValue as Point?).Value.Y; ctl.InvalidateVisual(); }
public static void OnThumbSizeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { // Force a re-render of the object if the thumb size changes WheelSelector ctl = (obj as WheelSelector); ctl.UpdateThumbSize(); ctl.InvalidateMeasure(); // Updating the thumbsize changes the dial radius ctl.UpdateSelector(); // Also need to re-calculate the thumb position ctl.InvalidateVisual(); // And then re-paint everything }