Exemple #1
0
 private async void DownloadDataButton_Clicked(object sender, EventArgs e)
 {
     UserDialogs.Instance.ShowLoading("Downloading Data...");
     await Task.Run(async() =>
     {
         bool success = await Kucha.RefreshLocalData();
         Device.BeginInvokeOnMainThread(() =>
         {
             UserDialogs.Instance.HideLoading();
             if (success)
             {
                 UserDialogs.Instance.Toast("Data successfully downloaded!");
                 downloadDataButton.IsEnabled = false;
                 downloadStatusLabel.Text     = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString();
                 if (!loginButton.IsEnabled)
                 {
                     continueButton.IsEnabled = true;
                 }
             }
             else
             {
                 UserDialogs.Instance.Toast("Data download failed. Please check your connectivity.");
             }
         });
     });
 }
        public CaveFilterUI(CAVE_FILTER_TYPE type, CaveSearchUI parent)
        {
            this.type   = type;
            this.parent = parent;
            switch (type)
            {
            case CAVE_FILTER_TYPE.DISTRICT: Title = "Districts"; break;

            case CAVE_FILTER_TYPE.REGION: Title = "Regions"; break;

            case CAVE_FILTER_TYPE.SITE: Title = "Sites"; break;
            }
            StackLayout finalStack = new StackLayout
            {
                Padding = new Thickness(16, 10, 16, 10)
            };

            listStack = new StackLayout();
            if (type == CAVE_FILTER_TYPE.DISTRICT)
            {
                foreach (CaveDistrictModel caveDistrict in Kucha.GetCaveDistricts())
                {
                    listStack.Children.Add(new CaveDistrictGrid(caveDistrict, parent.pickedDistricts.Contains(caveDistrict)));
                }
            }
            else if (type == CAVE_FILTER_TYPE.REGION)
            {
                foreach (CaveRegionModel caveRegion in Kucha.GetCaveRegions())
                {
                    listStack.Children.Add(new CaveRegionGrid(caveRegion, parent.pickedRegions.Contains(caveRegion)));
                }
            }
            else if (type == CAVE_FILTER_TYPE.SITE)
            {
                foreach (CaveSiteModel caveSite in Kucha.GetCaveSites())
                {
                    listStack.Children.Add(new CaveSiteGrid(caveSite, parent.pickedSites.Contains(caveSite)));
                }
            }
            ScrollView scrollView = new ScrollView
            {
                Content = listStack
            };

            finalStack.Children.Add(scrollView);
            Button doneButton = new Button
            {
                Text              = "Select",
                BackgroundColor   = Color.Accent,
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.Center
            };

            doneButton.Clicked += DoneButton_Clicked;
            doneButton.Margin   = new Thickness(0, 20, 0, 10);
            listStack.Children.Add(doneButton);

            Content = finalStack;
        }
Exemple #3
0
 public static string GetCaveBackgroundImageURL(int caveTypeID)
 {
     if (!String.IsNullOrEmpty(sessionID))
     {
         string caveSketch   = Kucha.GetCaveTypeSketchByID(caveTypeID);
         string returnString = backendURL + "resource?background=" + caveSketch + "&sessionID=" + sessionID;
         return(returnString);
     }
     return(String.Empty);
 }
Exemple #4
0
 /// <summary>
 /// Called from LoadingScreen once the local database has been loaded
 /// </summary>
 public void LoadingPersistantDataFinished()
 {
     if (!Kucha.KuchaContainerIsValid() || !Internal.Connection.HasLegitSessionID())
     {
         MainPage = new LoginPage();
     }
     else
     {
         MainPage = new MainPage();
     }
 }
