|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Timers;
namespace WPFSparkClient
{
/// <summary>
/// Interaction logic for SprocketControlDemo.xaml
/// </summary>
public partial class SprocketControlDemo : Window
{
Timer timer1 = new Timer(70);
Timer timer2 = new Timer(70);
public SprocketControlDemo()
{
InitializeComponent();
timer1.Elapsed += new ElapsedEventHandler(timer1_Elapsed);
timer2.Elapsed += new ElapsedEventHandler(timer2_Elapsed);
}
void timer1_Elapsed(object sender, ElapsedEventArgs e)
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
sprocketControl3.Progress++;
if (sprocketControl3.Progress >= 100)
{
timer1.Enabled = false;
button1.IsEnabled = true;
}
}));
}
void timer2_Elapsed(object sender, ElapsedEventArgs e)
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
sprocketControl4.Progress++;
if (sprocketControl4.Progress >= 100)
{
timer2.Enabled = false;
button2.IsEnabled = true;
}
}));
}
private void button1_Click(object sender, RoutedEventArgs e)
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
button1.IsEnabled = false;
sprocketControl3.Progress = 0;
textBlock1.Visibility = System.Windows.Visibility.Visible;
timer1.Enabled = true;
}));
}
private void button2_Click(object sender, RoutedEventArgs e)
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
button2.IsEnabled = false;
sprocketControl4.Progress = 0;
textBlock2.Visibility = System.Windows.Visibility.Visible;
timer2.Enabled = true;
}));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
An individual with more than a decade of experience in desktop computing and mobile app development primarily on the Microsoft platform. He loves programming in C#, WPF & XAML related technologies.
Current interests include web application development, developing rich user experiences across various platforms and exploring his creative side.
Ratish's personal blog:
wpfspark.wordpress.com