public static Uri GetUri(AcObjectNew obj) { if (_provider == null) { throw new Exception(@"Provider is missing"); } return _provider.GetUri(obj); }
private void SelectedAcObject_Outdated(object sender, EventArgs e) { SetCurrentValue(SelectedSourceProperty, null); var oldItem = _selectedWrapper.Value; var id = (sender as AcObjectNew)?.Id; if (id == null) return; var newItem = ItemsSource.OfType<AcItemWrapper>().GetByIdOrDefault(id); if (oldItem != null && newItem == oldItem) { CurrentObject = newItem.Loaded(); } else if (newItem != null) { ItemsSource.MoveCurrentTo(newItem); } else { var replacement = ItemsSource.OfType<AcItemWrapper>().FirstOrDefault(x => (x.Value as AcCommonObject)?.PreviousId == id); if (replacement != null) { ItemsSource.MoveCurrentTo(replacement); return; } if (CurrentObject != null) { SetCurrentValue(SelectedSourceProperty, AcObjectsUriManager.GetUri(CurrentObject)); } else { ItemsSource.MoveCurrentToFirst(); } } }
public AcListPage() { SelectMode = false; _selectedWrapper = new DelayedPropertyWrapper<AcItemWrapper>(async v => { CurrentObject = v?.Loaded(); if (v != null && SettingsHolder.Content.ScrollAutomatically) { await Task.Delay(1); _list?.ScrollIntoView(_list.SelectedItem); } }); }
Uri IAcObjectsUriProvider.GetUri(AcObjectNew obj) { if (obj is CarObject) { return UriExtension.Create("/Pages/Selected/SelectedCarPage.xaml?Id={0}", obj.Id); } if (obj is TrackObject) { return UriExtension.Create("/Pages/Selected/SelectedTrackPage.xaml?Id={0}", obj.Id); } if (obj is ShowroomObject) { return UriExtension.Create("/Pages/Selected/SelectedShowroomPage.xaml?Id={0}", obj.Id); } if (obj is WeatherObject) { return UriExtension.Create("/Pages/Selected/SelectedWeatherPage.xaml?Id={0}", obj.Id); } if (obj is ReplayObject) { return UriExtension.Create("/Pages/Selected/SelectedReplayPage.xaml?Id={0}", obj.Id); } if (obj is FontObject) { return UriExtension.Create("/Pages/Selected/SelectedFontPage.xaml?Id={0}", obj.Id); } if (obj is PpFilterObject) { return UriExtension.Create("/Pages/Selected/SelectedPpFilterPage.xaml?Id={0}", obj.Id); } if (obj is PythonAppObject) { return UriExtension.Create("/Pages/Selected/SelectedPythonAppPage.xaml?Id={0}", obj.Id); } var carSkinObject = obj as CarSkinObject; if (carSkinObject != null) { return UriExtension.Create("/Pages/Selected/SelectedCarSkinPage.xaml?Id={0}&CarId={1}", carSkinObject.Id, carSkinObject.CarId); } var carSetupObject = obj as CarSetupObject; if (carSetupObject != null) { return UriExtension.Create("/Pages/Selected/SelectedCarSetupPage.xaml?Id={0}&CarId={1}", carSetupObject.Id, carSetupObject.CarId); } if (obj is ServerPresetObject) { return UriExtension.Create("/Pages/ServerPreset/SelectedPage.xaml?Id={0}", obj.Id); } throw new NotImplementedException("Not supported type: " + obj.GetType()); }
private void OnSelectedItemChanged(AcObjectNew newValue) { if (InnerItemsSource == null) return; if (InnerItemsSource.CurrentItem != newValue) { InnerItemsSource.MoveCurrentToOrNull(newValue); UpdateSelected(); } if (SelectionMode != SelectionMode.Single && _listBox != null) { _ignoreSelectionChange = true; _listBox.SelectedItems.Clear(); _listBox.SelectedItems.Add(InnerItemsSource.CurrentItem); _ignoreSelectionChange = false; } }
public AcObjectEventArgs(AcObjectNew obj) { AcObject = obj; }