private StackLayout FillGrenade(StackLayout result, string fullResourcePath) { Grenade grenade = CreateGrenadeFromData(fullResourcePath); Label desciptionTitle; Label description; Label damageTitle; Label damage; string[,] grendeValues = grenade.ReturnValues(); desciptionTitle = new Label { Text = grendeValues[0, 0] }; description = new Label { Text = grendeValues[0, 1] }; damageTitle = new Label { Text = grendeValues[1, 0] }; damage = new Label { Text = grendeValues[1, 1] }; try { ImageSource imageSource = grenade.GetImageSource(); Image image = new Image { Source = imageSource }; result.Children.Add(image); } catch (Exception) { Label errorLabel = new Label { Text = "Error has occured while loading image", TextColor = Color.White }; result.Children.Add(errorLabel); } result.Children.Add(SetTitleLabelProperties(desciptionTitle)); result.Children.Add(SetLabelProperties(description)); result.Children.Add(SetTitleLabelProperties(damageTitle)); result.Children.Add(SetLabelProperties(damage)); return(result); }
public Grenade CreateGrenadeFromData(string resourcePath) { try { ResourceManager resourceManager = new ResourceManager(resourcePath, Assembly.GetExecutingAssembly()); Grenade result; string description = resourceManager.GetString("description"); string damage = resourceManager.GetString("damage"); string imageSource = resourceManager.GetString("imagePath"); result = new Grenade(description, damage, imageSource); return(result); } catch (Exception) { ResourceManager resourceManager = new ResourceManager(resourcePath, Assembly.GetExecutingAssembly()); Grenade result; string description = resourceManager.GetString("description"); string damage = resourceManager.GetString("damage"); result = new Grenade(description, damage); return(result); } }