ui/wpf/UIcore/TextArea.cs

Sun, 15 Jan 2017 15:08:07 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 15 Jan 2017 15:08:07 +0100
changeset 132
a24465cc7262
parent 104
3efe0210e27e
child 135
b9dc9cdfa23a
permissions
-rw-r--r--

fixes VS settings

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UI
{
    public class TextArea : System.Windows.Controls.TextBox
    {
        public TextArea(Container container, String text, bool textarea) : base()
        {
            bool fill = false;
            if (textarea)
            {
                AcceptsReturn = true;
                IsUndoEnabled = false; // we need our own undo stack
                VerticalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto;
                HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto;
                fill = true;
            }
            else
            {
                HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto;
                MinWidth = 15;
            }

            if (text != null)
            {
                Text = text;
            }

            container.Add(this, fill);
        }

        public static TextArea CreateTextArea(Container container, String text)
        {
            return Application.GetInstance().Exec<TextArea>(() => new TextArea(container, text, true));
        }

        public static TextArea CreateTextField(Container container, String text)
        {
            return Application.GetInstance().Exec<TextArea>(() => new TextArea(container, text, false));
        }


        // ------------------ UiText methods ------------------

        public void SetText(String str)
        {
            Application.GetInstance().Exec(() => Text = str);
        }

        public String GetText()
        {
            return Application.GetInstance().Exec<String>(() => Text);
        }

        public String GetSubString(int begin, int end)
        {
            return null;
        }

        public void Insert(int pos, String str)
        {

        }

        public int Position()
        {
            return Application.GetInstance().Exec<int>(() => CaretIndex);
        }

        public int Selection()
        {
            return 0;
        }

        public int Length()
        {
            return Application.GetInstance().Exec<int>(() => Text.Length);
        }

        public void Remove(int begin, int end)
        {

        }
    }
}

mercurial