// Adds label to RequestQueueView private void AddLabelToRequestQueueView(EncryptionRequest request) { var label = new Label { Content = request.FileLocation }; RequestQueueView.Children.Add(label); }
private void DragStackPanel_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { // Get all files string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); // Push to queue foreach (var file in files) { var request = new EncryptionRequest(file, GetKey()); // Add to queue EncryptorManager.RequestEncrypt(request); // Add a label AddLabelToRequestQueueView(request); } } }
// Take a request and manage its execution // Returns exit code indicating success of operation private static int ExecuteSingleEncryption(EncryptionRequest request) { // Expected arguments string[] arguments = { "-key", request.Key, request.FileLocation }; // Standard process properties ProcessStartInfo setup = new ProcessStartInfo { FileName = EXECUTABLE_FILE, Arguments = string.Join(" ", arguments), RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }; // Start VFAES var process = System.Diagnostics.Process.Start(setup); // Wait for exit and return success process.WaitForExit(); return(process.ExitCode); }
// Add an encryption request public static void RequestEncrypt(EncryptionRequest request) { RequestQueue.Add(request); }