Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TimeLineViewModel"/> class.
        /// </summary>
        public TimeLineViewModel()
        {
            var now = DateTime.UtcNow;

            _maxTime = now;
            _minTime = now.AddHours(-24);

            _scrollPosition         = 0;
            _scrollScale            = 1.0;
            _warpGradientParameters = CalculateSkyGradient();

            _service = ServiceLocator.GetInstance <EarthQuakesService>();
            //NOTE: service is null when Blend calls this constructor when opening the TimeLineView.xaml
            if (_service != null)
            {
                _service.RequestMode          = EarthQuakeRequestMode.LastWeek;
                _regionsFilter                = new FilterViewModel(_service.EartQuakeRegionNames, _service.SelectedRegions);
                _regionsFilter.FilterChanged += RegionsFilterPropertyChanged;

                //Register using a weak event on the service PropertyChanged event.
                WeakPropertyChangedListener.CreateIfNecessary(_service, this);
                UpdateEarthQuakeData(_service.EarthQuakes);

                if (!_service.IsStarted)
                {
                    _service.StartService();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapViewModel"/> class.
        /// </summary>
        public MapViewModel()
        {
            _earthQuakeRadiusScaleMin = 10;
            _earthQuakeRadiusScaleMax = 90;
            _earthQuakeColorScaleMin  = 2.5;
            _earthQuakeColorScaleMax  = 10;

            _service = ServiceLocator.GetInstance <EarthQuakesService>();
            // NOTE: service is null when Blend calls this constructor when opening the TimeLineView.xaml
            if (_service != null)
            {
                _service.RequestMode          = EarthQuakeRequestMode.LastWeek;
                _regionsFilter                = new FilterViewModel(_service.EartQuakeRegionNames, _service.SelectedRegions);
                _regionsFilter.FilterChanged += RegionsFilterPropertyChanged;

                WeakPropertyChangedListener.CreateIfNecessary(_service, this);
                GetEarthQuakeData(_service.EarthQuakes);

                if (!_service.IsStarted)
                {
                    _service.StartService();
                }
            }
        }