protected void LoadFile() { if (!File.Exists(FilePath)) { MessageBox.Show("Error", "Cannot Find Attached File"); return; } L2Encdec encDec = new L2Encdec(); encDec.AttachFile(FilePath); string DecryptedFile = encDec.Decrypt(); if (!File.Exists(DecryptedFile)) { MessageBox.Show("Error", "Failed to Decrypt File"); return; } String Contents = File.ReadAllText(DecryptedFile); editorText.Text = Contents; }
public void Attach(String bmpFile) { FilePath = bmpFile; filePathText.Text = FilePath; try { previewBox.Image = Image.FromFile(FilePath); IsEncrypted = false; } catch (Exception ex) { IsEncrypted = true; //Try to Encrypt L2Encdec encdec = new L2Encdec(); encdec.AttachFile(FilePath); ModifiedPath = encdec.Decrypt(); if (ModifiedPath != null || File.Exists(ModifiedPath)) { try { previewBox.Image = Image.FromFile(ModifiedPath); } catch (Exception ex2) { MessageBox.Show("Malformed BMP File", "Error"); return; } } } finally { stateLabel.Text = (IsEncrypted) ? "Encrypted" : "Decrypted"; encryptBtn.Enabled = !IsEncrypted; decryptBtn.Enabled = IsEncrypted; //Transparent Key Bitmap bitmap = ((Bitmap)previewBox.Image); bitmap.MakeTransparent(Color.FromArgb(0, 255, 0)); previewBox.Image = bitmap; } }
public void LoadFile(String filePath) { L2Encdec encrypter = new L2Encdec(); try { CurrentFilePath = filePath; CurrentFile = Path.GetFileName(filePath); currentFileLabel.Text = CurrentFile; encrypter.AttachFile(filePath); string decryptedFile = encrypter.Decrypt(); if (decryptedFile != null) { L2ASM asm = new L2ASM(); asm.AttachFile(decryptedFile); String txtFile = asm.Decrypt((Chronicle)chronicleCombo.SelectedIndex); if (txtFile != null) { ParseTextFile(txtFile); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }