private KryptonMessageBox(string text, string caption,
                                  MessageBoxButtons buttons, MessageBoxIcon icon,
                                  MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
                                  HelpInfo helpInfo)
        {
            // Store incoming values
            _text = text;
            _caption = caption;
            _buttons = buttons;
            _icon = icon;
            _defaultButton = defaultButton;
            _options = options;
            _helpInfo = helpInfo;

            // Create the form contents
            InitializeComponent();

            // Update contents to match requirements
            UpdateText();
            UpdateIcon();
            UpdateButtons();
            UpdateDefault();
            UpdateHelp();

            // Finally calculate and set form sizing
            UpdateSizing();
        }
Exemple #2
0
        private static DialogResult ShowCore(IWin32Window owner, string text, string caption,
                                             MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton,
                                             MessageBoxOptions options, HelpInfo hpi)
        {
            DialogResult result = DialogResult.None;

            try
            {
                PushHelpInfo(hpi);
                result = ShowCore(owner, text, caption, buttons, icon, defaultButton, options, true);
            }
            finally
            {
                PopHelpInfo();
            }
            return(result);
        }
Exemple #3
0
        string GetHelpMessage(HelpInfo helpInfo)
        {
            if (helpInfo == null)
                return null;

            return string.Format(_helpMessageFormat, helpInfo.DisplayName);
        }
Exemple #4
0
        /// <summary>
        /// Adds the help for a control.
        /// </summary>
        /// <param name="control">The control to add the help for.</param>
        /// <param name="displayName">The name to display in the status bar.</param>
        /// <param name="wikiPage">The wiki page to navigate to.</param>
        void AddInternal(object control, string displayName, string wikiPage)
        {
            _helpInfos[control] = new HelpInfo { DisplayName = displayName, WikiPage = wikiPage };

            SetEventListeners(control, false);
            SetEventListeners(control, true);
        }
Exemple #5
0
 /// <summary>
 ///  Displays a message box with specified text, caption, style, Help file Path and HelpNavigator for IWin32Window.
 /// </summary>
 public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
                                 MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator)
 {
     HelpInfo hpi = new HelpInfo(helpFilePath, navigator);
     return ShowCore(owner, text, caption, buttons, icon, defaultButton, options, hpi);
 }
