Exemple #1
0
        private async void TapGestureRecognizer_Tapped(object sender, PointEventArgs e)
        {
            if (fingerPrintPage.Children.Contains(imageFingerPrint))
            {
                fingerPrintPage.Children.Remove(imageFingerPrint);
                fingerPrintPage.Children.Remove(reqThumb);
                var ver = DependencyService.Get <IDeviceChecker>().GetDeviceVersion();
                subImage.IsVisible = true;
                var image = new FFImageLoading.Forms.CachedImage();
                image.Source = "fingerprint";
                if (ver == 5)
                {
                    image.HeightRequest = 162;
                    image.WidthRequest  = 315;
                }
                else if (ver == 6)
                {
                    image.HeightRequest = 162;
                    image.WidthRequest  = 372;
                }
                else if (ver == 61)
                {
                    image.HeightRequest = 162;
                    image.WidthRequest  = 413;
                }
                image.Aspect = Aspect.AspectFit;
                fingerPrintPage.Children.Add(image);
                await Task.Delay(6000);

                subImage.IsVisible = false;
                await Task.Run(new Action(() => FadeFingerPrint()));
            }
        }
Exemple #2
0
        private void initUI()
        {
            FFImageLoading.Forms.CachedImage cachedImage = new FFImageLoading.Forms.CachedImage();
            cachedImage.HorizontalOptions = LayoutOptions.Center;
            cachedImage.VerticalOptions   = LayoutOptions.Center;
            cachedImage.WidthRequest      = 300;
            cachedImage.HeightRequest     = 300;
            cachedImage.CacheDuration     = TimeSpan.FromSeconds(1d); // CacheDuration (Timespan `, default: `TimeSpan.FromDays(90))

            //Downsampling properties
            //DownSample always maintain original image aspect ratio.If you set both DownsampleWidth and DownsampleHeight, one of them is ignored.

            //DownsampleWidth (int, default: 0)
            //Resizes image to defined width in pixels(or DIP if DownsampleUseDipUnits property is set to true.If you set this property don’t set DownsampleHeight as aspect ratio will be maintained.

            //DownsampleHeight(int, default: 0)
            //Resizes image to defined height in pixels(or DIP if DownsampleUseDipUnits property is set to true.If you set this property don’t set `DownsampleWidth ` as aspect ratio will be maintained.
            cachedImage.DownsampleToViewSize = true;
            cachedImage.DownsampleWidth      = 100;
            cachedImage.DownsampleHeight     = 100;

            cachedImage.RetryCount         = 0;                                                                  // RetryCount (int, default: 3)
            cachedImage.RetryDelay         = 250;                                                                // RetryDelay (int, default: 250)
            cachedImage.LoadingPlaceholder = ImageSource.FromResource("Client.Images.FFImageLoading.loading.png");
            cachedImage.ErrorPlaceholder   = ImageSource.FromResource("Client.Images.FFImageLoading.error.png"); // 读取失败时没有出现 Error 图片
            // cachedImage.Source = ImageSource.FromUri(new Uri(@"http://cn.bing.com/th?id=OHR.BigWindDay_ZH-CN1837859776_1920x1080.jpg"));
            // cachedImage.Source = ImageSource.FromUri(new Uri(@"http://cn.bing.com/th?id=OHR.BigWindDay_ZH-CN332211_1920x1080.jpg")); // 错误的地址 但没有显示 ErrorPlaceholder
            cachedImage.Source = ImageSource.FromResource("Client.Images.BuBuGao_Japanese.Hiragana.2_i.gif"); // 成功
            // cachedImage.Source = ImageSource.FromResource("Client.Images.FFImageLoading.error.png"); // 成功

            sl1.Children.Add(cachedImage);
        }
Exemple #3
0
        public AudioInfoView()
        {
            Orientation = StackOrientation.Horizontal;
            Padding     = pad;
            FFImageLoading.Forms.CachedImage Cover = new FFImageLoading.Forms.CachedImage();
            Cover.HeightRequest        = 48;
            Cover.WidthRequest         = 48;
            Cover.MinimumHeightRequest = 48;
            Cover.MinimumWidthRequest  = 48;
            NameLabel.SetBinding(Label.TextProperty, "Name");
            AuthorLabel.SetBinding(Label.TextProperty, "Author");
            Children.Add(Cover);
            BindingContextChanged += (i, e) => {
                if (BindingContext == null)
                {
                    return;
                }
                var res = ((IAudio)BindingContext);

                var cv = ((FFImageLoading.Forms.CachedImage) this.Children[0]);
                if (res.Cover == "")
                {
                    cv.Source = defaultCover;
                }
                else
                {
                    cv.Source = ImageSource.FromUri(new Uri(res.Cover));
                }
            };
            Children.Add(new StackLayout {
                Orientation = StackOrientation.Vertical, Children = { NameLabel, AuthorLabel }
            });
        }
        async void ProductListControl_ProductAdded(System.Object sender, System.EventArgs e)
        {
            var button = sideBar.FindByName <Button>("cartButton");
            var image  = new FFImageLoading.Forms.CachedImage {
                Source               = (sender as Product).Photo,
                TranslationY         = button.Y,
                WidthRequest         = 70,
                HeightRequest        = 70,
                TranslationX         = button.X + 100,
                DownsampleToViewSize = true,
                Scale = 0
            };

            mainContainer.Children.Add(image);
            await image.ScaleTo(1, 200, Easing.CubicOut);

            await Task.WhenAll(
                image.TranslateTo(button.X + 10, button.Y, 300, Easing.CubicIn),
                image.ScaleTo(0, 300, Easing.CubicIn),
                button.ScaleTo(1.2, 200, Easing.CubicIn)
                );

            await button.ScaleTo(1, 200, Easing.CubicIn);

            if (AddItemToCartCommand != null)
            {
                if (AddItemToCartCommand.CanExecute(null))
                {
                    AddItemToCartCommand.Execute(null);
                }
            }

            mainContainer.Children.Remove(image);
        }
        private View CreateImage(object item)
        {
            var fileName = item as string;
            var image    = new FFImageLoading.Forms.CachedImage()
            {
                Source            = ImageSource.FromFile(fileName),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill,
            };

            return(image);
        }
        public void AddBackgroundImage()
        {
            var mainGrid = this.FindByName <Grid>("MainGrid");

            if (mainGrid != null)
            {
                var image = new FFImageLoading.Forms.CachedImage()
                {
                    Aspect = Aspect.AspectFill,
                    Source = _backgroundImage
                };
                mainGrid.Children.Add(image);
            }
        }
Exemple #7
0
        void HandleTimer()
        {
            MessagingCenter.Subscribe <TickedListMessages>(this, "TickedListMessages", message => {
                Device.BeginInvokeOnMainThread(() => {
                    timeText.Text = message.Message;
                });
            });

            MessagingCenter.Subscribe <CancelledMessage>(this, "CancelledMessage", message => {
                Device.BeginInvokeOnMainThread(async() => {
                    try{
                        var image               = new FFImageLoading.Forms.CachedImage();
                        image.Source            = "explosion";
                        image.Aspect            = Aspect.Fill;
                        image.HorizontalOptions = LayoutOptions.FillAndExpand;
                        image.VerticalOptions   = LayoutOptions.FillAndExpand;
                        if (Global.GetNum() == 1)
                        {
                            stackExplosion.Children.Add(image);
                            timeText.Text = "0";
                        }
                        else
                        {
                            await Task.Delay(850);
                            stackExplosion.Children.Add(image);
                            timeText.Text = "0";
                        }
                        if (Global.GetNum() == 1)
                        {
                            await Task.Delay(800);
                        }
                        stack.IsVisible  = false;
                        stack2.IsVisible = false;
                        messg.IsVisible  = false;
                        var v            = CrossVibrate.Current;
                        var player       = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                        player.Load("iphone_mp3.mp3");
                        player.Play();
                        v.Vibration();
                        await Task.Delay(2000);
                        player.Stop();
                        await Navigation.PopAsync();
                    }
                    catch (Exception ex) {
                        System.Diagnostics.Debug.WriteLine("Pop Modal " + ex.Message);
                    }
                });
            });
        }
Exemple #8
0
        public LargePhoto(FFImageLoading.Forms.CachedImage img)
        {
            InitializeComponent();
            //int userid = Preferences.Get("UserID", 0);

            //string url = EndPoint.BACKEND_ENDPOINT + "uploads/" + userid.ToString() + ".jpg";
            ////Prueba(url);

            //var webClient = new WebClient();
            //byte[] imageBytes = webClient.DownloadData(url);

            Myfoto.Source = img.Source;

            //Myfoto.Source = EndPoint.BACKEND_ENDPOINT + "uploads/" + userid.ToString() + ".jpg";
        }
Exemple #9
0
        private void Image_PropertyChanging(object sender, PropertyChangingEventArgs e)
        {
            FFImageLoading.Forms.CachedImage image = ((FFImageLoading.Forms.CachedImage)sender);

            if (play_btts.Where(t => t.Id == image.Id).Count() == 0)
            {
                play_btts.Add(image);
                image.Source = image.Source = App.GetImageSource("nexflixPlayBtt.png");//ImageSource.FromResource("CloudStreamForms.Resource.playBtt.png", Assembly.GetExecutingAssembly());
                if (Device.RuntimePlatform == Device.Android)
                {
                    image.Scale = 0.5f;
                }
                else
                {
                    image.Scale = 0.3f;
                }
            }
        }
Exemple #10
0
        public static View CreateMediaItemForImage(byte[] imagesource, string path, string date, double width = 90, double height = 90)
        {
            //images.Add(new ImageHelper() { ImageSource = imagesource, Path = path, Date = date });

            var viewcell = new CustomStackLayout()
                           //var viewcell = new CustomFrame()
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(5, 5),
                BackgroundColor   = Color.Transparent,
                IsPicture         = true,
                CustomData        = path
            };

            FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.Transparent,
                Source            = ImageSource.FromStream(() => new System.IO.MemoryStream(imagesource)),
                WidthRequest      = width,
                HeightRequest     = height,
            };

            viewcell.LongClick += Viewcell_LongClick;
            //viewcell.Content = img;
            //img.Transformations.Add(new FFImageLoading.Transformations.CircleTransformation());

            viewcell.Children.Add(img);

            TapGestureRecognizer gesture = new TapGestureRecognizer();

            gesture.Tapped += (object sender, EventArgs e) =>
            {
                var platform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();
                platform.ShowPicture(path);
            };

            viewcell.GestureRecognizers.Add(gesture);

            return(viewcell);
        }
Exemple #11
0
        private void DoAppStartup()
        {
            //The purpose of this loading section is to improve image load time on the home page
            //Getting the images into memory can take some time, and if other things start
            //Running first, such as the database or HTTP requests, this can get started very late
            //Causing an unpleasent first experience.
            var sl = new StackLayout();

            MainPage = new ContentPage()
            {
                Content         = sl,
                BackgroundColor = Color.Black
            };
            sl.Children.Add(new ActivityIndicator
            {
                IsRunning = true,
                Color     = Color.White,
                Margin    = new Thickness(0, 30, 0, 0)
            });

            if (App.Current.Properties.ContainsKey("PreloadImages") &&
                !string.IsNullOrWhiteSpace(App.Current.Properties["PreloadImages"].ToString()))
            {
                foreach (var imageSource in App.Current.Properties["PreloadImages"].ToString().Split(","))
                {
                    sl.Children.Add(new FFImageLoading.Forms.CachedImage {
                        Source = imageSource, Opacity = 0
                    });
                }
            }

            var finalImage = new FFImageLoading.Forms.CachedImage {
                Opacity = 0
            };

            finalImage.Finish += Startup_Finish;
            finalImage.Source  = "pixel.png";
            sl.Children.Add(finalImage);
        }
Exemple #12
0
        public AdditionalCell()
        {
            image       = new Image();
            CachedImage = new FFImageLoading.Forms.CachedImage();
            CachedImage.VerticalOptions   = LayoutOptions.FillAndExpand;
            CachedImage.HorizontalOptions = LayoutOptions.FillAndExpand;
            CachedImage.Aspect            = Aspect.Fill;
            CachedImage.HeightRequest     = ImageHeight;


            frame = new PancakeView(); // MaterialFrame();

            //frame.Elevation = 20;
            frame.HorizontalOptions = LayoutOptions.FillAndExpand;
            frame.VerticalOptions   = LayoutOptions.Start;
            // frame.BackgroundColor =  Color.White;
            frame.IsClippedToBounds = true;
            frame.Margin            = new Thickness(10, 0, 10, 10);
            frame.Padding           = new Thickness(0);
            frame.CornerRadius      = 40;

            //frame.BackgroundColor = Color.Red;

            //Frame cell = new Frame();
            //cell.Padding = new Thickness(0);
            //cell.HorizontalOptions = LayoutOptions.FillAndExpand;
            //cell.VerticalOptions = LayoutOptions.Start;
            //cell.BackgroundColor = Color.White;
            //cell.IsClippedToBounds = true;
            //cell.CornerRadius = 40;
            //cell.Content = image;
            //cell.Children.Add(image);

            frame.Content = CachedImage;// image;

            View = frame;
        }
