private void Recieve(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { // Collecting the characters received to our 'buffer' (string). string received_data = "AAA"; long start_time = 0; bool isError = false; try { received_data = serialMonitor.ReadTo(selectedDelimiter); } catch { isError = true; } if (isError == false) { if (_microStopwatch.IsRunning == false) { _microStopwatch.Start(); Dispatcher.BeginInvoke(myDelegate, start_time, received_data); } else { Dispatcher.BeginInvoke(myDelegate, _microStopwatch.ElapsedMicroseconds, received_data); } } }
private void FDEncryptButton_Click(object sender, EventArgs e) { MicroLibrary.MicroStopwatch utimer = new MicroLibrary.MicroStopwatch(); Image inputImage = PlainText_Image.Image; String path = OpenImageDialog.FileName; //Bitmap secretImage = ImageEncryption.ImageEncryption.GenerateSecretImage(inputImage.Size); SecretImageSelection sis = new SecretImageSelection(inputImage as Bitmap); sis.ShowDialog(); if (sis.DialogResult != System.Windows.Forms.DialogResult.OK) { return; } Bitmap secretImage = sis.SecretImage; FluidDynamicsKey fdKey = new FluidDynamicsKey(3.717, 0.55, 3.8222, 0.18, 199, 17, 32, secretImage); fd = new FluidDynamicsEncryptor((Bitmap)inputImage, fdKey); fd.Filename = path.Substring(path.LastIndexOf('\\') + 1); utimer.Start(); fd.Encrypt(); utimer.Stop(); long mem = proc.PrivateMemorySize64; EncryptionFinishedActions(fd.CiphertextImage, utimer.ElapsedMicroseconds, mem); }
/// <summary> /// Loads a file with recorded sensor data and replays it through the observerable interface /// Note that this function blocks, so call it in a different thread /// </summary> /// <param name="filename">The file to play</param> public void replayFile(string filename) { loadFile(filename); mPreciseCounter.Start(); while (mCurrentIndex < mMaxIndex) { SensorDataEntry data = mData.mDataList[mCurrentIndex]; if (mPreciseCounter.Elapsed.CompareTo(data.timeSpan) >= 0) { NotifyObservers(data); mCurrentIndex++; } Thread.SpinWait(500); } ; mPreciseCounter.Reset(); mMaxIndex = 0; mCurrentIndex = 0; mData.mDataList.Clear(); }
private void CAEncryptButton_Click(object sender, EventArgs e) { MicroLibrary.MicroStopwatch utimer = new MicroLibrary.MicroStopwatch(); Image inputImage = PlainText_Image.Image; String path = OpenImageDialog.FileName; CellularAutomataKey caKey = new CellularAutomataKey(42, 53, 15); ca = new CellularAutomataEncryptor((Bitmap)inputImage, caKey); ca.Filename = path.Substring(path.LastIndexOf('\\') + 1); utimer.Start(); ca.Encrypt(); utimer.Stop(); long mem = proc.PrivateMemorySize64; EncryptionFinishedActions(ca.CiphertextImage, utimer.ElapsedMicroseconds, mem); }
private void BioEncryptButton_Click(object sender, EventArgs e) { MicroLibrary.MicroStopwatch utimer = new MicroLibrary.MicroStopwatch(); Image inputImage = PlainText_Image.Image; String path = OpenImageDialog.FileName; //Bitmap secretImage = ImageEncryption. // ImageEncryption.GenerateSecretImage(inputImage.Size); SecretImageSelection sis = new SecretImageSelection(inputImage as Bitmap); sis.ShowDialog(); if (sis.DialogResult != System.Windows.Forms.DialogResult.OK) { return; } Bitmap secretImage = sis.SecretImage; // Key from the paper. BioInspiredKey bioKey = new BioInspiredKey( 3.7158, 0.11, 3.89858, 0.25, 3.76158, 0.35, 3.8458, 0.552, secretImage); bio = new BioInspiredEncryptor((Bitmap)inputImage, bioKey); bio.Filename = path.Substring(path.LastIndexOf('\\') + 1); utimer.Start(); bio.Encrypt(); utimer.Stop(); long mem = proc.PrivateMemorySize64; EncryptionFinishedActions(bio.CiphertextImage, utimer.ElapsedMicroseconds, mem); }