public TransitMap() { this.InitializeComponent(); MainMap.MapServiceToken = Keys.BingMapKey; CenterConverter.Add(new LatLonTransformConverter() { Transform = ll => CenterOffset.IsNotALocation ? ll : ll + CenterOffset, ReverseTransform = ll => CenterOffset.IsNotALocation ? ll : ll - CenterOffset }); CenterConverter.Add(LatLonToGeopointConverter.Instance); WeakEventListener <TransitMap, object, NotifyCollectionChangedEventArgs> addInsListener = new WeakEventListener <TransitMap, object, NotifyCollectionChangedEventArgs>(this); addInsListener.OnEventAction = (map, obj, e) => map.AddIns_CollectionChanged(obj, e); AddIns.CollectionChanged += addInsListener.OnEvent; MapRouteBindings = new CompositeCollectionBinding <MapRouteView, TransitMapAddInBase>(MainMap.Routes); MapElementBindings = new CompositeCollectionBinding <MapElement, TransitMapAddInBase>(MainMap.MapElements); MapChildrenBindings = new CompositeCollectionBinding <DependencyObject, TransitMapAddInBase>(MainMap.Children); //MainMap.SetBinding(MapControl.CenterProperty, new Binding() { Converter = CenterConverters, Source = this, Path = new PropertyPath("Center"), Mode = BindingMode.TwoWay }); //MainMap.SetBinding(MapControl.ZoomLevelProperty, new Binding() { Source = this, Path = new PropertyPath("ZoomLevel"), Mode = BindingMode.TwoWay }); //MapIcon centerIndicator = new MapIcon() { NormalizedAnchorPoint = new Point(0.5, 1) }; //BindingOperations.SetBinding(centerIndicator, MapIcon.LocationProperty, new Binding() { Source = this, Path = new PropertyPath("Center"), Converter = LatLonToGeopointConverter.Instance }); //MainMap.MapElements.Add(centerIndicator); }
public void ConvertTest(object value) { var converterGroup = new ValueConverterGroup(); converterGroup.Add(new MockConverter()); converterGroup.Add(new MockConverter()); converterGroup.Add(new MockConverter()); var result = converterGroup.Convert(value, typeof(string), null, CultureInfo.CurrentCulture); var correctValue = $"{MockConverter.Tag}{MockConverter.Tag}{MockConverter.Tag}{value.ToString()}"; Assert.AreEqual(correctValue, result); }
public void ConvertList(object value) { var expectedResult = value.ToString(); for (var i = 0; i < 10; i++) { var c = new MockConverter(i); converter.Add(c); expectedResult = string.Format(MockConverter.TagFormat, i) + expectedResult; } var actualResult = converter.Convert(value, typeof(string), null, CultureInfo.CurrentCulture); Assert.AreEqual(expectedResult, actualResult); }