Exemple #13
0
        private DataTemplate CreateTemplateForRow(CColumn[] columns, ListView listQuery, string language)
        {
            DataTemplate template = new DataTemplate(() =>
            {
                var layout = new StackLayout()
                {
                    Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.StartAndExpand
                };
                var headerlayout = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
                };

                Label lblHeader = new Label();

                lblHeader.VerticalOptions   = LayoutOptions.FillAndExpand;
                lblHeader.HorizontalOptions = LayoutOptions.FillAndExpand;
                lblHeader.SetBinding(Label.TextProperty, "Items[ " + pickerIndex + "].Text");
                lblHeader.FontAttributes = FontAttributes.Bold;

                FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage();
                Binding binding   = new Binding("Items[ " + pickerIndex + "].Picture");
                binding.Converter = converter;
                img.SetBinding(FFImageLoading.Forms.CachedImage.SourceProperty, binding);

                img.HeightRequest = 20;
                img.WidthRequest  = 20;

                // document download

                /*
                 *
                 * AFButton btdoc = new AFButton();
                 * Binding bindinguid = new Binding("Items[ " + pickerIndex + "].UID");
                 * bindinguid.Converter = docconverter;
                 * btdoc.SetBinding(AFButton.IsVisibleProperty, bindinguid);
                 * btdoc.Text = "\uf019";
                 * btdoc.HorizontalOptions = LayoutOptions.EndAndExpand;
                 * btdoc.BackgroundColor = Color.Transparent;
                 * btdoc.BorderColor = Color.Transparent;
                 * btdoc.Clicked += (object sender, EventArgs e) =>
                 * {
                 *              AFButton af = (AFButton)sender;
                 *               Services.ComosDocumentHandler.DownloadDocument(m_ProjectData, "");
                 * };
                 *
                 */

                // incident creation

                /*
                 * AFButton btdev = new AFButton();
                 * Binding bindinguiddev = new Binding("Items[ " + pickerIndex + "].UID");
                 * bindinguiddev.Converter = devconverter;
                 * btdev.SetBinding(AFButton.IsVisibleProperty, bindinguiddev);
                 * btdev.Text = "\uf071";
                 * btdev.HorizontalOptions = LayoutOptions.EndAndExpand;
                 * btdev.BackgroundColor = Color.Transparent;
                 * btdev.BorderColor = Color.Transparent;
                 * btdev.Clicked += async (object sender, EventArgs e) =>
                 * {
                 *              AFButton af = (AFButton)sender;
                 *              CRow cell = (CRow)af.BindingContext;
                 *              string uid = cell.Items[pickerIndex].UID;
                 *              string pic = cell.Items[pickerIndex].Picture;
                 *              string ownername = cell.Items[pickerIndex].Text;
                 *
                 *              var db = Services.XServices.Instance.GetService<Services.XDatabase>();
                 *              ComosWebSDK.UI.UICachedScreen screen = db.GetCachedScreen(comos.Constants.IncidentCDevUID);
                 *              await this.Navigation.PushAsync(new PageNewDevice(screen, uid, pic, ownername));
                 *
                 * };
                 */

                var contentlayout = new StackLayout()
                {
                    Orientation = StackOrientation.Vertical,
                    IsVisible   = false,
                };

                contentlayout.FadeTo(0, 300, Easing.Linear);

                int colid = 0;

                foreach (CColumn column in columns)
                {
                    AFButton bt          = new AFButton();
                    Label lbl            = new Label();
                    Label lblvalue       = new Label();
                    StackLayout stackRow = new StackLayout {
                        Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 5
                    };

                    lbl.VerticalOptions   = LayoutOptions.Center;
                    lbl.HorizontalOptions = LayoutOptions.Start;
                    lbl.FontAttributes    = FontAttributes.Bold;
                    lbl.Text = column.DisplayDescription;

                    FFImageLoading.Forms.CachedImage imginterior = new FFImageLoading.Forms.CachedImage();
                    Binding bindinginterior   = new Binding("Items[ " + colid.ToString() + "].Picture");
                    bindinginterior.Converter = converter;
                    imginterior.SetBinding(FFImageLoading.Forms.CachedImage.SourceProperty, bindinginterior);
                    imginterior.HeightRequest = 15;
                    imginterior.WidthRequest  = 15;

                    lblvalue.VerticalOptions   = LayoutOptions.Center;
                    lblvalue.HorizontalOptions = LayoutOptions.End;
                    lblvalue.SetBinding(Label.TextProperty, "Items[ " + colid.ToString() + "].Text");

                    colid = colid + 1;

                    bt.Text = "\uf054";
                    bt.HorizontalOptions = LayoutOptions.EndAndExpand;
                    bt.BackgroundColor   = Color.Transparent;
                    bt.BorderColor       = Color.Transparent;
                    bt.StyleId           = colid.ToString();

                    //stackRow.Children.Add(imginterior);
                    stackRow.Children.Add(lbl);
                    stackRow.Children.Add(lblvalue);
                    //stackRow.Children.Add(bt);

                    // store index to click

                    contentlayout.Children.Add(stackRow);

                    #region "Old arrow for each column stuff"
                    //stackRow.StyleId = colid.ToString();
                    //TapGestureRecognizer tap = new TapGestureRecognizer();
                    //tap.Tapped += async (object sender, EventArgs e) =>
                    //{
                    //    AFButton item = (AFButton)sender;
                    //    CRow qcell = (CRow)item.BindingContext;

                    //    //CSystemObject sysobj = await m_ComosWeb.GetObject(m_Layer, qcell.Items[int.Parse(item.StyleId)].UID, language);
                    //    //aways the first object to avoid arrows at all lines?
                    //    CSystemObject sysobj = await m_ComosWeb.GetObject(m_Layer, qcell.Items[0].UID, language);
                    //    CObject o = new CObject()
                    //    {
                    //        ClassType = sysobj.SystemType,
                    //        Description = sysobj.Description,
                    //        IsClientPicture = sysobj.IsClientPicture,
                    //        Name = sysobj.Name,
                    //        UID = sysobj.UID,
                    //        OverlayUID = m_ProjectData.SelectedLayer.UID,
                    //        Picture = sysobj.Picture,
                    //        ProjectUID = m_ProjectData.SelectedProject.ProjectUID,
                    //        SystemFullName = sysobj.Name,
                    //    };

                    //    PageSpecifications page = new PageSpecifications(m_Navigator, o, language);
                    //    await this.Navigation.PushAsync(page);

                    //};

                    //contentlayout.GestureRecognizers.Add(tap);

                    //stackRow.GestureRecognizers.Add(tap);
                    //bt.GestureRecognizers.Add(tap);

                    #endregion
                }


                TapGestureRecognizer tap = new TapGestureRecognizer();

                tap.Tapped += async(object sender, EventArgs e) =>
                {
                    if (OnCellTaped == null)
                    {
                        StackLayout item = (StackLayout)sender;
                        CRow qcell       = (CRow)item.BindingContext;
                        //aways the first object to avoid arrows at all lines?
                        CSystemObject sysobj;
                        try
                        {
                            sysobj = await m_ComosWeb.GetObject(m_Layer, qcell.Items[0].UID, language);
                        }
                        catch (Exception ex)
                        {
                            await App.Current.MainPage.DisplayAlert("Error", "Error al cargar objetos de Comos Web: " + ex.Message, Services.TranslateExtension.TranslateText("OK"));
                            return;
                        }

                        if (sysobj == null)
                        {
                            return;
                        }

                        CObject o = new CObject()
                        {
                            ClassType       = sysobj.SystemType,
                            Description     = sysobj.Description,
                            IsClientPicture = sysobj.IsClientPicture,
                            Name            = sysobj.Name,
                            UID             = sysobj.UID,
                            OverlayUID      = m_ProjectData.SelectedLayer.UID,
                            Picture         = sysobj.Picture,
                            ProjectUID      = m_ProjectData.SelectedProject.ProjectUID,
                            SystemFullName  = sysobj.Name,
                        };
                        PageSpecifications page = new PageSpecifications(m_Navigator, o, language);
                        await this.Navigation.PushAsync(page);
                    }
                    else
                    {
                        CellTaped(sender, e);
                    }
                };

                contentlayout.GestureRecognizers.Add(tap);

                headerlayout.Children.Add(img);
                headerlayout.Children.Add(lblHeader);
                //headerlayout.Children.Add(btdoc);
                //headerlayout.Children.Add(btdev);


                layout.Children.Add(headerlayout);
                layout.Children.Add(contentlayout);

                TapGestureRecognizer headertap = new TapGestureRecognizer();
                headertap.Tapped += async(object sender, EventArgs e) =>
                {
                    if (expandable)
                    {
                        contentlayout.IsVisible = !contentlayout.IsVisible;
                        if (contentlayout.IsVisible)
                        {
                            contentlayout.FadeTo(1, 750, Easing.Linear);
                        }
                        else
                        {
                            await contentlayout.FadeTo(0, 300, Easing.Linear);
                        }
                        OnPropertyChanged("IsVisible");
                    }
                };

                Frame frm = new Frame()
                {
                    OutlineColor    = (Color)Application.Current.Resources["ComosColorNavBarButton"],
                    HasShadow       = true,
                    BackgroundColor = (Color)Application.Current.Resources["ComosColorModuleCard"],
                    Margin          = new Thickness(0, 0, 0, 5)
                };

                frm.Content = layout;
                frm.GestureRecognizers.Add(headertap);

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

            return(template);
        }
        public EventCellView()
        {
            var layoutIntero = new Grid
            {
                HeightRequest   = 300,
                BackgroundColor = Color.Transparent,
                RowDefinitions  = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = new GridLength(0.70, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(0.30, GridUnitType.Star)
                    }
                },
                RowSpacing = 0,
                Padding    = new Thickness(5),
            };
            var grigliaTesto = new Grid
            {
                BackgroundColor = Color.White,
                RowDefinitions  = new RowDefinitionCollection {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition {
                        Width = 50
                    },
                    new ColumnDefinition {
                        Width = GridLength.Star
                    }
                },
                Padding = new Thickness(5, 0, 5, 0)
            };
            var title = new Label
            {
                TextColor               = Color.Black,
                FontSize                = DefaultTema.FontMedium,
                FontAttributes          = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Start,
                HorizontalOptions       = LayoutOptions.Start,
            };

            title.SetBinding(Label.TextProperty, nameof(EventCellVM.Title));

            var data = new Label {
                TextColor = Color.White, FontSize = DefaultTema.FontSmall
            };

            data.SetBinding(Label.TextProperty, nameof(EventCellVM.DataInizio));

            var luogoLabel = new Label {
                TextColor = Color.White
            };

            luogoLabel.SetBinding(Label.TextProperty, nameof(EventCellVM.Luogo));

            var prezzoLabel = new Label {
                TextColor = Color.White
            };

            prezzoLabel.SetBinding(Label.TextProperty, nameof(EventCellVM.Prezzo));

            var startLabel = new Label {
            };

            startLabel.SetBinding(Label.FormattedTextProperty, nameof(EventCellVM.DataFormatted));

#if __DROID__
            var img = new FFImageLoading.Forms.CachedImage()
            {
                Aspect             = Aspect.AspectFill,
                LoadingPriority    = FFImageLoading.Work.LoadingPriority.Low,
                CacheDuration      = TimeSpan.FromDays(360),
                ErrorPlaceholder   = Globals.DefaultThumb,
                LoadingPlaceholder = Globals.DefaultThumb,
            };
            img.SetBinding(SpeedImage.SourceProperty, nameof(EventCellVM.Copertina));
#else
            var img = new Image()
            {
                Aspect = Aspect.AspectFill,
            };
            img.SetBinding(Image.SourceProperty, nameof(EventCellVM.Copertina));
                        #endif

            //var img = new Image() { Aspect = Aspect.AspectFill,};
            //img.Bind(nameof(EventCellVM.Copertina));

            var layoutDataLuogo = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 5,
                Children    = { new Label {
                                    Text = "@", TextColor = Color.Pink
                                }, luogoLabel, data }
            };
            var boxView = new BoxView {
                Color = Color.Black, Opacity = 0.5
            };                                                                            //prima era 0.8

            grigliaTesto.AddChild(startLabel, 0, 0, 2, 1);
            grigliaTesto.AddChild(title, 0, 1, 1, 1);

            layoutIntero.AddChild(img, 0, 0, 1, 1);
            layoutIntero.AddChild(grigliaTesto, 1, 0, 1, 1);

            layoutIntero.Margin = new Thickness(5);

            View = layoutIntero;
        }
