using System;
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;
using System.ComponentModel;

namespace NumberFlickerLibrary
{
    public partial class NumberFlicker : UserControl, INotifyPropertyChanged
    {
        public NumberFlicker()
        {
            // Required to initialize variables
            InitializeComponent();
            this.DataContext = this;
        }

        private int numberValue = 0;
        public int NumberValue
        {
            get { return numberValue; }
            set
            {
                if (value == 10)
                {
                    value = 0;
                }
                if (value == -1)
                {
                    value = 9;
                }
                numberValue = value;
                NotifyPropertyChanged("NumberValue");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        private void upBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            NumberValue++;
        }

        private void downBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            NumberValue--;
        }
    }
}