private void MyClickedItemListener(object sender, RadioGroup.CheckedChangeEventArgs e)
        {
            // Handle errors through java Exceptions
            ErrorManager.EnableExceptions(true);

            try
            {
                // get the current settings from the BarcodeManager
                configuration = ScannerProperties.Edit(manager);
                // disables KeyboardWedge
                configuration.KeyboardWedge.Enable.Set(false);
                // enable wedge intent
                configuration.IntentWedge.Enable.Set(true);

                switch (e.CheckedId)
                {
                case Resource.Id.radioBroadcast:
                    // set wedge intent action and category
                    configuration.IntentWedge.Action.Set(ACTION_BROADCAST_RECEIVER);
                    configuration.IntentWedge.Category.Set(CATEGORY_BROADCAST_RECEIVER);
                    // set wedge intent delivery through broadcast
                    configuration.IntentWedge.DeliveryMode.Set(IntentDeliveryMode.Broadcast);
                    configuration.Store(manager, false);
                    break;

                case Resource.Id.radioStartActivity:
                    // set wedge intent action and category
                    configuration.IntentWedge.Action.Set(ACTION);
                    configuration.IntentWedge.Category.Set(CATEGORY);
                    // intent delivery startActivity
                    configuration.IntentWedge.DeliveryMode.Set(IntentDeliveryMode.StartActivity);
                    configuration.Store(manager, false);
                    break;
                }
            }
            catch (Exception exception) //catch any errors that occured.
            {
                if (exception is ConfigException)
                {
                    ConfigException ex = (ConfigException)exception;
                    Log.Info(this.GetType().Name, "Error while retrieving/setting properties:" + exception.Message);
                }
                else if (exception is DecodeException)
                {
                    DecodeException ex = (DecodeException)exception;
                    Log.Info(this.GetType().Name, "Error while retrieving/setting properties:" + exception.Message);
                }
                else
                {
                    Log.Info(this.GetType().Name, "Error while retrieving/setting properties:" + exception.Message);
                }
            }
        }
Exemplo n.º 2
0
        public void Lsb_Encrypt_With_Key_Decrypt_Without_Key_Should_Throws_Error()
        {
            var fileBytes = System.IO.File.ReadAllBytes(FileHelper.GetPathToSecretData());

            using (var stego = new Stego(FileHelper.GetPathToImage()))
            {
                stego.SetSecretData(fileBytes);
                stego.SetSettings(new StegoCore.Model.Settings
                {
                    Key = "aaa"
                });
                var imageWithSecret = stego.Embed(AlgorithmEnum.Lsb);
                stego.SetImage(imageWithSecret);
                stego.SetSettings(null);

                DecodeException ex = Assert.Throws <DecodeException>(() => { stego.Decode(AlgorithmEnum.Lsb); });
            }
        }