Exemple #15
0
        void UpdateBookmarks()
        {
            try {
                int height = 150;
                Bookmarks.HeightRequest = height;
                string[]      keys = App.GetKeys <string>(App.BOOKMARK_DATA);
                List <string> data = new List <string>();
                bookmarkPosters = new List <BookmarkPoster>();
                Bookmarks.Children.Clear();
                updateLabels.Clear();
                IsBookmarked.Clear();

                int  index   = 0;
                bool allDone = false;
                for (int i = 0; i < keys.Length; i++)
                {
                    string __key = keys[i];
                    if (__key == "")
                    {
                        continue;
                    }
                    string name      = FindHTML(__key, "Name=", "|||");
                    string posterUrl = FindHTML(__key, "PosterUrl=", "|||");
                    posterUrl = ConvertIMDbImagesToHD(posterUrl, 182, 268);

                    string id = FindHTML(__key, "Id=", "|||");
                    if (name != "" && posterUrl != "" && id != "")
                    {
                        if (CheckIfURLIsValid(posterUrl))
                        {
                            IsBookmarked.Add(id, true);
                            string posterURL = ConvertIMDbImagesToHD(posterUrl, 76, 113, 1.75);
                            if (CheckIfURLIsValid(posterURL))
                            {
                                Grid stackLayout = new Grid()
                                {
                                    VerticalOptions = LayoutOptions.Start,
                                };

                                stackLayout.Effects.Add(Effect.Resolve("CloudStreamForms.LongPressedEffect"));
                                var _b = new BookmarkPoster()
                                {
                                    id = id, name = name, posterUrl = posterUrl
                                };
                                bookmarkPosters.Add(_b);

                                LongPressedEffect.SetCommand(stackLayout, new Command(() => {
                                    PushPageFromUrlAndName(_b.id, _b.name);
                                }));
                                var ff = new FFImageLoading.Forms.CachedImage {
                                    Source           = posterURL,
                                    HeightRequest    = RecPosterHeight,
                                    WidthRequest     = RecPosterWith,
                                    BackgroundColor  = Color.Transparent,
                                    VerticalOptions  = LayoutOptions.Start,
                                    InputTransparent = true,
                                    Transformations  =
                                    {
                                        //  new FFImageLoading.Transformations.RoundedTransformation(10,1,1.5,10,"#303F9F")
                                        new FFImageLoading.Transformations.RoundedTransformation(10, 1, 1.5, 0, "#303F9F")
                                    },
                                    //	InputTransparent = true,
                                };

                                // ================================================================ RECOMMENDATIONS CLICKED ================================================================
                                //stackLayout.SetValue(XamEffects.BorderView.CornerRadiusProperty, 20);

                                /*
                                 * var brView = new BorderView() { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, CornerRadius = 5 };
                                 *
                                 * brView.SetValue(XamEffects.TouchEffect.ColorProperty, Color.White);
                                 * Commands.SetTap(brView, new Command((o) => {
                                 *      var z = (BookmarkPoster)o;
                                 *      PushPageFromUrlAndName(z.id, z.name);
                                 * }));
                                 * Commands.SetTapParameter(brView, _b);*/


                                // var _color = Settings.BlackColor + 5;

                                Frame boxView = new Frame()
                                {
                                    BackgroundColor = Settings.ItemBackGroundColor,                                    // Color.FromRgb(_color, _color, _color),
                                    //	InputTransparent = true,
                                    CornerRadius  = 5,
                                    HeightRequest = RecPosterHeight + bookmarkLabelTransY,
                                    TranslationY  = 0,
                                    WidthRequest  = RecPosterWith,
                                    HasShadow     = true,
                                };

                                stackLayout.Children.Add(boxView);
                                stackLayout.Children.Add(ff);
                                //stackLayout.Children.Add(imageButton);
                                stackLayout.Children.Add(new Label()
                                {
                                    Text = name, VerticalOptions = LayoutOptions.Start, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.Center, Padding = 1, TextColor = Color.White, MaxLines = 2, ClassId = "OUTLINE", TranslationY = RecPosterHeight
                                });
                                //stackLayout.Children.Add(brView);



                                if (Settings.ShowNextEpisodeReleaseDate)
                                {
                                    CloudStreamCore.NextAiringEpisodeData?nextData = App.GetKey <NextAiringEpisodeData?>(App.NEXT_AIRING, id, null);
                                    if (nextData.HasValue)
                                    {
                                        var    nextAir = nextData.Value;
                                        string nextTxt = GetAirDate(nextAir.airingAt);

                                        var btt = new Button()
                                        {
                                            //BackgroundColor = new Color(0.188, 0.247, 0.623, 0.8)
                                            BackgroundColor   = new Color(0, 0, 0, 0.4),
                                            Text              = nextTxt,
                                            ClassId           = "CUST",
                                            TextColor         = Color.White,
                                            InputTransparent  = true,
                                            HeightRequest     = 20,
                                            FontSize          = 11,
                                            VerticalOptions   = LayoutOptions.Start,
                                            HorizontalOptions = LayoutOptions.End,
                                            CornerRadius      = 1,
                                            Padding           = 2,
                                            Margin            = 0,
                                            Scale             = 1,
                                            TranslationX      = 1,
                                            WidthRequest      = 60
                                        };
                                        updateLabels.Add(new UpdateLabel()
                                        {
                                            label = btt, id = id
                                        });
                                        stackLayout.Children.Add(btt);
                                    }
                                }

                                stackLayout.Opacity = 0;

                                async void WaitUntillComplete()
                                {
                                    stackLayout.Opacity = 0;
                                    while (!allDone)
                                    {
                                        await Task.Delay(50);
                                    }
                                    await stackLayout.FadeTo(1, (uint)(200 + index * 50), Easing.Linear);
                                }

                                WaitUntillComplete();

                                index++;
                                //slay.Children.Add(stackLayout);
                                Bookmarks.Children.Add(stackLayout);

                                /*
                                 * Grid stackLayout = new Grid();
                                 *
                                 *
                                 * var ff = new FFImageLoading.Forms.CachedImage {
                                 * Source = posterUrl,
                                 * HeightRequest = height,
                                 * WidthRequest = 87,
                                 * BackgroundColor = Color.Transparent,
                                 * VerticalOptions = LayoutOptions.Start,
                                 * Transformations = {
                                 * new FFImageLoading.Transformations.RoundedTransformation(1,1,1.5,0,"#303F9F")
                                 * },
                                 * InputTransparent = true,
                                 * };
                                 *
                                 * //Source = p.posterUrl
                                 *
                                 * stackLayout.Children.Add(ff);
                                 * // stackLayout.Children.Add(imageButton);
                                 * bookmarkPosters.Add(new BookmarkPoster() { id = id, name = name, posterUrl = posterUrl });
                                 * Grid.SetColumn(stackLayout, Bookmarks.Children.Count);
                                 * Bookmarks.Children.Add(stackLayout);
                                 *
                                 * // --- RECOMMENDATIONS CLICKED -----
                                 * stackLayout.SetValue(XamEffects.TouchEffect.ColorProperty, Color.White);
                                 * Commands.SetTap(stackLayout, new Command((o) => {
                                 * int z = (int)o;
                                 * PushPageFromUrlAndName(bookmarkPosters[z].id, bookmarkPosters[z].name);
                                 * }));
                                 * Commands.SetTapParameter(stackLayout, i);*/
                            }
                        }
                        // data.Add(App.GetKey("BookmarkData"))
                    }
                    //await Task.Delay(100);

                    //MScroll.HeightRequest = keys.Count > 0 ? 130 : 0;
                }
                allDone      = true;
                hasBookmarks = bookmarkPosters.Count > 0;

                UpdateNoBookmarks();

                /*if (ImdbTypePicker.SelectedIndex == -1) {
                 * ImdbTypePicker.SelectedIndex = bookmarkPosters.Count > 0 ? 0 : 2; // SET TO POPULAR BY DEAFULT
                 * }*/
                SetRecs();
            }
            catch (Exception _ex) {
                error(_ex);
            }
            ChangeSizeOfTabs();
        }
