Пример #1
0
        private void EncryptBtn_Click(object sender, EventArgs e)
        {
            _watch.Reset();
            if (!File.Exists(FilePathTxt.Text))
            {
                MessageBox.Show(Resources.FileNotFoundMessage);
                return;
            }

            ChangeStates(false);
            StatusLbl.Text = Resources.EncryptionInProgressMessage;
            Task.Run(() =>
            {
                _watch.Start();
                ICrypt.BmpEncrypt(File.ReadAllBytes(FilePathTxt.Text))
                .Save(Path.GetDirectoryName(FilePathTxt.Text) + $"\\encrypted-{DateTime.Now.Ticks}.png");
                _watch.Stop();
                Invoke(new MethodInvoker(() =>
                {
                    ChangeStates(true);
                    StatusLbl.Text = string.Format(Resources.EncryptionSuccessMessage, _watch.ElapsedMilliseconds);
                }));
            });
        }