private void PromptMacros()
        {
            var builderSingle = new Android.App.AlertDialog.Builder(this);

            builderSingle.SetTitle("Select Macro");

            var negative = new EventHandler <DialogClickEventArgs>(
                (s, args) =>
            {
            });

            var positive = new EventHandler <DialogClickEventArgs>(
                async(s, args) =>
            {
                if (_macrosValues != null && _macrosValues.Count > args.Which)
                {
                    var value       = _macrosValues[args.Which];
                    var currentHtml = await _editorWebView.GetHTML();
                    _editorWebView.SetHTML(currentHtml + value + "<br/>");
                }
            });

            builderSingle.SetItems(_macros.ToArray(), positive);
            builderSingle.SetNegativeButton("Cancel", negative);

            var adialog = builderSingle.Create();

            adialog.Show();
        }
Ejemplo n.º 2
0
        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);
        }
        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;

            SetSupportActionBar(_topToolBar);

            if (SupportActionBar != null)
            {
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetDisplayShowHomeEnabled(true);
                SupportActionBar.SetDisplayShowCustomEnabled(true);
            }

            _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();

            string htmlString = Intent.GetStringExtra("HTMLString") ?? "<p></p>";

            _editorWebView.SetHTML(htmlString);

            bool autoFocusInput = Intent.GetBooleanExtra("AutoFocusInput", false);

            _editorWebView.SetAutoFocusInput(autoFocusInput);


            _macros       = Intent.GetStringArrayListExtra("macroKeys");
            _macrosValues = Intent.GetStringArrayListExtra("macroValues");
        }
Ejemplo n.º 4
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            ((LNWebView)Element).GetHTML = GetHTML;
            ((LNWebView)Element).SetHTML = SetHTML;

            if (Control == null)
            {
                //the master layout
                m_lay = new LNLinearLayout(Context)
                {
                    Orientation = Orientation.Vertical, WeightSum = 1
                };

                //the toolbar
                m_toolbarParent = new LinearLayout(Context);
                HorizontalScrollView sv = new HorizontalScrollView(Context);
                m_toolbar = new LinearLayout(Context);
                BuildToolbar();
                sv.AddView(m_toolbar);
                m_toolbarParent.AddView(sv);

                //the webview
                m_wv = new TEditorWebView(Context);
                m_wv.SetHTML(((LNWebView)Element).HTML);


                //add the webview and toolbar to the master layout
                m_lay.AddView(m_toolbarParent, new LNLinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent));
                m_lay.AddView(m_wv, new LNLinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent));

                //set the keyboard handler and the native control
                m_lay.onKeyboardShown += HandleSoftKeyboardShwon;
                SetNativeControl(m_lay);
            }
        }
Ejemplo n.º 5
0
 public string SetHTML(string html)
 {
     m_wv.SetHTML(html);
     return(html);
 }