Click here to Skip to main content
15,885,278 members
Articles / Mobile Apps / Windows Phone 7

Custom Gauge Controls for Windows Phone 7: Part I

Rate me:
Please Sign up or sign in to vote.
4.91/5 (61 votes)
25 Feb 2013CPOL15 min read 143.4K   3.5K   78  
The first article in this series presents the implementation considerations and the way to use some custom gauges in WP7.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace WPScadaControlsV2
{
    public abstract class BarIndicator:Indicator
    {
        #region dependency properties

        public int BarThickness
        {
            get { return (int)GetValue(BarThicknessProperty); }
            set { SetValue(BarThicknessProperty, value); }
        }
        public static readonly DependencyProperty BarThicknessProperty =
            DependencyProperty.Register("BarThickness", typeof(int), typeof(BarIndicator), new PropertyMetadata(3, BarThicknessPropertyChanged));

        public Brush BarBrush
        {
            get { return (Brush)GetValue(BarBrushProperty); }
            set { SetValue(BarBrushProperty, value); }
        }
        public static readonly DependencyProperty BarBrushProperty =
            DependencyProperty.Register("BarBrush", typeof(Brush), typeof(BarIndicator), new PropertyMetadata(new SolidColorBrush(Colors.White), BarBrushPropertyChanged));

        #endregion

        #region dp handlers
        private static void BarThicknessPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            BarIndicator ind = o as BarIndicator;
            if (ind != null)
            {
                ind.OnBarThicknesChanged((int)e.NewValue, (int)e.OldValue);
            }
        }
        private static void BarBrushPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
        }
        protected virtual void OnBarThicknesChanged(int newVal, int oldVal) { }
        #endregion
    }
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions