Пример #1
0
        private void Taplab_Tapped(object sender, EventArgs e)
        {
            popupLayout = this.Content as PopupLayout;
            if (popupLayout.IsPopupActive)
            {
                popupLayout.DismissPopup();
            }
            else
            {
                StackLayout blueline = new StackLayout()
                {
                    BackgroundColor = Color.FromHex("#304269"), HeightRequest = 0.5
                };
                StackLayout labelstack = new StackLayout()
                {
                    Padding = new Thickness(0, 0, 0, 0), BackgroundColor = Color.FromHex("#304269")
                };

                Label label = new Label()
                {
                    Text = "Courses", TextColor = Color.FromHex("#304269"), FontSize = 24, BackgroundColor = Color.White
                };
                labelstack.Children.Add(label);
                StackLayout mainstack1 = new StackLayout()
                {
                    Orientation       = StackOrientation.Vertical,
                    HeightRequest     = this.Height * .5,
                    WidthRequest      = this.Width * .8,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    BackgroundColor   = Color.FromHex("#304269"),
                    Padding           = new Thickness(2, 1, 2, 1)
                };
                mainstack1.Children.Add(labelstack);
                popupLayout.ShowPopup(mainstack1);
                //		mainstack.Opacity = 0.2;
            }
        }
Пример #2
0
        //#region compress decompress image
        //private Bitmap DecodeSmallFile(String filename, int width, int height)
        //{
        //    var options = new BitmapFactory.Options { InJustDecodeBounds = true };
        //    BitmapFactory.DecodeFile(filename, options);
        //    options.InSampleSize = CalculateInSampleSize(options, width, height);
        //    options.InJustDecodeBounds = false;
        //    return BitmapFactory.DecodeFile(filename, options);
        //}
        //public static int CalculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight)
        //{
        //    // Raw height and width of image
        //    float height = options.OutHeight;
        //    float width = options.OutWidth;
        //    double inSampleSize = 1D;

        //    if (height > reqHeight || width > reqWidth)
        //    {
        //        int halfHeight = (int)(height / 2);
        //        int halfWidth = (int)(width / 2);

        //        // Calculate a inSampleSize that is a power of 2 - the decoder will use a value that is a power of two anyway.
        //        while ((halfHeight / inSampleSize) > reqHeight && (halfWidth / inSampleSize) > reqWidth)
        //        {
        //            inSampleSize *= 2;
        //        }
        //    }

        //    return (int)inSampleSize;
        //}
        ////async Task<BitmapFactory.Options> GetBitmapOptionsOfImageAsync()
        ////{
        ////    BitmapFactory.Options options = new BitmapFactory.Options
        ////    {
        ////        InJustDecodeBounds = true
        ////    };

        ////    // The result will be null because InJustDecodeBounds == true.
        ////    Bitmap result = await BitmapFactory.DecodeResourceAsync(Resources, Resource.Drawable.samoyed, options);

        ////    int imageHeight = options.OutHeight;
        ////    int imageWidth = options.OutWidth;

        ////    _originalDimensions.Text = string.Format("Original Size= {0}x{1}", imageWidth, imageHeight);

        ////    return options;
        ////}
        ////public async void CallWebService()

        //#endregion
        public void popupviewIos(string id)
        {
            popupLayout = this.Content as PopupLayout;
            try
            {
                if (popupLayout.IsPopupActive)
                {
                    // PhotoDetailList.GestureRecognizers.Remove
                    popupLayout.DismissPopup();
                    PhotoDetailMainStack.Opacity = 1;
                    //   MainStack.BackgroundColor = Color.Transparent;
                }
                else
                {
                    PhotoDetailMainStack.Opacity = 0.2;
                    //MainStack.BackgroundColor = Color.Black;
                    #region xaml design popup
                    StackLayout MainStack = new StackLayout()
                    {
                        BackgroundColor   = Xamarin.Forms.Color.White,
                        HeightRequest     = this.Height * .5,
                        WidthRequest      = this.Width * .8,
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center,
                        Padding           = new Thickness(5, 5, 5, 5)
                    };
                    StackLayout ImageStack = new StackLayout()
                    {
                        HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center
                    };
                    Grid ImageGridLayout = new Grid()
                    {
                        BackgroundColor   = Xamarin.Forms.Color.White,
                        HeightRequest     = this.Height * .45,
                        WidthRequest      = this.Width * .8,
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center,
                    };
                    Image ImageContent = new Image()
                    {
                        Aspect        = Aspect.Fill,
                        HeightRequest = this.Height * .45,
                        WidthRequest  = this.Width * .8
                    };
                    Image ImageContentPlaceholder = new Image()
                    {
                        Aspect        = Aspect.Fill,
                        HeightRequest = this.Height * .45,
                        WidthRequest  = this.Width * .8,
                        Source        = "photogalleryplaceholder.png"
                    };
                    #endregion

                    #region bottom stack

                    StackLayout BottomStack = new StackLayout()
                    {
                        Orientation       = StackOrientation.Horizontal,
                        BackgroundColor   = Xamarin.Forms.Color.White,
                        HeightRequest     = this.Height * .05,
                        WidthRequest      = this.Width * .8,
                        VerticalOptions   = LayoutOptions.Center,
                        HorizontalOptions = LayoutOptions.CenterAndExpand
                    };
                    Label ImageNumber = new Label()
                    {
                        BackgroundColor = Xamarin.Forms.Color.White, TextColor = Xamarin.Forms.Color.FromHex("#09091a"), VerticalOptions = LayoutOptions.Center, FontSize = 20, HorizontalOptions = LayoutOptions.Start
                    };
                    Image LeftArrow = new Image()
                    {
                        Source = "prev_btn.png", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start
                    };
                    Image RightArrow = new Image()
                    {
                        Source = "next_btn.png", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Start
                    };
                    Image CloseButton = new Image()
                    {
                        Source = "btn_close.png", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.EndAndExpand
                    };
                    int MinTapValue     = 1;
                    int PhotoCountValue = Convert.ToInt32(id);
                    int Maxtap          = PopupPhotoList.Count;
                    //ImageContent.Source = PopupPhotoList[MinTapValue - 1].photo_path;
                    ImageContent.Source = PopupPhotoList[PhotoCountValue - 1].photo_path;
                    ImageNumber.Text    = PhotoCountValue + " " + AppResources.LOf + " " + PopupPhotoList.Count;
                    var LeftArrowTap = new TapGestureRecognizer(); LeftArrowTap.Tapped += (object sender, EventArgs e) =>
                    {
                        //if (PhotoCountValue <= 0)
                        //{
                        //}
                        //else
                        //{
                        if (PhotoCountValue > 1)
                        {
                            PhotoCountValue = PhotoCountValue - 1;
                            //ImageContent.Source = PopupPhotoList[PhotoCountValue - 1].photo_path;
                            ImageContent.Source = PopupPhotoList[PhotoCountValue - 1].photo_path;
                            ImageNumber.Text    = PhotoCountValue + " " + AppResources.LOf + " " + PopupPhotoList.Count;
                        }
                        //}
                    };
                    var RightArrowTap = new TapGestureRecognizer(); RightArrowTap.Tapped += (object sender, EventArgs e) =>
                    {
                        //if (PhotoCountValue >= PopupPhotoList.Count)
                        //{
                        //}
                        //else
                        //{
                        if (PhotoCountValue < PopupPhotoList.Count)
                        {
                            PhotoCountValue = PhotoCountValue + 1;
                            //ImageContent.Source = PopupPhotoList[PhotoCountValue - 1].photo_path;
                            ImageContent.Source = PopupPhotoList[PhotoCountValue - 1].photo_path;
                            ImageNumber.Text    = PhotoCountValue + " " + AppResources.LOf + " " + PopupPhotoList.Count;
                        }

                        //}
                    };
                    var CloseButtonTap = new TapGestureRecognizer(); CloseButtonTap.Tapped += (object sender, EventArgs e) =>
                    {
                        //if (popupLayout.IsPopupActive)
                        //{
                        //    PhotoDetailMainStack.Opacity = 1;
                        //    popupLayout.DismissPopup();
                        //}
                        popupviewIos(PhotoCountValue.ToString());
                    };
                    LeftArrow.GestureRecognizers.Add(LeftArrowTap);
                    RightArrow.GestureRecognizers.Add(RightArrowTap);
                    CloseButton.GestureRecognizers.Add(CloseButtonTap);
                    BottomStack.Children.Add(LeftArrow);
                    BottomStack.Children.Add(ImageNumber);
                    BottomStack.Children.Add(RightArrow);
                    BottomStack.Children.Add(CloseButton);
                    #endregion
                    ImageGridLayout.Children.Add(ImageContentPlaceholder);
                    ImageGridLayout.Children.Add(ImageContent);
                    ImageStack.Children.Add(ImageGridLayout);
                    //  ImageStack.Children.Add(ImageContent);
                    ImageStack.Children.Add(BottomStack);
                    MainStack.Children.Add(ImageStack);
                    popupLayout.ShowPopup(MainStack);
                }
            }
            catch (Exception e)
            {
                DisplayAlert(AppResources.LNetworkError, e.Message, AppResources.LOk);
            }
        }