Exemple #16
0
        void UpdateNextEpisode()
        {
            var  epis   = App.GetKeys <CloudStreamCore.CachedCoreEpisode>(nameof(CloudStreamCore.CachedCoreEpisode)).OrderBy(t => - t.createdAt.Ticks).ToArray();
            bool hasTxt = epis.Length > 0;

            UpdateHasNext(hasTxt);

            NextEpisode.Children.Clear();
            var pSource = App.GetImageSource("nexflixPlayBtt.png");

            for (int i = 0; i < Math.Min(epis.Length, 5); i++)
            {
                var  ep    = epis[i];
                Grid stack = new Grid()
                {
                };

                var ff = new FFImageLoading.Forms.CachedImage {
                    Source           = ep.poster,
                    HeightRequest    = FastPosterHeight,
                    WidthRequest     = FastPosterWith,
                    BackgroundColor  = Color.Transparent,
                    VerticalOptions  = LayoutOptions.Start,
                    InputTransparent = true,
                    Transformations  =
                    {
                        //  new FFImageLoading.Transformations.RoundedTransformation(10,1,1.5,10,"#303F9F")
                        new FFImageLoading.Transformations.RoundedTransformation(10, 1.78, 1, 0, "#303F9F")
                    },
                    //	InputTransparent = true,
                };

                const double textAddSpace = 20;
                Frame        boxView      = new Frame()
                {
                    BackgroundColor = Settings.ItemBackGroundColor,                    // Color.FromRgb(_color, _color, _color),
                    //	InputTransparent = true,
                    CornerRadius  = 5,
                    HeightRequest = FastPosterHeight + textAddSpace,
                    TranslationY  = 0,
                    WidthRequest  = FastPosterWith,
                    HasShadow     = true,
                };

                const double playSize = 30;
                var          playBtt  = new FFImageLoading.Forms.CachedImage {
                    Source            = pSource,
                    HeightRequest     = playSize,
                    WidthRequest      = playSize,
                    TranslationY      = -textAddSpace / 2,
                    BackgroundColor   = Color.Transparent,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    InputTransparent  = true,
                };

                ProgressBar progress = new ProgressBar()
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    ProgressColor     = Color.FromHex("#829eff"),
                    VerticalOptions   = LayoutOptions.End,
                    BackgroundColor   = Color.Transparent,
                    Progress          = ep.progress,
                    WidthRequest      = FastPosterWith,
                    TranslationY      = -(4 + textAddSpace / 2),
                };

                /*
                 * var brView = new BorderView() { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, CornerRadius = 5 };
                 *
                 * brView.SetValue(XamEffects.TouchEffect.ColorProperty, Color.White);
                 * Commands.SetTap(brView, new Command((o) => {
                 *      //PushPageFromUrlAndName(z.id, z.name);
                 * }));*/
                stack.Children.Add(boxView);
                stack.Children.Add(ff);
                stack.Children.Add(playBtt);
                stack.Children.Add(progress);
                bool isMovie = ep.season <= 0 || ep.episode <= 0;
                stack.Children.Add(new Label()
                {
                    Text = (isMovie ? "" : $"S{ep.season}:E{ep.episode} ") + $"{ep.episodeName}", VerticalOptions = LayoutOptions.Start, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.Center, Padding = 1, TextColor = Color.White, MaxLines = 1, ClassId = "OUTLINE", TranslationY = FastPosterHeight, WidthRequest = FastPosterWith
                });

                stack.Effects.Add(Effect.Resolve("CloudStreamForms.LongPressedEffect"));

                LongPressedEffect.SetCommand(stack, new Command(async() => {
                    var res = new MovieResult(ep.state);
                    await Navigation.PushModalAsync(res, false);
                    await res.LoadLinksForEpisode(new EpisodeResult()
                    {
                        Episode = ep.episode, Season = ep.season, Id = ep.episode - 1, Description = ep.description, IMDBEpisodeId = ep.imdbId, OgTitle = ep.episodeName
                    });
                }));

                NextEpisode.Children.Add(stack, i, 0);
            }
        }
