Exemplo n.º 1
0
        static UCSettings()
        {
            SettingsContainer = ApplicationData.Current.LocalSettings;

            _currentClockSize   = GetClockSizeOrDefault();
            _currentClockFormat = GetClockFormatOrDefault();
        }
        static UCSettings()
        {
            SettingsContainer = ApplicationData.Current.LocalSettings;

            _currentClockSize = GetClockSizeOrDefault();
            _currentClockFormat = GetClockFormatOrDefault();
        }
Exemplo n.º 3
0
 private void Current_Exit(object sender, System.Windows.ExitEventArgs e)
 {
     Console.WriteLine("Saving settings");
     Settings.Default.HighlightDPS                 = HighlightDPS;
     Settings.Default.BackgroundImagePath          = BackgroundImagePath == null ? string.Empty : BackgroundImagePath;
     Settings.Default.EnabledLineSeries            = LineSeriesSettings.GetEnumValue().ToString();
     Settings.Default.DetailedDamageVisibleColumns = DetailedDamageVisibleSettings.GetEnum().ToString();
     Settings.Default.HiddenDamageTypes            = DamageTypesSettings.GetHiddenTrackersEnum().ToString();
     Settings.Default.SplitDamageTypes             = DamageTypesSettings.GetSeparatedTrackersEnum(false).ToString();
     Settings.Default.ShortenDPSReadout            = ShortenDPSReadout;
     Settings.Default.OpenGraphForSelf             = OpenGraphForSelfAutomatically;
     Settings.Default.AnonymizePlayers             = AnonymizePlayers;
     SettingsVM.SaveSettings();
     ClockFormat.Save();
     Settings.Default.Save();
     Console.WriteLine("Settings saved");
 }
Exemplo n.º 4
0
        public ClockFormat FactoryMethod(ClockFormats formats)
        {
            ClockFormat cf = null;

            switch (formats)
            {
            case ClockFormats.BerlinClockFormat:
                cf = new BerlinClockFormat();
                break;

            case ClockFormats.DifImpBerlinClockFormat:
                cf = new DifImpBerlinClockFormat();
                break;

            default:
                cf = new UnknownClockFormat();
                break;
            }

            return(cf);
        }
        private void ScheduleTileUpdate(DateTime baseTime, TimeSpan shift, TileUpdater tileUpdater, ClockFormat clockFormat)
        {
            var shiftedTime = baseTime.Add(shift);
            var interval = 60/_baseDateTimes.Count();
            var i = 0;
            var calculatedCitiesInfo = _baseDateTimes.Select(c => new CalculatedCityInfo { CityInfo = c.Key, DestinationTime = c.Value.Add(shift) }).ToList();
            foreach (var info in calculatedCitiesInfo)
            {
                var tileXmlNow = GetTileUpdateMessage(info, calculatedCitiesInfo, _baseDateTimes.Count(), clockFormat);
                var document = new XmlDocument();
                document.LoadXml(tileXmlNow);

                var deliveryTime = shiftedTime.AddSeconds(i * interval);
                if (deliveryTime <= DateTime.Now)
                {
                    tileUpdater.Update(new TileNotification(document) { ExpirationTime = shiftedTime.AddSeconds(interval) });
                }
                else
                {
                    var scheduledNotification = new ScheduledTileNotification(document, deliveryTime) { ExpirationTime = deliveryTime.AddSeconds(interval) };
                    tileUpdater.AddToSchedule(scheduledNotification);
                }
                i++;
            }
        }
        private string GetTileUpdateMessage(CalculatedCityInfo info, IEnumerable<CalculatedCityInfo> calculatedCitiesInfo, int userCititesCount, ClockFormat clockFormat)
        {
            var format = clockFormat == ClockFormat.TwentyFourClock ? "HH:mm" : "hh:mm tt";
            var cityInfo = info.CityInfo;
            var cityDescription = string.Format("{0}, {1}", cityInfo.Name, info.DestinationTime.ToString("M"));
            var largeTileCandidates = calculatedCitiesInfo
                .Where(c => !c.CityInfo.Equals(cityInfo));
            if (userCititesCount < 3)
                return string.Format(TileUpdateMessageForLessThen3Items, info.DestinationTime.ToString(format),
                    cityDescription,
                    cityInfo.CountryCode);

            var cityIndex1 = GetRandom(0, largeTileCandidates.Count(), -1);
            var cityIndex2 = GetRandom(0, largeTileCandidates.Count(), cityIndex1);
            var largeCity2 = largeTileCandidates.ElementAt(cityIndex1);
            var largeCity3 = largeTileCandidates.ElementAt(cityIndex2);
            var city2Description = string.Format("{0}, {1}", largeCity2.CityInfo.Name, largeCity2.DestinationTime.ToString("M"));
            var city3Description = string.Format("{0}, {1}", largeCity3.CityInfo.Name, largeCity3.DestinationTime.ToString("M"));
            return string.Format(TileUpdateMessageFor3OrMoreItems, info.DestinationTime.ToString(format), cityDescription,
                cityInfo.CountryCode,
                largeCity2.DestinationTime.ToString(format), city2Description,
                largeCity3.DestinationTime.ToString(format), city3Description,
                largeCity2.CityInfo.CountryCode, largeCity3.CityInfo.CountryCode);
        }