private void Polygon_PointerPressed(object sender, PointerRoutedEventArgs e) { if (_textboxFocusing || _animating) { return; } _trianglePressing = true; 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); //Compute SeletcedColorEllipse position Point targetPoint = new Point( currentPoint.X - seletcedColorEllipse_r, currentPoint.Y - seletcedColorEllipse_r); EnterHSV(Hue, Saturation, Value, targetPoint, true); }
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 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 EnterColor(Color c, bool animation) { if (c.A == 0) // The recent color has no color { c.R = c.G = c.B = 0; } // Black CurrentColor = c; HSVColor hsv = Math2.RGBToHSV(c); Hue = hsv.H; Saturation = hsv.S; Value = hsv.V; CompositeTransform ct = SeletcedColorEllipseCompositeTransform; // Compute SeletcedColorEllipse position Point targetPoint = Math2.SVToPoint(Saturation, Value, triangleSide); targetPoint.X = trianglePoint1.X + targetPoint.X; targetPoint.Y = trianglePoint1.Y - targetPoint.Y; targetPoint = Math2.RotatePoint(targetPoint, triangleCenter, -Hue); targetPoint.X -= seletcedColorEllipse_r; targetPoint.Y -= seletcedColorEllipse_r; if (animation) { ColorPickerStoryboardStart(Hue, 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); } } }