Exemplo n.º 1
0
        public ClockViewModel()
        {
            //setup the preferences of the user.
            var dateFormat = ClockConfiguration.GetPreference(ClockConfiguration.Preferences.DateFormat);

            if (dateFormat == null)
            {
                dateFormat = DateFormats.First().Value;
                ClockConfiguration.SetPreference(ClockConfiguration.Preferences.DateFormat, dateFormat);
            }
            SelectedDateFormat = dateFormat;

            var timeFormat = ClockConfiguration.GetPreference(ClockConfiguration.Preferences.TimeFormat);

            if (timeFormat == null)
            {
                timeFormat = TimeFormats.First().Value;
                ClockConfiguration.SetPreference(ClockConfiguration.Preferences.TimeFormat, timeFormat);
            }

            SelectedTimeFormat = timeFormat;

            _timer          = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 1);
            _timer.Tick    += timer_Tick;
            _timer.Start();
        }