コード例 #1
0
        private void Dialoge_Load(object sender, EventArgs e)
        {
            switch (FType.Name.ToString())
            {
            case "Times New Roman":
                radioButton1.Checked = true;
                break;

            case "Arial":
                radioButton2.Checked = true;
                break;

            case "Courier New":
                radioButton3.Checked = true;
                break;
            }

            switch (FSize.ToString())
            {
            case "16":
                radioButton4.Checked = true;
                break;

            case "20":
                radioButton5.Checked = true;
                break;

            case "24":
                radioButton6.Checked = true;
                break;
            }
            textBox1.Text = Olds;
        }
コード例 #2
0
 private void clb_Files_SelectedIndexChanged(object sender, EventArgs e)
 {
     FNum  = 0;
     FSize = 0;
     foreach (string r in clb_Files.CheckedItems)
     {
         FNum  += Directory.GetFiles(/*@"D:\TAT\T.S.2\S.R.F\" +*/ r.ToString() + "\\").Length;
         FSize += (int)CalculateFolderSize(/*@"D:\TAT\T.S.2\S.R.F\" +*/ r);
     }
     lbl_size.Text = FNum.ToString() + " Files, " + FSize.ToString() + " Bytes.";
 }
コード例 #3
0
        public VerificationResult Verify()
        {
            // mild handling

            VerificationResult VR = new VerificationResult();

            VR.File = this;

            // might need to change this a bit
            if (Path != null)
            {
                VR.WasFileValid = true;

                if (Strictness == VerificationStrictness.Moderate)
                {
                    if (FSize < 0)
                    {
                        VR.WasFileValid = false;
                        return(VR);
                    }
                }
                else if (Strictness == VerificationStrictness.Strict)
                {
                    if (FSize > 0 && FSHA256 != null)
                    {
                        if (FSHA256.Length != 32)
                        {
                            VR.FailureReason = $"Invalid SHA256 hash - must be 32 bytes long, was {FSHA256.Length}!";
                            return(VR);
                        }
                    }
                    else
                    {
                        VR.FailureReason = "CriticalFile entry invalid - invalid file size or null SHA256 hash!";
                        VR.WasFileValid  = false;
                        return(VR);
                    }
                }
            }
            else
            {
                // false by default
                return(VR);
            }

            switch (Strictness)
            {
            case VerificationStrictness.Low:
                // false by default
                VR.Successful = VerifyFileExistence();

                return(VR);

            case VerificationStrictness.Moderate:
                VR.Successful = VerifyFileExistence();

                if (!VR.Successful)
                {
                    VR.FailureReason = "File does not exist!";
                    return(VR);
                }

                VR.Successful = VerifyFileSize();

                if (!VR.Successful)
                {
                    VR.FailureReason = $"File size is invalid - should be {FSize.ToString()} bytes!";
                }

                return(VR);

            case VerificationStrictness.Strict:

                VR.Successful = VerifyFileExistence();

                if (!VR.Successful)
                {
                    VR.FailureReason = "File does not exist!";
                    return(VR);
                }

                VR.Successful = VerifyFileSize();

                if (!VR.Successful)
                {
                    VR.FailureReason = $"File size is invalid - should be {FSize.ToString()} bytes!";
                    return(VR);
                }

                VR.Successful = VerifyFileSHA256();

                if (!VR.Successful)
                {
                    VR.FailureReason = $"File is corrupted or modified - please turn on DeveloperMode if you are working with source code!\n The SHA256 hash should be {FSHA256.ByteArrayToHexString()}.";
                }

                return(VR);
            }

            // someting went wrong
            return(VR);
        }