using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PTMedicalInsurance.Forms
{
    public partial class PrintersForm : Form
    {

        /// <summary>
        /// 选中的打印机名称
        /// </summary>
        public string PrinterName { set; get; }

        /// <summary>
        /// 是否横向打印
        /// </summary>
        public bool Landscape { set; get; }

        public PrintersForm()
        {
            InitializeComponent();
        }

        private void frmPrinters_Load(object sender, EventArgs e)
        {
            foreach (var printer in PrinterSettings.InstalledPrinters)
            {
                combPrinters.Items.Add(printer.ToString());
            }

            radioDirection.SelectedIndex = 1;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if(combPrinters.SelectedItem == null)
            {
                MessageBox.Show("请先选择打印机!");
                return;
            }
            PrinterName = combPrinters.SelectedItem.ToString();
            Landscape = (radioDirection.SelectedIndex == 0);
            DialogResult = DialogResult.OK;
        }
    }
}
