| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | 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    {        /// <summary>        /// 角度转为弧度        /// </summary>        /// <param name="a"></param>        /// <returns></returns>        public static double AngleToArc(this double a)        {            return Math.PI * a / 180;        }        /// <summary>        /// 角度及半径计算坐标点位置        /// </summary>        /// <param name="a"></param>        /// <param name="radius"></param>        /// <param name="offset"></param>        /// <returns></returns>        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);        }    }}
 |