private void PaintSlider(SKCanvas canvas, SliderLocation slider, SKSize canvasSize) { var pickerRadiusPixels = GetPickerRadiusPixels(); var sliderTop = slider.GetSliderOffset(pickerRadiusPixels); SKPoint startPoint; SKPoint endPoint; if (Vertical) { startPoint = new SKPoint(sliderTop, pickerRadiusPixels * 2); endPoint = new SKPoint(sliderTop, canvasSize.Height - (pickerRadiusPixels * 2)); } else { startPoint = new SKPoint(pickerRadiusPixels * 2, sliderTop); endPoint = new SKPoint(canvasSize.Width - (pickerRadiusPixels * 2), sliderTop); } var paint = slider.Slider.GetPaint(SelectedColor, startPoint, endPoint); paint.StrokeWidth = pickerRadiusPixels * 1.3F; if (slider.Slider.PaintChessPattern) { PaintChessPattern(canvas, slider, canvasSize); } canvas.DrawLine(startPoint, endPoint, paint); }
private void PaintChessPattern(SKCanvas canvas, SliderLocation slider, SKSize canvasSize) { var pickerRadiusPixels = GetPickerRadiusPixels(); var sliderTop = slider.GetSliderOffset(pickerRadiusPixels); var scale = pickerRadiusPixels / 3; SKPath path = new SKPath(); path.MoveTo(-1 * scale, -1 * scale); path.LineTo(0 * scale, -1 * scale); path.LineTo(0 * scale, 0 * scale); path.LineTo(1 * scale, 0 * scale); path.LineTo(1 * scale, 1 * scale); path.LineTo(0 * scale, 1 * scale); path.LineTo(0 * scale, 0 * scale); path.LineTo(-1 * scale, 0 * scale); path.LineTo(-1 * scale, -1 * scale); SKMatrix matrix = SKMatrix.MakeScale(2 * scale, 2 * scale); SKPaint paint = new SKPaint { PathEffect = SKPathEffect.Create2DPath(matrix, path), Color = Color.LightGray.ToSKColor(), IsAntialias = true }; SKRect patternRect; SKRect clipRect; SKRoundRect clipRoundRect; if (Vertical) { patternRect = new SKRect(sliderTop - pickerRadiusPixels, pickerRadiusPixels , sliderTop + pickerRadiusPixels, canvasSize.Height - pickerRadiusPixels); clipRect = new SKRect(sliderTop - (pickerRadiusPixels * 0.65f), pickerRadiusPixels * 1.35f , sliderTop + (pickerRadiusPixels * 0.65f), canvasSize.Height - (pickerRadiusPixels * 1.35f)); clipRoundRect = new SKRoundRect(clipRect, pickerRadiusPixels * 0.65f, pickerRadiusPixels * 0.65f); } else { patternRect = new SKRect(pickerRadiusPixels, sliderTop - pickerRadiusPixels , canvasSize.Width - pickerRadiusPixels, sliderTop + pickerRadiusPixels); clipRect = new SKRect(pickerRadiusPixels * 1.35f, sliderTop - (pickerRadiusPixels * 0.65f) , canvasSize.Width - (pickerRadiusPixels * 1.35f), sliderTop + (pickerRadiusPixels * 0.65f)); clipRoundRect = new SKRoundRect(clipRect, pickerRadiusPixels * 0.65f, pickerRadiusPixels * 0.65f); } canvas.Save(); canvas.ClipRoundRect(clipRoundRect); canvas.DrawRect(patternRect, paint); canvas.Restore(); }
protected void UpdateSliders() { sliders.Clear(); var i = 1; foreach (var slider in GetSliders()) { var sliderLocation = new SliderLocation(slider) { OffsetLocationMultiplier = (float)(-1.1 + (i * 2.2)) }; sliders.Add(sliderLocation); i++; } InvalidateSurface(); }
private void UpdateColors(SliderLocation slider, SKSize canvasSize) { var newColor = SelectedColor; float newValue; if (Vertical) { newValue = (slider.Location.Y - (GetPickerRadiusPixels() * 2)) / SlidersWidht(canvasSize); } else { newValue = (slider.Location.X - (GetPickerRadiusPixels() * 2)) / SlidersWidht(canvasSize); } newColor = slider.Slider.GetNewColor(newValue, newColor); SelectedColor = newColor; InvalidateSurface(); }