csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="ProgressBar.cs" company="Steven Kirk">
|
|
// Copyright 2015 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
namespace Perspex.Controls
|
|
{
|
|
using Perspex.Controls.Primitives;
|
|
using Perspex.Controls.Templates;
|
|
|
|
/// <summary>
|
|
/// A control used to indicate the progress of an operation.
|
|
/// </summary>
|
|
public class ProgressBar : RangeBase
|
|
{
|
|
private Border indicator;
|
|
|
|
static ProgressBar()
|
|
{
|
|
ValueProperty.Changed.AddClassHandler<ProgressBar>(x => x.ValueChanged);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
protected override void OnTemplateApplied()
|
|
{
|
|
this.indicator = this.GetTemplateChild<Border>("PART_Indicator");
|
|
}
|
|
|
|
private void ValueChanged(PerspexPropertyChangedEventArgs e)
|
|
{
|
|
if (this.indicator != null)
|
|
{
|
|
double percent = this.Maximum == this.Minimum ? 1.0 : ((double)e.NewValue - this.Minimum) / (this.Maximum - this.Minimum);
|
|
this.indicator.Width = this.Bounds.Width * percent;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|