├── ScreenShots
└── ThinProgressLine_on_BlackBkg.JPG
├── CleanProject.bat
├── CircularProgressBar
├── App.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── App.xaml.cs
├── App.xaml
├── MainWindow.xaml.cs
├── MainWindow.xaml
├── mvvmSupport
│ └── CommandHandler.cs
├── MainViewModel.cs
├── CircularProgressBarApp.csproj
├── Converters.cs
├── CircularProgressBar.cs
└── styles.xaml
├── README.md
├── CircularProgressBar.sln
└── .gitignore
/ScreenShots/ThinProgressLine_on_BlackBkg.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aalitor/WPF_Circular-Progress-Bar/HEAD/ScreenShots/ThinProgressLine_on_BlackBkg.JPG
--------------------------------------------------------------------------------
/CleanProject.bat:
--------------------------------------------------------------------------------
1 | cd /d %~dp0
2 | FOR /F "tokens=*" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
3 | FOR /F "tokens=*" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
--------------------------------------------------------------------------------
/CircularProgressBar/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/CircularProgressBar/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/CircularProgressBar/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace CircularProgressBarApp
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WPF_Circular-Progress-Bar
2 | Circular progress bar created in WPF
3 |
4 |
5 |
6 | .... or with settings
7 |
8 | ```
9 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/CircularProgressBar/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace CircularProgressBarApp
17 | {
18 | ///
19 | /// Interaction logic for MainWindow.xaml
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | public MainWindow()
24 | {
25 | InitializeComponent();
26 | this.DataContext = new MainViewModel();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/CircularProgressBar.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26403.7
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CircularProgressBarApp", "CircularProgressBar\CircularProgressBarApp.csproj", "{9F2E3F63-513A-4F87-B839-8B0136B1039A}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {9F2E3F63-513A-4F87-B839-8B0136B1039A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {9F2E3F63-513A-4F87-B839-8B0136B1039A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {9F2E3F63-513A-4F87-B839-8B0136B1039A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {9F2E3F63-513A-4F87-B839-8B0136B1039A}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/CircularProgressBar/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace CircularProgressBarApp.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CircularProgressBar/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
36 |
37 |
38 |
44 |
45 |
--------------------------------------------------------------------------------
/CircularProgressBar/mvvmSupport/CommandHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Input;
7 |
8 | namespace CircularProgressBarApp.mvvmSupport
9 | {
10 | public class CommandHandler : ICommand
11 | {
12 | private Action execute;
13 |
14 | private Func canExecute;
15 |
16 | private event EventHandler CanExecuteChangedInternal;
17 |
18 | public CommandHandler(Action execute)
19 | : this(execute, DefaultCanExecute)
20 | {
21 | }
22 |
23 | public CommandHandler(Action execute, Func canExecute)
24 | {
25 | if (execute == null)
26 | {
27 | throw new ArgumentNullException("execute");
28 | }
29 |
30 | if (canExecute == null)
31 | {
32 | throw new ArgumentNullException("canExecute");
33 | }
34 |
35 | this.execute = execute;
36 | this.canExecute = canExecute;
37 | }
38 |
39 | public event EventHandler CanExecuteChanged
40 | {
41 | add
42 | {
43 | CommandManager.RequerySuggested += value;
44 | this.CanExecuteChangedInternal += value;
45 | }
46 |
47 | remove
48 | {
49 | CommandManager.RequerySuggested -= value;
50 | this.CanExecuteChangedInternal -= value;
51 | }
52 | }
53 |
54 | public bool CanExecute(object parameter)
55 | {
56 | return this.canExecute != null && this.canExecute();
57 | }
58 |
59 | public void Execute(object parameter)
60 | {
61 | this.execute();
62 | }
63 |
64 | public void OnCanExecuteChanged()
65 | {
66 | EventHandler handler = this.CanExecuteChangedInternal;
67 | if (handler != null)
68 | {
69 | handler.Invoke(this, EventArgs.Empty);
70 | }
71 | }
72 |
73 | private static bool DefaultCanExecute()
74 | {
75 | return true;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/CircularProgressBar/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using System.Windows.Input;
9 | using CircularProgressBarApp.mvvmSupport;
10 |
11 | namespace CircularProgressBarApp
12 | {
13 | public class MainViewModel : INotifyPropertyChanged
14 | {
15 | public ICommand StartCommand { get; private set; }
16 | private readonly BackgroundWorker worker;
17 | private int _progressValue;
18 | public int ProgressValue
19 | {
20 | get { return _progressValue; }
21 | set
22 | {
23 | _progressValue = value;
24 | OnPropertyChanged("ProgressValue");
25 | OnPropertyChanged("ProgressText");
26 | }
27 | }
28 |
29 | public string ProgressText
30 | {
31 | get { return string.Format("{0} %", _progressValue); }
32 | }
33 |
34 |
35 | public MainViewModel()
36 | {
37 | this.worker = new BackgroundWorker();
38 | this.worker.WorkerReportsProgress = true;
39 | this.worker.DoWork += this.DoWork;
40 | this.worker.ProgressChanged += this.ProgressChanged;
41 | StartCommand = new CommandHandler(() =>
42 | {
43 | this.worker.RunWorkerAsync();
44 | }, () =>
45 | {
46 | return !this.worker.IsBusy;
47 | });
48 |
49 | }
50 | private void DoWork(object sender, DoWorkEventArgs e)
51 | {
52 | for (int i = 0; i <= 100; i++)
53 | {
54 | Thread.Sleep(100);//Do your Work Here instead of sleeping
55 | worker.ReportProgress(i);
56 | }
57 | }
58 |
59 | private void ProgressChanged(object sender, ProgressChangedEventArgs e)
60 | {
61 | this.ProgressValue = e.ProgressPercentage;
62 | }
63 |
64 |
65 | #region INotifyPropertyChanged
66 | public event PropertyChangedEventHandler PropertyChanged;
67 | protected void OnPropertyChanged(string name)
68 | {
69 | if (PropertyChanged != null)
70 | PropertyChanged(this, new PropertyChangedEventArgs(name));
71 | }
72 | #endregion
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/CircularProgressBar/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("TestApp")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("Microsoft")]
14 | [assembly: AssemblyProduct("TestApp")]
15 | [assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/CircularProgressBar/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace CircularProgressBarApp.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CircularProgressBarApp.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/CircularProgressBar/CircularProgressBarApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {9F2E3F63-513A-4F87-B839-8B0136B1039A}
8 | WinExe
9 | CircularProgressBarApp
10 | CircularProgressBarApp
11 | v4.5
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 |
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 4.0
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | MSBuild:Compile
56 | Designer
57 |
58 |
59 | MSBuild:Compile
60 | Designer
61 |
62 |
63 | App.xaml
64 | Code
65 |
66 |
67 |
68 |
69 |
70 | MainWindow.xaml
71 | Code
72 |
73 |
74 | MSBuild:Compile
75 | Designer
76 |
77 |
78 |
79 |
80 |
81 | Code
82 |
83 |
84 | True
85 | True
86 | Resources.resx
87 |
88 |
89 | True
90 | Settings.settings
91 | True
92 |
93 |
94 | ResXFileCodeGenerator
95 | Resources.Designer.cs
96 |
97 |
98 | SettingsSingleFileGenerator
99 | Settings.Designer.cs
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
--------------------------------------------------------------------------------
/CircularProgressBar/Converters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 | using System.Windows.Media;
6 |
7 | namespace CircularProgressBarApp
8 | {
9 | public class AngleToPointConverter : IMultiValueConverter
10 | {
11 |
12 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | double angle = (double)values[0];
15 | double radius = (double)values[1];
16 | double stroke = (double)values[2];
17 | double piang = angle * Math.PI / 180;
18 |
19 | double px = Math.Sin(piang) * (radius - stroke / 2) + radius;
20 | double py = -Math.Cos(piang) * (radius - stroke / 2) + radius;
21 | return new Point(px, py);
22 | }
23 |
24 | public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
25 | {
26 | throw new NotImplementedException();
27 | }
28 | }
29 | public class AngleToIsLargeConverter : IValueConverter
30 | {
31 |
32 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
33 | {
34 | double angle = (double)value;
35 |
36 | return angle > 180;
37 | }
38 |
39 | public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
40 | {
41 | throw new NotImplementedException();
42 | }
43 | }
44 | public class StrokeToStartPointConverter : IMultiValueConverter
45 | {
46 |
47 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
48 | {
49 | double radius = (double)values[0];
50 | double stroke = (double)values[1];
51 | return new Point(radius, stroke / 2);
52 | }
53 |
54 | public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
55 | {
56 | throw new NotImplementedException();
57 | }
58 | }
59 | public class RadiusToSizeConverter : IMultiValueConverter
60 | {
61 |
62 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
63 | {
64 | double radius = (double)values[0];
65 | double stroke = (double)values[1];
66 | return new Size(radius - stroke / 2, radius - stroke / 2);
67 | }
68 |
69 | public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
70 | {
71 | throw new NotImplementedException();
72 | }
73 | }
74 | public class RadiusToCenterConverter : IValueConverter
75 | {
76 |
77 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
78 | {
79 | double radius = (double)value;
80 | return new Point(radius, radius);
81 | }
82 |
83 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
84 | {
85 | throw new NotImplementedException();
86 | }
87 | }
88 | public class RadiusToDiameter : IValueConverter
89 | {
90 |
91 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
92 | {
93 | double radius = (double)value;
94 | return 2 * radius;
95 | }
96 |
97 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
98 | {
99 | throw new NotImplementedException();
100 | }
101 | }
102 | public class InnerRadiusConverter : IMultiValueConverter
103 | {
104 |
105 | public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
106 | {
107 | double radius = (double)values[0];
108 | double stroke = (double)values[1];
109 | StrokeMode mode = (StrokeMode) values[2];
110 |
111 | switch (mode)
112 | {
113 | case StrokeMode.Inside:
114 | return radius - stroke;
115 | case StrokeMode.Outside:
116 | return radius;
117 | default:
118 | return radius - stroke / 2;
119 | }
120 |
121 | }
122 |
123 | public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
124 | {
125 | throw new NotImplementedException();
126 | }
127 | }
128 |
129 | public class StrokeLineCapConverter : IMultiValueConverter
130 | {
131 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
132 | {
133 | if (values[0] is double progress && progress > 0)
134 | {
135 | PenLineCap cap = (PenLineCap) values[1];
136 | return cap;
137 | }
138 | return PenLineCap.Flat;
139 | }
140 |
141 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
142 | {
143 | throw new NotImplementedException();
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/CircularProgressBar/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/CircularProgressBar/CircularProgressBar.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Media;
9 | using System.Windows.Media.Animation;
10 |
11 | namespace CircularProgressBarApp
12 | {
13 | public class CircularProgressBar : ProgressBar
14 | {
15 | public CircularProgressBar()
16 | {
17 | this.ValueChanged += CircularProgressBar_ValueChanged;
18 | this.SizeChanged += CircularProgressBar_SizeChanged;
19 |
20 | }
21 | protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
22 | {
23 | if (e.Property == CircularProgressBar.RadiusProperty)
24 | {
25 | Width = Height = Radius * 2;
26 | }
27 | base.OnPropertyChanged(e);
28 | }
29 | void CircularProgressBar_SizeChanged(object sender, SizeChangedEventArgs e)
30 | {
31 | this.Radius = Math.Min(ActualWidth, ActualHeight) / 2;
32 | }
33 | void CircularProgressBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
34 | {
35 |
36 | CircularProgressBar bar = sender as CircularProgressBar;
37 | double currentAngle = bar.Angle;
38 | double targetAngle = e.NewValue / bar.Maximum * 359.999;
39 | double duration = Math.Abs(currentAngle - targetAngle) / 359.999 * 500;
40 | DoubleAnimation anim = new DoubleAnimation(currentAngle, targetAngle, TimeSpan.FromMilliseconds(duration > 0 ? duration : 10));
41 | bar.BeginAnimation(CircularProgressBar.AngleProperty, anim, HandoffBehavior.Compose);
42 | }
43 |
44 | public double Angle
45 | {
46 | get { return (double)GetValue(AngleProperty); }
47 | set { SetValue(AngleProperty, value); }
48 | }
49 |
50 | // Using a DependencyProperty as the backing store for Angle. This enables animation, styling, binding, etc...
51 | public static readonly DependencyProperty AngleProperty =
52 | DependencyProperty.Register("Angle", typeof(double), typeof(CircularProgressBar), new PropertyMetadata(0.0));
53 |
54 | public double StrokeThickness
55 | {
56 | get { return (double)GetValue(StrokeThicknessProperty); }
57 | set { SetValue(StrokeThicknessProperty, value); }
58 | }
59 |
60 | // Using a DependencyProperty as the backing store for StrokeThickness. This enables animation, styling, binding, etc...
61 | public static readonly DependencyProperty StrokeThicknessProperty =
62 | DependencyProperty.Register(nameof(StrokeThickness), typeof(double), typeof(CircularProgressBar), new PropertyMetadata(1.0));
63 |
64 | public double Thickness
65 | {
66 | get { return (double)GetValue(ThicknessProperty); }
67 | set { SetValue(ThicknessProperty, value); }
68 | }
69 |
70 | // Using a DependencyProperty as the backing store for StrokeThickness. This enables animation, styling, binding, etc...
71 | public static readonly DependencyProperty ThicknessProperty =
72 | DependencyProperty.Register(nameof(Thickness), typeof(double), typeof(CircularProgressBar), new PropertyMetadata(10d));
73 |
74 | public double Radius
75 | {
76 | get { return (double)GetValue(RadiusProperty); }
77 | set { SetValue(RadiusProperty, value); }
78 | }
79 |
80 | // Using a DependencyProperty as the backing store for Radius. This enables animation, styling, binding, etc...
81 | public static readonly DependencyProperty RadiusProperty =
82 | DependencyProperty.Register("Radius", typeof(double), typeof(CircularProgressBar), new PropertyMetadata(50.0));
83 |
84 |
85 | public Brush Fill
86 | {
87 | get { return (Brush)GetValue(FillProperty); }
88 | set { SetValue(FillProperty, value); }
89 | }
90 | public static readonly DependencyProperty FillProperty =
91 | DependencyProperty.Register(nameof(Fill), typeof(Brush), typeof(CircularProgressBar), new PropertyMetadata(Brushes.Transparent));
92 |
93 | public Brush Stroke
94 | {
95 | get { return (Brush)GetValue(StrokeProperty); }
96 | set { SetValue(StrokeProperty, value); }
97 | }
98 | public static readonly DependencyProperty StrokeProperty =
99 | DependencyProperty.Register(nameof(Stroke), typeof(Brush), typeof(CircularProgressBar), new PropertyMetadata(Brushes.LightGray));
100 |
101 | public PenLineCap StartLineCap
102 | {
103 | get { return (PenLineCap)GetValue(StartLineCapProperty); }
104 | set { SetValue(StartLineCapProperty, value); }
105 | }
106 | public static readonly DependencyProperty StartLineCapProperty =
107 | DependencyProperty.Register(nameof(StartLineCap), typeof(PenLineCap), typeof(CircularProgressBar), new PropertyMetadata(PenLineCap.Flat));
108 |
109 |
110 | public PenLineCap EndLineCap
111 | {
112 | get { return (PenLineCap)GetValue(EndLineCapProperty); }
113 | set { SetValue(EndLineCapProperty, value); }
114 | }
115 | public static readonly DependencyProperty EndLineCapProperty =
116 | DependencyProperty.Register(nameof(EndLineCap), typeof(PenLineCap), typeof(CircularProgressBar), new PropertyMetadata(PenLineCap.Round));
117 |
118 | public StrokeMode StrokeMode
119 | {
120 | get { return (StrokeMode) GetValue(StrokeModeProperty); }
121 | set { SetValue(StrokeModeProperty, value); }
122 | }
123 | public static readonly DependencyProperty StrokeModeProperty =
124 | DependencyProperty.Register(nameof(StrokeMode), typeof(StrokeMode), typeof(CircularProgressBar), new PropertyMetadata(StrokeMode.Middle));
125 |
126 | }
127 |
128 | public enum StrokeMode
129 | {
130 | Middle,
131 | Inside,
132 | Outside,
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/CircularProgressBar/styles.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
105 |
--------------------------------------------------------------------------------