Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WinFormsFormMenuBuilder"/> class.
        /// </summary>
        /// <param name="mainItem">The main menu item to the add the open forms within the <see cref="Application"/>.</param>
        /// <param name="tabbedTextControl">The main form's <see cref="ScintillaTabbedTextControl"/> class instance.</param>
        public TabMenuBuilder(ToolStripMenuItem mainItem, ScintillaTabbedTextControl tabbedTextControl)
        {
            // save the Tab menu for further use..
            this.mainItem = mainItem;

            this.tabbedTextControl = tabbedTextControl;

            // subscribe to the Tab menu's opening event..
            mainItem.DropDownOpening += MainItem_DropDownOpening;
        }
Пример #2
0
        /// <summary>
        /// Shows the form as a modal dialog box with the specified owner.
        /// </summary>
        /// <param name="owner">Any object that implements <see cref="T:System.Windows.Forms.IWin32Window" /> that represents the top-level window that will own the modal dialog box. </param>
        /// <param name="tabbedTextControl">An instance of the <see cref="ScintillaTabbedTextControl"/> control in which the current new document should be renamed.</param>
        /// <returns>A new file name for a new file if successful; otherwise null.</returns>
        /// <exception cref="T:System.ArgumentException">The form specified in the <paramref name="owner" /> parameter is the same as the form being shown.</exception>
        /// <exception cref="T:System.InvalidOperationException">The form being shown is already visible.-or- The form being shown is disabled.-or- The form being shown is not a top-level window.-or- The form being shown as a dialog box is already a modal form.-or-The current process is not running in user interactive mode (for more information, see <see cref="P:System.Windows.Forms.SystemInformation.UserInteractive" />).</exception>
        public static string ShowDialog(IWin32Window owner, ScintillaTabbedTextControl tabbedTextControl)
        {
            if (tabbedTextControl.CurrentDocument == null)
            {
                return(null);
            }

            using (var dialog = new FormDialogRenameNewFile())
            {
                dialog.TabbedTextControl  = tabbedTextControl;
                dialog.tbCurrentName.Text = tabbedTextControl.CurrentDocument.FileName;
                dialog.tbNewName.Text     = tabbedTextControl.CurrentDocument.FileName;
                if (dialog.ShowDialog(owner) == DialogResult.OK)
                {
                    return(dialog.tbNewName.Text);
                }
            }

            return(null);
        }