/// <summary>
        /// Test case which exposed the AutoScale bug, this was submitted by Harry Stein
        /// </summary>
        private void Test3()
        {
            // as an experiment, I moved these from class members to local members

            // to see if it helps -- it didn't -- but it helps show you nothing else

            // is going on!

            MessageBoxEx m_msgBoxSummary1 = null;

            MessageBoxExButton m_btnYes = null;

            // Tahoma 8.25 in Ex originally

            m_msgBoxSummary1 = MessageBoxExManager.CreateMessageBox("Summary1");

            m_btnYes = new MessageBoxExButton();

            string m_sPROGRAM_NAME = "Possrv.Debug Merchant Parser";
            string m_sVersion      = "1.00A";;

            m_msgBoxSummary1.Caption = m_sPROGRAM_NAME + " " + m_sVersion;

            // fyi: m_sPROGRAM_NAME = "Possrv.Debug Merchant Parser";

            // and m_sVersion = "1.00A";

            m_msgBoxSummary1.Icon = MessageBoxExIcon.Information;

            m_btnYes.Text = "Okay";

            m_btnYes.Value = "OK";

            m_msgBoxSummary1.AddButton(m_btnYes);

            String sResultM =

                "Hello this is a reasonably long message with 1234 56789";

            m_msgBoxSummary1.Font = new Font("Lucida Console", 8);

            m_msgBoxSummary1.Text = sResultM;

            String sResult3 = m_msgBoxSummary1.Show();  // first call

            sResult3 = m_msgBoxSummary1.Show();         // second call

            if (sResult3 == "" || (1 + 1 == 2))
            {
                return;                             // quiet the compiler
            }
        }
Exemple #2
0
        private void Encrypt()
        {
            foreach (string file in SelectedItemPaths)
            {
                byte[] key = new byte[16];
                new RNGCryptoServiceProvider().GetBytes(key);
                byte[] enc = Program.EncryptBytes(File.ReadAllBytes(file), key, out byte[] iv);

                File.WriteAllBytes(file, enc);

                if (enc.Length != 0)
                {
                    string strKey = Program.GetByteArrayAsIs(key);

                    MessageBoxEx bx = MessageBoxExManager.CreateMessageBox("success");

                    MessageBoxExButton btnClipbd = new MessageBoxExButton {
                        Text           = "Copy to clipboard",
                        Value          = "cpyclip",
                        IsCancelButton = false,
                        Click          = () => {
                            Clipboard.SetText(strKey);
                        }
                    };

                    bx.AddButton("OK", "OK");
                    bx.AddButton(btnClipbd);

                    bx.AllowSaveResponse = false;
                    bx.Text    = "Key:\n" + strKey;
                    bx.Caption = $"Success: {file}!";
                    bx.Icon    = MessageBoxExIcon.Information;
                }
                else
                {
                    MessageBox.Show("Error while encrypting :(", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private MessageBoxEx CreateMessageBox(string name)
        {
            MessageBoxEx mbox = MessageBoxExManager.CreateMessageBox(name);

            mbox.Caption           = txtCaption.Text;
            mbox.Text              = txtMessage.Text;
            mbox.AllowSaveResponse = chbAllowSaveResponse.Checked;
            mbox.SaveResponseText  = txtSaveResponse.Text;

            foreach (MessageBoxExButton button in GetButtons())
            {
                mbox.AddButton(button);
            }

            mbox.Icon = GetIcon();
            return(mbox);
        }
Exemple #4
0
        private bool makeDefaultEditor()
        {
            try
            {
                RegistryKey keyExt = Registry.ClassesRoot.CreateSubKey(".kms");

                keyExt.SetValue("", "KEYMAGIC.KMS");

                RegistryKey keyKMS = Registry.ClassesRoot.CreateSubKey("KEYMAGIC.KMS");
                keyKMS.SetValue("", "KeyMagic keyboard layout script file");

                RegistryKey openCommand = keyKMS.CreateSubKey("shell\\Open\\command");

                string command = string.Format("\"{0}\" \"%1\"", Environment.GetCommandLineArgs()[0]);
                openCommand.SetValue("", command, RegistryValueKind.ExpandString);

                string      icon        = string.Format("\"{0}\",0", Environment.GetCommandLineArgs()[0]);
                RegistryKey defaultIcon = keyKMS.CreateSubKey("DefaultIcon");
                defaultIcon.SetValue("", icon, RegistryValueKind.ExpandString);

                openCommand.Close();
                keyKMS.Close();

                SHChangeNotify(0x08000000, 0, UIntPtr.Zero, UIntPtr.Zero);

                keyExt.Close();
            }
            catch (UnauthorizedAccessException uax)
            {
                if (Properties.Settings.Default.DoNotAskForAdmin == true)
                {
                    return(false);
                }


                MessageBoxEx msgBox = MessageBoxExManager.GetMessageBox("access denied");
                if (msgBox == null)
                {
                    msgBox         = MessageBoxExManager.CreateMessageBox("access denied");
                    msgBox.Caption = "Access denied";
                    msgBox.Text    = string.Format("{0}\n{1}", uax.Message, "Do you want to run the KMS Editor as administrator.");
                    msgBox.Icon    = MessageBoxExIcon.Exclamation;

                    msgBox.AddButton("OK", "OK");
                    msgBox.AddButton("Not Now", "NN");
                    msgBox.AddButton("Don't ask again", "DONT");
                }
                switch (msgBox.Show(this))
                {
                case "DONT":
                    Properties.Settings.Default.ForceDefaultEditor = false;
                    break;

                case "OK":
                    RunAsAdmin(string.Empty);
                    break;
                }
                return(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            return(true);
        }