// We want to dynamically generate the buttons and their text based on the number of "IDs" gathered in the View Model // Unfortunately, XAML doesn't support looping statements of any kind, so I had to move the parent XAML code into this code-behind class // This feels messy, but I'm sure there's a better way by creating a custom control? private Grid CreateGridOfButtons(PAVViewModel vmContext) { var tileGrid = new Grid { Padding = ButtonGridPadding, VerticalOptions = ButtonGridVertOptions, HorizontalOptions = ButtonGridHorzOptions, RowSpacing = ButtonGridRowSpacing, ColumnSpacing = ButtonGridColumnSpacing, RowDefinitions = CreateRowDefinitions(vmContext), ColumnDefinitions = CreateColumnDefinitions(vmContext) }; for (var i = 0; i < vmContext.GetIDsCount(); i++) { tileGrid.Children.Add(new ThemedNavigationButton { Text = vmContext.GetParentIDText(i), Command = vmContext.NavigateToViewModel(i), BackgroundColor = ThemedNavigationButton.ButtonBackgroundColor, TextColor = ThemedNavigationButton.ButtonTextColor, FontSize = ThemedNavigationButton.ButtonFontSize, FontAttributes = ThemedNavigationButton.ButtonFontAttributes }, 0, i); } return(tileGrid); }
private ColumnDefinitionCollection CreateColumnDefinitions(PAVViewModel vmContext) { var columnDefinitionCollection = new ColumnDefinitionCollection(); columnDefinitionCollection.Add(new ColumnDefinition { Width = ButtonGridColumnDefWidth }); return(columnDefinitionCollection); }
private RowDefinitionCollection CreateRowDefinitions(PAVViewModel vmContext) { var rowDefinitionCollection = new RowDefinitionCollection(); for (var i = 0; i < vmContext.GetIDsCount(); i++) { rowDefinitionCollection.Add(new RowDefinition { Height = ButtonGridRowDefHeight }); } return(rowDefinitionCollection); }
private void ResolveAllPAVViewModels() { using (var the1KVScope = _runtime.Container.BeginLifetimeScope()) { var the1KVPlantPhaseVoltageVM = the1KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"1kV" }, { "level2ID", @"Plant" } }); var the1KVVehiclePhaseVoltageVM = the1KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"1kV" }, { "level2ID", @"Vehicle" } }); var the1KVVMsICanNavigateTo = the1KVScope.Resolve <IViewModelsICanNavigateTo>(); the1KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the1KVPlantPhaseVoltageVM); the1KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the1KVVehiclePhaseVoltageVM); var the1KVPhaseVoltageVM = the1KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", the1KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"1kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(the1KVPhaseVoltageVM); } using (var the33KVScope = _runtime.Container.BeginLifetimeScope()) { var the33KVPlantPhaseVoltageVM = the33KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"33kV" }, { "level2ID", @"Plant" } }); var the33KVVehiclePhaseVoltageVM = the33KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"33kV" }, { "level2ID", @"Vehicle" } }); var the33KVVMsICanNavigateTo = the33KVScope.Resolve <IViewModelsICanNavigateTo>(); the33KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the33KVPlantPhaseVoltageVM); the33KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the33KVVehiclePhaseVoltageVM); var the33KVPhaseVoltageVM = the33KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", the33KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"33kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(the33KVPhaseVoltageVM); } using (var the66KVScope = _runtime.Container.BeginLifetimeScope()) { var the66KVPlantPhaseVoltageVM = the66KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"66kV" }, { "level2ID", @"Plant" } }); var the66KVVehiclePhaseVoltageVM = the66KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"66kV" }, { "level2ID", @"Vehicle" } }); var the66KVVMsICanNavigateTo = the66KVScope.Resolve <IViewModelsICanNavigateTo>(); the66KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the66KVPlantPhaseVoltageVM); the66KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the66KVVehiclePhaseVoltageVM); var the66KVPhaseVoltageVM = the66KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", the66KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"66kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(the66KVPhaseVoltageVM); } using (var the110KVScope = _runtime.Container.BeginLifetimeScope()) { var the110KVPlantPhaseVoltageVM = the110KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"110kV" }, { "level2ID", @"Plant" } }); var the110KVVehiclePhaseVoltageVM = the110KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"110kV" }, { "level2ID", @"Vehicle" } }); var the110KVVMsICanNavigateTo = the110KVScope.Resolve <IViewModelsICanNavigateTo>(); the110KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the110KVPlantPhaseVoltageVM); the110KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the110KVVehiclePhaseVoltageVM); var the110KVPhaseVoltageVM = the110KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", the110KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"110kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(the110KVPhaseVoltageVM); } using (var the132KVScope = _runtime.Container.BeginLifetimeScope()) { var the132KVPlantPhaseVoltageVM = the132KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"132kV" }, { "level2ID", @"Plant" } }); var the132KVVehiclePhaseVoltageVM = the132KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"132kV" }, { "level2ID", @"Vehicle" } }); var the132KVVMsICanNavigateTo = the132KVScope.Resolve <IViewModelsICanNavigateTo>(); the132KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the132KVPlantPhaseVoltageVM); the132KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the132KVVehiclePhaseVoltageVM); var the132KVPhaseVoltageVM = the132KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", the132KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"132kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(the132KVPhaseVoltageVM); } using (var the275KVScope = _runtime.Container.BeginLifetimeScope()) { var the275KVPlantPhaseVoltageVM = the275KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"275kV" }, { "level2ID", @"Plant" } }); var the275KVVehiclePhaseVoltageVM = the275KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"275kV" }, { "level2ID", @"Vehicle" } }); var the275KVVMsICanNavigateTo = the275KVScope.Resolve <IViewModelsICanNavigateTo>(); the275KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the275KVPlantPhaseVoltageVM); the275KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the275KVVehiclePhaseVoltageVM); var the275KVPhaseVoltageVM = the275KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", the275KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"275kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(the275KVPhaseVoltageVM); } using (var the330KVScope = _runtime.Container.BeginLifetimeScope()) { var the330KVPlantPhaseVoltageVM = the330KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"330kV" }, { "level2ID", @"Plant" } }); var the330KVVehiclePhaseVoltageVM = the330KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"330kV" }, { "level2ID", @"Vehicle" } }); var the330KVVMsICanNavigateTo = the330KVScope.Resolve <IViewModelsICanNavigateTo>(); the330KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the330KVPlantPhaseVoltageVM); the330KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(the330KVVehiclePhaseVoltageVM); var the330KVPhaseVoltageVM = the330KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", the330KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"330kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(the330KVPhaseVoltageVM); } using (var theAbove330KVScope = _runtime.Container.BeginLifetimeScope()) { var theAbove330KVPlantPhaseVoltageVM = theAbove330KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"Above 330kV" }, { "level2ID", @"Plant" } }); var theAbove330KVVehiclePhaseVoltageVM = theAbove330KVScope.ResolveWithParameters <ObserverStatesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "level1ID", @"Above 330kV" }, { "level2ID", @"Vehicle" } }); var theAbove330KVVMsICanNavigateTo = theAbove330KVScope.Resolve <IViewModelsICanNavigateTo>(); theAbove330KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(theAbove330KVPlantPhaseVoltageVM); theAbove330KVVMsICanNavigateTo.AddTo <ApprTypesViewModel>(theAbove330KVVehiclePhaseVoltageVM); var theAbove330KVPhaseVoltageVM = theAbove330KVScope.ResolveWithParameters <ApprTypesViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", theAbove330KVVMsICanNavigateTo.GetAllFrom <ApprTypesViewModel>() }, { "level1ID", @"Above 330kV" } }); _VMsICanNavigateTo.AddTo <PAVViewModel>(theAbove330KVPhaseVoltageVM); } _PAVVM = _runtime.Container.ResolveWithParameters <PAVViewModel>(new Dictionary <string, object> { { "deserializedContents", _pavContent }, { "viewModelsICanNavigateTo", _VMsICanNavigateTo.GetAllFrom <PAVViewModel>() } }); }