private void init() { var lblDate = new Label(); var lblTemperature = new Label(); var lblHumid = new Label(); var lblWindSpeed = new Label(); var lblClouds = new Label(); var imgWindDir = new Image(); var imgConditionIcon = new Image(); var windDirSOurce = ImageSource.FromResource("QuickWeather.arrow.png"); imgWindDir.Source = windDirSOurce; imgWindDir.SetBinding(Image.RotationProperty, "WindDirection"); var conditionSource = new UriImageSource(); conditionSource.SetBinding(UriImageSource.UriProperty, "WeaherConditionIcon"); lblClouds.SetBinding(Label.TextProperty, "Clouds"); lblDate.SetBinding(Label.TextProperty, "Date"); lblHumid.SetBinding(Label.TextProperty, "Humidity"); lblTemperature.SetBinding(Label.TextProperty, "Temperature"); lblWindSpeed.SetBinding(Label.TextProperty, "WindSpeed"); var head = new StackLayout() { Orientation = StackOrientation.Horizontal }; var mid = new StackLayout() { Orientation = StackOrientation.Horizontal }; var bottom = new StackLayout() { Orientation = StackOrientation.Horizontal }; head.Children.Add(lblDate); head.Children.Add(imgConditionIcon); mid.Children.Add(lblWindSpeed); mid.Children.Add(imgWindDir); bottom.Children.Add(lblTemperature); bottom.Children.Add(lblHumid); this.Children.Add(head); this.Children.Add(mid); this.Children.Add(bottom); }
public ImageModelView() { var imageSource = new UriImageSource { CachingEnabled = true, CacheValidity = TimeSpan.MaxValue }; imageSource.SetBinding(UriImageSource.UriProperty, "Uri"); Content = new Image { Source = imageSource, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Aspect = Aspect.AspectFill }; }
private void init() { var lblDate = new Label(); var lblTemperature = new Label(); var lblHumid = new Label(); var imgIcon = new Image(); var iconSource = new UriImageSource(); iconSource.SetBinding(UriImageSource.UriProperty, "WeaherConditionIcon"); imgIcon.Source = iconSource; lblDate.SetBinding(Label.TextProperty, "Date"); lblHumid.SetBinding(Label.TextProperty, "Humidity"); lblTemperature.SetBinding(Label.TextProperty, "Temperature"); var head = new StackLayout() { Orientation = StackOrientation.Horizontal }; var bottom = new StackLayout() { Orientation = StackOrientation.Horizontal }; lblDate.HorizontalOptions = LayoutOptions.Start; imgIcon.HorizontalOptions = LayoutOptions.End; lblTemperature.HorizontalOptions = LayoutOptions.Center; lblHumid.HorizontalOptions = LayoutOptions.Center; head.Children.Add(lblDate); head.Children.Add(imgIcon); bottom.Children.Add(lblTemperature); bottom.Children.Add(lblHumid); var content = new StackLayout(); content.Children.Add(head); content.Children.Add(bottom); this.View = content; }
public CustomCell() { var image = new Image { HorizontalOptions = LayoutOptions.Start, Aspect = Aspect.AspectFill }; var source = new UriImageSource { CachingEnabled = false, }; source.SetBinding(UriImageSource.UriProperty, new Binding("Image", converter: new UriConverter())); image.Source = source; View = image; }
public CustomViewCellFavPage(Result result) { HeightRequest = 350; Direction = FlexDirection.Column; Margin = 16; AlignContent = FlexAlignContent.Center; Container = new Lazy<StackLayout>(() => new StackLayout() { Margin = 16, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.FillAndExpand }); SubContainer = new Lazy<StackLayout>(() => new StackLayout() { Margin = new Thickness(16, 0, 16, 0), HeightRequest = 280, BackgroundColor = Color.FromHex("#44312D2D"), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }); absoluteLayout = new Lazy<AbsoluteLayout>(() => new AbsoluteLayout() { VerticalOptions = LayoutOptions.FillAndExpand }); var BackdropPathSource = new UriImageSource() { CachingEnabled = true, CacheValidity = TimeSpan.MaxValue }; BackdropPathSource.SetBinding(UriImageSource.UriProperty, new Binding("BackdropPath", BindingMode.Default, new BackgroundImageUrlConverter())); //blurCachedImage = new Lazy<CachedImage>(() => new CachedImage() //{ // HeightRequest = 300, // WidthRequest = 300, // Opacity = 60, // Source = BackdropPathSource, // Transformations = Transformations, // HorizontalOptions = LayoutOptions.FillAndExpand, // Scale = 3, // VerticalOptions = LayoutOptions.FillAndExpand //}); blurCachedImage = new Lazy<Image>(() => new Image() { HeightRequest = 300, WidthRequest = 300, Opacity = 60, Source = BackdropPathSource, Scale = 3 }); var PosterPathSource = new UriImageSource() { CachingEnabled = true, CacheValidity = TimeSpan.MaxValue }; PosterPathSource.SetBinding(UriImageSource.UriProperty, new Binding("PosterPath", BindingMode.Default, new PosterImageUrlConverter())); cachedImage = new Lazy<Image>(() => new Image() { Aspect = Aspect.AspectFill, Source = PosterPathSource }); FrameCover = new Lazy<Frame>(() => new Frame() { IsClippedToBounds = true, Margin = new Thickness(0, 0, 0, 0), HasShadow = true, BorderColor = Color.FromHex("#00000000"), Padding = new Thickness(0, 0, 0, 0), BackgroundColor = Color.FromHex("#00000000"), CornerRadius = 15 }); panelContainer = new Lazy<StackLayout>(() => new StackLayout() { HeightRequest = 125, HorizontalOptions = LayoutOptions.Center, }); FrameUnderImages = new Lazy<Frame>(() => new Frame() { BackgroundColor = Color.FromHex("#44312D2D"), CornerRadius = 5, HasShadow = true, HorizontalOptions = LayoutOptions.Center }); ColumnDefinitionCollection columnDefinitions = new ColumnDefinitionCollection() { new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star)}, new ColumnDefinition() { Width = GridLength.Star}, new ColumnDefinition() { Width = GridLength.Star} }; RowDefinitionCollection rowDefinitions = new RowDefinitionCollection() { new RowDefinition() { Height = GridLength.Star}, new RowDefinition() { Height = GridLength.Star} }; gridInsideFrame = new Lazy<Grid>(() => new Grid() { ColumnDefinitions = columnDefinitions, RowDefinitions = rowDefinitions }); title = new Lazy<Label>(() => new Label() { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), TextColor = Color.White, LineBreakMode = LineBreakMode.TailTruncation, Margin = new Thickness(16, 0, 0, 0), FontFamily = "Arial", FontAttributes = FontAttributes.Bold }); title.Value.SetBinding(Label.TextProperty, "Title"); releaseDate = new Lazy<Label>(() => new Label() { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), TextColor = Color.FromHex("#65FFFFFF"), LineBreakMode = LineBreakMode.NoWrap, Margin = new Thickness(16, 0, 0, 0), FontFamily = "Arial", FontAttributes = FontAttributes.Bold }); releaseDate.Value.SetBinding(Label.TextProperty, "ReleaseDate"); compat = new Lazy<StackLayout>(() => new StackLayout() { HeightRequest = 50 }); unPinFromFavList = new Lazy<Image>(() => new Image() { HeightRequest = 40, WidthRequest = 40 }); unPinFromFavList.Value.SetBinding(Image.SourceProperty, "FavoriteMovie"); FrameCover.Value.Content = cachedImage.Value; compat.Value.Children.Add(unPinFromFavList.Value); gridInsideFrame.Value.Children.Add(title.Value, 0, 0); Grid.SetColumnSpan(title.Value, 3); gridInsideFrame.Value.Children.Add(releaseDate.Value, 0, 1); gridInsideFrame.Value.Children.Add(compat.Value, 2, 1); AbsoluteLayout.SetLayoutBounds(blurCachedImage.Value, new Rectangle(.5, 0, 1, 1)); AbsoluteLayout.SetLayoutFlags(blurCachedImage.Value, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(FrameCover.Value, new Rectangle(.5, 0, 0.46, 1)); AbsoluteLayout.SetLayoutFlags(FrameCover.Value, AbsoluteLayoutFlags.All); FrameUnderImages.Value.Content = gridInsideFrame.Value; absoluteLayout.Value.Children.Add(blurCachedImage.Value); absoluteLayout.Value.Children.Add(FrameCover.Value); CompressedLayout.SetIsHeadless(absoluteLayout.Value, true); panelContainer.Value.Children.Add(FrameUnderImages.Value); SubContainer.Value.Children.Add(absoluteLayout.Value); CompressedLayout.SetIsHeadless(SubContainer.Value, true); Container.Value.Children.Add(SubContainer.Value); Container.Value.Children.Add(panelContainer.Value); Children.Add(Container.Value); tap = new TapGestureRecognizer(); tap.Tapped += QuitFromFavListTap; compat.Value.GestureRecognizers.Add(tap); Result = result; var OnTapNavigationGesture = new TapGestureRecognizer(); OnTapNavigationGesture.Tapped += OnTapNavigationGesture_Tapped; GestureRecognizers.Add(OnTapNavigationGesture); }
public MatchStack(ObservableCollection <TreeProfile> faves) { InitializeComponent(); Title = "Browse"; favorites = faves; CosmosDBService.GetTrees().ContinueWith((task) => { if (!task.IsCompleted) { // Usually would display something to indicate error return; } List <TreeProfile> trees = task.Result; if (trees.Count == 0) { // Display alert return; } Debug.Print(trees.Count.ToString()); CardStackView stack = new CardStackView(); stack.VerticalOptions = LayoutOptions.FillAndExpand; stack.ItemTemplate = new DataTemplate(() => { Frame frame = new Frame(); RelativeLayout layout = new RelativeLayout(); frame.Content = layout; frame.CornerRadius = 15; frame.Padding = 0; ImageSource source = new UriImageSource(); source.SetBinding(UriImageSource.UriProperty, "ProfilePic"); Label nameLabel = new Label() { FontAttributes = FontAttributes.Bold, FontSize = 24, TextColor = Color.White }; nameLabel.SetBinding(Label.TextProperty, "Name"); Label description = new Label() { FontSize = 18, TextColor = Color.GhostWhite }; description.SetBinding(Label.TextProperty, "Description"); Label age = new Label() { FontSize = 24, TextColor = Color.White }; age.SetBinding(Label.TextProperty, "Age", BindingMode.Default, new IntToString()); Image profilePic = new Image() { Aspect = Aspect.AspectFill }; profilePic.Source = source; Image likeStamp = new Image() { Aspect = Aspect.AspectFit }; likeStamp.Source = ImageSource.FromResource("Timbr.like.png"); likeStamp.SetBinding(Image.IsVisibleProperty, "Status"); Image dislikeStamp = new Image() { Aspect = Aspect.AspectFit }; dislikeStamp.Source = ImageSource.FromResource("Timbr.nope.png"); dislikeStamp.SetBinding(Image.IsVisibleProperty, "Status"); layout.Children.Add(profilePic, Constraint.Constant(0), Constraint.Constant(0), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height); }) ); layout.Children.Add(description, Constraint.RelativeToParent((parent) => { return(parent.X + 10); }), Constraint.RelativeToParent((parent) => { return(parent.Y + parent.Height - (parent.Height * 0.15)); }) ); layout.Children.Add(nameLabel, Constraint.RelativeToView(description, (parent, sibling) => { return(sibling.X); }), Constraint.RelativeToView(description, (parent, sibling) => { return(sibling.Y - sibling.Height - 5); }) ); layout.Children.Add(age, Constraint.RelativeToView(nameLabel, (parent, sibling) => { return(sibling.X + sibling.Width + 10); }), Constraint.RelativeToView(nameLabel, (parent, sibling) => { return(sibling.Y); }) ); layout.Children.Add(dislikeStamp, Constraint.RelativeToParent((parent) => { return(parent.Width * 0.6); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.1); }), Constraint.RelativeToParent((parent) => { return(parent.Width * 0.4); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.5); }) ); layout.Children.Add(likeStamp, Constraint.RelativeToParent((parent) => { return(parent.Width * 0.1); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.1); }), Constraint.RelativeToParent((parent) => { return(parent.Width * 0.4); }), Constraint.RelativeToParent((parent) => { return(parent.Height * 0.5); }) ); return(frame); }); stack.ItemsSource = trees; stack.Swiped += processSwipe; stack.StartedDragging += processDragStart; stack.FinishedDragging += processDragEnd; Device.BeginInvokeOnMainThread(() => Content = stack); }); }
public RatingDetailView(CheeseAndRating theRating) { _viewModel = new RatingDetailViewModel(theRating, this); BindingContext = _viewModel; this.SetBinding(ContentPage.TitleProperty, "Title"); AbsoluteLayout cheeseInfoLayout = new AbsoluteLayout { HeightRequest = 250, BackgroundColor = CheeseColors.PURPLE }; var cheeseName = new Label { FontSize = 30, FontFamily = "AvenirNext-DemiBold", TextColor = Color.White }; cheeseName.SetBinding(Label.TextProperty, "CheeseName"); var dairyName = new Label { TextColor = Color.FromHex("#ddd"), FontFamily = "AvenirNextCondensed-Medium" }; dairyName.SetBinding(Label.TextProperty, "DairyName"); UriImageSource uriImgSource = new UriImageSource(); uriImgSource.SetBinding(UriImageSource.UriProperty, "CheesePhotoUri"); _backgroundImage = new Image() { Source = uriImgSource, Aspect = Aspect.AspectFill, }; var overlay = new BoxView() { Color = Color.Black.MultiplyAlpha(.7f) }; var notesLabel = new Label() { FontSize = 14, TextColor = Color.FromHex("#ddd") }; notesLabel.SetBinding(Label.TextProperty, "RatingDescription"); var description = new Frame() { Padding = new Thickness(10, 5), HasShadow = false, BackgroundColor = Color.Transparent, Content = notesLabel }; AbsoluteLayout.SetLayoutFlags(overlay, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(overlay, new Rectangle(0, 1, 1, 0.3)); AbsoluteLayout.SetLayoutFlags(_backgroundImage, AbsoluteLayoutFlags.All); AbsoluteLayout.SetLayoutBounds(_backgroundImage, new Rectangle(0f, 0f, 1f, 1f)); AbsoluteLayout.SetLayoutFlags(cheeseName, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(cheeseName, new Rectangle(0.1, 0.85, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize) ); AbsoluteLayout.SetLayoutFlags(dairyName, AbsoluteLayoutFlags.PositionProportional); AbsoluteLayout.SetLayoutBounds(dairyName, new Rectangle(0.1, 0.95, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize) ); cheeseInfoLayout.Children.Add(_backgroundImage); cheeseInfoLayout.Children.Add(overlay); cheeseInfoLayout.Children.Add(cheeseName); cheeseInfoLayout.Children.Add(dairyName); Content = new StackLayout() { BackgroundColor = Color.FromHex("#333"), Children = { cheeseInfoLayout, description } }; }