CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.Windows/BusyAnimation.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="BusyAnimation.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>User control that displays busy animation</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.ComponentModel;
11using System.Drawing;
12using System.Data;
13using System.Linq;
14using System.Text;
15using System.Windows.Forms;
16
17namespace Csla.Windows
18{
22 [ToolboxItem(true), ToolboxBitmap(typeof(BusyAnimation), "Csla.Windows.BusyAnimation")]
23 public partial class BusyAnimation : UserControl
24 {
29 {
30 InitializeComponent();
31 this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
32 this.BusyProgressBar.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase).Invoke(this.BusyProgressBar, new object[] { ControlStyles.SupportsTransparentBackColor, true });
33 if (!IsInDesignMode)
34 this.BusyProgressBar.BackColor = _progressBarBackColor;
35 }
36
37 private Color _progressBarForeColor = System.Drawing.Color.LawnGreen;
41 [Category("Csla")]
42 [Description("Foreground color for busy animation's progress bar.")]
43 [DefaultValue(typeof(System.Drawing.Color), "LawnGreen")]
44 [Browsable(true)]
46 {
47 get
48 {
49 return _progressBarForeColor;
50 }
51 set
52 {
53 _progressBarForeColor = value;
54 this.BusyProgressBar.ForeColor = _progressBarForeColor;
55 }
56 }
57
58
59 private Color _progressBarBackColor = System.Drawing.Color.White;
63 [Category("Csla")]
64 [Description("Background color for busy animation's progress bar.")]
65 [DefaultValue(typeof(System.Drawing.Color), "White")]
66 [Browsable(true)]
68 {
69 get
70 {
71 return _progressBarBackColor;
72 }
73 set
74 {
75 _progressBarBackColor = value;
76 this.BusyProgressBar.BackColor = _progressBarBackColor;
77 }
78 }
79
80 private bool _isRunning = false;
85 [Category("Csla")]
86 [Description("Indicates if animation needs to be shown. Set to true to start progress bar animation")]
87 [DefaultValue(false)]
88 [Bindable(true)]
89 [Browsable(true)]
90 public bool IsRunning
91 {
92 get
93 {
94 return _isRunning;
95 }
96 set
97 {
98 _isRunning = value;
99 Run(_isRunning);
100 }
101 }
102
103 private void Run(bool run)
104 {
105 if (!IsInDesignMode)
106 {
107 this.Visible = run;
108 this.BusyProgressBar.Visible = run;
109 this.ProgressTimer.Enabled = run;
110 }
111 }
112
113
114 private void ProgressTimer_Tick(object sender, EventArgs e)
115 {
116 if (_isRunning)
117 {
118 int newValue = this.BusyProgressBar.Value + this.BusyProgressBar.Step;
119 if (newValue > this.BusyProgressBar.Maximum)
120 {
121 this.BusyProgressBar.Value = 0;
122 }
123 else
124 {
125 this.BusyProgressBar.Value = newValue;
126 }
127 }
128 }
129
130 private bool IsInDesignMode
131 {
132 get
133 {
134 if (this.GetService(typeof(System.ComponentModel.Design.IDesignerHost)) != null)
135 return true;
136 else
137 return false;
138 }
139 }
140
141 private void BusyAnimation_Load(object sender, EventArgs e)
142 {
143 if (IsInDesignMode)
144 {
145 this.BusyProgressBar.Value = (int)(this.BusyProgressBar.Maximum / 2);
146 this.BusyProgressBar.Visible = true;
147 }
148 }
149
150 }
151}
User control that displays busy animation
Color ProgressBarForeColor
Set or get foreground color for busy animation's progress bar
Color ProgressBarBackColor
Set or get background color for busy animation's progress bar
bool IsRunning
Indicates if animation needs to be shown.
BusyAnimation()
new instance busy animation