public void OnAddInputClose(InputPromptClosedEventArgs arg)
 {
     if (arg.Result == DialogResult.OK)
     {
         if (IsValidCommand(arg.Text))
         {
             SettingsManager.AddNewVoiceCommand(SettingToModify, arg.Text.Trim());
             UpdateVoiceCommandList();
         }
     }
 }
示例#2
0
        private async void UseCodeButton_Click(object sender, RoutedEventArgs e)
        {
            string code = null;
            InputPromptClosedEventArgs args = await RadInputPrompt.ShowAsync(AppResources.EnterCodeTitle, vibrate : false);

            code = args.Text;
            if (code == null)
            {
                return;
            }
            byte[] byteCode;
            try
            {
                byteCode = Convert.FromBase64String(code);
            }
            catch (Exception)
            {
                MessageBox.Show(AppResources.InvalidCodeText);
                return;
            }

            string dataString = Convert.ToBase64String(DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[]) + "_noads_premium";

            // Create byte arrays to hold original, encrypted, and decrypted data.

            UTF8Encoding ByteConverter = new UTF8Encoding();

            byte[] originalData = ByteConverter.GetBytes(dataString);



            RSACryptoServiceProvider RSAalg = new RSACryptoServiceProvider(2048);

            Stream src = Application.GetResourceStream(new Uri("Assets/VBA8publicKey.xml", UriKind.Relative)).Stream;

            using (StreamReader sr = new StreamReader(src))
            {
                string text = sr.ReadToEnd();
                RSAalg.FromXmlString(text);
            }

            RSAParameters Key = RSAalg.ExportParameters(false);

            if (VerifySignedHash(originalData, byteCode, Key))
            {
                App.metroSettings.PromotionCode = code;
                MessageBox.Show(AppResources.ValidCodeText);
            }
            else
            {
                MessageBox.Show(AppResources.InvalidCodeText);
            }
        }
示例#3
0
        private async void setAlert_Click(object sender, RoutedEventArgs e)
        {
            InputPromptSettings ips = new InputPromptSettings();
            Style usernameStyle     = new System.Windows.Style(typeof(TextBox));

            usernameStyle.Setters.Add(new Setter(TextBox.InputScopeProperty, "Number"));
            ips.Field1Mode = InputMode.Text;
            string messageTitle = "Count Limit!";
            string message      = "Enter the No.of repetitions at which you want to get alerted";

            if (GlobalValues.alertCount > 0 || settings.Contains("alertCount"))
            {
                //MessageBox.Show("There is a AlertCountValue"); //Checking IT!
                string valu = string.Empty;
                if (GlobalValues.alertCount > 0)
                {
                    valu = GlobalValues.alertCount.ToString();
                }
                else
                {
                    try { valu = ((string)settings["alertCount"]); }
                    catch { }
                }
                usernameStyle.Setters.Add(new Setter(RadTextBox.TextProperty, valu));
            }
            else
            {
            }
            ips.Field1Style = usernameStyle;
            InputPromptClosedEventArgs args = await RadInputPrompt.ShowAsync(ips, messageTitle, MessageBoxButtons.OKCancel, message);

            if (args.Result == DialogResult.OK)
            {
                try { GlobalValues.alertCount = Convert.ToInt32(args.Text); }
                catch { }
            }
        }