Exemple #5
0
        private void LoginButton_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(nameEntry.Text) || String.IsNullOrEmpty(passwordEntry.Text))
            {
                UserDialogs.Instance.Toast("Please enter a username and a password");
                return;
            }
            UserDialogs.Instance.ShowLoading();
            Task.Run(() =>
            {
                var loginSuccess = Connection.Login(nameEntry.Text, passwordEntry.Text);
                Device.BeginInvokeOnMainThread(() =>
                {
                    UserDialogs.Instance.HideLoading();
                    if (loginSuccess == Connection.LOGIN_STATUS.SUCCESS)
                    {
                        UserDialogs.Instance.Toast("Login successful!");
                        nameEntry.IsEnabled          = false;
                        passwordEntry.IsEnabled      = false;
                        loginButton.IsEnabled        = false;
                        downloadDataButton.IsEnabled = true;

                        if (Kucha.KuchaContainerIsValid())
                        {
                            continueButton.IsEnabled = true;
                        }
                    }
                    else if (loginSuccess == Connection.LOGIN_STATUS.OFFLINE)
                    {
                        if (Kucha.KuchaContainerIsValid())
                        {
                            UserDialogs.Instance.Toast("No Connection! Functionality is restricted!");
                            continueButton.IsEnabled = true;
                        }
                        else
                        {
                            UserDialogs.Instance.Toast("No Connection! Login failed!");
                        }
                    }
                    else
                    {
                        UserDialogs.Instance.Toast("Login failed! Wrong username/password!");
                    }
                });
            });
        }
Exemple #6
0
 private async void UpdateLocalDatabaseButton_Clicked(object sender, EventArgs e)
 {
     UserDialogs.Instance.ShowLoading("Downloading Data...");
     await Task.Run(async() =>
     {
         bool success = await Kucha.RefreshLocalData();
         Device.BeginInvokeOnMainThread(() =>
         {
             UserDialogs.Instance.HideLoading();
             if (success)
             {
                 UserDialogs.Instance.Toast("Download successful!");
                 downloadStatusLabel.Text = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString();
             }
             else
             {
                 UserDialogs.Instance.Toast("Download failed. Please check connectivity.");
             }
         });
     });
 }
Exemple #7
0
        private void SearchButton_Clicked(object sender, EventArgs e)
        {
            string        selectedCaveTypeName = caveFilterPicker.Items[caveFilterPicker.SelectedIndex];
            CaveTypeModel caveTypeModel        = caveTypeDictionary[selectedCaveTypeName];

            List <CaveModel>  caves         = Kucha.GetCavesByFilters(caveTypeModel, pickedDistricts, pickedRegions, pickedSites);
            List <CaveFilter> searchHistory = Settings.CaveSearchHistorySetting ?? new List <CaveFilter>();
            CaveFilter        caveFilter    = new CaveFilter
            {
                caveTypeModel      = caveTypeModel,
                pickedDistricts    = pickedDistricts,
                pickedRegions      = pickedRegions,
                pickedSites        = pickedSites,
                FoundResultsString = "Results: " + caves.Count,
                SearchTimeString   = "At " + DateTime.UtcNow.ToString()
            };

            searchHistory.Add(caveFilter);
            Settings.CaveSearchHistorySetting = searchHistory.OrderByDescending(x => x.SearchTimeString).ToList();

            Navigation.PushAsync(new CaveSearchResultUI(caves), true);
        }
Exemple #8
0
        public SettingsUI()
        {
            Title = "Settings";
            StackLayout contentStack = new StackLayout
            {
                Padding = 16
            };

            Grid  previewPicGrid  = new Grid();
            Label previewPicLabel = new Label
            {
                Text = "Enable Preview Images in Painted Representations"
            };
            Switch previewPicSwitch = new Switch
            {
                IsToggled = Settings.ShowPreviewPicturesSetting
            };

            previewPicSwitch.Toggled += PreviewPicSwitch_Toggled;
            previewPicGrid.Children.Add(previewPicLabel, 0, 0);
            previewPicGrid.Children.Add(previewPicSwitch, 1, 0);
            previewPicGrid.HorizontalOptions = LayoutOptions.CenterAndExpand;
            contentStack.Children.Add(previewPicGrid);

            if (Connection.IsInOfflineMode())
            {
                Button showLoginScreenButton = new Button
                {
                    Text = "Go to Login Screen"
                };
                showLoginScreenButton.Clicked += ShowLoginScreenButton_Clicked;
                contentStack.Children.Add(showLoginScreenButton);
            }

            downloadStatusLabel = new Label
            {
                Text = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString()
            };
            contentStack.Children.Add(downloadStatusLabel);

            Button updateLocalDatabaseButton = new Button
            {
                Text = "Update Database"
            };

            updateLocalDatabaseButton.Clicked += UpdateLocalDatabaseButton_Clicked;
            contentStack.Children.Add(updateLocalDatabaseButton);

            Button clearAllNotesButton = new Button
            {
                Text = "Clear private notes"
            };

            clearAllNotesButton.Clicked += ClearAllNotesButton_Clicked;
            contentStack.Children.Add(clearAllNotesButton);

            Button deleteLocalFilesButton = new Button
            {
                Text = "Delete all local files"
            };

            deleteLocalFilesButton.Clicked += DeleteLocalFilesButton_Clicked;
            contentStack.Children.Add(deleteLocalFilesButton);

            Label licenseLabel = new Label
            {
                TextColor = Color.LightGray,
                Text      = "Icon licenses\n\ncave by Alexander Skowalsky from the Noun Project\nImage by Viktor Vorobyev from the Noun Project\ncog by Vicons Design from the Noun Project\n\nAll icons issued under Creative Commons license.",
                Margin    = new Thickness(0, 50, 0, 0)
            };

            contentStack.Children.Add(licenseLabel);
            Content = contentStack;
        }
