using FCOMMON;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FPJ0000.Note
{
    public partial class fTextEditor : fBase
    {
      
       // Boolean bInit = false;
        public fTextEditor(string rtf)
        {
            InitializeComponent();
        
            this.KeyPreview = true;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.KeyDown += (s1, e1) =>
            {
                if (e1.KeyCode == Keys.Escape) this.Close();
            };
            if (string.IsNullOrEmpty(rtf) == false) this.richTextBoxEx1.Rtf = rtf;
            else this.richTextBoxEx1.Text = string.Empty;

        }

       
        private void fJobReport_Add_Load(object sender, EventArgs e)
        {

            EnsureVisibleAndUsableSize();
            this.Show();
            Application.DoEvents();

            this.richTextBoxEx1.Focus();

           // bInit = true;
        }
    //    editform.editor ed;
        void ctl_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Control ctl = sender as Control;
                string nm = ctl.Name.ToLower();
                string search = ctl.Text.Trim();

                Console.WriteLine("inner keydown " + nm + ":" + search);

                switch (nm)
                {
                    //case "cmbrequest":

                    //    //요청자가 마지막으로 입력한 자료의 process 를 찾아서 기입해준다.
                    //    var lastprocess = FCOMMON.DBM.getFirstValue("process", "purchase", "request like '%" + this.cmbUser.Text + "%'", "pdate desc");
                    //    if (lastprocess != "") cbProcess.Text = lastprocess;
                    //    tbSID.Focus();
                    //    break;
                    case "tbdescription":
                        if (e.Control)
                        {
                            btSave.Focus();
                        }
                        break;
                    
                    default:
                        SendKeys.Send("{TAB}");
                        break;
                }
            }
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            this.Invalidate();
          
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

       
    

    }
}
