├── 1.gif ├── 2.gif ├── ProgressControlSample ├── ProgressControlSample │ ├── Assets │ │ ├── StoreLogo.png │ │ ├── SplashScreen.scale-200.png │ │ ├── LockScreenLogo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Wide310x150Logo.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── App.xaml │ ├── ProgressControl │ │ ├── ProgressState.cs │ │ ├── ProgressStateEventArgs.cs │ │ ├── ProgressControl.Constants.cs │ │ └── ProgressControl.cs │ ├── ProgressStateIndicator │ │ ├── ProgressStateIndicator.Constants.cs │ │ └── ProgressStateIndicator.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Properties │ │ ├── Default.rd.xml │ │ ├── AssemblyInfo.cs │ │ └── Annotations.cs │ ├── Converter │ │ └── BorderToStrokeThicknessConverter.cs │ ├── Download │ │ ├── DownloadServiceClient.cs │ │ ├── DownloadPage.xaml │ │ ├── DownloaderModel.cs │ │ ├── AddDownloadDialog.xaml │ │ ├── Downloader.cs │ │ ├── DownloadPage.xaml.cs │ │ └── AddDownloadDialog.xaml.cs │ ├── Behaviors │ │ ├── RectangleToEllipseBehavior.cs │ │ ├── ProgressBehavior.cs │ │ ├── AdjustToSquareBehavior.cs │ │ ├── RelativeOffsetBehavior.cs │ │ └── EllipseProgressBehavior.cs │ ├── TestService.cs │ ├── Package.appxmanifest │ ├── FrameworkElementExtensions.cs │ ├── SizeBridge.cs │ ├── BasicPage.xaml │ ├── BasicPage.xaml.cs │ ├── App.xaml.cs │ ├── ProgressControlSample.csproj │ └── Themes │ │ └── Generic.xaml ├── ProgressControlSample.sln.DotSettings └── ProgressControlSample.sln ├── README.md ├── .gitattributes └── .gitignore /1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/1.gif -------------------------------------------------------------------------------- /2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/2.gif -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/ProgressControlSample/ProgressControlSample/Assets/StoreLogo.png -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/ProgressControlSample/ProgressControlSample/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/ProgressControlSample/ProgressControlSample/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/ProgressControlSample/ProgressControlSample/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/ProgressControlSample/ProgressControlSample/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/ProgressControlSample/ProgressControlSample/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Progress-Control-Sample 2 | 3 | ![ProgressControl](https://github.com/DinoChan/Progress-Control-Sample/blob/master/1.gif) 4 | 5 | ![ProgressStateIndicator](https://github.com/DinoChan/Progress-Control-Sample/blob/master/2.gif) 6 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DinoChan/Progress-Control-Sample/HEAD/ProgressControlSample/ProgressControlSample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/ProgressControl/ProgressState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProgressControlSample 8 | { 9 | public enum ProgressState 10 | { 11 | Ready, 12 | Started, 13 | Completed, 14 | Faulted, 15 | Paused, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/ProgressControl/ProgressStateEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProgressControlSample 8 | { 9 | public class ProgressStateEventArgs : EventArgs 10 | { 11 | public ProgressStateEventArgs(ProgressState oldValue, ProgressState newValue) 12 | { 13 | OldValue = oldValue; 14 | NewValue = newValue; 15 | } 16 | 17 | public bool Cancel { get; set; } 18 | 19 | public ProgressState OldValue { get; } 20 | 21 | public ProgressState NewValue { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/ProgressStateIndicator/ProgressStateIndicator.Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProgressControlSample 8 | 9 | { 10 | public partial class ProgressStateIndicator 11 | { 12 | private const string ProgressStatesGroupName = "ProgressStates"; 13 | private const string ReadyStateName = "Ready"; 14 | private const string StartedStateName = "Started"; 15 | private const string CompletedStateName = "Completed"; 16 | private const string FaultedStateName = "Faulted"; 17 | private const string PausedStateName = "Paused"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/MainPage.xaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/ProgressControl/ProgressControl.Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProgressControlSample 8 | { 9 | public partial class ProgressControl 10 | { 11 | private const string ProgressStatesGroupName = "ProgressStates"; 12 | private const string ReadyStateName = "Ready"; 13 | private const string StartedStateName = "Started"; 14 | private const string CompletedStateName = "Completed"; 15 | private const string FaultedStateName = "Faulted"; 16 | private const string PausedStateName = "Paused"; 17 | 18 | private const string ProgressStateIndicatorName = "ProgressStateIndicator"; 19 | private const string CancelButtonName = "CancelButton"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using System.Threading.Tasks; 7 | using Windows.Foundation; 8 | using Windows.Foundation.Collections; 9 | using Windows.UI.Xaml; 10 | using Windows.UI.Xaml.Controls; 11 | using Windows.UI.Xaml.Controls.Primitives; 12 | using Windows.UI.Xaml.Data; 13 | using Windows.UI.Xaml.Input; 14 | using Windows.UI.Xaml.Media; 15 | using Windows.UI.Xaml.Navigation; 16 | 17 | // https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板 18 | 19 | namespace ProgressControlSample 20 | { 21 | /// 22 | /// 可用于自身或导航至 Frame 内部的空白页。 23 | /// 24 | public sealed partial class MainPage : Page 25 | { 26 | public MainPage() 27 | { 28 | this.InitializeComponent(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Converter/BorderToStrokeThicknessConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Windows.UI.Xaml; 7 | using Windows.UI.Xaml.Data; 8 | 9 | namespace ProgressControlSample 10 | { 11 | public class BorderToStrokeThicknessConverter : IValueConverter 12 | { 13 | public object Convert(object value, Type targetType, object parameter, string language) 14 | { 15 | var thickness = (Thickness)value; 16 | var max = Math.Max(thickness.Left, thickness.Top); 17 | max = Math.Max(max, thickness.Right); 18 | max = Math.Max(max, thickness.Bottom); 19 | return max; 20 | } 21 | 22 | public object ConvertBack(object value, Type targetType, object parameter, string language) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Download/DownloadServiceClient.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net.Http; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Web; 9 | 10 | namespace ProgressControlSample.Download 11 | { 12 | public class DownloadServiceClient 13 | { 14 | public async Task Download(Progress progress = null) 15 | { 16 | HttpResponse r;r. 17 | var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader(); 18 | Task s; 19 | 20 | // Create a new download operation. 21 | var ownload = downloader.CreateDownload(null, null,null).StartAsync().AsTask().w; 22 | 23 | // Start the download and persist the promise to be able to cancel the download. 24 | promise = ownload.Progress....startAsync().then(complete, error, progress); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Behaviors/RectangleToEllipseBehavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Windows.UI.Xaml.Shapes; 7 | 8 | namespace ProgressControlSample 9 | { 10 | public class RectangleToEllipseBehavior : ProgressBehavior 11 | { 12 | protected override void OnProgressChanged(double oldValue, double newValue) 13 | { 14 | UpdateStrokeDashArray(); 15 | } 16 | 17 | protected override void OnAttached() 18 | { 19 | base.OnAttached(); 20 | UpdateStrokeDashArray(); 21 | } 22 | 23 | 24 | private void UpdateStrokeDashArray() 25 | { 26 | if (AssociatedObject == null || AssociatedObject.ActualHeight == 0 || AssociatedObject.ActualWidth == 0) 27 | return; 28 | 29 | var radius = Math.Min(AssociatedObject.ActualHeight, AssociatedObject.ActualWidth) / 2; 30 | radius = radius * Progress; 31 | AssociatedObject.RadiusX = radius; 32 | AssociatedObject.RadiusY = radius; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ProgressControlSample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ProgressControlSample")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/TestService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ProgressControlSample 8 | { 9 | public class TestService 10 | { 11 | public TestService() 12 | { 13 | _progress = 0; 14 | } 15 | 16 | private double _progress; 17 | 18 | public bool IsCompleted { get; private set; } 19 | 20 | public event EventHandler ProgressChanged; 21 | 22 | public bool IsPaused { get; set; } 23 | 24 | public bool IsStarted { get; private set; } 25 | 26 | public async Task Start(bool throwException = false) 27 | { 28 | IsStarted = true; 29 | try 30 | { 31 | ProgressChanged?.Invoke(this, _progress); 32 | await Task.Delay(1000); 33 | while (_progress < 100) 34 | { 35 | await Task.Delay(100); 36 | _progress += 3; 37 | ProgressChanged?.Invoke(this, _progress); 38 | if (_progress > 70 && throwException) 39 | throw new Exception("test"); 40 | 41 | if (IsPaused) 42 | return; 43 | } 44 | 45 | IsCompleted = true; 46 | } 47 | finally 48 | { 49 | IsStarted = false; 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Behaviors/ProgressBehavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Windows.UI.Xaml; 7 | using Microsoft.Xaml.Interactivity; 8 | 9 | namespace ProgressControlSample 10 | { 11 | public class ProgressBehavior : Behavior where T : DependencyObject 12 | { 13 | /// 14 | /// 获取或设置Progress的值 15 | /// 16 | public double Progress 17 | { 18 | get { return (double)GetValue(ProgressProperty); } 19 | set { SetValue(ProgressProperty, value); } 20 | } 21 | 22 | /// 23 | /// 标识 Progress 依赖属性。 24 | /// 25 | public static readonly DependencyProperty ProgressProperty = 26 | DependencyProperty.Register("Progress", typeof(double), typeof(ProgressBehavior), new PropertyMetadata(default(double), OnProgressChanged)); 27 | 28 | private static void OnProgressChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) 29 | { 30 | ProgressBehavior target = obj as ProgressBehavior; 31 | double oldValue = (double)args.OldValue; 32 | double newValue = (double)args.NewValue; 33 | if (oldValue != newValue) 34 | target.OnProgressChanged(oldValue, newValue); 35 | } 36 | 37 | protected virtual void OnProgressChanged(double oldValue, double newValue) 38 | { 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | ProgressControlSample 18 | JChen 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgressControlSample", "ProgressControlSample\ProgressControlSample.csproj", "{D115F213-6A7F-40B8-93A2-7ED1BB672701}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM = Release|ARM 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|ARM.ActiveCfg = Debug|ARM 19 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|ARM.Build.0 = Debug|ARM 20 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|ARM.Deploy.0 = Debug|ARM 21 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|x64.ActiveCfg = Debug|x64 22 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|x64.Build.0 = Debug|x64 23 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|x64.Deploy.0 = Debug|x64 24 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|x86.ActiveCfg = Debug|x86 25 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|x86.Build.0 = Debug|x86 26 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Debug|x86.Deploy.0 = Debug|x86 27 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|ARM.ActiveCfg = Release|ARM 28 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|ARM.Build.0 = Release|ARM 29 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|ARM.Deploy.0 = Release|ARM 30 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|x64.ActiveCfg = Release|x64 31 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|x64.Build.0 = Release|x64 32 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|x64.Deploy.0 = Release|x64 33 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|x86.ActiveCfg = Release|x86 34 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|x86.Build.0 = Release|x86 35 | {D115F213-6A7F-40B8-93A2-7ED1BB672701}.Release|x86.Deploy.0 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {1A045F4C-0C97-4632-BE1E-E1AFCB3DFB4F} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /ProgressControlSample/ProgressControlSample/Download/DownloadPage.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |