Ejemplo n.º 1
0
        public AnswerDetailPage(int questionId)
        {
            _theAnswer  = new AnswerInfo();
            _questionId = questionId;

            Title = "Possible Answer";

            HtmlWebViewSource webSource = new HtmlWebViewSource();

            webSource.BindingContext = _theAnswer;
            webSource.SetBinding(HtmlWebViewSource.HtmlProperty, new Binding("AnswerBody"));

            _theFullAnswer = new WebView {
                Source          = webSource,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    _theFullAnswer
                }
            };
        }
Ejemplo n.º 2
0
        public void TestBindingContextPropagatesToSource()
        {
            var htmlWebView = new WebView {
            };
            var urlWebView  = new WebView {
            };

            var htmlSource = new HtmlWebViewSource();

            htmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTML");
            htmlWebView.Source = htmlSource;

            var urlSource = new UrlWebViewSource();

            urlSource.SetBinding(UrlWebViewSource.UrlProperty, "URL");
            urlWebView.Source = urlSource;

            var viewModel = new ViewModel();

            var container = new StackLayout {
                BindingContext = viewModel,
                Padding        = new Size(20, 20),
                Children       =
                {
                    htmlWebView,
                    urlWebView
                }
            };

            Assert.AreEqual("<html><body><p>This is a WebView!</p></body></html>", htmlSource.Html);
            Assert.AreEqual("http://xamarin.com", urlSource.Url);
        }
Ejemplo n.º 3
0
        public WebViewGallery()
        {
            var htmlWebView = new WebView {
                HeightRequest = 40,
                //Source = new HtmlWebViewSource {Html ="<html><body><p>This is a WebView!</p></body></html>"}
            };
            var urlWebView = new WebView {
                VerticalOptions = LayoutOptions.FillAndExpand,
                //Source = new UrlWebViewSource {Url = "http://xamarin.com/"}
            };

            var htmlSource = new HtmlWebViewSource();

            htmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTML");
            htmlWebView.Source = htmlSource;

            var urlSource = new UrlWebViewSource();

            urlSource.SetBinding(UrlWebViewSource.UrlProperty, "URL");
            urlWebView.Source = urlSource;

            var viewModel = new ViewModel();

            BindingContext = viewModel;

            Content = new StackLayout {
                Padding  = new Size(20, 20),
                Children =
                {
                    htmlWebView,
                    urlWebView
                }
            };
        }
Ejemplo n.º 4
0
        protected async override void OnAppearing()
        {
            try
            {
                //await Task.Run(() =>
                //{
                MC.GetDetail();
                Title = MC.MovieDet.Title;

                GridMovie.BindingContext    = MC.MovieDet;
                HorListActor.ItemsSource    = MC.MovieDet.Actors;
                HorListDirector.ItemsSource = MC.MovieDet.Directors;

                //Add trailer video
                if (MC.MovieDet.Trailer != "")
                {
                    HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();
                    personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
                    //style='background-color: #343e42;'
                    personHtmlSource.Html = string.Format(@"<html><body style='margin:0 0 0 0'><iframe allowtransparency='true' style.backgroundColor ='transparent' type='text/html' width=320 height=180 src='{0}' frameborder= 0 allowfullscreen/></body></html>", MC.MovieDet.Trailer);
                    Trailer.Source        = personHtmlSource;
                }
                else
                {
                    Trailer.IsVisible = false;
                }
                //});
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 5
0
        public Presentacion()
        {
            InitializeComponent();
            string            presentacion     = "Hola a todos, mi nombre es Pablo y os presento mi proyecto para el Trabajo Final de Grado, una aplicación móvil programada en Xamarin Forms llamada KAPTA.";
            string            presentacion2    = "A continuación os presento un vídeo de presentación de mi compañero Jose María, estudiante de CAFD el cual me ha proporcionado los datos necesarios para poder llevar a cabo el proyecto.";
            HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();

            personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
            personHtmlSource.Html = @"<html><body > <b> Kapta </b> te permitirá guardar tus lesiones de un modo sencillo. Para ello simplemente tienes que rellenar el formulario que te aparece en en la pestaña de entrenamiento personalizado y listo. <br/></br> También encontrarás ejercicios útiles para tus lesiones y la prevención de aquellas que puedan surgir debido a la practica deportiva. 
            <div style=' position: relative; padding-bottom: 56.25%; padding-top: 25px;'>   <iframe style='position: absolute; top: 30; left: 0; width: 100%; height: 115%;'  src='https://www.youtube.com/embed/sAoRwesqUCU' frameborder='0' allowfullscreen></iframe></div><br>.<br> </body></html>";
            var browser = new WebView();

            browser.Source = personHtmlSource;
            Content        = browser;

            /*  var label = new Label
             *  {
             *
             *      Text = "Registra tus lesiones de un modo sencillo, simplemente tienes que rellenar " +
             *      "el formulario que te aparece en en la pestaña de entrenamiento personalizado y listo. " +
             *      "también encontrarás ejercicios útiles para tus lesiones " +
             *      "y la prevención de aquellas que puedan surgir debido a la practica deportiva.\n"
             *
             * };*/
            /*  Content = new StackLayout
             * {
             *
             * Padding = 30,
             *    Spacing = 10,
             *    Children = {label}
             *
             * };*/
        }
Ejemplo n.º 6
0
        public QuestionDetailPage(int questionId)
        {
            _theAnswer = new AnswerInfo();

            Title = "Possible Answer";

            Label loadedFromLabel = new Label {
                MinimumHeightRequest = 50,
                XAlign = TextAlignment.Center
            };

            HtmlWebViewSource webSource = new HtmlWebViewSource();

            webSource.BindingContext = _theAnswer;
            webSource.SetBinding(HtmlWebViewSource.HtmlProperty, new Binding("AnswerBody"));

            _theFullAnswer = new WebView {
                Source          = webSource,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    _theFullAnswer
                }
            };

            Task.Run(async() => {
                await LoadAnswer(questionId);
            });
        }
        private async void LoadData()
        {
            htmlSource = new HtmlWebViewSource();



            var listview = new List <ChartsF.Pages.ListViewPage.Objetos>()
            {
                new ChartsF.Pages.ListViewPage.Objetos("YHOO", "-10 %", "R$ 10,00", "1"),
                new ChartsF.Pages.ListViewPage.Objetos("FB", "-10 %", "R$ 10,00", "2"),
                new ChartsF.Pages.ListViewPage.Objetos("BAC", "-10 %", "R$ 10,00", "3"),
                new ChartsF.Pages.ListViewPage.Objetos("INTC", "-10 %", "R$ 10,00", "3"),
                new ChartsF.Pages.ListViewPage.Objetos("AAPL", "-10 %", "R$ 10,00", "3"),
            };

            htmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HtmlContent.PageContent");


            stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(8)
            };

            var activity = new ActivityIndicator
            {
                Color     = Color.Blue,
                IsEnabled = true
            };

            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

            stack.Children.Add(activity);

            var listViewItem = new ListView();

            listViewItem.ItemsSource = listview;



            var titleList = new Label
            {
                HorizontalOptions = LayoutOptions.Fill,
                Text = "Itens"
            };

            listViewItem.ItemTemplate = new DataTemplate(typeof(LayoutCotacaoCell));
            //Define item selecionado

            stack.Children.Add(titleList);


            GenerateGraphics(GetItem1(), listViewPage);
        }
Ejemplo n.º 8
0
        public DetailsPage(string groupIdApiUrl)
        {
            var isRetrievingDataActivityIndicator = new ActivityIndicator();

            isRetrievingDataActivityIndicator.SetBinding(IsEnabledProperty, nameof(ViewModel.IsRetrievingData));
            isRetrievingDataActivityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsRetrievingData));

            var getChartButton = new Button
            {
                Text             = "Get Chart",
                CommandParameter = groupIdApiUrl
            };

            getChartButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsRetrievingData));
            getChartButton.SetBinding(IsVisibleProperty, nameof(ViewModel.IsGetChartButtonVisible));
            getChartButton.SetBinding(Button.CommandProperty, nameof(ViewModel.GetChartButtonCommand));

            var iframeSource = new HtmlWebViewSource();

            iframeSource.SetBinding(HtmlWebViewSource.HtmlProperty, nameof(ViewModel.IFrameHtml));

            var embededDashboardWebView = new WebView
            {
                Source = iframeSource
            };

            var relativeLayout = new RelativeLayout();

            Func <RelativeLayout, double> getDetailsButtonWidth  = (p) => getChartButton.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getDetailsButtonHeight = (p) => getChartButton.Measure(p.Width, p.Height).Request.Height;

            Func <RelativeLayout, double> getIsRetrievingDataActivityIndicatorWidth  = (p) => isRetrievingDataActivityIndicator.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getIsRetrievingDataActivityIndicatorHeight = (p) => isRetrievingDataActivityIndicator.Measure(p.Width, p.Height).Request.Height;

            relativeLayout.Children.Add(embededDashboardWebView,
                                        Constraint.Constant(0),
                                        Constraint.Constant(0),
                                        Constraint.RelativeToParent(parent => parent.Width),
                                        Constraint.RelativeToParent(parent => parent.Height)
                                        );

            relativeLayout.Children.Add(getChartButton,
                                        Constraint.RelativeToParent(parent => parent.Width / 2 - getDetailsButtonWidth(parent) / 2),
                                        Constraint.Constant(0)
                                        );

            relativeLayout.Children.Add(isRetrievingDataActivityIndicator,
                                        Constraint.RelativeToParent(parent => parent.Width / 2 - getIsRetrievingDataActivityIndicatorWidth(parent) / 2),
                                        Constraint.RelativeToParent(parent => parent.Height / 2 - getIsRetrievingDataActivityIndicatorHeight(parent) / 2)
                                        );

            Content = relativeLayout;
        }
        CustomWebView createNewsBody()
        {
            var source = new HtmlWebViewSource();

            source.SetBinding(HtmlWebViewSource.HtmlProperty, "NewsBody");

            var webView = new CustomWebView {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Source            = source
            };

            webView.SetBinding(CustomWebView.HttpNavigatingCommandProperty, "HttpNavigatingCommand");
            return(webView);
        }
