private void protectFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Title = "Protect file"; open.Filter = "Media file|*.mp4"; open.Multiselect = false; DialogResult rst = open.ShowDialog(this); if (rst == DialogResult.OK) { FileInfo file = new FileInfo(open.FileName); if (!MediaHash.Protect(file)) { MessageBox.Show(this, Properties.Resources.protect_fail, Properties.Resources.protect_title, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(this, Properties.Resources.protect_success, Properties.Resources.protect_title, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private bool ValidateMedia(FileInfo file) { bool allow = true; // checking if the extension is container of our choice (mp4) if (file.Extension.Equals(".mp4", StringComparison.OrdinalIgnoreCase)) { try { switch (MediaHash.Validate(file)) { case MediaProtection.Unknow: // checking if file not protected if (MessageBox.Show(this, Properties.Resources.err_msg_unknow, Properties.Resources.err_title_unknow, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { allow = false; } break; case MediaProtection.Modified: // checking if the file is modified if (MessageBox.Show(this, Properties.Resources.err_msg_modified, Properties.Resources.err_title_modified, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { allow = false; } break; case MediaProtection.Protected: // good to go break; } } catch { MessageBox.Show(this, Properties.Resources.validate_error_msg, Properties.Resources.validate_error, MessageBoxButtons.OK, MessageBoxIcon.Error); allow = false; } } return(allow); }
private void validateFileToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Title = "Validate file"; open.Filter = "Media file|*.mp4"; open.Multiselect = false; DialogResult rst = open.ShowDialog(this); if (rst == DialogResult.OK) { FileInfo file = new FileInfo(open.FileName); switch (MediaHash.Validate(file)) { case MediaProtection.Unknow: MessageBox.Show(this, Properties.Resources.validate_msg_unknow, Properties.Resources.validate_title_unknow, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case MediaProtection.Modified: MessageBox.Show(this, Properties.Resources.validate_msg_modified, Properties.Resources.validate_title_modified, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case MediaProtection.Protected: MessageBox.Show(this, Properties.Resources.validate_msg_protected, Properties.Resources.validate_title_protected, MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } }