VAGSuite.frmMain.VerifyChecksum C# (CSharp) Метод

VerifyChecksum() приватный Метод

private VerifyChecksum ( string filename, bool showQuestion, bool showInfo ) : void
filename string
showQuestion bool
showInfo bool
Результат void
        private void VerifyChecksum(string filename, bool showQuestion, bool showInfo)
        {
            string chkType = string.Empty;
            barChecksum.Caption = "---";
            ChecksumResultDetails result = new ChecksumResultDetails();
            if (m_appSettings.AutoChecksum)
            {
                result = Tools.Instance.UpdateChecksum(filename, false);
                if (showInfo)
                {
                    if (result.CalculationOk)
                    {
                        if (result.TypeResult == ChecksumType.VAG_EDC15P_V41) chkType = " V4.1";
                        else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41V2) chkType = " V4.1v2";
                        else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41_2002) chkType = " V4.1 2002";
                        else if (result.TypeResult != ChecksumType.Unknown) chkType = result.TypeResult.ToString();
                        frmInfoBox info = new frmInfoBox("Checksums are correct [" + chkType + "]");
                    }
                    else
                    {
                        if (result.TypeResult == ChecksumType.VAG_EDC15P_V41) chkType = " V4.1";
                        else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41V2) chkType = " V4.1v2";
                        else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41_2002) chkType = " V4.1 2002";
                        else if (result.TypeResult != ChecksumType.Unknown) chkType = result.TypeResult.ToString();
                        frmInfoBox info = new frmInfoBox("Checksums are INCORRECT [" + chkType + "]");

                    }
                }
            }
            else
            {
                result = Tools.Instance.UpdateChecksum(filename, true);
                if (!result.CalculationOk)
                {
                    if (showQuestion && result.TypeResult != ChecksumType.Unknown)
                    {
                         if (result.TypeResult == ChecksumType.VAG_EDC15P_V41) chkType = " V4.1";
                         else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41V2) chkType = " V4.1v2";
                         else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41_2002) chkType = " V4.1 2002";
                         else if (result.TypeResult != ChecksumType.Unknown) chkType = result.TypeResult.ToString();
                        frmChecksumIncorrect frmchk = new frmChecksumIncorrect();
                        frmchk.ChecksumType = chkType;
                        frmchk.NumberChecksums = result.NumberChecksumsTotal;
                        frmchk.NumberChecksumsFailed = result.NumberChecksumsFail;
                        frmchk.NumberChecksumsPassed = result.NumberChecksumsOk;
                        if(frmchk.ShowDialog() == DialogResult.OK)
                        //if (MessageBox.Show("Checksums are invalid. Do you wish to correct them?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            result = Tools.Instance.UpdateChecksum(filename, false);
                        }
                    }
                    else if (showInfo && result.TypeResult == ChecksumType.Unknown)
                    {
                        frmInfoBox info = new frmInfoBox("Checksum for this filetype is not yet implemented");
                    }
                }
                else
                {
                    if (showInfo)
                    {
                        if (result.TypeResult == ChecksumType.VAG_EDC15P_V41) chkType = " V4.1";
                        else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41V2) chkType = " V4.1v2";
                        else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41_2002) chkType = " V4.1 2002";
                        else if (result.TypeResult != ChecksumType.Unknown) chkType = result.TypeResult.ToString();
                        frmInfoBox info = new frmInfoBox("Checksums are correct [" + chkType + "]");
                    }
                }
            }

            if (result.TypeResult == ChecksumType.VAG_EDC15P_V41) chkType = " V4.1";
            else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41V2) chkType = " V4.1v2";
            else if (result.TypeResult == ChecksumType.VAG_EDC15P_V41_2002) chkType = " V4.1 2002";
            if (!result.CalculationOk)
            {
                barChecksum.Caption = "Checksum failed" + chkType;
            }
            else
            {
                barChecksum.Caption = "Checksum Ok" + chkType;
            }
            Application.DoEvents();
        }
frmMain