/// <summary> /// Refreshes all color marker polygons. /// </summary> protected virtual void RefreshGradientCircleColorMarkers() { foreach (Polygon cm in _gradientCircleColorMarkers) { _canvas.Children.Remove(cm); } _gradientCircleColorMarkers.Clear(); int cnt = _colorMarkers.Count; for (byte cmIx = 0; cmIx < cnt; ++cmIx) { SCSColorMarker scscm = _colorMarkers[cmIx]; Polygon cm = new Polygon(); cm.StrokeThickness = 1; _gradientCircleColorMarkers.Add(cm); _canvas.Children.Add(cm); RefreshGradientCircleColorMarkerGeometry(cmIx); RefreshGradientCircleColorMarkerColorAndPosition(cmIx); byte indexCopy = cmIx; cm.MouseLeftButtonDown += (sender, e) => MarkerPolygon_MouseLeftButtonDown(sender, e, indexCopy); cm.MouseLeftButtonUp += (sender, e) => MarkerPolygon_MouseLeftButtonUp(sender, e, indexCopy); } }
protected virtual void RefreshGradientCircleColor() { if (_colorMarkers == null || _colorMarkers.Count < 2) { return; } int colorMarkerIndex = 0; int colorMarkerCount = _colorMarkers.Count; SCSColorMarker colorMarkerPrev = _colorMarkers[colorMarkerIndex++]; SCSColorMarker colorMarkerNext = _colorMarkers[colorMarkerIndex++]; for (int polyIx = 0; polyIx < __GRADIENT_CIRCLE_RESOLUTION; ++polyIx) { Polygon p = _gradientCircle[polyIx]; double inCirclePosition = polyIx / (double)__GRADIENT_CIRCLE_RESOLUTION; if (inCirclePosition >= colorMarkerNext.Position) { colorMarkerPrev = colorMarkerNext; colorMarkerNext = _colorMarkers[colorMarkerIndex++]; } double betweenMarkerProgress = (inCirclePosition - colorMarkerPrev.Position) / (colorMarkerNext.Position - colorMarkerPrev.Position); Color inCircleColor; MixColors(colorMarkerPrev.Color, colorMarkerNext.Color, (float)betweenMarkerProgress, out inCircleColor); SolidColorBrush brush = new SolidColorBrush(inCircleColor); p.Fill = brush; p.Stroke = brush; } }
/// <summary> /// Refreshes single color marker on gradient circle. /// </summary> /// <param name="index">Index of color marker.</param> protected virtual void RefreshGradientCircleColorMarkerColorAndPosition(byte index) { SCSColorMarker scscm = _colorMarkers[index]; Polygon cm = _gradientCircleColorMarkers[index]; cm.RenderTransform = new RotateTransform((scscm.Position - .75) * __FULL_CIRCLE_DEGREES, _canvasWDiv2, _canvasHDiv2); cm.Fill = new SolidColorBrush(scscm.Color); cm.Stroke = new SolidColorBrush(scscm.Color); }
/// <summary> /// Refreshes gradient circle progress marker color and position. /// </summary> /// <param name="progress">Progress.</param> protected virtual void RefreshGradientCircleProgressMarkerColorAndPosition(double progress) { if (_colorMarkers == null || _colorMarkers.Count < 2) { return; } _gradientCircleProgressMarker.RenderTransform = new RotateTransform((progress - .75) * __FULL_CIRCLE_DEGREES, _canvasWDiv2, _canvasHDiv2); int colorMarkerIndex = 0; int colorMarkerCount = _colorMarkers.Count; SCSColorMarker colorMarkerPrev = _colorMarkers[colorMarkerIndex++]; SCSColorMarker colorMarkerNext = _colorMarkers[colorMarkerIndex++]; int cnt = _colorMarkers.Count; for (int markerIx = 0; markerIx < cnt; ++markerIx) { if (progress < 1.0 && progress >= colorMarkerNext.Position) { colorMarkerPrev = colorMarkerNext; colorMarkerNext = _colorMarkers[colorMarkerIndex++]; } else { break; } } double betweenMarkerProgress = (progress - colorMarkerPrev.Position) / (colorMarkerNext.Position - colorMarkerPrev.Position); Color inCircleColor; MixColors(colorMarkerPrev.Color, colorMarkerNext.Color, (float)betweenMarkerProgress, out inCircleColor); SolidColorBrush brush = new SolidColorBrush(inCircleColor); _gradientCircleProgressMarker.Fill = brush; _gradientCircleProgressMarker.Stroke = brush; }