void SegmentValueChanged()
        {
            if (_viewSegment.SelectedSegment == 0)
            {
                if (_previewView != null)
                {
                    _previewView.RemoveFromSuperview();
                    _previewView.Dispose();
                    _previewView = null;
                }

                Add(TextView);
                TextView.BecomeFirstResponder();
            }
            else
            {
                if (_previewView == null)
                {
                    _previewView = new WKWebView(this.View.Bounds, new WKWebViewConfiguration());
                }

                TextView.RemoveFromSuperview();
                Add(_previewView);

                LoadPreview(_previewView).ToBackground();
            }
        }
        void SegmentValueChanged(object sender, EventArgs e)
        {
            if (_viewSegment.SelectedSegment == 0)
            {
                if (_previewView != null)
                {
                    _previewView.RemoveFromSuperview();
                    _previewView.Dispose();
                    _previewView = null;
                }

                Add(TextView);
                TextView.BecomeFirstResponder();
            }
            else
            {
                if (_previewView == null)
                {
                    _previewView = new WKWebView(this.View.Bounds, new WKWebViewConfiguration());
                }

                TextView.RemoveFromSuperview();
                Add(_previewView);

                var markdownService = Mvx.Resolve <IMarkdownService>();
                var markdownText = markdownService.Convert(Text);
                var model = new DescriptionModel(markdownText, (int)UIFont.PreferredSubheadline.PointSize);
                var view = new MarkdownView {
                    Model = model
                }.GenerateString();
                _previewView.LoadHtmlString(view, NSBundle.MainBundle.BundleUrl);
            }
        }
示例#3
0
        void SegmentValueChanged(object sender, EventArgs e)
        {
            if (_viewSegment.SelectedSegment == 0)
            {
                if (_previewView != null)
                {
                    _previewView.RemoveFromSuperview();
                    _previewView.Dispose();
                    _previewView = null;
                }

                Add(TextView);
                TextView.BecomeFirstResponder();
            }
            else
            {
//                if (_previewView == null)
//                    _previewView = new UIWebView(this.View.Bounds);
//
//                TextView.RemoveFromSuperview();
//                Add(_previewView);
//
//                var markdownService = IoC.Resolve<IMarkdownService>();
//                var path = MarkdownHtmlGenerator.CreateFile(markdownService.Convert(Text));
//                var uri = Uri.EscapeUriString("file://" + path) + "#" + Environment.TickCount;
//                _previewView.LoadRequest(new MonoTouch.Foundation.NSUrlRequest(new MonoTouch.Foundation.NSUrl(uri)));
            }
        }
示例#4
0
        void SegmentValueChanged(object sender, EventArgs e)
        {
            if (_viewSegment.SelectedSegment == 0)
            {
                if (_previewView != null)
                {
                    _previewView.RemoveFromSuperview();
                    _previewView.Dispose();
                    _previewView = null;
                }

                Add(TextView);
                TextView.BecomeFirstResponder();
            }
            else
            {
                if (_previewView == null)
                {
                    _previewView = new UIWebView(this.View.Bounds);
                }

                TextView.RemoveFromSuperview();
                Add(_previewView);

                var markdownService = IoC.Resolve <IMarkdownService>();
                var markdownView    = new MarkdownView()
                {
                    Model = markdownService.Convert(TextView.Text)
                };
                _previewView.LoadHtmlString(markdownView.GenerateString(), null);
            }
        }
示例#5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            StyleBackground(BackgroundView);

            StyleHeader(HeaderView, HeaderLabel);

            if (SingleLine)
            {
                TextField.Text   = _Value;
                TextField.Hidden = false;
                TextView.Hidden  = true;

                CGRect rect = BackgroundView.Frame;
                rect.Height         -= 220;
                rect.Y              += 100;
                BackgroundView.Frame = rect;
                TextField.BecomeFirstResponder();
                TextField.ReturnKeyType   = UIReturnKeyType.Done;
                _textFieldDelegate        = new TextFieldDelegate(this);
                TextField.Delegate        = _textFieldDelegate;
                TextField.ClearButtonMode = UITextFieldViewMode.Always;
            }
            else
            {
                TextView.Text    = _Value;
                TextField.Hidden = true;
                TextView.Hidden  = false;
                TextView.BecomeFirstResponder();
            }

            StyleButton(OKButton);
            StyleButton(CancelButton);
        }
