Esempio n. 1
0
        public void Init(string uri, string title, string source, string LinkTitle, bool isUrl)
        {
            CornerRadius = 10;
            Opacity      = 30;
            BorderColor  = Color.FromHex("#1B3147");
            Padding      = 0;

            StackLayout stack = new MR.Gestures.StackLayout {
                HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Spacing = 10, Padding = new Thickness(10, 10, 10, 10), BackgroundColor = Color.Accent, VerticalOptions = LayoutOptions.FillAndExpand
            };

            Down   += (s, e) => stack.BackgroundColor = Color.FromHex("#1B3147");
            Up     += (s, e) => stack.BackgroundColor = Color.Accent;
            Tapped += (s, e) => {
                if (LinkTitle.Contains(".apk"))
                {
                    DependencyService.Get <IDownloaderManager>().Download(uri);
                }
                else if (isUrl)
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await DependencyService.Get <IAppHandler>().LaunchApp(uri);
                    });
                }
                else
                {
                    DependencyService.Get <IDownloaderManager>().Download(uri);
                }
            };

            var image = new Image
            {
                Source            = source,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill
            };

            stack.Children.Add(image);
            stack.Children.Add(new Label
            {
                FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                TextColor         = Color.White,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Text = title
            });
            Content = stack;
        }
Esempio n. 2
0
        public SensorCell()
        {
            var image       = new Image();
            var cellWrapper = new MR.Gestures.StackLayout();

            StackLayout horizontalLayout = new StackLayout();

            StackLayout ImageLayout = new StackLayout();

            ImageLayout.HorizontalOptions = LayoutOptions.Start;

            Label left  = new Label();
            Label right = new Label();

            left.TextColor  = Color.FromHex("#37A0AA");
            right.TextColor = Color.FromHex("#C4C4C4");

            left.SetBinding(Label.TextProperty, "Name");
            right.SetBinding(Label.TextProperty, "Description");
            image.SetBinding(Image.SourceProperty, "Type.Image");
            image.WidthRequest = 55;

            cellWrapper.Orientation = StackOrientation.Horizontal;
            cellWrapper.Padding     = 10;

            horizontalLayout.Orientation     = StackOrientation.Vertical;
            horizontalLayout.VerticalOptions = LayoutOptions.EndAndExpand;

            ImageLayout.Children.Add(image);

            horizontalLayout.Children.Add(left);
            horizontalLayout.Children.Add(right);

            cellWrapper.Children.Add(ImageLayout);
            cellWrapper.Children.Add(horizontalLayout);

            cellWrapper.LongPressing += (s, e) =>
            {
                MessagingCenter.Send(IotHandlerPage.TAG, "REMOVE");
            };

            cellWrapper.Tapping += (s, e) =>
            {
                var currentSensor = (Sensor)BindingContext;
                MessagingCenter.Send <String, object>("LALA", "DETAIL", currentSensor);
            };

            View = cellWrapper;
        }