public TransformationPage()
        {
            Title = "Transformations Demo";

            var cachedImage = new CachedImage()
            {
                WidthRequest         = 400,
                HeightRequest        = 400,
                DownsampleToViewSize = true,
                HorizontalOptions    = LayoutOptions.Center,
                VerticalOptions      = LayoutOptions.Center,
                CacheDuration        = TimeSpan.FromDays(30),
            };

            cachedImage.SetBinding <TransformationPageModel>(CachedImage.TransformationsProperty, v => v.Transformations);
            cachedImage.SetBinding <TransformationPageModel>(CachedImage.LoadingPlaceholderProperty, v => v.LoadingImagePath);
            cachedImage.SetBinding <TransformationPageModel>(CachedImage.ErrorPlaceholderProperty, v => v.ErrorImagePath);
            cachedImage.SetBinding <TransformationPageModel>(CachedImage.SourceProperty, v => v.ImagePath);

            var reloadButton = new Button()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text = "Load another image",
            };

            reloadButton.SetBinding <TransformationPageModel>(Button.CommandProperty, v => v.LoadAnotherImageCommand);

            var imagePath = new Label()
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                VerticalOptions         = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label))
            };

            imagePath.SetBinding <TransformationPageModel>(Label.TextProperty, v => v.ImagePath);

            var transformatioType = new Label()
            {
                HorizontalOptions     = LayoutOptions.FillAndExpand,
                VerticalTextAlignment = TextAlignment.Center,
            };

            transformatioType.SetBinding <TransformationPageModel>(Label.TextProperty, v => v.TransformationType);

            Content = new ScrollView()
            {
                Content = new StackLayout {
                    Children =
                    {
                        cachedImage,
                        transformatioType,
                        imagePath,
                        reloadButton,
                    }
                }
            };
        }
Beispiel #2
0
        public CropTransformationPage()
        {
            Title = "CropTransformation Demo";

            var cachedImage = new CachedImage()
            {
                WidthRequest         = 300f,
                HeightRequest        = 300f,
                DownsampleToViewSize = true,
                HorizontalOptions    = LayoutOptions.FillAndExpand,
                VerticalOptions      = LayoutOptions.FillAndExpand,
                CacheDuration        = TimeSpan.FromDays(30),
                FadeAnimationEnabled = false,
            };

            cachedImage.SetBinding <CropTransformationPageModel>(CachedImage.TransformationsProperty, v => v.Transformations);
            cachedImage.SetBinding <CropTransformationPageModel>(CachedImage.LoadingPlaceholderProperty, v => v.LoadingImagePath);
            cachedImage.SetBinding <CropTransformationPageModel>(CachedImage.ErrorPlaceholderProperty, v => v.ErrorImagePath);
            cachedImage.SetBinding <CropTransformationPageModel>(CachedImage.SourceProperty, v => v.ImagePath);

            var imagePath = new Label()
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label))
            };

            imagePath.SetBinding <CropTransformationPageModel>(Label.TextProperty, v => v.ImagePath);

            var pinchGesture = new PinchGestureRecognizer();

            pinchGesture.PinchUpdated += (object sender, PinchGestureUpdatedEventArgs e) => {
                this.GetPageModel().PinchImage(e);
            };

            var panGesture = new PanGestureRecognizer();

            panGesture.PanUpdated += (object sender, PanUpdatedEventArgs e) => {
                this.GetPageModel().PanImage(e);
            };

            cachedImage.GestureRecognizers.Add(pinchGesture);
            cachedImage.GestureRecognizers.Add(panGesture);

            Content = new ScrollView()
            {
                Content = new StackLayout {
                    Children =
                    {
                        imagePath,
                        cachedImage
                    }
                }
            };
        }
        public DownsamplingPage()
        {
            Title = "Downsampling example";

            var cachedImage = new CachedImage()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                CacheDuration     = TimeSpan.FromDays(30),
            };

            cachedImage.SetBinding <DownsamplingPageModel>(CachedImage.SourceProperty, v => v.ImagePath);
            cachedImage.SetBinding <DownsamplingPageModel>(CachedImage.DownsampleWidthProperty, v => v.DownsampleWidth);
            cachedImage.SetBinding <DownsamplingPageModel>(CachedImage.DownsampleHeightProperty, v => v.DownsampleHeight);

            var button1 = new Button()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text = "Downsample Height 200",
            };

            button1.SetBinding <DownsamplingPageModel>(Button.CommandProperty, v => v.DownsampleHeight200Command);

            var button2 = new Button()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text = "Downsample Width 200",
            };

            button1.SetBinding <DownsamplingPageModel>(Button.CommandProperty, v => v.DownsampleWidth200Command);

            var imagePath = new Label()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize          = Device.GetNamedSize(NamedSize.Micro, typeof(Label)),
            };

            imagePath.SetBinding <DownsamplingPageModel>(Label.TextProperty, v => v.ImagePath);

            Content = new ScrollView()
            {
                Content = new StackLayout {
                    Children =
                    {
                        cachedImage,
                        imagePath,
                        button1,
                        button2,
                    }
                }
            };
        }
