private void Circle_PointerPressed(object sender, PointerRoutedEventArgs e) { Point currentLocation = e.GetCurrentPoint(RingGrid).Position; RingGrid.CapturePointer(e.Pointer); PointerEventHandler moved = null; moved = (s, args) => { currentLocation = e.GetCurrentPoint(RingGrid).Position; double dx = currentLocation.X - colorRingCenter.X; double dy = currentLocation.Y - colorRingCenter.Y; //--- double hue = Math2.ComputeH(dx, dy); //--- Hue = Math2.ComputeH(dx, dy); CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value); CompositeTransform ct = SeletcedColorEllipseCompositeTransform; Point targetPoint = new Point(ct.TranslateX, ct.TranslateY); ColorPickerStoryboardStart(Hue, targetPoint); SelectedColorShowArea.Fill = new SolidColorBrush(CurrentColor); }; PointerEventHandler released = null; released = (s, args) => { double dx = currentLocation.X - colorRingCenter.X; double dy = currentLocation.Y - colorRingCenter.Y; //--- double hue = Math2.ComputeH(dx, dy); //--- Hue = Math2.ComputeH(dx, dy); CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value); CompositeTransform ct = SeletcedColorEllipseCompositeTransform; Point targetPoint = new Point(ct.TranslateX, ct.TranslateY); ColorPickerStoryboardStart(Hue, targetPoint); SelectedColorShowArea.Fill = new SolidColorBrush(CurrentColor); RingGrid.PointerMoved -= moved; RingGrid.PointerReleased -= released; }; RingGrid.PointerMoved += moved; RingGrid.PointerReleased += released; }
private void HiddenSquare_PointerPressed(object sender, PointerRoutedEventArgs e) { Point currentLocation = e.GetCurrentPoint(RingGrid).Position; RingGrid.CapturePointer(e.Pointer); PointerEventHandler moved = null; moved = (s, args) => { currentLocation = e.GetCurrentPoint(RingGrid).Position; CompositeTransform ct = SeletcedColorEllipseCompositeTransform; if (currentLocation.X < 70) { ct.TranslateX = 60; } else if (currentLocation.X > 230) { ct.TranslateX = 220; } else { ct.TranslateX = currentLocation.X - seletcedColorEllipse_r; } if (currentLocation.Y < 70) { ct.TranslateY = 60; } else if (currentLocation.Y > 230) { ct.TranslateY = 220; } else { ct.TranslateY = currentLocation.Y - seletcedColorEllipse_r; } ColorPickerStoryboardStart(Hue, new Point(ct.TranslateX, ct.TranslateY)); Saturation = (ct.TranslateX - 60) / squareSideLength; Value = (squareSideLength - (ct.TranslateY - 60)) / squareSideLength; CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value); SelectedColorShowArea.Fill = new SolidColorBrush(CurrentColor); }; PointerEventHandler released = null; released = (s, args) => { CompositeTransform ct = SeletcedColorEllipseCompositeTransform; if (currentLocation.X < 70) { ct.TranslateX = 60; } else if (currentLocation.X > 230) { ct.TranslateX = 220; } else { ct.TranslateX = currentLocation.X - seletcedColorEllipse_r; } if (currentLocation.Y < 70) { ct.TranslateY = 60; } else if (currentLocation.Y > 230) { ct.TranslateY = 220; } else { ct.TranslateY = currentLocation.Y - seletcedColorEllipse_r; } ColorPickerStoryboardStart(Hue, new Point(ct.TranslateX, ct.TranslateY)); Saturation = (ct.TranslateX - 60) / squareSideLength; Value = (squareSideLength - (ct.TranslateY - 60)) / squareSideLength; CurrentColor = Math2.HSVToRGB(Hue, Saturation, Value); SelectedColorShowArea.Fill = new SolidColorBrush(CurrentColor); RingGrid.PointerMoved -= moved; RingGrid.PointerReleased -= released; }; RingGrid.PointerMoved += moved; RingGrid.PointerReleased += released; }