Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/WPF/CS/GaugesDemo.Wpf/Modules/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/WPF/CS/GaugesDemo.Wpf/Modules/LinearScales.xaml.cs

using System;
using System.Windows;
using System.Windows.Threading;
using DevExpress.Xpf.DemoBase;
using DevExpress.Xpf.Gauges;
using DevExpress.Xpf.Utils;

namespace GaugesDemo {
    public partial class LinearScales : GaugesDemoModule {
        public LinearScales() {
            InitializeComponent();
            EqualizerDataGenerator dataGenerator = new EqualizerDataGenerator();
            gauge.DataContext = dataGenerator;
        }
    }

    public class EqualizerDataGenerator : DependencyObject {
        public static readonly DependencyProperty Frequency32Property = DependencyPropertyManager.Register("Frequency32",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency64Property = DependencyPropertyManager.Register("Frequency64",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency125Property = DependencyPropertyManager.Register("Frequency125",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency250Property = DependencyPropertyManager.Register("Frequency250",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency500Property = DependencyPropertyManager.Register("Frequency500",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency1KProperty = DependencyPropertyManager.Register("Frequency1K",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency2KProperty = DependencyPropertyManager.Register("Frequency2K",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency4KProperty = DependencyPropertyManager.Register("Frequency4K",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency8KProperty = DependencyPropertyManager.Register("Frequency8K",
            typeof(double), typeof(EqualizerDataGenerator));
        public static readonly DependencyProperty Frequency16KProperty = DependencyPropertyManager.Register("Frequency16K",
            typeof(double), typeof(EqualizerDataGenerator));

        public double Frequency32 {
            get { return (double)GetValue(Frequency32Property); }
            set { SetValue(Frequency32Property, value); }
        }
        public double Frequency64 {
            get { return (double)GetValue(Frequency64Property); }
            set { SetValue(Frequency64Property, value); }
        }
        public double Frequency125 {
            get { return (double)GetValue(Frequency125Property); }
            set { SetValue(Frequency125Property, value); }
        }
        public double Frequency250 {
            get { return (double)GetValue(Frequency250Property); }
            set { SetValue(Frequency250Property, value); }
        }
        public double Frequency500 {
            get { return (double)GetValue(Frequency500Property); }
            set { SetValue(Frequency500Property, value); }
        }
        public double Frequency1K {
            get { return (double)GetValue(Frequency1KProperty); }
            set { SetValue(Frequency1KProperty, value); }
        }
        public double Frequency2K {
            get { return (double)GetValue(Frequency2KProperty); }
            set { SetValue(Frequency2KProperty, value); }
        }
        public double Frequency4K {
            get { return (double)GetValue(Frequency4KProperty); }
            set { SetValue(Frequency4KProperty, value); }
        }
        public double Frequency8K {
            get { return (double)GetValue(Frequency8KProperty); }
            set { SetValue(Frequency8KProperty, value); }
        }
        public double Frequency16K {
            get { return (double)GetValue(Frequency16KProperty); }
            set { SetValue(Frequency16KProperty, value); }
        }

        const int MaxValue = 100;
        const int UpdateIneterval = 500;

        readonly Random random = new Random();
        readonly DispatcherTimer timer = new DispatcherTimer();

        public EqualizerDataGenerator() {
            timer.Tick += new EventHandler(OnTimedEvent);
            timer.Interval = new TimeSpan(0, 0, 0, 0, UpdateIneterval);
            timer.Start();
        }
        void OnTimedEvent(object source, EventArgs e) {
            Frequency32 = random.Next(MaxValue);
            Frequency64 = random.Next(MaxValue);
            Frequency125 = random.Next(MaxValue);
            Frequency250 = random.Next(MaxValue);
            Frequency500 = random.Next(MaxValue);
            Frequency1K = random.Next(MaxValue);
            Frequency2K = random.Next(MaxValue);
            Frequency4K = random.Next(MaxValue);
            Frequency8K = random.Next(MaxValue);
            Frequency16K = random.Next(MaxValue);
        }
    }
}