Beispiel #4
0
        public ChampionListCell()
        {
            var champProfileImage = new CachedImage
            {
                WidthRequest         = 43,
                HeightRequest        = 43,
                Aspect               = Aspect.AspectFill,
                HorizontalOptions    = LayoutOptions.Center,
                VerticalOptions      = LayoutOptions.Center,
                CacheDuration        = TimeSpan.FromDays(30),
                DownsampleToViewSize = true,
                RetryCount           = 5,
                RetryDelay           = 250
            };

            champProfileImage.SetBinding(CachedImage.SourceProperty, "Icon");

            var nameLabel = new Label()
            {
                TextColor = Color.Black
            };

            nameLabel.SetBinding(Label.TextProperty, "Name");

            var distanceLabel = new Label()
            {
                FontSize  = 12,
                TextColor = Color.Accent
            };

            distanceLabel.SetBinding(Label.TextProperty, "Title");


            var vetDetailsLayout = new StackLayout
            {
                Padding           = new Thickness(10, 5, 0, 0),
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          = { nameLabel, distanceLabel }
            };

            var champLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    champProfileImage, vetDetailsLayout
                }
            };

            var cellLayout = new StackLayout
            {
                Padding = new Thickness(10, 0, 0, 0),
                //Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          = { champLayout }
            };

            View = cellLayout;
        }
Beispiel #5
0
        public FlowCellImage()
        {
            var cachedImage = new CachedImage
            {
                Aspect = Aspect.AspectFill,
                DownsampleToViewSize = true,
                HeightRequest        = 100,
            };

            cachedImage.SetBinding(CachedImage.SourceProperty, "ThumbnailUrl");

            var title = new Label
            {
                TextColor = Theme.ThemeColor3,
            };

            title.SetBinding(Label.TextProperty, "Title");

            var stackLayout = new StackLayout
            {
                Children =
                {
                    title,
                    cachedImage
                }
            };

            Content = stackLayout;
        }
        public NationalityCell()
        {
            Height = 45;
            var img = new CachedImage()
            {
                Margin             = new Thickness(8, 4, 4, 4),
                HeightRequest      = 24,
                WidthRequest       = 24,
                RetryCount         = 0,
                RetryDelay         = 250,
                LoadingPlaceholder = "unchecked.png",
                CacheDuration      = TimeSpan.FromDays(10),
            };

            img.SetBinding(CachedImage.SourceProperty, new Binding(path: "IsSelected", converter: CoreSettings.ImageConverter));

            var lbl = new Label()
            {
                FontSize        = 18,
                VerticalOptions = LayoutOptions.Center
            };

            lbl.SetBinding(Label.TextProperty, "Description");

            View = new StackLayout()
            {
                Padding     = 10,
                Spacing     = 10,
                Orientation = StackOrientation.Horizontal,
                Children    = { img, lbl }
            };
        }
        public MediaDetailPage(MediaDetails media)
        {
            Title          = ApplicationResource.PageMediaDetailTitle;
            BindingContext = new MediaDetailViewModel(this.Navigation, media);

            var image = new CachedImage {
                Aspect = Aspect.AspectFill
            };

            image.SetBinding(CachedImage.SourceProperty, "MediaFilePath");

            var deleteToolbarItem = new ToolbarItem()
            {
                Text = "Delete"
            };

            deleteToolbarItem.Command = new Command(async() => await PromptDeleteMedia());

            //deleteToolbarItem.SetBinding(ToolbarItem.CommandProperty, new Binding("DeleteMediaCommand"));

            ToolbarItems.Add(deleteToolbarItem);

            var layout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    image
                }
            };

            Content = layout;
        }