Exemple #17
0
        void UpdateBookmarks()
        {
            try {
                int height = 150;
                Bookmarks.HeightRequest = height;
                List <string> keys = App.GetKeys <string>(App.BOOKMARK_DATA);
                List <string> data = new List <string>();
                bookmarkPosters = new List <BookmarkPoster>();
                Bookmarks.Children.Clear();
                int  index   = 0;
                bool allDone = false;
                for (int i = 0; i < keys.Count; i++)
                {
                    string __key = App.ConvertToObject <string>(keys[i], "");
                    if (__key == "")
                    {
                        continue;
                    }
                    string name      = FindHTML(__key, "Name=", "|||");
                    string posterUrl = FindHTML(__key, "PosterUrl=", "|||");
                    posterUrl = ConvertIMDbImagesToHD(posterUrl, 182, 268);

                    string id = FindHTML(__key, "Id=", "|||");
                    if (name != "" && posterUrl != "" && id != "")
                    {
                        if (CheckIfURLIsValid(posterUrl))
                        {
                            string posterURL = ConvertIMDbImagesToHD(posterUrl, 76, 113, 1.75); //.Replace(",76,113_AL", "," + pwidth + "," + pheight + "_AL").Replace("UY113", "UY" + pheight).Replace("UX76", "UX" + pwidth);
                            if (CheckIfURLIsValid(posterURL))
                            {
                                Grid stackLayout = new Grid()
                                {
                                    VerticalOptions = LayoutOptions.Start
                                };
                                Button imageButton = new Button()
                                {
                                    HeightRequest = RecPosterHeight, WidthRequest = RecPosterWith, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start
                                };
                                var ff = new FFImageLoading.Forms.CachedImage {
                                    Source          = posterURL,
                                    HeightRequest   = RecPosterHeight,
                                    WidthRequest    = RecPosterWith,
                                    BackgroundColor = Color.Transparent,
                                    VerticalOptions = LayoutOptions.Start,
                                    Transformations =
                                    {
                                        //  new FFImageLoading.Transformations.RoundedTransformation(10,1,1.5,10,"#303F9F")
                                        new FFImageLoading.Transformations.RoundedTransformation(10, 1, 1.5, 0, "#303F9F")
                                    },
                                    InputTransparent = true,
                                };

                                // ================================================================ RECOMMENDATIONS CLICKED ================================================================
                                // stackLayout.SetValue(XamEffects.BorderView.CornerRadiusProperty, 20);

                                var brView = new BorderView()
                                {
                                    VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, CornerRadius = 5
                                };

                                brView.SetValue(XamEffects.TouchEffect.ColorProperty, Color.White);
                                Commands.SetTap(brView, new Command((o) => {
                                    var z = (BookmarkPoster)o;
                                    PushPageFromUrlAndName(z.id, z.name);
                                }));
                                var _b = new BookmarkPoster()
                                {
                                    id = id, name = name, posterUrl = posterUrl
                                };
                                Commands.SetTapParameter(brView, _b);


                                bookmarkPosters.Add(_b);

                                // var _color = Settings.BlackColor + 5;

                                BoxView boxView = new BoxView()
                                {
                                    BackgroundColor  = Settings.ItemBackGroundColor,// Color.FromRgb(_color, _color, _color),
                                    InputTransparent = true,
                                    CornerRadius     = 10,
                                    HeightRequest    = RecPosterHeight + bookmarkLabelTransY,
                                    TranslationY     = 0,
                                    WidthRequest     = RecPosterWith,
                                };
                                stackLayout.Children.Add(boxView);
                                stackLayout.Children.Add(ff);
                                stackLayout.Children.Add(imageButton);
                                stackLayout.Children.Add(new Label()
                                {
                                    Text = name, VerticalOptions = LayoutOptions.Start, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.Center, Padding = 1, TextColor = Color.White, MaxLines = 2, ClassId = "OUTLINE", TranslationY = RecPosterHeight
                                });
                                stackLayout.Children.Add(brView);
                                stackLayout.Opacity = 0;

                                async void WaitUntillComplete()
                                {
                                    stackLayout.Opacity = 0;
                                    while (!allDone)
                                    {
                                        await Task.Delay(50);
                                    }
                                    await stackLayout.FadeTo(1, (uint)(200 + index * 50), Easing.Linear);
                                }

                                WaitUntillComplete();

                                index++;
                                Bookmarks.Children.Add(stackLayout);

                                /*
                                 * Grid stackLayout = new Grid();
                                 *
                                 *
                                 * var ff = new FFImageLoading.Forms.CachedImage {
                                 *  Source = posterUrl,
                                 *  HeightRequest = height,
                                 *  WidthRequest = 87,
                                 *  BackgroundColor = Color.Transparent,
                                 *  VerticalOptions = LayoutOptions.Start,
                                 *  Transformations = {
                                 *  new FFImageLoading.Transformations.RoundedTransformation(1,1,1.5,0,"#303F9F")
                                 * },
                                 *  InputTransparent = true,
                                 * };
                                 *
                                 * //Source = p.posterUrl
                                 *
                                 * stackLayout.Children.Add(ff);
                                 * // stackLayout.Children.Add(imageButton);
                                 * bookmarkPosters.Add(new BookmarkPoster() { id = id, name = name, posterUrl = posterUrl });
                                 * Grid.SetColumn(stackLayout, Bookmarks.Children.Count);
                                 * Bookmarks.Children.Add(stackLayout);
                                 *
                                 * // --- RECOMMENDATIONS CLICKED -----
                                 * stackLayout.SetValue(XamEffects.TouchEffect.ColorProperty, Color.White);
                                 * Commands.SetTap(stackLayout, new Command((o) => {
                                 *  int z = (int)o;
                                 *  PushPageFromUrlAndName(bookmarkPosters[z].id, bookmarkPosters[z].name);
                                 * }));
                                 * Commands.SetTapParameter(stackLayout, i);*/
                            }
                        }
                        // data.Add(App.GetKey("BookmarkData"))
                    }
                    //await Task.Delay(100);

                    //MScroll.HeightRequest = keys.Count > 0 ? 130 : 0;
                }
                allDone      = true;
                hasBookmarks = bookmarkPosters.Count > 0;

                UpdateNoBookmarks();

                /*if (ImdbTypePicker.SelectedIndex == -1) {
                 *  ImdbTypePicker.SelectedIndex = bookmarkPosters.Count > 0 ? 0 : 2; // SET TO POPULAR BY DEAFULT
                 * }*/
                SetRecs();
            }
            catch (Exception _ex) {
                error(_ex);
            }
            ChangeSizeOfTabs();
        }
Exemple #18
0
        void UpdateBookmarks()
        {
            int height = 150;

            Bookmarks.HeightRequest = height;
            List <string> keys = App.GetKeys <string>("BookmarkData");
            List <string> data = new List <string>();

            bookmarkPosters = new List <BookmarkPoster>();
            Bookmarks.Children.Clear();
            for (int i = 0; i < keys.Count; i++)
            {
                string __key = App.ConvertToObject <string>(keys[i], "");
                if (__key == "")
                {
                    continue;
                }
                string name = FindHTML(__key, "Name=", "|||");
                print("BOOKMARK:" + name);
                string posterUrl = FindHTML(__key, "PosterUrl=", "|||");
                posterUrl = ConvertIMDbImagesToHD(posterUrl, 182, 268);
                print("POSTERURL:::" + posterUrl);

                string id = FindHTML(__key, "Id=", "|||");
                if (name != "" && posterUrl != "" && id != "")
                {
                    if (CheckIfURLIsValid(posterUrl))
                    {
                        Grid stackLayout = new Grid();


                        //  Button imageButton = new Button() { HeightRequest = 150, WidthRequest = 90, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start };
                        var ff = new FFImageLoading.Forms.CachedImage {
                            Source          = posterUrl,
                            HeightRequest   = height,
                            WidthRequest    = 90,
                            BackgroundColor = Color.Transparent,
                            VerticalOptions = LayoutOptions.Start,
                            Transformations =
                            {
                                new FFImageLoading.Transformations.RoundedTransformation(1, 1, 1.5, 0, "#303F9F")
                            },
                            InputTransparent = true,
                        };

                        //Source = p.posterUrl

                        stackLayout.Children.Add(ff);
                        // stackLayout.Children.Add(imageButton);
                        bookmarkPosters.Add(new BookmarkPoster()
                        {
                            id = id, name = name, posterUrl = posterUrl
                        });
                        Grid.SetColumn(stackLayout, Bookmarks.Children.Count);
                        Bookmarks.Children.Add(stackLayout);

                        // --- RECOMMENDATIONS CLICKED -----
                        stackLayout.SetValue(XamEffects.TouchEffect.ColorProperty, Color.White);
                        Commands.SetTap(stackLayout, new Command((o) => {
                            int z = (int)o;
                            PushPageFromUrlAndName(bookmarkPosters[z].id, bookmarkPosters[z].name);
                            //do something
                        }));
                        Commands.SetTapParameter(stackLayout, i);

                        /*
                         * imageButton.Clicked += (o, _e) => {
                         *  for (int z = 0; z < bookmarkPosters.Count; z++) {
                         *      if (((Button)o).Id == bookmarkPosters[z].button.Id) {
                         *          PushPageFromUrlAndName(bookmarkPosters[z].id, bookmarkPosters[z].name);
                         *      }
                         *  }
                         * };*/
                    }
                }
                // data.Add(App.GetKey("BookmarkData"))
            }

            MScroll.HeightRequest = keys.Count > 0 ? 130 : 0;
            if (ImdbTypePicker.SelectedIndex == -1)
            {
                ImdbTypePicker.SelectedIndex = bookmarkPosters.Count > 0 ? 0 : 1;
            }
        }