Exemple #6
0
 /// <summary>
 ///  Displays a message box with specified text, caption, style, Help file Path and keyword.
 /// </summary>
 public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
                                 MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword)
 {
     HelpInfo hpi = new HelpInfo(helpFilePath, keyword);
     return ShowCore(null, text, caption, buttons, icon, defaultButton, options, hpi);
 }
        private static void PopHelpInfo() {

             // we roll our own stack here because we want a pretty lightweight implementation.
             // usually there's only going to be one message box shown at a time.  But if
             // someone shows two message boxes (say by launching them via a WM_TIMER message)
             // we've got to gracefully handle the current help info.
             if (helpInfoTable == null) {
                Debug.Fail("Why are we being called when there's nothing to pop?");
                
             } 
             else {
                if (helpInfoTable.Length == 1) {
                    helpInfoTable = null;
                }
                else {
                   int newCount = helpInfoTable.Length -1;
                   HelpInfo[] newTable = new HelpInfo[newCount];
                   Array.Copy(helpInfoTable, newTable, newCount);
                   helpInfoTable = newTable;
                
                }
             }
                
        }
        private static DialogResult InternalShow(IWin32Window owner,
                                                 string text, string caption,
                                                 MessageBoxButtons buttons, 
                                                 MessageBoxIcon icon,
                                                 MessageBoxDefaultButton defaultButton, 
                                                 MessageBoxOptions options,
                                                 HelpInfo helpInfo)
        {
            // Check if trying to show a message box from a non-interactive process, this is not possible
            if (!SystemInformation.UserInteractive && ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) == 0))
                throw new InvalidOperationException("Cannot show modal dialog when non-interactive");

            // Check if trying to show a message box from a service and the owner has been specified, this is not possible
            if ((owner != null) && ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) != 0))
                throw new ArgumentException("Cannot show message box from a service with an owner specified", "options");

            // Check if trying to show a message box from a service and help information is specified, this is not possible
            if ((helpInfo != null) && ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) != 0))
                throw new ArgumentException("Cannot show message box from a service with help specified", "options");

            // If help information provided or we are not a service/default desktop application then grab an owner for showing the message box
            IWin32Window showOwner = null;
            if ((helpInfo != null) || ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) == 0))
            {
                // If do not have an owner passed in then get the active window and use that instead
                if (owner == null)
                    showOwner = Control.FromHandle(PI.GetActiveWindow());
                else
                    showOwner = owner;
            }

            // Show message box window as a modal dialog and then dispose of it afterwards
            using (KryptonMessageBox kmb = new KryptonMessageBox(text, caption, buttons, icon, defaultButton, options, helpInfo))
            {
                if (showOwner == null)
                    kmb.StartPosition = FormStartPosition.CenterScreen;
                else
                    kmb.StartPosition = FormStartPosition.CenterParent;

                return kmb.ShowDialog(showOwner);
            }
        }
 private static DialogResult ShowCore(IWin32Window owner, string text, string caption,   
                              MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton,
                              MessageBoxOptions options, HelpInfo hpi) {
     DialogResult result = DialogResult.None;
     try {
         PushHelpInfo(hpi);
         result = ShowCore(owner, text, caption, buttons, icon, defaultButton, options, true);
     }
     finally {
         PopHelpInfo();
     }
     return result;
     
 }
        /// <include file='doc\MessageBox.uex' path='docs/doc[@for="MessageBox.Show20"]/*' />
        /// <devdoc>
        ///    <para>
        ///      Displays a message box with specified text, caption, style, Help file Path ,HelpNavigator and object for a IWin32Window.
        ///    </para>
        /// </devdoc>
        public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, 
                                        MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param) {

            HelpInfo hpi = new HelpInfo(helpFilePath, navigator, param);
      
            return ShowCore(owner, text, caption, buttons, icon, defaultButton, options, hpi);
        }
        /// <include file='doc\MessageBox.uex' path='docs/doc[@for="MessageBox.Show17"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Displays a message box with specified text, caption, style, Help file Path and HelpNavigator.
        ///    </para>
        /// </devdoc>
        public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, 
                                        MessageBoxDefaultButton defaultButton, MessageBoxOptions options,string helpFilePath, HelpNavigator navigator) {

            HelpInfo hpi = new HelpInfo(helpFilePath, navigator);
            return ShowCore(null, text, caption, buttons, icon, defaultButton, options, hpi);
        }
        /// <include file='doc\MessageBox.uex' path='docs/doc[@for="MessageBox.Show16"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Displays a message box with specified text, caption, style, Help file Path and keyword for a IWin32Window.
        ///    </para>
        /// </devdoc>
        public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, 
                                        MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword) {

            HelpInfo hpi = new HelpInfo(helpFilePath, keyword);
            return ShowCore(owner, text, caption, buttons, icon, defaultButton, options, hpi);
        }
        private static void PushHelpInfo(HelpInfo hpi) {
            
            // we roll our own stack here because we want a pretty lightweight implementation.
            // usually there's only going to be one message box shown at a time.  But if
            // someone shows two message boxes (say by launching them via a WM_TIMER message)
            // we've got to gracefully handle the current help info.

            int lastCount = 0;
            HelpInfo[] newTable; 
   
            if (helpInfoTable == null) {
               newTable = new HelpInfo[lastCount+1];
            }
            else {       
                // if we already have a table - allocate a new slot
                lastCount = helpInfoTable.Length;
                newTable = new HelpInfo[lastCount+1];
                Array.Copy(helpInfoTable, newTable, lastCount);
            }
            newTable[lastCount] = hpi;
            helpInfoTable = newTable;
        
        }