Beispiel #8
0
        public PhotoDetailsPage(PhotoModel selectedPhoto)
        {
            ViewModel.SetPhotoCommand?.Execute(selectedPhoto);

            var photoTitleLabel = new PhotoDetailLabel(AutomationIdConstants.PhotoTitleLabel);

            photoTitleLabel.SetBinding(Label.TextProperty, nameof(ViewModel.PhotoTitle));

            var photoImage = new CachedImage {
                AutomationId = AutomationIdConstants.PhotoImage
            };

            photoImage.SetBinding(CachedImage.SourceProperty, nameof(ViewModel.PhotoImageSource));

            Title = PageTitles.PhotoListPage;

            Padding = new Thickness(20);

            Content = new StackLayout
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,

                Spacing = 20,

                Children =
                {
                    photoImage,
                    photoTitleLabel
                }
            };
        }
Beispiel #9
0
        public ImageViewPage()
        {
            Xamarin.Forms.NavigationPage.SetHasNavigationBar(this, false);

            InitializeComponent();

            if (Device.RuntimePlatform == Device.iOS)
            {
                var zoom = new ZoomImageIOS()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Aspect = Aspect.AspectFit, BackgroundColor = Color.Black
                };
                zoom.SetBinding(CachedImage.SourceProperty, "Image");
                stack_container.Children.Insert(0, zoom);
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                var zoom = new ZoomImageAndroid()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
                };
                var image = new CachedImage()
                {
                    DownsampleToViewSize = false, BitmapOptimizations = true, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Aspect = Aspect.AspectFit, BackgroundColor = Color.Black
                };
                image.SetBinding(CachedImage.SourceProperty, "Image");
                zoom.Content = image;
                stack_container.Children.Insert(0, zoom);
            }
        }
Beispiel #10
0
        public AddPhotoPage()
        {
            _photoTitleEntry = new CustomReturnEntry
            {
                Placeholder       = "Title",
                BackgroundColor   = Color.White,
                TextColor         = ColorConstants.TextColor,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ReturnType        = ReturnType.Go
            };
            _photoTitleEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.PhotoTitle));
            _photoTitleEntry.SetBinding(CustomReturnEntry.ReturnCommandProperty, nameof(ViewModel.TakePhotoCommand));

            _takePhotoButton = new Button
            {
                Text            = "Take Photo",
                BackgroundColor = ColorConstants.NavigationBarBackgroundColor,
                TextColor       = ColorConstants.TextColor
            };
            _takePhotoButton.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhotoCommand));

            _photoImage = new CachedImage();
            _photoImage.SetBinding(CachedImage.SourceProperty, nameof(ViewModel.PhotoImageSource));

            _saveToobarItem = new ToolbarItem
            {
                Text         = "Save",
                Priority     = 0,
                AutomationId = AutomationIdConstants.SaveButton,
            };
            _saveToobarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.SavePhotoCommand));
            ToolbarItems.Add(_saveToobarItem);

            _cancelToolbarItem = new ToolbarItem
            {
                Text         = "Cancel",
                Priority     = 1,
                AutomationId = AutomationIdConstants.CancelButton
            };
            ToolbarItems.Add(_cancelToolbarItem);

            this.SetBinding(TitleProperty, nameof(ViewModel.PhotoTitle));

            Padding = new Thickness(20);

            Content = new StackLayout
            {
                Spacing = 20,

                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    _photoImage,
                    _photoTitleEntry,
                    _takePhotoButton,
                }
            };
        }
        public DefaultCardItemView()
        {
            var tapGesture = new TapGestureRecognizer();

            tapGesture.Tapped += (s, e) => Application.Current.MainPage.DisplayAlert("Tap!", null, "Ok");
            GestureRecognizers.Add(tapGesture);

            var frame = new Frame
            {
                Padding           = 0,
                HasShadow         = false,
                CornerRadius      = 10,
                IsClippedToBounds = true
            };

            frame.SetBinding(BackgroundColorProperty, "Color");
            Children.Add(frame, new Rectangle(.5, .5, 300, 300), AbsoluteLayoutFlags.PositionProportional);

            var image = new CachedImage
            {
                Aspect = Aspect.AspectFill
            };

            image.SetBinding(CachedImage.SourceProperty, "Source");

            frame.Content = image;
        }
