UsrWorkMode2.cs 3.9 KB
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Asa.FaceControl;
using BLL;
using Model;

namespace SmartScan
{
    public partial class UsrWorkMode2 : UserControl, ISetMenu
    {
        public UsrWorkMode2()
        {
            InitializeComponent();

            //打印机
            LstPrinter.Items.AddRange(Printer.AllName);
            LstPrinter.Text = BLLCommon.config.PrinterName;
            if (BLLCommon.config.PrintLandscape)
                RdoLandscape.Checked = true;
            else
                RdoVertical.Checked = true;

            //图像保存
            ((FaceRadioBox)facePanel1.Controls["Rdo" + BLLCommon.config.HistoryImage.ToString()]).Checked = true;

            //6个复选框
            ChkSelectPN.Checked = BLLCommon.config.SelectHttpPN;
            ChkLabelEmptyCheck.Checked = BLLCommon.config.LabelEmptyCheck;
            ChkOpenEnterWork.Checked = BLLCommon.config.OpenStartWork;
            ChkPrintCompletedClear.Checked = BLLCommon.config.PrintCompletedClear;
            ChkOpenMaximize.Checked = BLLCommon.config.OpenMaximize;
            ChkTriggerOpenLight.Checked = BLLCommon.config.TriggerOpenLight;
            ChkPromptAfterPrinting.Checked = BLLCommon.config.PromptAfterPrinting;
            ChkAutoPrint.Checked = BLLCommon.config.AutoPrint;

            //默认标签
            LstLabel.Items.AddRange(BLLCommon.labelEdit.Name);
            LstLabel.Text = BLLCommon.config.DefaultPrintLabel;

            //优先模板
            LstMate.Items.AddRange(BLLCommon.mateEdit.Name);
            LstMate.Text = BLLCommon.config.DefaultMaterialName;

            Language.SetLanguage(this);
        }

        public FacePanel GetPanel()
        {
            return facePanel1;
        }

        public void Save()
        {
            //保存打印机
            BLLCommon.config.PrintLandscape = RdoLandscape.Checked;
            if (LstPrinter.SelectedIndex == -1)
            {
                if (LstPrinter.Items.Count == 1)
                    BLLCommon.config.PrinterName = LstPrinter.Items[0];
            }
            else
            {
                BLLCommon.config.PrinterName = LstPrinter.Text;
            }
        
            //追溯图像保存
            if (RdoOriginal.Checked)
                BLLCommon.config.HistoryImage = HistoryImage.Original;
            else if (RdoCondense.Checked)
                BLLCommon.config.HistoryImage = HistoryImage.Condense;
            else if (RdoNoImage.Checked)
                BLLCommon.config.HistoryImage = HistoryImage.NoImage;

            //默认打印标签
            if (LstLabel.SelectedIndex == -1)
            {
                if (LstLabel.Items.Count == 1)
                    BLLCommon.config.DefaultPrintLabel = LstLabel.Items[0];
            }
            else
            {
                BLLCommon.config.DefaultPrintLabel = LstLabel.Text;
            }

            //优先匹配模板
            if (LstMate.SelectedIndex == -1)
            {
                if (LstMate.Items.Count == 1)
                    BLLCommon.config.DefaultMaterialName = LstMate.Items[0];
            }
            else
            {
                BLLCommon.config.DefaultMaterialName = LstMate.Text;
            }

            //6个复选框
            BLLCommon.config.SelectHttpPN = ChkSelectPN.Checked;
            BLLCommon.config.LabelEmptyCheck = ChkLabelEmptyCheck.Checked;
            BLLCommon.config.OpenStartWork = ChkOpenEnterWork.Checked;
            BLLCommon.config.OpenMaximize = ChkOpenMaximize.Checked;
            BLLCommon.config.PrintCompletedClear = ChkPrintCompletedClear.Checked;
            BLLCommon.config.TriggerOpenLight = ChkTriggerOpenLight.Checked;
            BLLCommon.config.PromptAfterPrinting = ChkPromptAfterPrinting.Checked;
            BLLCommon.config.AutoPrint = ChkAutoPrint.Checked;

            BLLCommon.config.Save();
        }
    }
}