public MapDisplay() { _LoadConfig(); bool firstRun = false; if (_mapDisplayConfig == null) { _mapDisplayConfig = new MapDisplayConfig(); TrueRoute = true; LabelingEnabled = true; ShowLeadingStemTime = true; ShowTrailingStemTime = true; AutoZoom = true; firstRun = true; } _CreateOrdersTipsConfig("", _orderTitles, _orderTitlesSelected, _mapDisplayConfig.OrderSelectedProp); _CreateStopsTipsConfig(_stopTitles, _stopTitlesSelected, _mapDisplayConfig.StopSelectedProp); _CreateOrdersTipsConfig("AssociatedObject.", _stopTitles, _stopTitlesSelected, _mapDisplayConfig.StopSelectedProp); // select all by default if (firstRun) { string xPropName = Order.PropertyNameGeoLocation+ '.' + Order.PropertyNameX; string yPropName = Order.PropertyNameGeoLocation + '.' + Order.PropertyNameY; foreach (TipProperty property in _orderTitles) { if (!property.Name.Equals(Order.PropertyNamePlannedDate) && !property.Name.Equals(xPropName) && !property.Name.Equals(yPropName)) { _orderTitlesSelected.Add(property); _mapDisplayConfig.OrderSelectedProp.Add(property.Name); } } foreach (TipProperty property in _stopTitles) { if (!property.Name.Equals(Order.PropertyNamePlannedDate) && !property.Name.Equals(xPropName) && !property.Name.Equals(yPropName)) { _stopTitlesSelected.Add(property); _mapDisplayConfig.StopSelectedProp.Add(property.Name); } } _FillInCorrectDirection(); Save(); } }
/// <summary> /// Load Config /// </summary> private void _LoadConfig() { DataContractSerializer ser = new DataContractSerializer(typeof(MapDisplayConfig)); Settings settings = Settings.Default; string configText = settings.MapDisplayConfig; if (!string.IsNullOrEmpty(configText)) { MemoryStream stream = null; try { stream = new MemoryStream(Encoding.UTF8.GetBytes(configText)); _mapDisplayConfig = (MapDisplayConfig)ser.ReadObject(stream); } catch (Exception ex) { Logger.Error(ex); } finally { if (stream != null) stream.Close(); } } }