Esempio n. 1
0
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            if (_microStopwatch.IsRunning)
            {
                _microStopwatch.Stop();
            }

            this.Close();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Redis Connection
            ConnectionMultiplexer redis   = ConnectionMultiplexer.Connect("K1D-REDIS-CLST.ksg.int,password=ZECjTH9cx24ukQA");
            IDatabase             redisDB = redis.GetDatabase();

            // GraphQL Connection
            GraphQLClient graphQL = new GraphQLClient("https://globaldeviceservice.dev.koreone/api/v1");

            // Stopwatch
            MicroLibrary.MicroStopwatch stopwatch = new MicroLibrary.MicroStopwatch();

            // Time the query 10 times
            string query = "query {" +
                           "   deviceById(deviceId: 1) {" +
                           "       description" +
                           "   }" +
                           "}" +
                           "# Your Name Here";

            redisDB.KeyDelete(query);
            for (int i = 0; i < 20; i++)
            {
                stopwatch.Restart();
                do_query_with_caching(query, redisDB, graphQL);
                stopwatch.Stop();
                Console.WriteLine("Execution #" + i.ToString() + ": " + stopwatch.ElapsedMicroseconds + "µs");
            }
        }
        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);
        }
        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 play()
        {
            if (mCurrentState == DataPlayerState.Uninitialized)
            {
                throw new BadJooJooException("Can't start playing data if uninitialized");
            }

            mCurrentState = DataPlayerState.Playing;

            mPreciseCounter.Start();
            while ((mCurrentIndex < mMaxIndex) && mCurrentState == DataPlayerState.Playing)
            {
                SensorDataEntry data = mData.mDataList[mCurrentIndex];
                if (mPreciseCounter.Elapsed.CompareTo(data.timeSpan - mOffsetSpan) >= 0)
                {
                    NotifyObservers(data);
                    mCurrentIndex++;
                }
                Thread.SpinWait(500);
            }
            ;

            Logger.Info("Player leaving while loop");
            if (mCurrentIndex >= mMaxIndex)
            {
                mPreciseCounter.Reset();
                //mMaxIndex = 0;
                mCurrentIndex = 0;
                mCurrentState = DataPlayerState.Finished;
                mOffsetSpan   = TimeSpan.Zero;
                Logger.Info("Player leaving beause current index > max");
                return;
            }

            if (mCurrentState == DataPlayerState.Paused)
            {
                Logger.Info("Player leaving beause state change to pause");
                mPreciseCounter.Stop();
                return;
            }
        }
        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);
        }