Exemple #1
0
        private void Initialize()
        {
            UserInteractionEnabled = true;

            _input      = new UITextView();
            _input.Font = UIFont.BoldSystemFontOfSize(20);
            _input.AutocapitalizationType = UITextAutocapitalizationType.None;
            _input.Text = _query.Title;
            Add(_input);

            Layout = () =>
            {
                _input.ChangeSize(Frame.Width, Frame.Height);
                _input.ChangePosition(0, 0);
            };

            Layout();

            AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                if (ShouldBecomeFirstResponderOnClick)
                {
                    _input.BecomeFirstResponder();
                }

                Clicked();
            }));
        }
Exemple #2
0
        private void Initialize()
        {
            _content = new UITextView();

            _content.Editable = true;
            _content.AllowsEditingTextAttributes = true;
            _content.ShouldChangeText           += OnShouldChangeText;
            _content.Changed                     += ContentOnChanged;
            _content.AutocorrectionType           = UITextAutocorrectionType.No;
            _content.AutocapitalizationType       = UITextAutocapitalizationType.None;
            _content.SelectionChanged            += OnSelectionChanged;
            _content.ShowsVerticalScrollIndicator = false;
            _content.Font = UIFont.FromName("TimesNewRomanPSMT", 20);

            var novelContent = new AtLeastSingleSpaceString(_novel.Content);

            var result = new NSMutableAttributedString(novelContent.PlainText);

            var paragraphStyle = CreateDefaultParagraph();

            result.AddAttribute(UIStringAttributeKey.ParagraphStyle, paragraphStyle, new NSRange(0, novelContent.Length));

            result.AddAttribute(UIStringAttributeKey.Font, UIFont.FromName("TimesNewRomanPSMT", 20), new NSRange(0, novelContent.Length));

            foreach (var textInfo in _novel.Format)
            {
                switch (textInfo.Style)
                {
                case TextStyle.Centered:
                    var paragraph = CreateDefaultParagraph();
                    paragraph.Alignment = UITextAlignment.Center;
                    result.AddAttribute(UIStringAttributeKey.ParagraphStyle, paragraph, new NSRange(textInfo.Range.Offset, textInfo.Range.Length));
                    break;

                case TextStyle.Right:
                    var paragraph2 = CreateDefaultParagraph();
                    paragraph2.Alignment = UITextAlignment.Right;
                    result.AddAttribute(UIStringAttributeKey.ParagraphStyle, paragraph2, new NSRange(textInfo.Range.Offset, textInfo.Range.Length));
                    break;

                case TextStyle.Bold:
                    result.AddAttribute(UIStringAttributeKey.Font, UIFont.FromName("TimesNewRomanPS-BoldMT", 20), new NSRange(textInfo.Range.Offset, textInfo.Range.Length));
                    break;

                case TextStyle.Italic:
                    result.AddAttribute(UIStringAttributeKey.Font, UIFont.FromName("TimesNewRomanPS-ItalicMT", 20), new NSRange(textInfo.Range.Offset, textInfo.Range.Length));
                    break;

                case TextStyle.BoldAndItalic:
                    result.AddAttribute(UIStringAttributeKey.Font, UIFont.FromName("TimesNewRomanPS-BoldItalicMT", 20), new NSRange(textInfo.Range.Offset, textInfo.Range.Length));
                    break;
                }
            }

            MarkSpelling(result);

            _content.AttributedText = result;

            Add(_content);

            _cursor = new CursorView();
            InitCursor();

            InitSpellchecker();

            Layout = () =>
            {
                _content.ChangeSize(Frame.Width - _margin * 2, Frame.Height);
                _content.ChangeX(_margin);

                _cursor.PositionToCenterInside(this);
            };

            Layout();
        }