Exemple #19
0
        public LoginSuccessPage()
        {
            NavigationPage.SetHasBackButton(this, false);
            InitializeComponent();
            var b = new Dictionary <string, string>();

            b.Add("access_token", "2080856236.1677ed0.a9a19f6272c645fa9212a8b1654326d6");
            Application.Current.Properties["Account"] = new Account("*****@*****.**", b);
            this.Content = layout;

            var jsonResponse = "";

            // Shows an example how you get information of the current user
            Task getUserSelf = new Task(() =>
            {
                jsonResponse           = InstagramAPI.GetUserSelf().Result;
                InstagramUser userSelf = InstagramUser.CreateFromJsonResponse(jsonResponse);
                Debug.WriteLine("UserSelf JSON response: " + jsonResponse);

                var id = new Label {
                    Text = "Id: " + userSelf.Data.Id, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(id);

                var username = new Label {
                    Text = "Username: "******"Bio: " + userSelf.Data.Bio, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(bio);

                var website = new Label {
                    Text = "Website: " + userSelf.Data.Website, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(website);

                var amountOfPics = new Label {
                    Text = "Amount of pics: " + userSelf.Data.Counts.Media, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(amountOfPics);

                var amountOfFollows = new Label {
                    Text = "Amount of follows: " + userSelf.Data.Counts.Follows, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(amountOfFollows);

                var amountOfFollower = new Label {
                    Text = "Amount of follower: " + userSelf.Data.Counts.Followed_by, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(amountOfFollower);

                var meta = new Label {
                    Text = "Meta: " + userSelf.Meta.Code, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(meta);
            });

            getUserSelf.Start();
            getUserSelf.Wait();

            /*
             * // Shows an example how you get information of the an other user
             * Task getUserOther = new Task(() =>
             * {
             *  jsonResponse = InstagramAPI.GetUserOther("2142923999").Result;
             *  InstagramUser userOther = InstagramUser.CreateFromJsonResponse(jsonResponse);
             *  Debug.WriteLine("UserOther username: "******"AllMediaSelf filter: " + mediaSelf.Data[0].Filter);

                var image = new FFImageLoading.Forms.CachedImage()
                {
                    CacheDuration = new TimeSpan(0, 0, 7, 0), BackgroundColor = Color.Yellow
                };
                image.Source = new UriImageSource()
                {
                    Uri = new Uri(mediaSelf.Data[0].Images.Standard_resolution.Url), CachingEnabled = false
                };                                                                                                                               //ImageSource.FromUri(new Uri("https://s1.logaster.com/static/v3/img/products/logo.png"));
                layout.Children.Add(image);

                var meta = new Label {
                    Text = "likes: " + mediaSelf.Data[0].Likes.Count, TextColor = Color.FromHex(fontColor), FontSize = fontSize
                };
                layout.Children.Add(meta);
            });

            getAllMediaSelf.Start();
            getAllMediaSelf.Wait();

            /*
             * // Shows an example how you get all the recent media of an other user
             * Task getAllMediaOther = new Task(() =>
             * {
             *  jsonResponse = InstagramAPI.GetUserMediaOther("2142923999").Result;
             *  InstagramMediaList mediaOther = InstagramMediaList.CreateFromJsonResponse(jsonResponse);
             *  Debug.WriteLine("AllMediaOther likes: " + mediaOther.Data[0].Likes.Count);
             * });
             * getAllMediaOther.Start();
             * getAllMediaOther.Wait();
             *
             * // Shows an example how you get more information of a media
             * Task getSingleMediaInfo = new Task(() =>
             * {
             *  jsonResponse = InstagramAPI.GetMediaInfo("1065424377547227936_2142923999").Result;
             *  InstagramMediaSingle mediaSingle = InstagramMediaSingle.CreateFromJsonResponse(jsonResponse);
             *  Debug.WriteLine("SingleMediaInfo id: " + mediaSingle.Data.Id);
             * });
             * getSingleMediaInfo.Start();
             * getSingleMediaInfo.Wait();
             *
             * // Shows an example how you set a like on a media
             * Task addLike = new Task(() =>
             * {
             *  jsonResponse = InstagramAPI.SetLike("1065424377547227936_2142923999").Result;
             *  InstagramLike media = InstagramLike.CreateFromJsonResponse(jsonResponse);
             *  Debug.WriteLine("AddLike response code: " + media.Meta.Code);
             * });
             * addLike.Start();
             * addLike.Wait();
             *
             * // Shows an example how you get all likes on a media
             * Task getLikes = new Task(() =>
             * {
             *  jsonResponse = InstagramAPI.GetLikes("1065424377547227936_2142923999").Result;
             *  InstagramLike media = InstagramLike.CreateFromJsonResponse(jsonResponse);
             *  Debug.WriteLine("GetLikes username: "******"1065991007700419021_2142923999").Result;
             *  InstagramLike media = InstagramLike.CreateFromJsonResponse(jsonResponse);
             *  Debug.WriteLine("RemoveLike response code: " + media.Meta.Code);
             * });
             * removeLike.Start();
             * removeLike.Wait();
             */
        }
Exemple #20
0
        public View UpdateAttributesUI(ComosWebSDK.UI.UIQuery ui)
        {
            int rowIndex    = 0;
            int columnIndex = 0;

            if (ui.Result == null || ui.Result.Rows == null || ui.Result.Rows.Length == 0)
            {
                return(null);
            }

            var table = new Grid();

            foreach (var column in ui.Result.Columns)
            {
                table.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Auto)
                });
            }

            foreach (var row in ui.Result.Rows)
            {
                table.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });
            }

            if (ui.Result.Columns.Length > 1)
            {
                table.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Auto)
                });

                foreach (var column in ui.Result.Columns)
                {
                    UIGrid.AddChild(table, new Label()
                    {
                        Text = column.DisplayDescription,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        FontAttributes    = FontAttributes.Bold,
                    }, rowIndex, columnIndex);
                    columnIndex++;
                }

                rowIndex++;
                columnIndex = 0;
            }

            foreach (var row in ui.Result.Rows)
            {
                if (row.Items[0].Text != "")
                {
                    var viewcell = new StackLayout()
                    {
                        Orientation       = StackOrientation.Horizontal,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.Fill,
                        //Padding = new Thickness(10, 5),
                        //BackgroundColor = (Color)Application.Current.Resources["ComosColorModuleCard"],
                    };
                    viewcell.SetDynamicResource(StackLayout.StyleProperty, "ComosQueryResult");

                    FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage()
                    {
                        HeightRequest = 20,
                        WidthRequest  = 20,
                        Source        = converter.GetAsUrl("?keyid=" + row.Items[0].Picture),
                    };

                    Label lbl = new Label()
                    {
                        Text = row.Items[0].Text,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.FillAndExpand,
                    };

                    viewcell.Children.Add(img);
                    viewcell.Children.Add(lbl);
                    viewcell.BindingContext = row;
                    TapGestureRecognizer gesture = new TapGestureRecognizer();
                    gesture.Tapped += ViewCell_DocumentTapped;
                    viewcell.GestureRecognizers.Add(gesture);

                    UIGrid.AddChild(table, viewcell, rowIndex, columnIndex);
                    columnIndex++;

                    for (int i = 1; i < row.Items.Length; i++)
                    {
                        UIGrid.AddChild(table, new Label()
                        {
                            Text = row.Items[i].Text,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions   = LayoutOptions.FillAndExpand,
                        }, rowIndex, columnIndex);
                        columnIndex++;
                    }
                }

                rowIndex++;
                columnIndex = 0;
            }

            table.SetDynamicResource(StackLayout.StyleProperty, "ComosQueryResult");
            table.ColumnSpacing   = 20;
            table.BackgroundColor = (Color)Application.Current.Resources["ComosColorNavBarText"];

            ScrollView scroll = new ScrollView
            {
                Orientation = ScrollOrientation.Horizontal,
            };

            scroll.BackgroundColor = (Color)Application.Current.Resources["ComosColorNavBarText"];
            scroll.Content         = table;

            /*var table = new StackLayout() {
             *              HorizontalOptions =LayoutOptions.Fill,
             *              VerticalOptions =LayoutOptions.StartAndExpand,
             *              BackgroundColor = (Color)Application.Current.Resources["ComosColorNavBar"],
             *              Spacing = 1,
             * };
             *
             * if (ui.Result == null || ui.Result.Rows == null || ui.Result.Rows.Length == 0)
             *              return null;
             *
             * foreach (var row in ui.Result.Rows)
             * {
             *              if (row.Items[0].Text != "")
             *              {
             *                              var viewcell = new StackLayout()
             *                              {
             *                                              Orientation = StackOrientation.Horizontal,
             *                                              VerticalOptions = LayoutOptions.FillAndExpand,
             *                                              HorizontalOptions = LayoutOptions.Fill,
             *                                              Padding = new Thickness(10,5),
             *                                              //BackgroundColor = (Color)Application.Current.Resources["ComosColorModuleCard"],
             *                              };
             *                              viewcell.SetDynamicResource(StackLayout.StyleProperty, "ComosQueryResult");
             *
             *                              FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage()
             *                              {
             *                                              HeightRequest = 20,
             *                                              WidthRequest = 20,
             *                                              Source = converter.GetAsUrl("?keyid=" + row.Items[0].Picture),
             *                              };
             *                              viewcell.Children.Add(img);
             *
             *                              for(int i=0; i < row.Items.Length;i++)
             *                              {
             *                                              viewcell.Children.Add(new Label()
             *                                              {
             *                                                              Text = row.Items[i].Text,
             *                                                              HorizontalOptions = LayoutOptions.FillAndExpand,
             *                                                              VerticalOptions = LayoutOptions.FillAndExpand,
             *                                              });
             *                              }
             *
             *                              viewcell.BindingContext = row;
             *                              TapGestureRecognizer gesture = new TapGestureRecognizer();
             *                              gesture.Tapped += ViewCell_DocumentTapped;
             *                              viewcell.GestureRecognizers.Add(gesture);
             *
             *                              table.Children.Add(viewcell);
             *              }
             * }*/
            //table.SizeChanged += Table_SizeChanged;
            return(scroll);
        }
        void HtmlToView(string html)
        {
            var result = new List <StringSection>();

            if (html is string val)
            {
                // Remove tags que não estão tratadas
                val = Regex.Replace(val, "<span([^>]*)>", string.Empty);
                val = Regex.Replace(val, "<p([^>]*)>", string.Empty);
                val = Regex.Replace(val, "<div([^>]*)>", string.Empty);

                val = Regex.Replace(val, "<ul([^>]*)>", string.Empty);
                val = val.Replace("</ul>", string.Empty);

                val = Regex.Replace(val, "&nbsp;", " ");
                val = val.Replace("</b>", string.Empty);
                val = val.Replace("</span>", string.Empty);
                val = val.Replace("</p>", Environment.NewLine);
                val = val.Replace("</div>", Environment.NewLine);
                val = val.Replace("<br>", Environment.NewLine);
                val = val.Replace("<br />", Environment.NewLine);
                val = val.Replace("<br/>", Environment.NewLine);
                val = Regex.Replace(val, "<b([^>]*)>", string.Empty);

                if (val?.Length > 0 && val.Substring(val.Length - 1) == Environment.NewLine)
                {
                    val = val.Remove(val.Length - 1);
                }

                //Processa os Links do Html
                var sections    = ProcessString(val);
                var resultImage = new List <StringSection>();

                foreach (var item in sections)
                {
                    var sectionsDetail = ProcessImage(item.Text, item.Link);
                    if (sectionsDetail.Count > 0)
                    {
                        foreach (var sectionItem in sectionsDetail)
                        {
                            resultImage.Add(sectionItem);
                        }
                    }
                    else
                    {
                        resultImage.Add(item);
                    }
                }

                //Processa as Tags <H1> a <H6>
                foreach (var item in resultImage)
                {
                    var sectionsDetail = ProcessH(item.Text, item.Link);
                    if (sectionsDetail.Count > 0)
                    {
                        foreach (var sectionItem in sectionsDetail)
                        {
                            result.Add(sectionItem);
                        }
                    }
                    else
                    {
                        result.Add(item);
                    }
                }

                //Monta a formatação
                foreach (var item in result)
                {
                    item.Sections = FormatTextSection(item);
                }
            }

            // Cria o StackLayout para armazenar os Labels e imagens
            StackLayout stackLayout = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                Margin            = new Thickness(0, 0),
                Padding           = new Thickness(0, 0),
                Spacing           = 0,
                Orientation       = StackOrientation.Vertical
            };

            Label label     = NewLabel();
            var   formatted = new FormattedString();

            foreach (var item in result)
            {
                //Ajusta tags que não foram tratadas
                item.Image = FindUrlImage(item.Image);

                if (!string.IsNullOrEmpty(item.Image))
                {
                    //Inclui o Label no StackLayout
                    if (formatted != new FormattedString())
                    {
                        label.FormattedText = formatted;
                        stackLayout.Children.Add(label);
                        label     = NewLabel();
                        formatted = new FormattedString();
                    }

                    // Cria o Grid para a Imagem
                    Grid grid = new Grid
                    {
                        RowDefinitions =
                        {
                            new RowDefinition {
                                Height = 100
                            }
                        },
                        ColumnDefinitions =
                        {
                            new ColumnDefinition()
                            {
                                Width = 130
                            }
                        },
                        Margin        = new Thickness(0),
                        Padding       = new Thickness(0),
                        ColumnSpacing = 0,
                        RowSpacing    = 0
                    };

                    var tapGestureRecognizer = new TapGestureRecognizer();
                    tapGestureRecognizer.Tapped += async(s, e) => {
                        Debug.Print("ABRIR VISUALIZAÇÃO");
                        //await Application.Current.MainPage.AbrirModal(new ViewImagePage(item.Image), false);
                    };

                    //Cria a Imagem
                    var ffImage = new FFImageLoading.Forms.CachedImage()
                    {
                        Source            = item.Image,
                        VerticalOptions   = LayoutOptions.Fill,
                        HorizontalOptions = LayoutOptions.Fill,
                        Margin            = new Thickness(0),
                        Aspect            = Aspect.AspectFill,
                    };
                    ffImage.GestureRecognizers.Add(tapGestureRecognizer);

                    //Incluir a Imagem no Grid e o Grid no StackLayout
                    grid.Children.Add(ffImage);
                    stackLayout.Children.Add(grid);
                }
                else
                {
                    foreach (var sectionSpan in item.Sections)
                    {
                        sectionSpan.Text = RemoveTags(sectionSpan.Text);
                        if (!string.IsNullOrEmpty(sectionSpan.Text))
                        {
                            formatted.Spans.Add(CreateSpan(sectionSpan));
                        }
                    }
                }
            }

            if (formatted != new FormattedString())
            {
                label.FormattedText = formatted;
                stackLayout.Children.Add(label);
            }

            Content = stackLayout;
        }
