Пример #1
0
        private static void setPointCollection(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ExtendedProgressBar copy = d as ExtendedProgressBar;

            if (copy != null && copy.ProgressBarWidth != 0.0)
            {
                double _height = copy.Height;
                if (double.IsNaN(_height) || _height == 0)
                {
                    _height = copy.ActualHeight;
                }
                PointCollection result = new PointCollection();
                if (copy.Points == null)
                {
                    copy.Points = new PointCollection(new List <Point>()
                    {
                        new Point(0, 1), new Point(0, 0.99), new Point(1, 0), new Point(1, 1)
                    });
                }
                foreach (Point item in copy.Points)
                {
                    result.Add(new Point(item.X * copy.ProgressBarWidth, item.Y * (_height - 12)));
                }
                copy.ProgressBarPoints = result;
            }
        }
Пример #2
0
 private static void OnProgressBarPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.Property == PointsProperty)
     {
         setPointCollection(d, e);
     }
     else if (e.Property == ProgressBarBackgroundProperty || e.Property == ProgressBarForegroundProperty)
     {
         ExtendedProgressBar copy = d as ExtendedProgressBar;
         if (copy != null)
         {
             if (copy.ProgressBarFill == null)
             {
                 copy.ProgressBarFill            = new LinearGradientBrush();
                 copy.ProgressBarFill.StartPoint = new Point(0, 0);
                 copy.ProgressBarFill.EndPoint   = new Point(1, 0);
             }
             copy.ProgressBarFill.GradientStops.Clear();
             copy.ProgressBarFill.GradientStops.Add(new GradientStop(copy.ProgressBarForeground.Color, 0));
             copy.ProgressBarFill.GradientStops.Add(new GradientStop(copy.ProgressBarForeground.Color, copy.Value / copy.Maximum));
             copy.ProgressBarFill.GradientStops.Add(new GradientStop(copy.ProgressBarBackground.Color, copy.Value / copy.Maximum));
         }
     }
 }