using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;
namespace Venus_Themes.CustomControls
{
public class RingProgress : RangeBase
{
static RingProgress()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(RingProgress), new FrameworkPropertyMetadata(typeof(RingProgress)));
}
#region StrokeThickness 圆环描边宽度
public static readonly DependencyProperty StrokeThicknessProperty =
DependencyProperty.Register("StrokeThickness", typeof(double), typeof(RingProgress), new PropertyMetadata(10d));
public double StrokeThickness
{
get { return (double)GetValue(StrokeThicknessProperty); }
set { SetValue(StrokeThicknessProperty, value); }
}
#endregion
#region Stroke 圆环描边颜色
public static readonly DependencyProperty StrokeProperty =
DependencyProperty.Register("Stroke", typeof(Brush), typeof(RingProgress), new PropertyMetadata(Brushes.Red));
public Brush Stroke
{
get { return (Brush)GetValue(StrokeProperty); }
set { SetValue(StrokeProperty, value); }
}
#endregion
}
internal static class RingProgressExtension
{
///
/// 角度转为弧度
///
///
///
public static double AngleToArc(this double a)
{
return Math.PI * a / 180;
}
///
/// 角度及半径计算坐标点位置
///
///
///
///
///
public static Point AngleToPoint(this double a, double radius, double offset = 0)
{
return new Point(Math.Cos(a.AngleToArc()) * radius + radius + offset, Math.Sin(a.AngleToArc()) * radius + radius + offset);
}
}
}