Exemple #9
0
 private void DeleteLocalFilesButton_Clicked(object sender, EventArgs e)
 {
     Kucha.RemoveAllData();
     UserDialogs.Instance.Toast("All local files deleted!");
 }
Exemple #10
0
        /// <summary>
        /// This is the App Start in the shared project. Will be called by Android/iOS Project
        /// </summary>
        protected override void OnStart()
        {
            Task.Run(() => Kucha.LoadPersistantData());

            MainPage = new LoadingScreenUI();
        }
Exemple #11
0
        public LoginPage()
        {
            StackLayout contentStack = new StackLayout
            {
                Padding = 16
            };
            Image huLogo = new Image
            {
                Source        = "SAW_logo.png",
                HeightRequest = 100,
                Aspect        = Aspect.AspectFit
            };

            contentStack.Children.Add(huLogo);
            nameEntry = new Entry
            {
                Placeholder = "Username"
            };
            if (Connection.HasLegitSessionID())
            {
                nameEntry.IsEnabled = false;
            }
            contentStack.Children.Add(nameEntry);

            passwordEntry = new Entry
            {
                Placeholder = "Password",
                IsPassword  = true
            };
            if (Connection.HasLegitSessionID())
            {
                passwordEntry.IsEnabled = false;
            }
            contentStack.Children.Add(passwordEntry);

            loginstatusLabel = new Label
            {
                Margin = new Thickness(0, 10, 0, 0)
            };
            loginstatusLabel.TranslationY += 10;
            if (Connection.HasLegitSessionID())
            {
                loginstatusLabel.Text = "Logged in with valid session";
            }
            else
            {
                loginstatusLabel.Text = "Please log in";
            }
            contentStack.Children.Add(loginstatusLabel);

            loginButton          = new Button();
            loginButton.Clicked += LoginButton_Clicked;

            if (Connection.HasLegitSessionID())
            {
                loginButton.IsEnabled = false;
            }
            loginButton.Text = "Login";
            contentStack.Children.Add(loginButton);

            downloadStatusLabel = new Label
            {
                Margin = new Thickness(0, 10, 0, 0)
            };
            downloadStatusLabel.TranslationY += 10;
            if (!Kucha.KuchaContainerIsValid())
            {
                downloadStatusLabel.Text = "Please download initial data";
            }
            else
            {
                downloadStatusLabel.Text = "Data from " + Kucha.GetDataTimeStamp().ToShortDateString();
            }
            contentStack.Children.Add(downloadStatusLabel);

            downloadDataButton          = new Button();
            downloadDataButton.Clicked += DownloadDataButton_Clicked;
            downloadDataButton.Text     = "Download Data";
            if (!Connection.HasLegitSessionID())
            {
                downloadDataButton.IsEnabled = false;
            }
            contentStack.Children.Add(downloadDataButton);

            continueButton = new Button
            {
                Margin          = new Thickness(0, 10, 0, 0),
                Text            = "Continue",
                BackgroundColor = Color.Accent,
                TextColor       = Color.White
            };
            continueButton.Clicked += ContinueButton_Clicked;
            if (!Connection.HasLegitSessionID() || !Kucha.KuchaContainerIsValid())
            {
                continueButton.IsEnabled = false;
            }
            contentStack.Children.Add(continueButton);

            Content = new ScrollView {
                Content = contentStack
            };
        }
 protected override void OnDisappearing()
 {
     Kucha.SavePaintedRepresentationNotes(paintedRepresentation.depictionID, notesEditor.Text);
     base.OnDisappearing();
 }
        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;
        }