Beispiel #12
0
        public AddFoodPage() : base(PageTitleConstants.AddFoodPage)
        {
            _takePhotoButton = new HealthClinicButton
            {
                Text = "Take Photo",
            };
            _takePhotoButton.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhotoCommand));
            _takePhotoButton.SetBinding(IsEnabledProperty, new Binding(nameof(ViewModel.IsPhotoUploading), BindingMode.Default, new InverseBooleanConverter(), ViewModel.IsPhotoUploading));

            _photoImage = new CachedImage();
            _photoImage.SetBinding(CachedImage.SourceProperty, nameof(ViewModel.PhotoImageSource));

            _uploadToolbarItem = new ToolbarItem
            {
                Text         = "Upload",
                Priority     = 0,
                AutomationId = AutomationIdConstants.AddFoodPage_UploadButton,
            };
            _uploadToolbarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.UploadButtonCommand));
            ToolbarItems.Add(_uploadToolbarItem);

            _cancelToolbarItem = new ToolbarItem
            {
                Text         = "Cancel",
                Priority     = 1,
                AutomationId = AutomationIdConstants.AddFoodPage_CancelButton
            };
            ToolbarItems.Add(_cancelToolbarItem);

            var activityIndicator = new ActivityIndicator
            {
                Color        = ColorConstants.OffWhite,
                AutomationId = AutomationIdConstants.AddFoodPage_ActivityIndicator
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsPhotoUploading));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsPhotoUploading));

            Padding = new Thickness(20);

            var stackLayout = new StackLayout
            {
                Spacing = 20,

                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    _photoImage,
                    _takePhotoButton,
                    activityIndicator
                }
            };

            Content = new ScrollView {
                Content = stackLayout
            };
        }
Beispiel #13
0
        /// <summary>
        /// Create checkbox.
        /// </summary>
        /// <returns>Checkbox image.</returns>
        CachedImage createCheckbox()
        {
            var checkbox = new CachedImage {
                HeightRequest     = _checkboxHeight,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                Source            = ImageSource.FromFile(Theme.Current.CheckboxIcon)
            };

            checkbox.SetBinding(VisualElement.IsVisibleProperty, "IsChecked");
            return(checkbox);
        }
        public UserListCell()
        {
            var userPhoto = new CachedImage
            {
                HeightRequest = 50,
                WidthRequest  = 50,
                Aspect        = Aspect.AspectFit
            };

            userPhoto.SetBinding(CachedImage.SourceProperty, Binding.Create <User>(o => o.ImageUri));

            var Name = new Label
            {
                Text           = "UserName",
                TextColor      = App.StyleKit.PrimaryTextColor,
                FontAttributes = FontAttributes.Bold
            };

            Name.SetBinding(Label.TextProperty, Binding.Create <User>(o => o.Name));

            var Phone = new Label
            {
                Text      = "telephone",
                TextColor = App.StyleKit.SecondaryTextColor
            };

            Phone.SetBinding(Label.TextProperty, Binding.Create <User>(o => o.Phone));

            var contentLines = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    Name,
                    Phone
                }
            };

            View = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Padding           = 8,
                Spacing           = 10,
                Children          =
                {
                    userPhoto, contentLines
                }
            };
        }
