コード例 #1
0
        public static void UpdateApplicationSettingsToCurrentVersion()
        {
            var s = ApplicationSettings.DefaultDocumentSettings;

            // add some speed waypoint attribute settings, introduced in QR 2.1
            if (!s.ColorRangeIntervalSliderSettings.ContainsKey(WaypointAttribute.Speed))
            {
                var defaultCRISS = DocumentSettings.CreateDefaultColorRangeIntervalSliderSettings();
                s.ColorRangeIntervalSliderSettings.Add(WaypointAttribute.Speed, defaultCRISS[WaypointAttribute.Speed]);
            }

            if (!s.LapHistogramSettings.ContainsKey(WaypointAttribute.Speed))
            {
                var defaultLHS = DocumentSettings.CreateDefaultLapHistogramSettings();
                s.LapHistogramSettings.Add(WaypointAttribute.Speed, defaultLHS[WaypointAttribute.Speed]);
            }

            if (!s.DefaultSessionSettings.RouteLineSettingsCollection.ContainsKey(WaypointAttribute.Speed))
            {
                var defaultRLS = SessionSettings.CreateDefaultRouteLineSettingsCollection();
                s.DefaultSessionSettings.RouteLineSettingsCollection.Add(WaypointAttribute.Speed, defaultRLS[WaypointAttribute.Speed]);
            }

            // add some direction waypoint attribute settings, introduced in QR 2.2
            if (!s.ColorRangeIntervalSliderSettings.ContainsKey(WaypointAttribute.DirectionDeviationToNextLap))
            {
                var defaultCRISS = DocumentSettings.CreateDefaultColorRangeIntervalSliderSettings();
                s.ColorRangeIntervalSliderSettings.Add(WaypointAttribute.DirectionDeviationToNextLap, defaultCRISS[WaypointAttribute.DirectionDeviationToNextLap]);
            }

            if (!s.LapHistogramSettings.ContainsKey(WaypointAttribute.DirectionDeviationToNextLap))
            {
                var defaultLHS = DocumentSettings.CreateDefaultLapHistogramSettings();
                s.LapHistogramSettings.Add(WaypointAttribute.DirectionDeviationToNextLap, defaultLHS[WaypointAttribute.DirectionDeviationToNextLap]);
            }

            if (!s.DefaultSessionSettings.RouteLineSettingsCollection.ContainsKey(WaypointAttribute.DirectionDeviationToNextLap))
            {
                var defaultRLS = SessionSettings.CreateDefaultRouteLineSettingsCollection();
                s.DefaultSessionSettings.RouteLineSettingsCollection.Add(WaypointAttribute.DirectionDeviationToNextLap, defaultRLS[WaypointAttribute.DirectionDeviationToNextLap]);
            }

            // add some map reading duration attribute settings, introduced in QR 2.4
            if (!s.ColorRangeIntervalSliderSettings.ContainsKey(WaypointAttribute.MapReadingDuration))
            {
                var defaultCRISS = DocumentSettings.CreateDefaultColorRangeIntervalSliderSettings();
                s.ColorRangeIntervalSliderSettings.Add(WaypointAttribute.MapReadingDuration, defaultCRISS[WaypointAttribute.MapReadingDuration]);
            }

            if (!s.LapHistogramSettings.ContainsKey(WaypointAttribute.MapReadingDuration))
            {
                var defaultLHS = DocumentSettings.CreateDefaultLapHistogramSettings();
                s.LapHistogramSettings.Add(WaypointAttribute.MapReadingDuration, defaultLHS[WaypointAttribute.MapReadingDuration]);
            }

            if (!s.DefaultSessionSettings.RouteLineSettingsCollection.ContainsKey(WaypointAttribute.MapReadingDuration))
            {
                var defaultRLS = SessionSettings.CreateDefaultRouteLineSettingsCollection();
                s.DefaultSessionSettings.RouteLineSettingsCollection.Add(WaypointAttribute.MapReadingDuration, defaultRLS[WaypointAttribute.MapReadingDuration]);
            }

            if (ApplicationSettings.PublishMapSettings == null)
            {
                ApplicationSettings.PublishMapSettings = new List <PublishMapSettingsItem>();
            }

            // make sure new property types are propagated to the settings
            if (ApplicationSettings.LapPropertyTypes.Count < ApplicationSettings.AvailableLapPropertyTypes.Count)
            {
                foreach (var rpt in ApplicationSettings.AvailableLapPropertyTypes)
                {
                    if (!ApplicationSettings.LapPropertyTypes.ContainsRoutePropertyType(rpt.RoutePropertyType))
                    {
                        ApplicationSettings.LapPropertyTypes.Add(rpt);
                    }
                }
            }

            // make sure new property types are propagated to the settings
            if (ApplicationSettings.MomentaneousInfoPropertyTypes.Count < ApplicationSettings.AvailableMomentaneousInfoPropertyTypes.Count)
            {
                foreach (var rpt in ApplicationSettings.AvailableMomentaneousInfoPropertyTypes)
                {
                    if (!ApplicationSettings.MomentaneousInfoPropertyTypes.ContainsRoutePropertyType(rpt.RoutePropertyType))
                    {
                        ApplicationSettings.MomentaneousInfoPropertyTypes.Add(rpt);
                    }
                }
            }
        }