Exemple #14
0
        public CaveSearchUI()
        {
            Title = "Cave Search";
            ToolbarItems.Add(new ToolbarItem("History", null, HistoryButton_Clicked));

            pickedDistricts = new List <CaveDistrictModel>();
            pickedRegions   = new List <CaveRegionModel>();
            pickedSites     = new List <CaveSiteModel>();

            StackLayout contentStackLayout = new StackLayout
            {
                Padding           = new Thickness(16, 16, 16, 16),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            Frame caveTypeFrame = new Frame
            {
                BackgroundColor = Color.White,
                HasShadow       = true
            };

            StackLayout caveTypeStack = new StackLayout();

            Label caveFilterHeadlineLabel = new Label
            {
                FontSize  = 20,
                Text      = "Cave Type",
                TextColor = Color.Black
            };

            caveTypeStack.Children.Add(caveFilterHeadlineLabel);

            caveTypeDictionary = Kucha.GetCaveTypeDictionary();
            caveFilterPicker   = new Picker();
            foreach (string name in caveTypeDictionary.Keys)
            {
                caveFilterPicker.Items.Add(name);
            }

            caveFilterPicker.SelectedIndex = 0;

            caveTypeStack.Children.Add(caveFilterPicker);
            caveTypeFrame.Content = caveTypeStack;
            contentStackLayout.Children.Add(caveTypeFrame);

            Frame caveLocationFrame = new Frame
            {
                HasShadow       = true,
                BackgroundColor = Color.White
            };

            StackLayout caveLocationStack = new StackLayout();

            Label locationFilterHeadlineLabel = new Label
            {
                FontSize  = 20,
                TextColor = Color.Black,
                Text      = "Location Filter"
            };

            caveLocationStack.Children.Add(locationFilterHeadlineLabel);

            districtsFilterLabel = new Label
            {
                FontSize = 12,
                Text     = "Selected Districts: None"
            };
            caveLocationStack.Children.Add(districtsFilterLabel);

            Button districtsFilterButton = new Button
            {
                Text = "Select Districts"
            };

            districtsFilterButton.Clicked += DistrictsFilterButton_Clicked;
            caveLocationStack.Children.Add(districtsFilterButton);

            regionsFilterLabel = new Label
            {
                FontSize = 12,
                Text     = "Selected Regions: None"
            };
            caveLocationStack.Children.Add(regionsFilterLabel);

            Button regionsFilterButton = new Button
            {
                Text = "Select Regions"
            };

            regionsFilterButton.Clicked += RegionsFilterButton_Clicked;
            caveLocationStack.Children.Add(regionsFilterButton);

            sitesFilterLabel = new Label
            {
                FontSize = 12,
                Text     = "Selected Sites: None"
            };
            caveLocationStack.Children.Add(sitesFilterLabel);

            Button sitesFilterButton = new Button
            {
                Text = "Select Sites"
            };

            sitesFilterButton.Clicked += SitesFilterButton_Clicked;
            caveLocationStack.Children.Add(sitesFilterButton);

            caveLocationFrame.Content = caveLocationStack;
            contentStackLayout.Children.Add(caveLocationFrame);

            Frame buttonFrame = new Frame
            {
                HasShadow       = true,
                BackgroundColor = Color.White
            };

            StackLayout buttonStack         = new StackLayout();
            Label       buttonHeadlineLabel = new Label
            {
                FontSize  = 20,
                Text      = "Start searching",
                TextColor = Color.Black
            };

            buttonStack.Children.Add(buttonHeadlineLabel);

            Button searchButton = new Button
            {
                BackgroundColor = Color.Accent,
                TextColor       = Color.White,
                Text            = "Search"
            };

            searchButton.Clicked += SearchButton_Clicked;
            buttonStack.Children.Add(searchButton);
            buttonFrame.Content = buttonStack;

            contentStackLayout.Children.Add(buttonFrame);

            ScrollView scrollView = new ScrollView
            {
                Content = contentStackLayout
            };

            Content = scrollView;
        }
Exemple #15
0
 protected override void OnDisappearing()
 {
     Kucha.SaveCaveNotes(cave.caveID, notesEditor.Text);
     base.OnDisappearing();
 }
Exemple #16
0
        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;
        }