예제 #1
0
        public frmPrincipal()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            Texto = new Text();
            Texto.InsertLine("", -1);
            saveText = true;
            DrawText();
        }
예제 #2
0
        private void txtTexto_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox t     = sender as TextBox;
            int     pos   = t.SelectionStart;
            int     index = Convert.ToInt32(t.Tag);

            // Criando linha nova
            if (e.KeyCode == Keys.Enter)
            {
                string antes  = t.Text.Substring(0, t.SelectionStart);
                string depois = t.Text.Substring(t.SelectionStart);
                t.Text = antes;
                Texto.InsertLine(depois, index);
                DrawText();
                caixaTexto[index + 1].Focus();
                caixaTexto[index + 1].SelectionStart  = (pos - 1 >= 0?pos - 1:0);
                caixaTexto[index + 1].SelectionLength = 0;
            }
            if (e.KeyCode == Keys.Up)
            {
                index--;
                if (index < 0)
                {
                    index = 0;
                }
                caixaTexto[index].Focus();
                caixaTexto[index].SelectionStart  = pos + 1;
                caixaTexto[index].SelectionLength = 0;
            }
            if (e.KeyCode == Keys.Down)
            {
                index++;
                if (index >= caixaTexto.Length)
                {
                    index = caixaTexto.Length - 1;
                }
                caixaTexto[index].Focus();
                caixaTexto[index].SelectionStart  = (pos - 1 >= 0 ? pos - 1 : 0);
                caixaTexto[index].SelectionLength = 0;
            }
        }