private static void OnMaxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IndicatorMeter owner = d as IndicatorMeter;

            if (owner.Max <= owner.Min)
            {
                owner.Max = owner.Min;
                return;
            }

            if (owner.Max < owner.IndicatorValue)
            {
                owner.IndicatorValue = owner.Max;
            }

            if (owner.Max < owner.RangeBarMax)
            {
                owner.RangeBarMax = owner.Max;
            }



            /* 属性更改后需要立刻重绘刻度 */
            owner.DrawScale(owner.PrimaryScaleRaduisInner, owner.PrimaryScaleRadiusOuter, owner.PrimaryScaleCount, owner.MinorScaleRadiusInner, owner.MinorScaleRadiusOuter, owner.MinorScaleCount, owner.PrimaryScaleStartAngle, owner.PrimaryScaleEndAngle, owner.PrimaryScaleWitdh, owner.PrimaryScaleBackground);

            // 更改Indicator Bar颜色
            owner.ChangeIndicatorBarBackground();
        }
        private static void OnIndicatorBarPatternChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IndicatorMeter owner = d as IndicatorMeter;

            owner.IndicatorBarPattern.Sort(SortCompare);
            owner.ChangeIndicatorBarBackground();
        }
        private static void OnIndicatorValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            double indicator_bar_angle;

            IndicatorMeter owner = d as IndicatorMeter;
            double         value = (double)e.NewValue;

            // 显示指示值文本
            if (double.IsNaN(value))
            {
                owner.txt_Value.Text = "N/A";
                indicator_bar_angle  = 0;   // 如果输入的值是double.NaN,则指示条指向最小值
            }
            else
            {
                if (value > owner.Max)
                {
                    owner.IndicatorValue = owner.Max;
                    return;
                }

                if (value < owner.Min)
                {
                    owner.IndicatorValue = owner.Min;
                    return;
                }


                owner.txt_Value.Text = value.ToString();
                indicator_bar_angle  = 280 * (owner.IndicatorValue - owner.Min) / (owner.Max - owner.Min); // 根据指示值计算指示条的角度
                /* 如果 Min == Max,则会出现 Max - Min = 0 的情况,此时indicator_bar_angle == double.NaN */
                if (double.IsNaN(indicator_bar_angle))
                {
                    indicator_bar_angle = 0;
                }
            }


            // 绘制Indicator Bar
            owner.BeginIndicatorValueChangedAnimation(indicator_bar_angle);

            // 更改Indicator Bar颜色
            owner.ChangeIndicatorBarBackground();
        }
        private static void OnRangeBarMaxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IndicatorMeter owner = d as IndicatorMeter;
            double         max   = (double)e.NewValue;

            if (max > owner.Max)
            {
                owner.RangeBarMax = owner.Max;
                return;
            }

            if (max < owner.Min)
            {
                owner.RangeBarMax = owner.RangeBarMin;
                return;
            }

            double div   = (max - owner.Min) / (owner.Max - owner.Min);
            double angle = 280 * div;

            owner.RangeBar.EndAngle = angle;

            owner.ChangeIndicatorBarBackground();
        }
        private static void OnIndicatorBarBackgroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IndicatorMeter owner = d as IndicatorMeter;

            owner.ChangeIndicatorBarBackground();
        }