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;
using FooEditEngine;
using FooEditEngine.Windows;

namespace Test.Windows
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.fooTextBox1.ShowTab = true;
            this.fooTextBox1.ShowFullSpace = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FooPrintText fooPrint;
            fooPrint = new FooPrintText();
            fooPrint.Document = this.fooTextBox1.Document;
            fooPrint.DrawLineNumber = this.fooTextBox1.DrawLineNumber;
            fooPrint.Font = this.fooTextBox1.Font;
            fooPrint.isWordRap = this.fooTextBox1.LineBreak;
            fooPrint.RightToLeft = this.fooTextBox1.RightToLeft == System.Windows.Forms.RightToLeft.Yes;
            fooPrint.Header = "header";
            fooPrint.Footer = "footer";
            fooPrint.Foreground = this.fooTextBox1.Foreground;
            PrintPreviewDialog dialog = new PrintPreviewDialog();
            dialog.Document = fooPrint.PrintDocument;
            dialog.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.fooTextBox1.RightToLeft == System.Windows.Forms.RightToLeft.No)
                this.fooTextBox1.RightToLeft = RightToLeft.Yes;
            else
                this.fooTextBox1.RightToLeft = RightToLeft.No;
            this.fooTextBox1.Refresh();
        }

        private void lineNumberToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.lineNumberToolStripMenuItem.Checked)
                this.fooTextBox1.DrawLineNumber = false;
            else
                this.fooTextBox1.DrawLineNumber = true;
            this.lineNumberToolStripMenuItem.Checked = this.fooTextBox1.DrawLineNumber;
            this.fooTextBox1.Refresh();
        }

        private async void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                await this.fooTextBox1.Document.LoadAsync(ofd.FileName, Encoding.Default);
                this.fooTextBox1.Refresh();
            }
        }

        private void hilightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.fooTextBox1.Hilighter = new XmlHilighter();
            this.fooTextBox1.LayoutLines.HilightAll();
        }
    }
}
