public string GetHTML(EventHandler evt) { Task <string> tsk = m_wv.GetHTML(); tsk.ContinueWith(t2 => { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { evt(tsk.Result, null); }); }); return(""); }
public override bool OnOptionsItemSelected(IMenuItem item) { if (item.TitleFormatted?.ToString() == "Save") { Task <string> action = _editorWebView.GetHTML(); action.ContinueWith(x => { string html = x.Result; SetOutput?.Invoke(true, html); Finish(); }); } else if (item.TitleFormatted?.ToString() == "Macros") { PromptMacros(); } return(base.OnOptionsItemSelected(item)); }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.TEditorActivity); _topToolBar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.TopToolbar); _topToolBar.Title = CrossTEditor.PageTitle; _topToolBar.InflateMenu(Resource.Menu.TopToolbarMenu); _topToolBar.MenuItemClick += async(sender, e) => { if (SetOutput != null) { if (e.Item.TitleFormatted.ToString() == "Save") { var html = await _editorWebView.GetHTML(); SetOutput.Invoke(true, html); } else { SetOutput.Invoke(false, null); } } Finish(); }; _rootLayout = FindViewById <LinearLayoutDetectsSoftKeyboard>(Resource.Id.RootRelativeLayout); _editorWebView = FindViewById <TEditorWebView>(Resource.Id.EditorWebView); _toolbarLayout = FindViewById <LinearLayout>(Resource.Id.ToolbarLayout); _rootLayout.onKeyboardShown += HandleSoftKeyboardShwon; _editorWebView.SetOnCreateContextMenuListener(this); BuildToolbar(); var htmlString = Intent.GetStringExtra("HTMLString") ?? "<p></p>"; _editorWebView.SetHTML(htmlString); var autoFocusInput = Intent.GetBooleanExtra("AutoFocusInput", false); _editorWebView.SetAutoFocusInput(autoFocusInput); }