示例#6
0
 public void Select()
 {
     if (TextView != null)
     {
         TextView.BecomeFirstResponder();
     }
     else if (TextField != null)
     {
         TextField.BecomeFirstResponder();
     }
 }
示例#7
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            _notificationObservers.Add(NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, KeyboardDidShow));
            _notificationObservers.Add(NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyboardWillHide));

            TextView.Started += OnTextStarted;
            TextView.Ended   += OnTextEnded;

            TextView.BecomeFirstResponder();
        }
示例#8
0
        protected MarkdownComposerView(IMarkdownService markdownService)
        {
            TextView.Font     = UIFont.SystemFontOfSize(16f);
            TextView.Changed += (sender, e) => ViewModel.Text = TextView.Text;

            this.WhenAnyValue(x => x.ViewModel.Text)
            .Subscribe(x => Text = x);


            this.WhenAnyValue(x => x.ViewModel.PostToImgurCommand)
            .Select(x => x == null ? null : new MarkdownAccessoryView(TextView, ViewModel.PostToImgurCommand))
            .Subscribe(x => TextView.InputAccessoryView = x);

            _viewSegment = new UISegmentedControl(new [] { "Compose", "Preview" });
            _viewSegment.SelectedSegment = 0;
            NavigationItem.TitleView     = _viewSegment;
            _viewSegment.ValueChanged   += (sender, e) =>
            {
                if (_viewSegment.SelectedSegment == 0)
                {
                    if (_previewView != null)
                    {
                        _previewView.RemoveFromSuperview();
                        _previewView.Dispose();
                        _previewView = null;
                    }

                    Add(TextView);
                    TextView.BecomeFirstResponder();
                }
                else
                {
                    if (_previewView == null)
                    {
                        _previewView = new UIWebView(this.View.Bounds);
                    }

                    TextView.RemoveFromSuperview();
                    Add(_previewView);

                    var markdownView = new MarkdownView {
                        Model = markdownService.Convert(TextView.Text)
                    };
                    _previewView.LoadHtmlString(markdownView.GenerateString(), null);
                }
            };
        }
示例#9
0
        protected MarkdownComposerViewController(IMarkdownService markdownService)
        {
            TextView.Font               = UIFont.PreferredBody;
            TextView.Changed           += (sender, e) => ViewModel.Text = TextView.Text;
            TextView.InputAccessoryView = new MarkdownAccessoryView(TextView);

            this.WhenAnyValue(x => x.ViewModel.Text)
            .Subscribe(x => Text = x);

            var viewSegment = new UISegmentedControl(new [] { "Compose", "Preview" });

            viewSegment.SelectedSegment = 0;
            NavigationItem.TitleView    = viewSegment;
            viewSegment.ValueChanged   += (sender, e) =>
            {
                if (viewSegment.SelectedSegment == 0)
                {
                    if (_previewView != null)
                    {
                        _previewView.RemoveFromSuperview();
                        _previewView.Dispose();
                        _previewView = null;
                    }

                    Add(TextView);
                    TextView.BecomeFirstResponder();
                }
                else
                {
                    if (_previewView == null)
                    {
                        _previewView = new UIWebView(this.View.Bounds);
                    }

                    TextView.RemoveFromSuperview();
                    Add(_previewView);

                    var markdown     = markdownService.Convert(TextView.Text);
                    var model        = new DescriptionModel(markdown, (int)UIFont.PreferredSubheadline.PointSize);
                    var markdownView = new MarkdownView {
                        Model = model
                    };
                    _previewView.LoadHtmlString(markdownView.GenerateString(), null);
                }
            };
        }
示例#10
0
 public override void ViewDidAppear(bool animated)
 {
     base.ViewDidAppear(animated);
     TextView.BecomeFirstResponder();
 }
示例#11
0
 public override void BecomeFirstResponder( )
 {
     TextView.BecomeFirstResponder( );
 }