Beispiel #15
0
        public FFImageLoadingBasic()
        {
            Title = "CachedImage in ListView";
            var items = new List <ImageItem>();

            for (int i = 0; i < Images.Count; i++)
            {
                items.Add(new ImageItem
                {
                    Source = Images[i],
                    Title  = Images[i]
                });
            }

            Content = new ListView
            {
                HasUnevenRows = false,
                RowHeight     = 320,
                ItemsSource   = items,
                ItemTemplate  = new DataTemplate(() =>
                {
                    var cell  = new ViewCell();
                    var label = new Label
                    {
                        VerticalOptions   = LayoutOptions.Start,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                    };
                    var image = new CachedImage
                    {
                        HeightRequest      = 300,
                        ErrorPlaceholder   = "error.jpg",
                        LoadingPlaceholder = "placeholder.jpg",
                        VerticalOptions    = LayoutOptions.CenterAndExpand,
                        HorizontalOptions  = LayoutOptions.CenterAndExpand,
                    };
                    label.SetBinding(Label.TextProperty, new Binding("Title"));
                    image.SetBinding(CachedImage.SourceProperty, new Binding("Source"));

                    cell.View = new StackLayout
                    {
                        Children =
                        {
                            label,
                            image
                        }
                    };

                    return(cell);
                })
            };
        }
        private void CarViewReInit()
        {
            var tap = new TapGestureRecognizer();

            tap.Command = new Command((obj) =>
            {
                if (viewModel.IsBusy == false && viewModel.Items.Count != 0)
                {
                    viewModel.ImageTapCommand.Execute(carView?.Position);
                }
            });
            carView.GestureRecognizers.Add(tap);
            if (Device.RuntimePlatform == Device.Android)
            {
                carView.ItemTemplate = new DataTemplate(() =>
                {
                    var grid = new Grid();
                    var img  = new CachedImage()
                    {
                        Aspect = Aspect.AspectFill
                    };
                    img.SetBinding(ClassIdProperty, new Binding("StyleId"));
                    img.SetBinding(CachedImage.SourceProperty, new Binding("Image"));
                    var label = new Label()
                    {
                        Margin = new Thickness(10, 10, 10, 15),
                        VerticalTextAlignment = TextAlignment.End,
                        HorizontalOptions     = LayoutOptions.Start,
                        TextColor             = Color.White
                    };
                    label.SetBinding(Label.TextProperty, new Binding("Text"));
                    grid.Children.Add(img);
                    grid.Children.Add(label);
                    grid.GestureRecognizers.Add(tap);
                    return(grid);
                });
            }
        }
        public GalleryItemView()
        {
            var cachedImage = new CachedImage
            {
                Aspect = Aspect.AspectFill,
                DownsampleToViewSize = true,
                HeightRequest        = 500,
                HorizontalOptions    = LayoutOptions.FillAndExpand
            };

            cachedImage.SetBinding(CachedImage.SourceProperty, ".");

            Content = cachedImage;
        }
        CachedImage createAvatar()
        {
            var avatarImage = new CachedImage {
                HeightRequest   = _avatarHeight,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Transformations =
                {
                    new CircleTransformation()
                }
            };

            avatarImage.SetBinding(CachedImage.SourceProperty, "Avatar",
                                   converter: new Base64ToImageSourceConverter());
            return(avatarImage);
        }
            public TransformationExampleCell()
            {
                var image = new CachedImage()
                {
                    WidthRequest          = 200,
                    HeightRequest         = 200,
                    DownsampleHeight      = 200,
                    DownsampleUseDipUnits = true,
                    TransparencyEnabled   = false,
                    Aspect             = Aspect.AspectFill,
                    CacheDuration      = TimeSpan.FromDays(30),
                    RetryCount         = 3,
                    RetryDelay         = 500,
                    LoadingPlaceholder = "loading.png",
                    Transformations    = new List <ITransformation>()
                    {
                        // new SepiaTransformation(),
                        // new ColorSpaceTransformation(FFColorMatrix.InvertColorMatrix),
                        // new BlurredTransformation(10),
                        new GrayscaleTransformation(),
                        new RoundedTransformation(60),
                        // new CornersTransformation(50, 50, 50, 50, CornerTransformType.AllRounded),
                    }
                };

                image.SetBinding <ListExampleItem>(CachedImage.SourceProperty, v => v.ImageUrl);

                var fileName = new Label()
                {
                    LineBreakMode = LineBreakMode.CharacterWrap,
                    YAlign        = TextAlignment.Center,
                    XAlign        = TextAlignment.Center,
                };

                fileName.SetBinding <ListExampleItem>(Label.TextProperty, v => v.FileName);

                var root = new AbsoluteLayout()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Padding           = 5,
                };

                root.Children.Add(image, new Rectangle(0f, 0f, 200f, 200f));
                root.Children.Add(fileName, new Rectangle(200f, 0f, 150f, 200f));

                View = root;
            }
Beispiel #20
0
        public MessageCell()
        {
            photo.SetBinding(CachedImage.SourceProperty, nameof(Message.Photo));
            text.SetBinding(Label.TextProperty, nameof(Message.Text));
            time.SetBinding(Label.TextProperty, nameof(Message.TimeFormatted));
            this.SetBinding(SenderIdProperty, nameof(Message.SenderId));
            this.SetBinding(ReadProperty, nameof(Message.Read));
            this.SetBinding(VoiceMessageSourceProperty, nameof(Message.VoiceMessage));

            photoWrapperLayout.Children.Add(photo);
            photoWrapperLayout.Children.Add(time);
            wrapperLayout.Children.Add(photoWrapperLayout);
            wrapperLayout.Children.Add(text);
            outerLayout.Children.Add(wrapperLayout);
            View = outerLayout;
        }
