コード例 #1
0
        private void Test2()
        {
            MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox("Test2");

            msgBox.Caption = "Question";
            msgBox.Text    = "Do you want to save the data?";

            MessageBoxExButton btnYes = new MessageBoxExButton();

            btnYes.Text     = "Yes";
            btnYes.Value    = "Yes";
            btnYes.HelpText = "Save the data";

            MessageBoxExButton btnNo = new MessageBoxExButton();

            btnNo.Text     = "No";
            btnNo.Value    = "No";
            btnNo.HelpText = "Do not save the data";

            msgBox.AddButton(btnYes);
            msgBox.AddButton(btnNo);

            msgBox.Icon = MessageBoxExIcon.Question;

            msgBox.SaveResponseText  = "Don't ask me again";
            msgBox.AllowSaveResponse = true;

            msgBox.Font = new Font("Tahoma", 8);

            string result = msgBox.Show();
        }
コード例 #2
0
        public static string ShowErrorOld(string text, MessageBoxButtons buttons)
        {
            MessageBoxEx messageBox = MessageBoxExManager.CreateMessageBox(null);

            messageBox.Text    = text;
            messageBox.Caption = "Error";
            messageBox.AddButtons(MessageBoxButtons.OK);
            messageBox.Icon = MessageBoxExIcon.Error;
            return(messageBox.Show());
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="triggerName"></param>
        /// <returns></returns>
        static public string Trigger(string triggerName)
        {
            // Don't dispose the msgbox here - we store it and re-use it. Will be disposed in our Dispose() method.
            var msgBox = MessageBoxExManager.GetMessageBox(triggerName);

            if (msgBox == null)
            {
                throw new ApplicationException("Could not find the message box with trigger name = " + triggerName);
            }
            return(msgBox.Show());
        }
コード例 #4
0
        public void Test5()
        {
            MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox(null);

            msgBox.Caption = "Question";
            msgBox.Text    = "Voulez-vous sauver les données ?";
            msgBox.AddButtons(MessageBoxButtons.YesNoCancel);
            msgBox.Icon = MessageBoxExIcon.Question;

            msgBox.Show();
        }
コード例 #5
0
        /// <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
            }
        }
コード例 #6
0
        public void Test6()
        {
            MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox("test");

            msgBox.Caption = "Information";
            msgBox.AddButtons(MessageBoxButtons.OK);

            msgBox.Text = "The following items are defined:\nItem 1\nItem 2\nItem 3\nItem 4\nItem 5\nItem 6\nItem 7\nItem 8\nItem 9\nItem10\n";
            msgBox.Show();

            msgBox.Text = "Items:\nItem 1\nItem 2\nItem 3\nItem 4\nItem 5\nItem 6\nItem 7\nItem 8\nItem 9\nItem10\n";
            msgBox.Show();
        }
コード例 #7
0
        private void Test()
        {
            MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox("Test");

            msgBox.Caption = "Question";
            msgBox.Text    = "Do you want to save the data?";

            msgBox.AddButtons(MessageBoxButtons.YesNo);
            msgBox.Icon = MessageBoxExIcon.Question;

            msgBox.SaveResponseText  = "Don't ask me again";
            msgBox.AllowSaveResponse = true;

            msgBox.Font = new Font("Tahoma", 8);

            string result = msgBox.Show();
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: CustomMessageBox.cs プロジェクト: nagyist/datavault
        private static CustomMessageBoxDialogResult ShowCore(IWin32Window owner, String text, String caption, CustomMessageBoxButtons buttons, CustomMessageBoxIcon icon, CustomMessageBoxDefaultButton defaultButton)
        {
            var mbex = MessageBoxExManager.CreateMessageBox(Guid.NewGuid().ToString());

            mbex.AllowSaveResponse = false;
            mbex.UseSavedResponse  = false;
            mbex.Timeout           = -1;

            mbex.Text    = text;
            mbex.Caption = caption;
            buttons.Apply(mbex);
            icon.Apply(mbex);
            defaultButton.Apply(mbex);

            var result = mbex.Show(owner);

            return(new CustomMessageBoxDialogResult(mbex, result));
        }
コード例 #10
0
        private void Test4()
        {
            MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox(null);

            msgBox.Caption = "Question";
            msgBox.Text    = "Do you want to save the data?";

            msgBox.AddButtons(MessageBoxButtons.YesNo);
            msgBox.Icon = MessageBoxExIcon.Question;

            //Wait for 30 seconds for the user to respond
            msgBox.Timeout       = 30000;
            msgBox.TimeoutResult = TimeoutResult.Timeout;

            string result = msgBox.Show();

            if (result == MessageBoxExResult.Timeout)
            {
                //Take action to handle the case of timeouts
            }
        }
コード例 #11
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);
                }
            }
        }
コード例 #12
0
        /// <summary/>
        public void DefineMessageBox(string triggerName, string caption, string text,
                                     bool displayDontShowAgainButton, string iconName)
        {
            // Don't dispose msgBox here. MessageBoxExManager holds a reference to it and will dispose it eventually.
            MessageBoxEx msgBox;

            try
            {
                msgBox = MessageBoxExManager.CreateMessageBox(triggerName);
            }
            catch (ArgumentException)
            {
                return;
                //this message box library throws an exception if you have already defined this triggerName.
                //for us, this might just mean that you opened another window the same kind or something like that.
            }

            msgBox.Caption           = caption;
            msgBox.Text              = text;
            msgBox.SaveResponseText  = xCoreInterfaces.DonTShowThisAgain;
            msgBox.AllowSaveResponse = displayDontShowAgainButton;
            msgBox.UseSavedResponse  = displayDontShowAgainButton;
            switch (iconName)
            {
            default:
                msgBox.CustomIcon = GetIcon(iconName);
                //should be a bmp in the resources
                break;

            case "info":
                msgBox.Icon = MessageBoxExIcon.Information;
                break;

            case "exclamation":
                msgBox.Icon = MessageBoxExIcon.Exclamation;
                break;
            }
        }
コード例 #13
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + ". ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                WriteSavedResponses();
                if (s_singletonMessageBoxExManager.Count == 1)
                {
                    MessageBoxExManager.DisposeAllMessageBoxes();
                }

                s_singletonMessageBoxExManager.Remove(m_appName);
            }

            IsDisposed = true;
        }
コード例 #14
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);
        }