private void Circle_PointerPressed(object sender, PointerRoutedEventArgs e) { if (_textboxFocusing || _animating) { return; } _circlePressing = true; Point currentLocation = e.GetCurrentPoint(ImageGrid).Position; double dx = currentLocation.X - triangleCenter.X; double dy = currentLocation.Y - triangleCenter.Y; //--- double hue = Math2.ComputeH(dx, dy); EnterHSV(hue, Saturation, Value, true); //--- Hue = Math2.ComputeH(dx, dy); CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value); // Compute SeletcedColorEllipse position CompositeTransform ct = SeletcedColorEllipseCompositeTransform; Point targetPoint = Math2.RotatePoint( new Point(ct.TranslateX + seletcedColorEllipse_r, ct.TranslateY + seletcedColorEllipse_r), triangleCenter, _preAngle - Hue ); targetPoint.X = targetPoint.X - seletcedColorEllipse_r; targetPoint.Y = targetPoint.Y - seletcedColorEllipse_r; ColorPickerStoryboardStart(Hue, targetPoint); }
public void EnterHSV(double h, double s, double v, bool animation) { Hue = h; Saturation = s; Value = v; CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value); CompositeTransform ct = SeletcedColorEllipseCompositeTransform; Point targetPoint; // Compute SeletcedColorEllipse position targetPoint = Math2.RotatePoint( new Point(ct.TranslateX + seletcedColorEllipse_r, ct.TranslateY + seletcedColorEllipse_r), triangleCenter, _preAngle - Hue ); targetPoint.X = targetPoint.X - seletcedColorEllipse_r; targetPoint.Y = targetPoint.Y - seletcedColorEllipse_r; if (animation) { ColorPickerStoryboardStart(_preAngle, targetPoint); } else { TriangleImgRotation.Angle = Hue; SelesctedRingImgRotation.Angle = Hue; _preAngle = Hue; PolygonTransform.Angle = Hue; ct.TranslateX = targetPoint.X; ct.TranslateY = targetPoint.Y; _preCirclePoint = new Point(ct.TranslateX, ct.TranslateY); } }
private void Polygon_PointerMoved(object sender, PointerRoutedEventArgs e) { if (_trianglePressing && !_textboxFocusing) { Point currentPoint = e.GetCurrentPoint(this.ImageGrid).Position; // Rotation current position "Hue" degrees Point rotatedPoint = Math2.RotatePoint(currentPoint, triangleCenter, Hue); // Let trianglePoint1 become origin Point newPoint = new Point( Math.Abs(rotatedPoint.X - trianglePoint1.X), Math.Abs(rotatedPoint.Y - trianglePoint1.Y) ); Math2.ComputeSV(newPoint, triangleSide, out Saturation, out Value); CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value); // Compute SeletcedColorEllipse if (_pointerMovedStory) { Point targetPoint = new Point( currentPoint.X - seletcedColorEllipse_r, currentPoint.Y - seletcedColorEllipse_r ); ColorPickerStoryboardStart(_preAngle, targetPoint); } else { CompositeTransform ct = SeletcedColorEllipseCompositeTransform; ct.TranslateX = currentPoint.X - seletcedColorEllipse_r; ct.TranslateY = currentPoint.Y - seletcedColorEllipse_r; _preCirclePoint = new Point(ct.TranslateX, ct.TranslateY); } } }
internal Color GetRGB() { return(Math2.HSVToRGB(H, S, V)); }