/// <summary> /// Called when DropDown is Closing. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="ToolStripDropDownClosingEventArgs"/> instance containing the event data.</param> void OnDropDownClosing(object sender, ToolStripDropDownClosingEventArgs e) { if (e != null && e.CloseReason != null && e.CloseReason == ToolStripDropDownCloseReason.ItemClicked && ClassType == DialogClassType.Dialog) { if (ClickedItem != null && ClickedItem.ClassType == DialogClassType.DialogEntry) { DialogEntry_ToolStripMenuItem entry = (DialogEntry_ToolStripMenuItem)ClickedItem; if (entry != null && entry.Type != DialogEntryType.Activation) { e.Cancel = true; } } } }
/// <summary> /// Builds the Dialog_ToolStripMenuItem structure. Calls it self recursive with a Submenu entry. /// </summary> /// <param name="dlg">Dialog to be converted</param> /// /// <param name="IntegrateQuestions">IntegrateQuestions to integrate or leave out QuestionTypes</param> /// <returns>Dialog_ToolStripMenuItem</returns> private static Dialog_ToolStripMenuItem buildDialogToolStripMenuItemStructure(Dialog dlg, Boolean IntegrateQuestions = true) { Dialog_ToolStripMenuItem menuStripItem = null; if (dlg != null) { if (!IntegrateQuestions && dlg.Type == DialogType.Question) { Console.Out.WriteLine(dlg.Title + " is a Question!"); } else { menuStripItem = new Dialog_ToolStripMenuItem(dlg); List <DialogEntry> dlgEntryList = dlg.GetEntryList(); if (dlgEntryList != null && dlgEntryList.Count > 0) { bool needsGroupSeperator = false; int addSeperatorAfter = 0; foreach (DialogEntry item in dlgEntryList) { DialogToolStripMenuItem newMenuItem = null; if (item != null && item.Type != null) { if (item.Type == DialogEntryType.Submenu && item.GetSubmenu() != null) { if (!IntegrateQuestions && item.GetSubmenu().Type == DialogType.Question) { Console.Out.WriteLine(item.Title + " is an entry directing to a Question!"); } else { newMenuItem = buildDialogToolStripMenuItemStructure(item.GetSubmenu(), IntegrateQuestions); newMenuItem.dialogEntryItem = item; } } else { newMenuItem = new DialogEntry_ToolStripMenuItem(item); if (item.Type == DialogEntryType.Group) { needsGroupSeperator = true; addSeperatorAfter = item.GetChildEntryList().Count; menuStripItem.DropDownItems.Add(new ToolStripSeparator()); } } } if (menuStripItem != null && newMenuItem != null) { newMenuItem.Parent = menuStripItem; menuStripItem.DropDownItems.Add(newMenuItem); if (needsGroupSeperator && item.IsInGroup()) { addSeperatorAfter--; if (addSeperatorAfter == 0) { menuStripItem.DropDownItems.Add(new ToolStripSeparator()); needsGroupSeperator = false; } } } } } } } return(menuStripItem); }