Beispiel #1
0
        public void WriteConfiguration(PropertySetter propertySetter)
        {
            // write markers
            var count = Markers.Count;

            propertySetter(Constants.MarkersCount, count.ToString());

            for (int index = 0; index < count; index++)
            {
                var marker = Markers[index];
                propertySetter(GetIndexedName(Constants.MarkerId, index), marker.DeviceId.ToString());
                propertySetter(GetIndexedName(Constants.MarkerColor, index), MarkerNames.GetName(marker.MarkerType));
            }

            // write map type
            propertySetter(Constants.GMapProviderType, MapProviderNames.GetName(MapType));

            // write tooltip
            propertySetter(Constants.ToolTipAppearance, ToolTipAppearanceNames.GetName(ToolTip.Appearance));
            propertySetter(Constants.ToolTipText, ToolTipTextNames.GetName(ToolTip.TextType));

            // write timout in seconds
            propertySetter(Constants.TimeoutSeconds, TimeoutInSeconds.ToString());

            // write show zoom panel
            propertySetter(Constants.ShowZoomPanel, ShowZoomPanel.ToString());

            // write map zoom level
            propertySetter(Constants.MapZoomFactor, MapZoomLevel.ToString());

            // write map position
            propertySetter(Constants.MapPositionLng, MapPosition.Lng.ToString());
            propertySetter(Constants.MapPositionLat, MapPosition.Lat.ToString());
        }
Beispiel #2
0
        public void ReadConfiguration(PropertyGetter propertyGetter)
        {
            // read markers
            var count = 0;

            try { count = Convert.ToInt32(propertyGetter(Constants.MarkersCount)); }
            catch {}

            Markers.Clear();
            for (int index = 0; index < count; index++)
            {
                try
                {
                    var marker = new Marker();
                    marker.DeviceId   = new Guid(propertyGetter(GetIndexedName(Constants.MarkerId, index)));
                    marker.MarkerType = MarkerNames.GetType(propertyGetter(GetIndexedName(Constants.MarkerColor, index)));
                    Markers.Add(marker);
                }
                catch
                {
                }
            }

            // read map type
            MapType = MapProviderNames.GetType(propertyGetter(Constants.GMapProviderType));

            // read tooltip
            ToolTip.Appearance = ToolTipAppearanceNames.GetType(propertyGetter(Constants.ToolTipAppearance));
            ToolTip.TextType   = ToolTipTextNames.GetType(propertyGetter(Constants.ToolTipText));
            if (ToolTip.TextType < ToolTipTextTypes.Name)
            {
                ToolTip.TextType = ToolTipTextTypes.Name;
            }

            // read timeout in seconds
            try
            {
                var timeOutSecondsString = propertyGetter(Constants.TimeoutSeconds);
                if (!string.IsNullOrWhiteSpace(timeOutSecondsString))
                {
                    TimeoutInSeconds = Convert.ToInt32(timeOutSecondsString);
                }
            }
            catch { }


            // read show zoom panel
            ShowZoomPanel = (0 == String.Compare(propertyGetter(Constants.ShowZoomPanel),
                                                 true.ToString(), StringComparison.OrdinalIgnoreCase));

            // read map zoom level
            try { MapZoomLevel = Convert.ToInt32(propertyGetter(Constants.MapZoomFactor)); }
            catch { MapZoomLevel = MapZoomLevelInitialValue; }
            MapZoomLevel = Math.Min(MapZoomLevel, MapZoomLevelMaxValue);
            MapZoomLevel = Math.Max(MapZoomLevel, MapZoomLevelMinValue);

            // read map position
            try
            {
                var position = MapPosition;
                position.Lng = Convert.ToDouble(propertyGetter(Constants.MapPositionLng));
                position.Lat = Convert.ToDouble(propertyGetter(Constants.MapPositionLat));
                MapPosition  = position;
            }
            catch { }
        }