private void Init(Context context)
        {
            _richTextEditor = new Shared.RichEditor();
            SetWebViewClient(new RichEditorWebViewClient(_richTextEditor));
            SetWebChromeClient(new TEditorChromeWebClient());
            _richTextEditor.SetJavaScriptEvaluatingFunction((input) =>
            {
                EvaluateJavascript(input, null);
            });
            _richTextEditor.SetJavaScriptEvaluatingWithResultFunction(async(input) =>
            {
                var result = new JavaScriptResult();

                EvaluateJavascript(input, result);

                var result2 = await result.GetResultAsync();

                return(result2);
            });
            _colorPickerDialog = new ColorPickerDialog(context, Color.Red);
            _colorPickerDialog.ColorChanged += (o, args) =>
            {
                _richTextEditor.SetTextColor((int)args.Color.R, (int)args.Color.G, (int)args.Color.B);
            };

            _richTextEditor.LaunchColorPicker = () => { _colorPickerDialog.Show(); };
            LoadResource();
        }
Exemple #2
0
        private void AddColorPickerControl()
        {
            _colorPickerViewController = new PopColorPickerViewController();

            _colorPickerViewController.CancelButton.Clicked += (object sender, EventArgs e) =>
            {
                if (!IsIpad())
                {
                    _colorPickerViewController.NavigationController.PopViewController(true);
                }
                else
                {
                    _popoverController.Dismiss(true);
                }
            };

            _colorPickerViewController.DoneButton.Clicked += (object sender, EventArgs e) =>
            {
                if (!IsIpad())
                {
                    _colorPickerViewController.NavigationController.PopViewController(true);
                }
                else
                {
                    _popoverController.Dismiss(true);
                }
                nfloat r, g, b, a;
                _colorPickerViewController.SelectedColor.GetRGBA(out r, out g, out b, out a);
                _richTextEditor.SetTextColor((int)(r * 255), (int)(g * 255), (int)(b * 255));
            };

            _richTextEditor.LaunchColorPicker = () =>
            {
                if (!IsIpad())
                {
                    NavigationController.PushViewController(_colorPickerViewController, true);
                }
                else
                {
                    var navController = new UINavigationController(_colorPickerViewController);

                    _popoverController = new UIPopoverController(navController);
                    _popoverController.PresentFromRect(_toolbarHolder.Frame, View, UIPopoverArrowDirection.Down, true);
                }
            };
        }