예제 #1
0
        void Init()
        {
            //header styling
            Header.BackgroundColor = Constants.KleynGroupBG;
            Logo.HeightRequest     = 40;


            Return.HorizontalOptions = LayoutOptions.EndAndExpand;

            UserDatabaseController UserData = new UserDatabaseController();
            var Userinfo = UserData.GetAllUsers();

            if (Userinfo[0].picturePermisson == 1)
            {
                //Upload Button Style
                UploadButton.BackgroundColor = Constants.KleynGroupTXT;
                UploadButton.TextColor       = Constants.LoginEntryBgColor;
            }
            else
            {
                //Upload Button Style
                UploadButton.BackgroundColor = Constants.KleynGroupTXT;
                UploadButton.TextColor       = Constants.LoginEntryBgColor;
                UploadButton.IsVisible       = false;
            }

            //footer styling
            Footer.BackgroundColor       = Constants.KleynGroupBG;
            Lbl_CR.TextColor             = Constants.MainTextColor;
            Lbl_CR.HorizontalOptions     = LayoutOptions.Center;
            Lbl_CR.VerticalOptions       = LayoutOptions.EndAndExpand;
            Lbl_CR.VerticalTextAlignment = TextAlignment.Center;
            Lbl_CR.HeightRequest         = 80;

            //Activty Spinner
            Spinner.Color = Constants.KleynGroupTXT;
        }
예제 #2
0
        public async Task GetImages(List <PictureInfo> pictureInfo, string itemnummer)
        {
            //Make a new ByteConvertController
            var byteConverter = new ByteConverterController();

            //For each element in pictureInfo retrive the image
            for (int i = 0; i < pictureInfo.Count(); ++i)
            {
                //Show the Activity spinner
                this.IsBusy = true;
                //Get the image source from the api
                var Sources = await byteConverter.DownloadImage(itemnummer, pictureInfo[i].typecode);

                //Make a new image
                var img = new Image
                {
                    //Set the source to what we got from the api
                    Source = ImageSource.FromStream(() => new MemoryStream(Sources)),
                };
                //Make a new label
                var LabelType = new Label
                {
                    Text = pictureInfo[i].label + " - " + pictureInfo[i].typecode,
                    HorizontalOptions = LayoutOptions.StartAndExpand
                };
                //Add all the elements to the image page
                MasterContent.Children.Add(LabelType);
                MasterContent.Children.Add(img);
                //Make a new button the upload/change the image
                UserDatabaseController UserData = new UserDatabaseController();
                var Userinfo = UserData.GetAllUsers();
                if (Userinfo[0].picturePermisson == 1)
                {
                    var ActionButton = new Button
                    {
                        Text            = "Choose an action",
                        BackgroundColor = Constants.KleynGroupTXT,
                        TextColor       = Constants.LoginEntryBgColor
                    };
                    MasterContent.Children.Add(ActionButton);
                    //Make a new var with the type code
                    var TypeCode = pictureInfo[i].typecode;
                    // Check if the user pressed one of the Buttons
                    ActionButton.Clicked += async(sender, args) =>
                    {
                        // If so ask the user what he wants to do with the image
                        var action = await DisplayActionSheet("Select What you want to do with the image", "Cancel", null,
                                                              "Delete Image", "Edit Image");

                        //Make a new switch
                        switch (action)
                        {
                        //User pressed Delete
                        case "Delete Image":
                            //Make a new ByteController
                            var Deleted = new ByteConverterController();
                            // Do the delete request
                            var removeImage = Deleted.DeleteImage(itemnummer, TypeCode);
                            //Send the user back to the detail page
                            Navigation.InsertPageBefore(new DetailPage(itemnummer), this);
                            await Navigation.PopAsync(true);

                            break;

                        // User pressed Edit
                        case "Edit Image":
                            // Ask if the user wants to choose a image from the gallery or take one with the camera
                            var Editanswer = await DisplayActionSheet("Edit Choosed, Do you want to pick a photo from the gallery or one from the camera", "Abort", null, "Camera", "Gallery");

                            // If the user pressed Camera open the camera
                            switch (Editanswer)
                            {
                            case "Camera":
                                //Send the user to the camera and go on to the next function
                                BtnCamera_ClickedAsync(itemnummer, TypeCode, "PUT");
                                break;

                            case "Gallery":
                                //Send the user to his/her Gallery and go on to the next function
                                BtnPickPhoto_CickedAsync(itemnummer, TypeCode, "PUT");
                                break;

                            default:
                                await DisplayAlert("Action Canceld", "Action has been aborted", "Okay");

                                break;
                            }
                            break;

                        //if the user pressed canceld or press some where else on the screen cancel the question
                        default:
                            //Show the user he/she canceld it
                            await DisplayAlert("Nothing Choosed", "Nothing has been chosen", "Abort");

                            return;
                        }
                        ;
                    };
                }
                // Hide the Activity spinner
                this.IsBusy = false;
            }
        }
예제 #3
0
 public List <User> GetAllUsers()
 {
     return(database.GetAllUsers());
 }
예제 #4
0
 protected override void OnAppearing()
 {
     lstView.ItemsSource = _UserQuery.GetAllUsers();   //load the items to listview
     base.OnAppearing();
 }