public PdfPage(BaseInboxMessage request, Document document, bool showSignButton, EventHandler OnAssinar) { this.Document = document; this.SignatureRequest = request; this.Title = "PDF"; if (Device.OS == TargetPlatform.iOS) { this.Icon = (FileImageSource)FileImageSource.FromFile("pdf.png"); } pdfWebView = new CustomWebView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, MinimumHeightRequest = 300, OverviewMode = true }; if (showSignButton) { var relativeLayout = new RelativeLayout(); relativeLayout.Children.Add(pdfWebView, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height - 50); })); Button btnAssinar = new Button() { Text = AppResources.SIGN_DOCUMENT, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; relativeLayout.Children.Add(btnAssinar, Constraint.RelativeToView(pdfWebView, (Parent, sibling) => { return(0); }), Constraint.RelativeToView(pdfWebView, (parent, sibling) => { return(sibling.Height); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.Constant(50)); this.Content = relativeLayout; btnAssinar.Clicked += OnAssinar; } else { this.Content = pdfWebView; } CreateShareToolbarItem(this); }
public Home(string url) { this.Title = "Home"; if (!String.IsNullOrEmpty(url)) { if (this.UsuarioLogado()) this.PopulaEmailUsuario(); this._webView = new CustomWebView { Source = !this.UsuarioLogado() ? url : String.Concat(App.URL_USUARIO_LOGADO, App.EMAIL_USUARIO), HeightRequest = 1000, WidthRequest = 1000 }; this._mainLayout = new StackLayout { Children = { _webView } }; this.Content = _mainLayout; } else DisplayAlert("Aviso", "Erro ao carregar conteúdo", "OK"); }
private void InitializeCommands(CustomWebView element) { element.Refresh = () => { ((UIWebView)NativeView).Reload(); }; //element.GoBackCommand = new Command(() => //{ // var control = ((UIWebView)NativeView); // if (control.CanGoBack) // { // element.IsBackNavigating = true; // control.GoBack(); // } //}); element.CanGoBackFunction = () => { return(((UIWebView)NativeView).CanGoBack); }; var ctl = ((UIWebView)NativeView); ctl.ScalesPageToFit = true; }
private void PrepareCustomWebView() { var childrenFirstViewControl = (Content as StackLayout).Children[0]; if (childrenFirstViewControl is CustomWebView) { _customWebView = childrenFirstViewControl as CustomWebView; } _customWebView.RegisterAction(async(data) => { var isCrossMediaInitalized = await CrossMedia.Current.Initialize(); MediaFile mediaFile = isCrossMediaInitalized ? await TakePictureAsync() : null; //Please insert handling code for your media file... //Start // // //End if (mediaFile != null) { Device.BeginInvokeOnMainThread(() => { _customWebView.EvalJavaScript($"javascript: logSuccess();"); var writeMessageStr = $"This picture store path is: {mediaFile.Path}"; _customWebView.EvalJavaScript($"javascript: log('{writeMessageStr}');"); }); } }); }
public override void CreateView() { _view = new CustomWebView(Activity); _view.Settings.JavaScriptEnabled = true; _view.SetWebViewClient(new InternalWebViewClient(this)); _view.LayoutInvoke += View_LayoutInvoke; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { customWebView = null; } }
private void ScreenSwitchPressed(object sender, EventArgs e) { PDFWebView = new CustomWebView { Uri = "Hege1.pdf", HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; }
/// <summary> /// Will wire up the commands in the WebViewer control to the native method calls /// </summary> /// <param name="element"></param> private void InitializeCommands(CustomWebView element) { element.Refresh = () => { Control?.Reload(); }; //element.GoBackCommand = new Command(() => //{ // var ctrl = Control; // if (ctrl == null) // return; // if (ctrl.CanGoBack()) // ctrl.GoBack(); //}); element.CanGoBackFunction = () => { var ctrl = Control; if (ctrl == null) { return(false); } return(ctrl.CanGoBack()); }; // This allows you to show a file chooser dialog from the WebView Control.SetWebChromeClient(new WebViewChromeClient((uploadMsg, acceptType, capture) => { //MainActivity.UploadMessage = uploadMsg; if (Build.VERSION.SdkInt < BuildVersionCodes.Kitkat) { var i = new Intent(Intent.ActionGetContent); //To set all type of files i.SetType("image/*"); //Here File Chooser dialog is started as Activity, and it gives result while coming back from that Activity. //((MainActivity)this.Context).StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE); } else { var i = new Intent(Intent.ActionOpenDocument); i.AddCategory(Intent.CategoryOpenable); //To set all image file types. You can change to whatever you need i.SetType("image/*"); //Here File Chooser dialog is started as Activity, and it gives result while coming back from that Activity. //((MainActivity)this.Context).StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE); } })); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e) { base.OnElementChanged(e); _xwebView = e.NewElement as CustomWebView; _webView = Control; if (e.OldElement == null) { _webView.SetWebViewClient(new ExtendedWebViewClient()); } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == nameof(CustomWebView.HtmlToLoad)) { CustomWebView customControl = (CustomWebView)Element; if (!string.IsNullOrEmpty(customControl.HtmlToLoad)) { Control.LoadData(customControl.HtmlToLoad, "text/html", "UTF-8"); } } }
protected override void OnElementChanged(ElementChangedEventArgs <WebView> e) { base.OnElementChanged(e); if (e.OldElement == null) { CustomWebView customControl = (CustomWebView)Element; if (!string.IsNullOrEmpty(customControl.HtmlToLoad)) { Control.LoadData(customControl.HtmlToLoad, "text/html", "UTF-8"); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e) { base.OnElementChanged(e); if (Control != null) { CustomWebView customControl = (CustomWebView)Element; if (!string.IsNullOrEmpty(customControl.HtmlToLoad)) { Control.NavigateToString(customControl.HtmlToLoad); } } }
public void ShowFile(string uri) { if (webView == null) { webView = new CustomWebView() { Uri = uri, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; RootLayout.Children.Add(webView); ShowPreviewButton.IsVisible = false; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == nameof(CustomWebView.HtmlToLoad)) { CustomWebView customControl = (CustomWebView)Element; if (!string.IsNullOrEmpty(customControl.HtmlToLoad)) { Control.NavigateToString(customControl.HtmlToLoad); } } }
public WebPage() { /* easy approach * var browser = new CustomCrossWebView(); * browser.Open("https://microsoft.com"); */ // With custom renderer Content = new CustomWebView() { Source = "https://microsoft.com" }; }
protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); if (e.NewElement != null) { webView = Element as CustomWebView; this.NavigationDelegate = new NavigationDelegate(webView); this.ScrollView.Bounces = false; this.ScrollView.ScrollEnabled = false; } }
public App() { CustomWebView FormsWebView = new CustomWebView { Source = GetHTML() }; // The root page of your application var content = new ContentPage { Title = "NativeCallWebApp", Content = FormsWebView }; MainPage = content; }
private WebViewTab(CustomWebView webview) { //VirtualDevice device = IPhoneDevice.Create(IPhone.Model5); //device.Rotate(); //webview.SimulateDevice(device); this.Text = "about:blank"; webview.Dock = DockStyle.Fill; webview.CreateWindow += Webview_CreateWindow; webview.DocumentTitleChanged += HandleDocumentTitleChanged; webview.Closing += Webview_Closing; webview.Closed += Webview_Closed; this.WebView = webview; this.Controls.Add(webview); }
protected override void OnCreate(Bundle savedInstanceState) { Presenter = ServiceLocator.GetService <IPresenterFactory <Slug> >().GetPresenterFor(this); CustomLayoutId = Resource.Layout.activity_info; CurrentActivity = NavigableScreen.Info; CanNavigateTo = new List <NavigableScreen> { NavigableScreen.Main, NavigableScreen.Determination, NavigableScreen.SpeciesList }; base.OnCreate(savedInstanceState); ActivityTitle.Text = "Informatie"; webview = FindViewById <CustomWebView>(Resource.Id.infoWebview); }
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); }
public void UriTest1() { CustomWebView varEsperado = new CustomWebView { Uri = "http://google.com" }; var valorEsperado = varEsperado.Uri; CustomWebView varActual = new CustomWebView { Uri = "http://google.com" }; var valorActual = varActual.Uri; Assert.AreEqual(valorActual, valorEsperado); }
private void Webview_CreateWindow(object sender, CreateWindowEventArgs e) { TabControl tabs = this.FindTabControl(); if (tabs == null) { e.Cancel = true; return; } var webview = new CustomWebView((CustomWebView)this.WebView); e.WindowInfo.SetAsWindowless(IntPtr.Zero); e.Client = webview.Client; OnCreateWindow(webview); }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == "LoadPageFinished") { CustomWebView.LoadCompleted(sender, e); } else if (e.PropertyName == "LoadPageStarted") { CustomWebView.LoadStarted(sender, e); } else if (e.PropertyName == "LoadPageFailed") { CustomWebView.LoadFailed(sender, e); } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { if (Control != null) { CustomWebView webView = (CustomWebView)sender; //Control.SetWebChromeClient(new WebChromeClient()); //Control.SetWebViewClient(new WebViewClient()); Control.Settings.JavaScriptEnabled = true; Control.Settings.AllowUniversalAccessFromFileURLs = true; Control.Settings.BuiltInZoomControls = webView.OverviewMode; Control.Settings.LoadWithOverviewMode = webView.OverviewMode; Control.Settings.UseWideViewPort = webView.OverviewMode; Control.SetInitialScale(0); } base.OnElementPropertyChanged(sender, e); }
private void ReloadWebview(CustomWebView webView, bool isRetry = false) { Debug.WriteLine($"BookingViewModel - ReloadWebview()"); ErrorKind = ServiceErrorKind.None; ShowWebView = false; webView.Source = AvilaUrlBooking; webView.Uri = AvilaUrlBooking; webView.Reload(); if (isRetry) { webView.RetryNavigation(); } else { webView.Refresh(); } }
public void UriTest2() { /*CustomWebView operation = new CustomWebView * { * Uri = "http://google.com" * }; * var valorActual = operation.Uri; * Uri valorEsperado = new Uri("http://google.com"); * Assert.AreEqual(valorActual, valorEsperado);*/ CustomWebView varEsperado = new CustomWebView { Uri = "" }; var valorEsperado = varEsperado.Uri; CustomWebView varActual = new CustomWebView { Uri = "" }; var valorActual = varActual.Uri; Assert.AreEqual(valorActual, valorEsperado); }
protected override void OnCreate(Bundle savedInstanceState) { Presenter = ServiceLocator.GetService <IPresenterFactory <Slug> >().GetPresenterFor(this); CustomLayoutId = IsTablet() ? Resource.Layout.activity_slugresult_tablet : Resource.Layout.activity_slugresult_phone; CurrentActivity = NavigableScreen.Other; CanNavigateTo = new List <NavigableScreen> { NavigableScreen.Main, NavigableScreen.Determination, NavigableScreen.SpeciesList, NavigableScreen.Info }; base.OnCreate(savedInstanceState); SlugName = FindViewById <TextView>(Resource.Id.AnimalName); SlugScientificName = FindViewById <TextView>(Resource.Id.AnimalScientificName); SlugPicture = FindViewById <ResourceImageView>(Resource.Id.AnimalImage); SlugPicture.Click += (sender, e) => Presenter.OnResultPictureClicked(); SlugDescription = FindViewById <CustomWebView>(Resource.Id.AnimalPage); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e) { base.OnElementChanged(e); if (Control == null) { return; } Control.Settings.DomStorageEnabled = true; Control.Settings.JavaScriptEnabled = true; //javascriptのfileスキームへのアクセス許可 Control.Settings.AllowFileAccessFromFileURLs = true; Control.Settings.AllowUniversalAccessFromFileURLs = true; //Xamarin.Formのコントロール(CustomWebView) CustomWebView _formsWebView = (CustomWebView)e.NewElement; //ネイティブコントロール(Android.Webkit.WebView) Android.Webkit.WebView _droidWebView = this.Control; //Xamarin.FormのWebViewではNavigateのイベントを拾えないためWebViewClientを上書きする _droidWebView.SetWebViewClient(new CustomWebViewClient(_formsWebView)); }
private async void SaveBtn_Clicked(object sender, EventArgs e) { this.animationView.IsVisible = true; this.SaveBtn.IsEnabled = false; Stream CustomerJObSign = await MainSignaturePad.GetImageStreamAsync(SignaturePad.Forms.SignatureImageFormat.Jpeg, strokeColor : Color.Black, fillColor : Color.White); Stream TechSignJOb = await TechSign.GetImageStreamAsync(SignaturePad.Forms.SignatureImageFormat.Jpeg, strokeColor : Color.Black, fillColor : Color.White); byte[] image = new byte[CustomerJObSign.Length]; byte[] Techimage = new byte[TechSignJOb.Length];//declare arraysize CustomerJObSign.Read(image, 0, image.Length); TechSignJOb.Read(Techimage, 0, Techimage.Length); JobDetailsTabbed.updateModel.CustomerSignatureVector = JobService.jobDetailsModel.JobNo + "_Customer_" + DateTime.Now.Ticks + ".pdf"; JobDetailsTabbed.updateModel.CustomerSignatureImage = image; JobDetailsTabbed.updateModel.TechnicianSignatureVector = JobService.jobDetailsModel.JobNo + "_Technician_" + DateTime.Now.Ticks + ".pdf"; JobDetailsTabbed.updateModel.TechnicianSignatureImage = Techimage; JobDetailsTabbed.updateModel.Rating = theRating; //JobDetailsTabbed.updateModel.Rating.PoliteAndCourteous = PoliteAndCourteous.SelectedItem == null ? 0 : Convert.ToInt32(PoliteAndCourteous.SelectedItem); //JobDetailsTabbed.updateModel.Rating.ProfessionalService = ProfessionalService.SelectedItem == null ? 0 : Convert.ToInt32(ProfessionalService.SelectedItem); //JobDetailsTabbed.updateModel.Rating.WorkQuality = WorkQuality.SelectedItem == null ? 0 : Convert.ToInt32(WorkQuality.SelectedItem); JobDetailsTabbed.updateModel.JobNo = JobService.jobDetailsModel.JobNo; //JobDetailsTabbed.updateModel.Rating.Punctuality = Punctuality.SelectedItem == null ? 0 : Convert.ToInt32(Punctuality.SelectedItem); JobDetailsTabbed.updateModel.UserName = Settings.LastUsedUserId; JobDetailsTabbed.updateModel.ProjectLogo = JobService.jobDetailsModel.ProjectLogo; JobDetailsTabbed.updateModel.WorkInstructions = JobService.jobDetailsModel.WorkInstructions; JobDetailsTabbed.updateModel.AssetsList = JobService.jobDetailsModel.AssetsList; JobDetailsTabbed.updateModel.Department = JobService.jobDetailsModel.Department; JobDetailsTabbed.updateModel.CustomerName = JobService.jobDetailsModel.ContactPerson; JobDetailsTabbed.updateModel.Building = JobService.jobDetailsModel.Building; JobDetailsTabbed.updateModel.Floor = JobService.jobDetailsModel.Floor; JobDetailsTabbed.updateModel.ContactPerson = JobService.jobDetailsModel.ContactPerson; JobDetailsTabbed.updateModel.Phone1 = JobService.jobDetailsModel.Phone1; JobDetailsTabbed.updateModel.Phone2 = JobService.jobDetailsModel.Phone2; JobDetailsTabbed.updateModel.Fax = JobService.jobDetailsModel.Fax; //JobDetailsTabbed.updateModel.Email = JobService.jobDetailsModel.Email; JobDetailsTabbed.updateModel.SiteName = JobService.jobDetailsModel.SiteName; JobDetailsTabbed.updateModel.SiteAddress = JobService.jobDetailsModel.SiteAddress; var ResturnResults = await JobService.UpdateTechJob(JobDetailsTabbed.updateModel); ResturnResults.RetutnPDFFileName = DateTime.Now.Ticks.ToString() + ".pdf"; var assembly = IntrospectionExtensions.GetTypeInfo(typeof(JobDetailedCustomerSign)).Assembly; ////var name = System.IO.Path.GetFileName(path); //Stream stream = assembly.GetManifestResourceStream("TechApp2.insght.json"); Stream Logostream = assembly.GetManifestResourceStream("TechApp2.images.VerserLogo.png"); string text = ""; //using (var reader = new System.IO.StreamReader(stream)) //{ // text = reader.ReadToEnd(); //} // var ResturnResults = JsonConvert.DeserializeObject<JobUpdateReturnDto[]>(text); var customWebView = new CustomWebView() { VerticalOptions = LayoutOptions.FillAndExpand }; string filename1 = ""; var button = new Button { Text = "Open PDF", BackgroundColor = Color.Orange, WidthRequest = 30, HeightRequest = 50, TextColor = Color.White, FontSize = 10, CornerRadius = 10 }; var closeButton = new Button { Text = "Close", BackgroundColor = Color.Orange, WidthRequest = 30, HeightRequest = 50, TextColor = Color.White, FontSize = 10, CornerRadius = 10 }; //var emailButton = new Button { Text = "Email", BackgroundColor = Color.Orange, WidthRequest = 30, HeightRequest = 50, TextColor = Color.White, FontSize = 10, CornerRadius = 10 }; //PdfDocument outputDocument = new PdfDocument(); // Iterate files //foreach (JobUpdateReturnDto dto in ResturnResults) //{ // // Open the document to import pages from it. // PdfDocument inputDocument = PdfReader.Open(new MemoryStream(dto.RetutnPDFFileContent), PdfDocumentOpenMode.Import); // // Iterate pages // int count = inputDocument.PageCount; // for (int idx = 0; idx < count; idx++) // { // // Get the page from the external document... // PdfPage page = inputDocument.Pages[idx]; // // ...and add it to the output document. // outputDocument.AddPage(page); // } //} //filename1 = System.IO.Path.GetTempPath() + "//" + DateTime.Now.Ticks + ".pdf"; //outputDocument.Save(filename1); button.Clicked += (s, es) => { System.IO.File.WriteAllBytes(System.IO.Path.GetTempPath() + "//" + ResturnResults.RetutnPDFFileName, ResturnResults.RetutnPDFFileContent); string str = System.IO.Path.GetTempPath() + "//" + ResturnResults.RetutnPDFFileName; filename1 = str; var exists = File.Exists(str); //var document = new PdfDocument(); string filename = //document.Save(str); customWebView.Path = str; }; closeButton.Clicked += (s, es) => { Application.Current.MainPage = new NavigationPage(new MasterNavigation()); }; if (ResturnResults != null) { if (ResturnResults.IsOperationSuccess) { await DisplayAlert("Info", "Job Update Operation Completed Successfull", "OK"); this.Navigation.PushAsync(new ContentPage { Title = "Open PDF", Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Children = { button, closeButton, //emailButton, customWebView } } }); } } //emailButton.Clicked += async (s, es) => //{ // try // { // var message = new EmailMessage // { // Subject = "Hello", // Body = "World", // }; // var file = filename1; // MailMessage mail = new MailMessage(); // SmtpClient SmtpServer = new SmtpClient("smtp-mail.outlook.com"); // mail.From = new MailAddress("*****@*****.**"); // mail.To.Add(result); // AlternateView htmlView = AlternateView.CreateAlternateViewFromString($"Hi {JobService.jobDetailsModel.ContactPerson}, <br> Automated CAF Signed Job Completion Email With PDF reference Copy .<br><br>Regards<br><br><img src=cid:myImage>", null, "text/html"); // // MemoryStream ms = new MemoryStream(JobService.jobDetailsModel.ProjectLogo); // LinkedResource r = new LinkedResource(Logostream); // r.ContentId = "myImage"; // mail.Subject = JobService.jobDetailsModel.JobNo + "- CAF"; // mail.Body = "This is an automated email.Please do not reply to this. \r\nFor any further queries, please call us on 1200800900.\r\n\r\n\r\nRegards"; // System.Net.Mail.Attachment attachment; // attachment = new System.Net.Mail.Attachment(filename1); // mail.Attachments.Add(attachment); // //end email attachment part // htmlView.LinkedResources.Add(r); // mail.AlternateViews.Add(htmlView); // SmtpServer.Port = 587; // SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "VerserKV19"); // SmtpServer.EnableSsl = true; // ServicePointManager.ServerCertificateValidationCallback = delegate (object sender1, X509Certificate certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) // { // return true; // }; // await SmtpServer.SendMailAsync(mail); // DependencyService.Get<IAlertView>().Show("The email has been delivered successfully."); // } // catch (Exception ex) // { // DependencyService.Get<IAlertView>().Show(ex.ToString()); // throw ex; // } //}; }
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 } } }; }
public CustomWebViewClient(CustomWebView xwebView) { _xwebView = xwebView; }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.GameMessageboxView"/> class. /// </summary> /// <param name="gameMessageboxViewModel">Game messagebox view model.</param> public GameMessageboxView(GameMessageboxViewModel gameMessageboxViewModel) { BindingContext = gameMessageboxViewModel; NavigationPage.SetHasBackButton(this, false); App.GameNavigation.ShowBackButton = false; #if __HTML__ var webView = new CustomWebView() { BackgroundColor = App.Colors.Background, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; webView.SetBinding(WebView.SourceProperty, GameMessageboxViewModel.HtmlSourcePropertyName); ((StackLayout)ContentLayout).Children.Add(webView); #else var scrollLayout = new PinchScrollView() { Orientation = ScrollOrientation.Vertical, Padding = new Thickness(0, 0), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var layout = new StackLayout() { Orientation = StackOrientation.Vertical, Padding = 10, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var image = new ExtendedImage() { Aspect = Aspect.AspectFit, HorizontalOptions = Settings.ImageAlignment.ToLayoutOptions(), }; image.SetBinding(Image.SourceProperty, GameMessageboxViewModel.ImageSourcePropertyName); image.SetBinding(VisualElement.IsVisibleProperty, GameMessageboxViewModel.HasImagePropertyName); layout.Children.Add(image); var description = new ExtendedLabel() { TextColor = App.Colors.Text, FontSize = Settings.FontSize, FontFamily = Settings.FontFamily, XAlign = Settings.TextAlignment, UseMarkdown = App.Game.UseMarkdown, VerticalOptions = LayoutOptions.StartAndExpand, }; description.SetBinding(Label.TextProperty, GameMessageboxViewModel.TextPropertyName); description.SetBinding(VisualElement.IsVisibleProperty, GameMessageboxViewModel.HasTextPropertyName); layout.Children.Add(description); scrollLayout.Content = layout; ((StackLayout)ContentLayout).Children.Add(scrollLayout); #endif }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.GameInputView"/> class. /// </summary> /// <param name="gameInputViewModel">Game input view model.</param> public GameInputView(GameInputViewModel gameInputViewModel) : base() { BindingContext = gameInputViewModel; NavigationPage.SetHasBackButton(this, false); App.GameNavigation.ShowBackButton = false; #if __HTML__ var webView = new CustomWebView () { BackgroundColor = App.Colors.Background, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; webView.SetBinding (WebView.SourceProperty, GameDetailViewModel.HtmlSourcePropertyName); webView.SizeChanged += (object sender, EventArgs e) => { webView.HeightRequest = 1; }; ((StackLayout)ContentLayout).Children.Add(webView); #else ScrollLayout = new PinchScrollView() { Orientation = ScrollOrientation.Vertical, Padding = 0, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var layout = new StackLayout() { Orientation = StackOrientation.Vertical, Padding = 10, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var image = new ExtendedImage() { Aspect = Aspect.AspectFit, HorizontalOptions = Settings.ImageAlignment.ToLayoutOptions(), }; image.SetBinding(Image.SourceProperty, GameInputViewModel.ImageSourcePropertyName); image.SetBinding(VisualElement.IsVisibleProperty, GameInputViewModel.HasImagePropertyName); layout.Children.Add(image); var description = new ExtendedLabel() { TextColor = App.Colors.Text, FontSize = Settings.FontSize, FontFamily = Settings.FontFamily, XAlign = Settings.TextAlignment, UseMarkdown = App.Game.UseMarkdown, }; description.SetBinding(Label.TextProperty, GameInputViewModel.TextPropertyName); description.SetBinding(VisualElement.IsVisibleProperty, GameInputViewModel.HasTextPropertyName); layout.Children.Add(description); ScrollLayout.Content = layout; ((StackLayout)ContentLayout).Children.Add(ScrollLayout); #endif var scanner = new Image { BackgroundColor = Color.Transparent, Source = "IconScan.png", Aspect = Aspect.AspectFit, #if __IOS__ // WidthRequest = 42, // FontSize = 20, // FontFamily = Settings.FontFamily, #endif HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, }; var tapRecognizer = new TapGestureRecognizer { Command = ((GameInputViewModel)BindingContext).ScannerClicked, NumberOfTapsRequired = 1 }; scanner.GestureRecognizers.Add(tapRecognizer); var entry = new Entry { #if __IOS__ BackgroundColor = Color.FromRgb(223, 223, 223), TextColor = App.Colors.Tint, #endif HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Fill, }; entry.SetBinding(Entry.TextProperty, GameInputViewModel.InputTextPropertyName, BindingMode.TwoWay); entry.SetBinding(Entry.PlaceholderProperty, GameInputViewModel.PlaceholderPropertyName); entry.SetBinding(VisualElement.IsVisibleProperty, GameInputViewModel.HasEntryPropertyName); var button = new Button { BackgroundColor = Color.Transparent, Text = Catalog.GetString("Ok"), TextColor = App.Colors.Tint, #if __IOS__ FontSize = 20, FontFamily = Settings.FontFamily, #endif HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, }; button.SetBinding(Button.CommandProperty, GameInputViewModel.ButtonClickedPropertyName); // BottomEntry.Children.Add(button); BottomEntry = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = Device.OnPlatform(new Thickness(6, 6, 6, 6), new Thickness(6, 2, 2, 2), 2), Children = {scanner, entry, button }, }; }
/// <summary> /// Initializes a new instance of the <see cref="WF.Player.GameDetailView"/> class. /// </summary> /// <param name="gameDetailViewModel">Game detail view model.</param> public GameDetailView(GameDetailViewModel gameDetailViewModel) : base() { BindingContext = gameDetailViewModel; App.GameNavigation.ShowBackButton = true; this.SetBinding(GameDetailView.TitleProperty, GameDetailViewModel.NamePropertyName); // Set binding for direction this.DirectionLayout.SetBinding(StackLayout.IsVisibleProperty, GameDetailViewModel.HasDirectionPropertyName); this.DirectionSpaceLayout.SetBinding(BoxView.IsVisibleProperty, GameDetailViewModel.HasDirectionPropertyName); this.DirectionView.SetBinding(DirectionArrow.DirectionProperty, GameDetailViewModel.DirectionPropertyName); this.DistanceView.SetBinding(Label.TextProperty, GameDetailViewModel.DistancePropertyName, BindingMode.OneWay, new ConverterToDistance()); #if __HTML__ var webView = new CustomWebView() { BackgroundColor = App.Colors.Background, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; webView.SetBinding(WebView.SourceProperty, GameDetailViewModel.HtmlSourcePropertyName); ((StackLayout)ContentLayout).Children.Add(webView); #else var scrollLayout = new PinchScrollView() { Orientation = ScrollOrientation.Vertical, Padding = new Thickness(0, 0), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var layout = new StackLayout() { BackgroundColor = App.Colors.Background, Orientation = StackOrientation.Vertical, Padding = 10, Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; var image = new ExtendedImage() { Aspect = Aspect.AspectFit, HorizontalOptions = Settings.ImageAlignment.ToLayoutOptions(), }; image.SetBinding(Image.SourceProperty, GameDetailViewModel.ImageSourcePropertyName); image.SetBinding(VisualElement.IsVisibleProperty, GameDetailViewModel.HasImagePropertyName); layout.Children.Add(image); var description = new ExtendedLabel() { TextColor = App.Colors.Text, FontSize = Settings.FontSize, FontFamily = Settings.FontFamily, XAlign = Settings.TextAlignment, UseMarkdown = App.Game.UseMarkdown, }; description.SetBinding(Label.TextProperty, GameDetailViewModel.DescriptionPropertyName); description.SetBinding(VisualElement.IsVisibleProperty, GameDetailViewModel.HasDescriptionPropertyName); layout.Children.Add(description); scrollLayout.Content = layout; ((StackLayout)ContentLayout).Children.Add(scrollLayout); #endif }