private void DecryptLabel_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
if (isWorking)
return;
SetForegroundWindow(this.Handle);
using (Password pass = new Password())
{
if (pass.ShowDialog(this) == DialogResult.OK)
{
string p = pass.textBox1.Text.ToString();
isWorking = true;
cryptoThread = new Thread(() => DecryptList(e, p));
cryptoThread.Start();
}
pass.Dispose();
}
}
private void elevate()
{
Process elevated = new Process();
ProcessStartInfo proc = new ProcessStartInfo();
proc.UseShellExecute = true;
proc.WorkingDirectory = Environment.CurrentDirectory;
proc.FileName = Application.ExecutablePath;
proc.Verb = "runas";
elevated.StartInfo = proc;
try
{
elevated.Start();
this.Invoke((MethodInvoker)delegate { Environment.Exit(0); });
}
catch(Exception e)
{
this.Invoke((MethodInvoker)delegate { MessageBox.Show("Elevation Failed","LiteLock"); });
throw e;
}
}
private List<string> getFilepaths(string[] paths)
{
List<string> filepaths = new List<string>();
foreach (string fileLoc in paths)
{
if (File.Exists(fileLoc))
{
filepaths.Add(fileLoc);
}
else if (Directory.Exists(fileLoc))
{
this.Invoke((MethodInvoker)delegate {
this.currentFileLabel.Text = "Enumerating Directory: " + fileLoc;
});
try
{
filepaths.AddRange(Directory.EnumerateFiles(fileLoc, "*.*", SearchOption.AllDirectories));
}
catch (UnauthorizedAccessException e)
{
MessageBox.Show("LiteLock needs Administrative Access to Enumerate this Directory." + Environment.NewLine + Environment.NewLine +
"This is not currently supported - Please move the files to a readable location."
,"Elevation Required");
//elevate();
throw e;
}
}
}
return filepaths;
}
private void EncryptLabel_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
}
private void DecryptLabel_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.None;
}
private void Locker_FormClosing(object sender, FormClosingEventArgs e)
{
if (!isClosing)
{
isClosing = true;
try
{
if (cryptoThread.IsAlive)
{
e.Cancel = true;
this.Text = "Stopping Encryption/Decryption...";
Thread.Sleep(1000);
}
}
catch { }
}
else
{
try
{
Properties.Settings.Default.overwriteBox = this.overwriteOriginal.Checked;
Properties.Settings.Default.Save();
}
catch { }
}
}
}
}