using ManualSoftwareSystem.Inspection_Work;
using ManualSoftwareSystem.Operation_Manual;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ManualSoftwareSystem.Inspection_Result
{
    public partial class FrmInspectionResultSelectMode : Form
    {
        public dynamic objLanguage;

        public FrmInspectionResultSelectMode()
        {
            InitializeComponent();
            this.objLanguage = FrmOperationManualOperator.objLanguage;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (rbnDisplaysCompletionResults.Checked == true)
            {
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                //openFileDialog1.Filter = "Master file (*.003)|*.003|Working (*.000)|*.000";
                openFileDialog1.Filter = objLanguage.Translate("Completion file") + " (*.001)|*.001";
                DialogResult result = openFileDialog1.ShowDialog();

                if (result == DialogResult.OK)
                {

                    if (openFileDialog1.FileName == string.Empty)
                    {
                        MessageBox.Show(this, objLanguage.Translate("No file selected."),
                                       objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                                       MessageBoxIcon.Exclamation,
                                       MessageBoxDefaultButton.Button1, 0);
                        this.Close();
                        return;
                    }

                    FrmInspectionResult frmInspectionResult = new FrmInspectionResult(openFileDialog1.FileName);

                    this.Dispose();

                    frmInspectionResult.ShowDialog();


                }
                else
                {
                    this.Close();
                }
            }
            else if (rbnDisplaysInterimResults.Checked == true)
            {
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                //openFileDialog1.Filter = "Master file (*.003)|*.003|Working (*.000)|*.000";
                //openFileDialog1.Filter = objLanguage.Translate("Working file") + " (*.000)|*.000";
                openFileDialog1.Filter = objLanguage.Translate("Working file") + " (*.nck)|*.nck";
                DialogResult result = openFileDialog1.ShowDialog();

                if (result == DialogResult.OK)
                {

                    if (openFileDialog1.FileName == string.Empty)
                    {
                        MessageBox.Show(this, objLanguage.Translate("No file selected."),
                                       objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                                       MessageBoxIcon.Exclamation,
                                       MessageBoxDefaultButton.Button1, 0);
                        this.Close();
                        return;
                    }

                    FrmInspectionResult frmInspectionResult = new FrmInspectionResult(openFileDialog1.FileName);

                    this.Dispose();

                    frmInspectionResult.ShowDialog();


                }
                else
                {
                    this.Close();
                }
            }
        }

        private void FrmInspectionResultSelectMode_Load(object sender, EventArgs e)
        {
            string strSelectMode = "Select mode";
            string strOK = "OK";
            string strCancel = "Cancel";
            string strSelection = "Selection of inspection result display method.";
            string strDisplaysCompletionResults = "Displays inspection completion results.";
            string strDisplaysInterimResults = "Displays the interim results of the inspection.";

            lblSelectMode.Text = objLanguage.Translate(strSelectMode);
            btnOK.Text = objLanguage.Translate(strOK);
            btnCancel.Text = objLanguage.Translate(strCancel);
            lblSelection.Text = objLanguage.Translate(strSelection);
            rbnDisplaysCompletionResults.Text = objLanguage.Translate(strDisplaysCompletionResults);
            rbnDisplaysInterimResults.Text = objLanguage.Translate(strDisplaysInterimResults);
        }
    }
}