Ejemplo n.º 10
0
        public MPopUpPage(BlogDetailItem blogDetail)
        {
            blogDetailItem  = blogDetail;
            BackgroundColor = Color.FromHex("#80000000");
            Animation       = new ScaleAnimation();
            Label title = new Label {
                Text = blogDetailItem.title, FontSize = 25, TextColor = Color.Blue
            };
            Image mImage = new Image {
                Source = blogDetailItem.image
            };



            //html format
            MyView objMyView = new MyView();

            objMyView.MyHtml = blogDetailItem.content;

            HtmlWebViewSource objHtmlWebViewSource = new HtmlWebViewSource();

            objHtmlWebViewSource.SetBinding(HtmlWebViewSource.HtmlProperty, "MyHtml");
            objHtmlWebViewSource.BindingContext = objMyView;

            WebView objWebview = new WebView();

            objWebview.HorizontalOptions = LayoutOptions.FillAndExpand;
            objWebview.VerticalOptions   = LayoutOptions.FillAndExpand;
            objWebview.Source            = objHtmlWebViewSource;
            //html format



            StackLayout blogstackLayout = new StackLayout {
                BackgroundColor = Color.White
            };

            blogstackLayout.Children.Add(title);
            blogstackLayout.Children.Add(mImage);
            blogstackLayout.Children.Add(objWebview);
            ScrollView scrollView = new ScrollView {
                Orientation = ScrollOrientation.Vertical, HorizontalOptions = LayoutOptions.Center
            };

            scrollView.Content = blogstackLayout;
            Content            = scrollView;
        }
Ejemplo n.º 11
0
        public ItemsPage(URLHttpParams httpParams, ItemType pageType)
        {
            InitializeComponent();

            viewModel = new ItemsViewModel(httpParams)
            {
                PageType   = pageType,
                Navigation = this.Navigation
            };

            BindingContext = viewModel;

            if (pageType == ItemType.Content)
            {
                stackLayout.Children.RemoveAt(0);
                quizButton.IsVisible = true;

                gridView.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                Grid.SetColumnSpan(stackLayout, 3);
                gridView.Children.Add(quizButton, 2, 1);

                WebView webView = new WebView();
                webView.HorizontalOptions = LayoutOptions.FillAndExpand;
                webView.VerticalOptions   = LayoutOptions.FillAndExpand;

                var source = new HtmlWebViewSource();
                source.SetBinding(HtmlWebViewSource.HtmlProperty, "Text");
                webView.Source = source;

                stackLayout.Children.Add(webView);

                MessagingCenter.Subscribe <ItemsViewModel, object>(this, "ContentLoaded", (seder, obj) =>
                {
                    Content info = ((IEnumerable)obj).Cast <Content>().First();
                    if (info.Count > 0)
                    {
                        quizButton.IsEnabled = true;
                    }
                });
            }
        }
Ejemplo n.º 12
0
        public AnimalDetail(Animal anAnimal)
        {
            InitializeComponent();

            Name.Text        = anAnimal.Name;
            Description.Text = anAnimal.Description;

            string youtubeUrl = "https://www.youtube.com/embed/" + anAnimal.VideoId;

            HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();

            personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
            personHtmlSource.Html = $@"<html><body>  <div> <iframe style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'  src='{youtubeUrl}' frameborder='0' allowfullscreen></iframe></div> </body></html>";
            var browser = new WebView();

            browser.Source = personHtmlSource;

            MainElement.Children.Add(browser);
        }
Ejemplo n.º 13
0
        public VerVideo(Video video)
        {
            InitializeComponent();
            //this.Video = video;
            //string video = "https://www.youtube.com/embed/xFnHTQn5iqo";

            string nombre = video.NombreVideo;
            // TitleProperty.PropertyName.Insert(1, "ksks");

            string            linkk            = video.LinkVideo;
            string            descripcion      = video.Description;
            HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();

            personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
            personHtmlSource.Html = @"<html ><body style='background-color : #D4E6F1;' ><center><h2>" + nombre + "</h2></center><div style=' position: relative; padding-bottom: 56.25%; padding-top: 25px;'>   <iframe style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'  src='" + linkk + "' frameborder='0' allowfullscreen></iframe></div><br>" + descripcion + " </body></html>";
            var browser = new WebView();

            browser.Source = personHtmlSource;
            Content        = browser;
        }
Ejemplo n.º 14
0
        protected async override void OnAppearing()
        {
            try
            {
                await TC.GetDetail();

                Title = TC.TvShowDet.Title;

                GridMovie.BindingContext = TC.TvShowDet;

                //Add trailer video
                if (TC.TvShowDet.Trailer != "")
                {
                    HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();
                    personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
                    personHtmlSource.Html = string.Format(@"<html><body style='margin:0 0 0 0'><iframe allowtransparency='true' style.backgroundColor ='transparent' type='text/html' width=320 height=180 src='{0}' frameborder= 0 allowfullscreen/></body></html>", TC.TvShowDet.Trailer);
                    Trailer.Source        = personHtmlSource;
                }
                else
                {
                    Trailer.IsVisible = false;
                }

                await TC.GetCrew();

                HorListActor.ItemsSource    = TC.TvShowDet.Actors;
                HorListDirector.ItemsSource = TC.TvShowDet.Directors;

                await TC.GetWebRating();

                HorListRating.ItemsSource = TC.TvShowDet.Ratings;
                SeasonList.ItemsSource    = TC.TvShowDet.Seasons;

                await TC.UpdateSeasonCounter();
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                throw ex;
            }
        }
Ejemplo n.º 15
0
        public DishView()
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);
            var vm = App.AppSetup.CategoryViewModel;

            //vm.RecipeDishView.Title = "abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz";
            BindingContext = vm;

            if (vm.RecipeDishView.Title.Length <= 25)
            {
                vm.TitleHeight = 40;
            }
            else if (vm.RecipeDishView.Title.Length <= 50)
            {
                vm.TitleHeight = 60;
            }
            else
            {
                vm.TitleHeight = 90;
            }

            var Urls = new System.Collections.ObjectModel.ObservableCollection <string>();

            Urls.Add("" + vm.RecipeDishView.VideoUrl + "");
            videoView.BackgroundColor = Color.Black;
            videoView.ItemsSource     = Urls;

            HtmlWebViewSource personHtmlSource = new HtmlWebViewSource();

            personHtmlSource.SetBinding(HtmlWebViewSource.HtmlProperty, "HTMLDesc");
            personHtmlSource.Html = vm.RecipeDishView.Preparation;

            lst1.HeightRequest = vm.RecipeDishView.Ingredients.Count < 0 ? 50 : (vm.RecipeDishView.Ingredients.Count + 1) * 50;
            prewebView.Source  = personHtmlSource;
        }
Ejemplo n.º 16
0
        public EmailPage(EmailViewModel viewModel)
        {
            viewModel.Navigation = Navigation;
            BindingContext       = viewModel;

            var fromLabel = new Label {
                FontSize = 15
            };

            fromLabel.SetBinding <EmailViewModel> (Label.TextProperty, m => m.Email.MailFrom);

            var from = new StackLayout()
            {
                Children =
                {
                    new Label {
                        Text           = "From: ",
                        FontSize       = 15,
                        FontAttributes = FontAttributes.Bold,
                    },
                    fromLabel
                },
                Orientation = StackOrientation.Horizontal,
                Padding     = new Thickness(10)
            };

            var subjectLabel = new Label {
                FontSize       = 18,
                FontAttributes = FontAttributes.Bold,
            };

            subjectLabel.SetBinding <EmailViewModel> (Label.TextProperty, m => m.Email.MailSubject);

            var dateLabel = new Label {
                BackgroundColor = Color.White,
                FontSize        = 15,
            };

            dateLabel.SetBinding <EmailViewModel> (Label.TextProperty, m => m.Email.MailDate);

            var subject = new StackLayout()
            {
                Children =
                {
                    subjectLabel,
                },
                Padding = new Thickness(10, 0)
            };

            var htmlSource = new HtmlWebViewSource();

            htmlSource.SetBinding <EmailViewModel> (HtmlWebViewSource.HtmlProperty, m => m.Email.MailBody);

            var webView = new CustomWebView()
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Source          = htmlSource
            };

            var body = new StackLayout()
            {
                Children =
                {
                    webView
                },
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding         = new Thickness(10, 0)
            };

            // need to pass the binding onto the html source
            webView.BindingContextChanged += (sender, args) => {
                htmlSource.BindingContext = webView.BindingContext;
            };

            Content = new ScrollView()
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Spacing         = 10,
                    Children        = { from, subject, body }
                }
            };
        }