public PaintedRepresentationUI(PaintedRepresentationModel paintedRepresentation) { this.paintedRepresentation = paintedRepresentation; this.cave = Kucha.GetCaveByID(paintedRepresentation.caveID); Title = "Painted Representation " + paintedRepresentation.depictionID; StackLayout contentStack = new StackLayout { Padding = 16 }; Frame generalFrame = new Frame { HasShadow = true, BackgroundColor = Color.White }; StackLayout generalStack = new StackLayout(); Label generalInfoLabel = new Label { Text = "General Information", FontSize = 20, TextColor = Color.Black }; generalStack.Children.Add(generalInfoLabel); if (!String.IsNullOrEmpty(paintedRepresentation.description)) { Label descriptionLabel = new Label(); var descriptionText = new FormattedString(); descriptionText.Spans.Add(new Span { Text = "Description: ", FontAttributes = FontAttributes.Bold }); descriptionText.Spans.Add(new Span { Text = paintedRepresentation.description }); descriptionLabel.FormattedText = descriptionText; generalStack.Children.Add(descriptionLabel); } if (!String.IsNullOrEmpty(paintedRepresentation.acquiredByExpedition)) { Label aquiredByExpeditionLabel = new Label(); var descriptionText = new FormattedString(); descriptionText.Spans.Add(new Span { Text = "Aquired by Expedition: ", FontAttributes = FontAttributes.Bold }); descriptionText.Spans.Add(new Span { Text = paintedRepresentation.acquiredByExpedition }); aquiredByExpeditionLabel.FormattedText = descriptionText; generalStack.Children.Add(aquiredByExpeditionLabel); } if (!String.IsNullOrEmpty(paintedRepresentation.currentLocation)) { Label currentLocationLabel = new Label(); var descriptionText = new FormattedString(); descriptionText.Spans.Add(new Span { Text = "Current Location: ", FontAttributes = FontAttributes.Bold }); descriptionText.Spans.Add(new Span { Text = paintedRepresentation.currentLocation }); currentLocationLabel.FormattedText = descriptionText; generalStack.Children.Add(currentLocationLabel); } if (!String.IsNullOrEmpty(paintedRepresentation.vendor)) { Label vendorLabel = new Label(); var descriptionText = new FormattedString(); descriptionText.Spans.Add(new Span { Text = "Vendor: ", FontAttributes = FontAttributes.Bold }); descriptionText.Spans.Add(new Span { Text = paintedRepresentation.vendor }); vendorLabel.FormattedText = descriptionText; generalStack.Children.Add(vendorLabel); } if (paintedRepresentation.Iconography.Count > 0) { Label iconographyLabel = new Label(); var descriptionText = new FormattedString(); descriptionText.Spans.Add(new Span { Text = "Iconography:\n", FontAttributes = FontAttributes.Bold }); foreach (string i in paintedRepresentation.Iconography) { descriptionText.Spans.Add(new Span { Text = i + "\n" }); } iconographyLabel.FormattedText = descriptionText; generalStack.Children.Add(iconographyLabel); } if (paintedRepresentation.PictorialElements.Count > 0) { Label pictorialElementsLabel = new Label(); var descriptionText = new FormattedString(); descriptionText.Spans.Add(new Span { Text = "Pictorial Elements:\n", FontAttributes = FontAttributes.Bold }); foreach (string i in paintedRepresentation.PictorialElements) { descriptionText.Spans.Add(new Span { Text = i + "\n" }); } pictorialElementsLabel.FormattedText = descriptionText; generalStack.Children.Add(pictorialElementsLabel); } generalFrame.Content = generalStack; contentStack.Children.Add(generalFrame); Frame caveFrame = new Frame { BackgroundColor = Color.White, HasShadow = true }; StackLayout caveStack = new StackLayout { Spacing = 2 }; if (cave == null) { Label caveInfoLabel = new Label { Text = "Cave could not be loaded - the backend probably sent an invalid ID or the local database needs to be updated. (ID " + paintedRepresentation.caveID + ")", FontSize = 20, TextColor = Color.Black }; caveStack.Children.Add(caveInfoLabel); } else { TapGestureRecognizer caveTap = new TapGestureRecognizer(); caveTap.Tapped += CaveTap_Tapped; caveFrame.GestureRecognizers.Add(caveTap); Label caveInfoLabel = new Label { Text = "Cave Information", FontSize = 20, TextColor = Color.Black }; caveStack.Children.Add(caveInfoLabel); string caveInfoString = "Located in Cave: " + Kucha.GetCaveSiteStringByID(cave.siteID) + ": " + cave.caveID + " " + cave.optionalHistoricalName; Label caveLabel = new Label { Text = caveInfoString }; caveStack.Children.Add(caveLabel); if (!String.IsNullOrEmpty(cave.optionalCaveSketch)) { Image caveSketch = new Image { WidthRequest = 150, Aspect = Aspect.AspectFit, Source = ImageSource.FromUri(new Uri(Internal.Connection.GetCaveSketchURL(cave.optionalCaveSketch))) }; caveStack.Children.Add(caveSketch); } Image caveBackground = new Image { WidthRequest = 150, HeightRequest = 150, Source = ImageSource.FromUri(new Uri(Internal.Connection.GetCaveBackgroundImageURL(cave.caveTypeID))) }; caveStack.Children.Add(caveBackground); } caveFrame.Content = caveStack; contentStack.Children.Add(caveFrame); foreach (RelatedImage image in paintedRepresentation.relatedImages) { Frame imageFrame = new Frame { HasShadow = true, BackgroundColor = Color.White }; RelatedImageStack imageStack = new RelatedImageStack(image); imageFrame.Content = imageStack; contentStack.Children.Add(imageFrame); TapGestureRecognizer imageTap = new TapGestureRecognizer(); imageTap.Tapped += ImageTap_Tapped; imageStack.GestureRecognizers.Add(imageTap); } Frame notesFrame = new Frame { HasShadow = true, BackgroundColor = Color.White }; StackLayout notesStack = new StackLayout(); Label notesLabel = new Label { TextColor = Color.Black, FontSize = 20, Text = "Private Notes" }; notesStack.Children.Add(notesLabel); notesEditor = new Editor { BackgroundColor = Color.White, HeightRequest = 100 }; var index = Settings.SavedNotesSetting.FindIndex(pr => pr.ID == paintedRepresentation.depictionID && pr.Type == NotesSaver.NOTES_TYPE.NOTE_TYPE_PAINTEDREPRESENTATION); if (index != -1) { notesEditor.Text = Settings.SavedNotesSetting[index].Note; } notesStack.Children.Add(notesEditor); notesFrame.Content = notesStack; contentStack.Children.Add(notesFrame); ScrollView contentScrollView = new ScrollView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Content = contentStack }; Content = contentScrollView; }
public CaveUI(CaveModel cave) { this.cave = cave; Title = "Cave " + cave.caveID; StackLayout contentStack = new StackLayout { Padding = 16 }; Frame generalCaveFrame = new Frame { HasShadow = true, BackgroundColor = Color.White }; StackLayout generalCaveStack = new StackLayout(); Label generalHeadlineLabel = new Label { FontSize = 20, Text = "General", TextColor = Color.Black }; generalCaveStack.Children.Add(generalHeadlineLabel); Label nameLabel = new Label(); var nameText = new FormattedString(); nameText.Spans.Add(new Span { Text = "Historical Name: ", FontAttributes = FontAttributes.Bold }); nameText.Spans.Add(new Span { Text = cave.historicalName }); nameLabel.FormattedText = nameText; generalCaveStack.Children.Add(nameLabel); if (!String.IsNullOrEmpty(cave.optionalHistoricalName)) { Label optHistoricalNameLabel = new Label(); var optNameText = new FormattedString(); optNameText.Spans.Add(new Span { Text = "Optional Historical Name: ", FontAttributes = FontAttributes.Bold }); optNameText.Spans.Add(new Span { Text = cave.optionalHistoricalName }); optHistoricalNameLabel.FormattedText = optNameText; generalCaveStack.Children.Add(optHistoricalNameLabel); } Label siteLabel = new Label(); var siteText = new FormattedString(); siteText.Spans.Add(new Span { Text = "Site: ", FontAttributes = FontAttributes.Bold }); siteText.Spans.Add(new Span { Text = Kucha.GetCaveSiteStringByID(cave.siteID) }); siteLabel.FormattedText = siteText; generalCaveStack.Children.Add(siteLabel); Label districtLabel = new Label(); var districtText = new FormattedString(); districtText.Spans.Add(new Span { Text = "District: ", FontAttributes = FontAttributes.Bold }); districtText.Spans.Add(new Span { Text = Kucha.GetCaveDistrictStringByID(cave.districtID) }); districtLabel.FormattedText = districtText; generalCaveStack.Children.Add(districtLabel); Label regionLabel = new Label(); var regionText = new FormattedString(); regionText.Spans.Add(new Span { Text = "Region: ", FontAttributes = FontAttributes.Bold }); regionText.Spans.Add(new Span { Text = Kucha.GetCaveRegionStringByID(cave.regionID) }); regionLabel.FormattedText = regionText; generalCaveStack.Children.Add(regionLabel); Label typeLabel = new Label(); var typeText = new FormattedString(); typeText.Spans.Add(new Span { Text = "Type: ", FontAttributes = FontAttributes.Bold }); typeText.Spans.Add(new Span { Text = Kucha.GetCaveTypeStringByID(cave.caveTypeID) }); typeLabel.FormattedText = typeText; generalCaveStack.Children.Add(typeLabel); if (!String.IsNullOrEmpty(cave.measurementString)) { Label measurementLabel = new Label(); var measurementText = new FormattedString(); measurementText.Spans.Add(new Span { Text = "Measurement:\n", FontAttributes = FontAttributes.Bold }); measurementText.Spans.Add(new Span { Text = cave.measurementString }); measurementLabel.FormattedText = measurementText; generalCaveStack.Children.Add(measurementLabel); } generalCaveFrame.Content = generalCaveStack; contentStack.Children.Add(generalCaveFrame); Frame caveSketchFrame = new Frame { HasShadow = true, BackgroundColor = Color.White }; StackLayout caveSketchStack = new StackLayout(); Label caveSketchHeadline = new Label { FontSize = 20, Text = "Cave Sketch", TextColor = Color.Black }; caveSketchStack.Children.Add(caveSketchHeadline); if (!String.IsNullOrEmpty(cave.optionalCaveSketch)) { Image caveSketch = new Image { WidthRequest = 200, Aspect = Aspect.AspectFit, Source = ImageSource.FromUri(new Uri(Internal.Connection.GetCaveSketchURL(cave.optionalCaveSketch))) }; caveSketchStack.Children.Add(caveSketch); } Image caveBackground = new Image { WidthRequest = 200, HeightRequest = 200, Source = ImageSource.FromUri(new Uri(Internal.Connection.GetCaveBackgroundImageURL(cave.caveTypeID))) }; caveSketchStack.Children.Add(caveBackground); caveSketchFrame.Content = caveSketchStack; contentStack.Children.Add(caveSketchFrame); Frame notesFrame = new Frame { BackgroundColor = Color.White, HasShadow = true }; StackLayout notesStack = new StackLayout(); Label notesLabel = new Label { TextColor = Color.Black, FontSize = 20, Text = "Private Notes" }; notesStack.Children.Add(notesLabel); notesEditor = new Editor { BackgroundColor = Color.White, HeightRequest = 100 }; var index = Settings.SavedNotesSetting.FindIndex(c => c.ID == cave.caveID && c.Type == NotesSaver.NOTES_TYPE.NOTE_TYPE_CAVE); if (index != -1) { notesEditor.Text = Settings.SavedNotesSetting[index].Note; } notesStack.Children.Add(notesEditor); notesFrame.Content = notesStack; contentStack.Children.Add(notesFrame); ScrollView scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, Content = contentStack }; Content = scrollView; }