Beispiel #21
0
        private void InitializeComponent()
        {
            var listVideos = new ListView
            {
                HasUnevenRows          = true,
                IsPullToRefreshEnabled = true,
                SeparatorVisibility    = SeparatorVisibility.None,
                Margin        = new Thickness(20),
                SelectionMode = ListViewSelectionMode.Single,
                ItemTemplate  = new DataTemplate(() =>
                {
                    var stackLayout = new StackLayout
                    {
                        HeightRequest   = 250,
                        Margin          = new Thickness(10),
                        BackgroundColor = Color.Red,
                        Orientation     = StackOrientation.Vertical
                    };

                    var image = new CachedImage
                    {
                        Aspect = Aspect.AspectFill
                    };
                    image.SetBinding(CachedImage.SourceProperty, "Snippet.Thumbnails.High.Url.AbsoluteUri");
                    stackLayout.Children.Add(image);

                    var label = new Label
                    {
                        Margin    = new Thickness(10, 5, 0, 5),
                        TextColor = Color.White
                    };
                    label.SetBinding(Label.TextProperty, "Snippet.Title");
                    stackLayout.Children.Add(label);

                    return(new ViewCell {
                        View = stackLayout
                    });
                })
            };

            listVideos.SetBinding(ListView.SelectedItemProperty, "SelectedVideo", BindingMode.TwoWay);
            listVideos.SetBinding(ListView.ItemsSourceProperty, "Videos");

            Content = listVideos;
        }
Beispiel #22
0
        public PictureView()
        {
            img = new CachedImage()
            {
                HeightRequest      = 300,
                RetryCount         = 0,
                Aspect             = Aspect.AspectFill,
                RetryDelay         = 250,
                LoadingPlaceholder = "placeholder.png",
                CacheDuration      = TimeSpan.FromDays(10),
            };
            img.SetBinding(CachedImage.SourceProperty, "ImageUrl");

            Content = new StackContainer(true)
            {
                Children = { img }
            };
        }
Beispiel #23
0
        public DialogCell()
        {
            photo.SetBinding(CachedImage.SourceProperty, nameof(Dialog.Photo));
            title.SetBinding(Label.TextProperty, nameof(Dialog.Title));
            text.SetBinding(Label.TextProperty, nameof(Dialog.Text));
            this.SetBinding(UnreadCountProperty, nameof(Dialog.UnreadCount));
            this.SetBinding(OnlineProperty, nameof(Dialog.Online));
            this.SetBinding(TextProperty, nameof(Dialog.Text));

            titleLayout.Children.Add(title);
            titleLayout.Children.Add(unreadCount);
            titleLayout.Children.Add(onlineIndicator);
            titleAndTextLayout.Children.Add(titleLayout);
            titleAndTextLayout.Children.Add(text);
            wrapperLayout.Children.Add(photo);
            wrapperLayout.Children.Add(titleAndTextLayout);
            View = wrapperLayout;
        }
        public FilesPageViewCell()
        {
            var title = new Label {
                TextColor       = Color.FromHex(Theme.Current.FilesTitleColor),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Style           = AppStyles.GetLabelStyle()
            };

            title.SetBinding(Label.TextProperty, "Name");

            var description = new Label {
                TextColor       = Color.FromHex(Theme.Current.FilesSizeColor),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Style           = AppStyles.GetLabelStyle(NamedSize.Small)
            };

            description.SetBinding(Label.TextProperty, "Size");

            var downloadedIcon = new CachedImage {
                HeightRequest     = _iconDownloadHeight,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Source            = ImageSource.FromFile(Theme.Current.FilesDownloadedIcon)
            };

            downloadedIcon.SetBinding(VisualElement.IsVisibleProperty, "IsDownloaded");

            View = new StackLayout {
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor),
                Padding         = _padding,
                Children        =
                {
                    new StackLayout {
                        Children =
                        {
                            title,
                            description
                        }
                    },
                    downloadedIcon
                }
            };
        }
Beispiel #25
0
        public ImageCell(INavigation navigation)
        {
            // Navigation solution
            this.navigation = navigation;

            // Making elements
            CachedImage image     = new CachedImage();
            Grid        grid      = new Grid();
            StackLayout layout    = new StackLayout();
            Label       title     = new Label();
            Label       fullTitle = new Label();
            Button      subreddit = new Button();

            // Bindings
            image.SetBinding(CachedImage.SourceProperty, "ContentUrl");
            title.SetBinding(Label.TextProperty, new Binding("ShortTitle"));
            fullTitle.SetBinding(Label.TextProperty, "Title");
            subreddit.SetBinding(Button.TextProperty, "Subreddit");

            // Styles
            image.VerticalOptions         = LayoutOptions.StartAndExpand;
            layout.BackgroundColor        = Color.FromHex("#191919");
            layout.HorizontalOptions      = LayoutOptions.FillAndExpand;
            layout.Margin                 = new Thickness(0, 130, 0, 0);
            title.VerticalOptions         = LayoutOptions.CenterAndExpand;
            title.HorizontalOptions       = LayoutOptions.CenterAndExpand;
            title.HorizontalTextAlignment = TextAlignment.Center;
            subreddit.BackgroundColor     = Color.FromHex("#ff4500");
            subreddit.VerticalOptions     = LayoutOptions.StartAndExpand;
            subreddit.HorizontalOptions   = LayoutOptions.CenterAndExpand;

            // Gesture recognizer
            var tgr = new TapGestureRecognizer();

            tgr.Tapped += (s, e) => onImageClicked(image.Source);
            image.GestureRecognizers.Add(tgr);

            // Creating view
            layout.Children.Add(title);
            layout.Children.Add(subreddit);
            grid.Children.Add(image);
            grid.Children.Add(layout);
            View = grid;
        }
