using System;
using System.IO;
using System.Windows.Forms;

namespace FaxPrint
{
    public partial class PrintForm : Form
    {
        public PrintForm()
        {
            InitializeComponent();

            // Vorgaben 
            this.fileNameTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Readme.txt");
            this.openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            this.openFileDialog1.FileName = this.fileNameTextBox.Text;

            this.faxCheckBox.Checked = true;
        }

        private void fileOpenButton_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                this.fileNameTextBox.Text = this.openFileDialog1.FileName;
        }

        private void printButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists(this.fileNameTextBox.Text))
                {
                    new MultiPagePrint().Print(this.fileNameTextBox.Text, this.faxCheckBox.Checked);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Drucken", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