Exemple #22
0
        void UpdateBookmarks()
        {
            double multi  = 1.2;
            int    height = 100;
            int    width  = 65;

            if (Device.RuntimePlatform == Device.UWP)
            {
                height = 130;
                width  = 85;
            }

            height = (int)Math.Round(height * multi);
            width  = (int)Math.Round(width * multi);

            Bookmarks.HeightRequest = height;
            List <string> keys = App.GetKeys <string>("BookmarkData");
            List <string> data = new List <string>();

            bookmarkPosters = new List <BookmarkPoster>();
            Bookmarks.Children.Clear();
            for (int i = 0; i < keys.Count; i++)
            {
                string __key = App.ConvertToObject <string>(keys[i], "");
                if (__key == "")
                {
                    continue;
                }
                string name = FindHTML(__key, "Name=", "|||");
                print("BOOKMARK:" + name);
                string posterUrl = FindHTML(__key, "PosterUrl=", "|||");
                string id        = FindHTML(__key, "Id=", "|||");
                if (name != "" && posterUrl != "" && id != "")
                {
                    if (CheckIfURLIsValid(posterUrl))
                    {
                        Grid   stackLayout = new Grid();
                        Button imageButton = new Button()
                        {
                            HeightRequest = height, WidthRequest = width, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start
                        };
                        var ff = new FFImageLoading.Forms.CachedImage {
                            Source          = posterUrl,
                            HeightRequest   = height,
                            WidthRequest    = width,
                            BackgroundColor = Color.Transparent,
                            VerticalOptions = LayoutOptions.Start,
                            Transformations =
                            {
                                new FFImageLoading.Transformations.RoundedTransformation(10, 1, 1.5, 10, "#303F9F")
                            },
                            InputTransparent = true,
                        };

                        //Source = p.posterUrl

                        stackLayout.Children.Add(ff);
                        stackLayout.Children.Add(imageButton);
                        bookmarkPosters.Add(new BookmarkPoster()
                        {
                            button = imageButton, id = id, name = name, posterUrl = posterUrl
                        });
                        Grid.SetColumn(stackLayout, Bookmarks.Children.Count);
                        Bookmarks.Children.Add(stackLayout);

                        // --- RECOMMENDATIONS CLICKED -----
                        imageButton.Clicked += (o, _e) => {
                            for (int z = 0; z < bookmarkPosters.Count; z++)
                            {
                                if (((Button)o).Id == bookmarkPosters[z].button.Id)
                                {
                                    PushPageFromUrlAndName(bookmarkPosters[z].id, bookmarkPosters[z].name);
                                }
                            }
                        };
                    }
                }
                // data.Add(App.GetKey("BookmarkData"))
            }

            MScroll.HeightRequest = keys.Count > 0 ? 130 : 0;
        }