Beispiel #26
0
        /// <summary>
        /// Loads the template for the carousel in landscape layout.
        /// </summary>
        /// <returns>The view used as the template.</returns>
        private View LoadLandscapeTemplate()
        {
            // main content
            StackLayout outerStack = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, 0)
            };

            outerStack.SetBinding(BackgroundColorProperty, "BackgroundColor");
            CachedImage image = new CachedImage()
            {
                VerticalOptions = LayoutOptions.FillAndExpand, Aspect = Aspect.AspectFit, HorizontalOptions = LayoutOptions.FillAndExpand
            };

            image.SetBinding(CachedImage.SourceProperty, "Image");
            StackLayout innerStack = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                Padding           = new Thickness(10, 50),
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };
            Label headline = new Label()
            {
                TextColor  = Color.White, FontSize = 18, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center,
                FontFamily = Device.RuntimePlatform == Device.Android ? "SourceSansPro-Regular.ttf#SourceSansPro-Regular" : null,
            };

            headline.SetBinding(Label.TextProperty, "Headline");

            Label text = new Label()
            {
                TextColor  = Color.White, FontSize = 12, HorizontalTextAlignment = TextAlignment.Center,
                FontFamily = Device.RuntimePlatform == Device.Android ? "SourceSansPro-Regular.ttf#SourceSansPro-Regular" : null
            };

            text.SetBinding(Label.TextProperty, "Text");

            innerStack.Children.Add(headline);
            innerStack.Children.Add(text);
            outerStack.Children.Add(image);
            outerStack.Children.Add(innerStack);
            return(outerStack);
        }
        public MenuCell()
        {
            var icon = new CachedImage
            {
                HeightRequest = 40,
                WidthRequest  = 40,
                Aspect        = Aspect.AspectFill
            };

            icon.SetBinding(CachedImage.SourceProperty, Binding.Create <NavMenuItem>(o => o.Icon));

            var Name = new Label
            {
                Text           = "Name",
                TextColor      = Color.Red,
                FontAttributes = FontAttributes.Bold
            };

            Name.SetBinding(Label.TextProperty, Binding.Create <NavMenuItem>(o => o.Title));

            var contentLines = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    Name,
                }
            };

            View = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Spacing           = 10,
                Children          =
                {
                    icon, contentLines
                }
            };
        }
            public ListExampleCell()
            {
                var image = new CachedImage()
                {
                    WidthRequest          = 200,
                    HeightRequest         = 200,
                    DownsampleHeight      = 200,
                    DownsampleUseDipUnits = true,
                    TransparencyEnabled   = false,
                    Aspect             = Aspect.AspectFill,
                    CacheDuration      = TimeSpan.FromDays(30),
                    RetryCount         = 3,
                    RetryDelay         = 500,
                    LoadingPlaceholder = "loading.png",
                    //CUSTOM CACHE KEY:
                    CacheKeyFactory = new CustomCacheKeyFactory(),
                };

                image.SetBinding <ListExampleItem>(CachedImage.SourceProperty, v => v.ImageUrl);

                var fileName = new Label()
                {
                    LineBreakMode = LineBreakMode.CharacterWrap,
                    YAlign        = TextAlignment.Center,
                    XAlign        = TextAlignment.Center,
                };

                fileName.SetBinding <ListExampleItem>(Label.TextProperty, v => v.FileName);

                var root = new AbsoluteLayout()
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Padding           = 5,
                };

                root.Children.Add(image, new Rectangle(0f, 0f, 200f, 200f));
                root.Children.Add(fileName, new Rectangle(200f, 0f, 150f, 200f));

                View = root;
            }
        public LearningPageViewCell()
        {
            BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor);
            Padding         = _padding;

            var image = new CachedImage {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Aspect            = Aspect.AspectFill
            };

            image.SetBinding(CachedImage.SourceProperty, "Image",
                             converter: new StringToImageSourceConverter());

            var title = new Label {
                TextColor      = Color.FromHex(Theme.Current.LearningCardTextColor),
                FontAttributes = FontAttributes.Bold,
                Margin         = _titleMargin,
                Style          = AppStyles.GetLabelStyle(bold: true)
            };

            title.SetBinding(Label.TextProperty, "Title");

            Children.Add(new Frame {
                HasShadow         = false,
                Margin            = _framePadding,
                Padding           = _framePadding,
                IsClippedToBounds = true,
                CornerRadius      = _cornerRadius,
                BackgroundColor   = Color.FromHex(Theme.Current.BaseBlockColor),
                Content           = new Grid {
                    Children =
                    {
                        image, title
                    }
                }
            });
        }
