public StopPopupOuterControl() { this.InitializeComponent(); this.TopControlsVisibility = Visibility.Visible; ShownArrivalsBinding = new CompositeCollectionBinding <RealTimeArrival, int>(ShownArrivals); ShownArrivalsBinding.AddCollection(0, SubControl.ShownArrivals); }
public void CompositeCollectionBindingTests_AllTests() { List <int> list = new List <int>(); CompositeCollectionBinding <int, string> binding = new CompositeCollectionBinding <int, string>(list); ObservableCollection <int> collection0 = new ObservableCollection <int>() { 2, 5 }; ObservableCollection <int> collection1 = new ObservableCollection <int>(); ObservableCollection <int> collection2 = new ObservableCollection <int>() { 3 }; binding.AddCollection("first", collection0); Assert.AreEqual(list.Count, 2, "Test 0.0"); Assert.AreEqual(list[1], 5, "Test 0.1"); binding.AddCollection("second", collection1); binding.AddCollection("third", collection2); Assert.AreEqual(list.Count, 3, "Test 1.0"); collection1.Add(6); Assert.AreEqual(list[2], 6, "Test 2.0"); Assert.AreEqual(list[3], 3, "Test 2.1"); collection2.Add(4); Assert.AreEqual(list[4], 4, "Test 3.0"); collection0.Add(7); Assert.AreEqual(list[4], 3, "Test 4.0"); Assert.AreEqual(list[5], 4, "Test 4.1"); binding.RemoveCollection("first"); Assert.AreEqual(list[0], 6, "Test 5.0"); binding.RemoveCollection("second"); binding.RemoveCollection("third"); Assert.AreEqual(list.Count, 0, "Test 6.0"); }
public StopPopupOuterControl() { this.InitializeComponent(); this.TopControlsVisibility = Visibility.Visible; ShownArrivalsBinding = new CompositeCollectionBinding<RealTimeArrival, int>(ShownArrivals); ShownArrivalsBinding.AddCollection(0, SubControl.ShownArrivals); }
public void CompositeCollectionBindingTests_AllTests() { List<int> list = new List<int>(); CompositeCollectionBinding<int, string> binding = new CompositeCollectionBinding<int, string>(list); ObservableCollection<int> collection0 = new ObservableCollection<int>() { 2, 5 }; ObservableCollection<int> collection1 = new ObservableCollection<int>(); ObservableCollection<int> collection2 = new ObservableCollection<int>() { 3 }; binding.AddCollection("first", collection0); Assert.AreEqual(list.Count, 2, "Test 0.0"); Assert.AreEqual(list[1], 5, "Test 0.1"); binding.AddCollection("second", collection1); binding.AddCollection("third", collection2); Assert.AreEqual(list.Count, 3, "Test 1.0"); collection1.Add(6); Assert.AreEqual(list[2], 6, "Test 2.0"); Assert.AreEqual(list[3], 3, "Test 2.1"); collection2.Add(4); Assert.AreEqual(list[4], 4, "Test 3.0"); collection0.Add(7); Assert.AreEqual(list[4], 3, "Test 4.0"); Assert.AreEqual(list[5], 4, "Test 4.1"); binding.RemoveCollection("first"); Assert.AreEqual(list[0], 6, "Test 5.0"); binding.RemoveCollection("second"); binding.RemoveCollection("third"); Assert.AreEqual(list.Count, 0, "Test 6.0"); }
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 StopPopupControl() { this.InitializeComponent(); MainGrid.DataContext = VM; VM.PropertyChanged += VM_PropertyChanged; RefreshMainGridWidth(); //ExpandButton.SetBinding(Button.CommandProperty, new Binding() { Source = this, Path = new PropertyPath("ExpandCommand") }); //CompressButton.SetBinding(Button.CommandProperty, new Binding() { Source = this, Path = new PropertyPath("CompressCommand") }); //CloseButton.SetBinding(Button.CommandProperty, new Binding() { Source = this, Path = new PropertyPath("CloseCommand") }); //RegisterPropertyChangedCallback(WidthProperty, WidthChanged); ShownArrivalsBinding = new CompositeCollectionBinding<RealTimeArrival, string>(ShownArrivals); WeakEventListener<StopPopupControl, object, NotifyCollectionChangedEventArgs> childrenListener = new WeakEventListener<StopPopupControl, object, NotifyCollectionChangedEventArgs>(this); childrenListener.OnEventAction = (t, s, e) => t.Children_CollectionChanged(s, e); VM.Children.CollectionChanged += childrenListener.OnEvent; }
public StopPopupControl() { this.InitializeComponent(); MainGrid.DataContext = VM; VM.PropertyChanged += VM_PropertyChanged; RefreshMainGridWidth(); //ExpandButton.SetBinding(Button.CommandProperty, new Binding() { Source = this, Path = new PropertyPath("ExpandCommand") }); //CompressButton.SetBinding(Button.CommandProperty, new Binding() { Source = this, Path = new PropertyPath("CompressCommand") }); //CloseButton.SetBinding(Button.CommandProperty, new Binding() { Source = this, Path = new PropertyPath("CloseCommand") }); //RegisterPropertyChangedCallback(WidthProperty, WidthChanged); ShownArrivalsBinding = new CompositeCollectionBinding <RealTimeArrival, string>(ShownArrivals); WeakEventListener <StopPopupControl, object, NotifyCollectionChangedEventArgs> childrenListener = new WeakEventListener <StopPopupControl, object, NotifyCollectionChangedEventArgs>(this); childrenListener.OnEventAction = (t, s, e) => t.Children_CollectionChanged(s, e); VM.Children.CollectionChanged += childrenListener.OnEvent; }
public StopDetailsPopupAddIn() { ExpandCommand = new DisableableRelayCommand((obj) => { NumColsRequested += .5; RefreshPopupSize(); }); CompressCommand = new DisableableRelayCommand((obj) => { do { NumColsRequested -= .5; } while (NumColsRequested >= MaxColsVisible && NumColsRequested > 1); RefreshPopupSize(); }); CloseCommand = new DisableableRelayCommand((obj) => ClosePopup()); MapControl.SetNormalizedAnchorPoint(OnMapPopup, new Point(0.5, 1)); ArrivalsPopup.SetBinding(StopPopupOuterControl.TitleCommandProperty, new Binding() { Source = this, Path = new PropertyPath("StopTitleClickedCommand") }); ArrivalsPopup.ExpandCommand = ExpandCommand; ArrivalsPopup.CompressCommand = CompressCommand; ArrivalsPopup.CloseCommand = CloseCommand; ArrivalsPopup.Offset(offsetY: SLIDE_OFFSET).Fade(value: 0).SetDurationForAll(0).Start(); ArrivalsPopup.NavigateToLocationCommand = new RelayCommand(ll => { if (ll is LatLon) { MapControl.SetLocation(OnMapPopup, ((LatLon)ll).ToGeopoint()); SetTakeover(new MapView((LatLon)ll)); } }); ShownVehicleArrivals.CollectionChanged += ShownVehicleArrivals_CollectionChanged; ShownVehicleArrivalsBinding = new CompositeCollectionBinding <RealTimeArrival, int>(ShownVehicleArrivals); ShownVehicleArrivalsBinding.AddCollection(0, ArrivalsPopup.ShownArrivals); MapChildrenShown.Add(OnMapPopup); RefreshPopupSize(); ArrivalsPopup.ShownArrivals.CollectionChanged += ShownArrivals_CollectionChanged; }
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 StopDetailsPopupAddIn() { ExpandCommand = new DisableableRelayCommand((obj) => { NumColsRequested += .5; RefreshPopupSize(); }); CompressCommand = new DisableableRelayCommand((obj) => { do { NumColsRequested -= .5; } while (NumColsRequested >= MaxColsVisible && NumColsRequested > 1); RefreshPopupSize(); }); CloseCommand = new DisableableRelayCommand((obj) => ClosePopup()); MapControl.SetNormalizedAnchorPoint(OnMapPopup, new Point(0.5, 1)); ArrivalsPopup.SetBinding(StopPopupOuterControl.TitleCommandProperty, new Binding() { Source = this, Path = new PropertyPath("StopTitleClickedCommand") }); ArrivalsPopup.ExpandCommand = ExpandCommand; ArrivalsPopup.CompressCommand = CompressCommand; ArrivalsPopup.CloseCommand = CloseCommand; ArrivalsPopup.Offset(offsetY: SLIDE_OFFSET).Fade(value: 0).SetDurationForAll(0).Start(); ShownVehicleArrivals.CollectionChanged += ShownVehicleArrivals_CollectionChanged; ShownVehicleArrivalsBinding = new CompositeCollectionBinding<RealTimeArrival, int>(ShownVehicleArrivals); ShownVehicleArrivalsBinding.AddCollection(0, ArrivalsPopup.ShownArrivals); MapChildrenShown.Add(OnMapPopup); RefreshPopupSize(); ArrivalsPopup.ShownArrivals.CollectionChanged += ShownArrivals_CollectionChanged; }