Beispiel #30
0
        public SettingsPageViewCell()
        {
            var settingsIcon = new CachedImage {
                HeightRequest   = _settingsIcon,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            settingsIcon.SetBinding(CachedImage.SourceProperty, "Icon",
                                    converter: new StringToImageSourceConverter());

            var settingsTitle = new Label {
                Margin          = _settingsTitleMargin,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                TextColor       = Color.FromHex(Theme.Current.SettingsTitleColor),
                Style           = AppStyles.GetLabelStyle()
            };

            settingsTitle.SetBinding(Label.TextProperty, "Title");

            var forwardIcon = new CachedImage {
                HeightRequest     = _forwardIcon,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Source            = ImageSource.FromFile(Theme.Current.BaseArrowForwardIcon)
            };

            View = new StackLayout {
                Padding         = _padding,
                Orientation     = StackOrientation.Horizontal,
                BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor),
                Children        =
                {
                    settingsIcon,
                    settingsTitle,
                    forwardIcon
                }
            };
        }
		public CropTransformationPage()
		{
			Title = "CropTransformation Demo";
			ViewModel = new CropTransformationViewModel ();
			ViewModel.ImagePath = GetRandomImageUrl ();

			var cachedImage = new CachedImage() {
				WidthRequest = 300f,
				HeightRequest = 300f,
				DownsampleToViewSize = true,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				CacheDuration = TimeSpan.FromDays(30),
				FadeAnimationEnabled = false,
				Source = GetRandomImageUrl()
			};

			cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.TransformationsProperty, v => v.Transformations);
			cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.LoadingPlaceholderProperty, v => v.LoadingImagePath);
			cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.ErrorPlaceholderProperty, v => v.ErrorImagePath);
			cachedImage.SetBinding<CropTransformationViewModel>(CachedImage.SourceProperty, v => v.ImagePath);

			var imagePath = new Label() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				XAlign = TextAlignment.Center,
				FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label))
			};
			imagePath.SetBinding<TransformationExampleViewModel>(Label.TextProperty, v => v.ImagePath);

			var cropAddXButton = new Button() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "X+",
				Command = new Command((o) => ViewModel.AddCurrentXOffsetCommad.Execute (o)),
			};

			var cropSubXButton = new Button() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "X-",
				Command = new Command((o)=> ViewModel.SubCurrentXOffsetCommad.Execute(o)),
			};

			var cropAddYButton = new Button() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "Y+",
				Command = new Command((o)=> ViewModel.AddCurrentYOffsetCommad.Execute(o)),
			};

			var cropSubYButton = new Button() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "Y-",
				Command = new Command((o)=> ViewModel.SubCurrentYOffsetCommad.Execute(o)),
			};

			var cropAddZoomButton = new Button() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "+",
				Command = new Command((o)=> ViewModel.AddCurrentZoomFactorCommad.Execute(o)),
			};

			var cropSubZoomButton = new Button() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				Text = "-",
				Command = new Command((o)=> ViewModel.SubCurrentZoomFactorCommad.Execute(o)),
			};

			var buttonsLayout1 = new StackLayout() {
				Orientation = StackOrientation.Horizontal,
				Children = {
					cropAddXButton, 
					cropSubXButton,
					cropAddYButton,
					cropSubYButton,
				}
			};

			var buttonsLayout2 = new StackLayout() {
				Orientation = StackOrientation.Horizontal,
				Children = {
					cropAddZoomButton,
					cropSubZoomButton
				}
			};

			Content = new ScrollView() {
				Content = new StackLayout { 
					Children = {
						imagePath,
						cachedImage,
						buttonsLayout1,
						buttonsLayout2,
					}
				}
			};
		}