예제 #1
0
 /// <summary>
 /// Called when DropDownItem is clicked. Needed to get ClickedItem before deciding if Menu should be closed.
 /// Event OnClick is after DropDown.Closing.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="ToolStripItemClickedEventArgs"/> instance containing the event data.</param>
 void OnDropDownItemClicked(Object sender, ToolStripItemClickedEventArgs e)
 {
     if (e != null && e.ClickedItem != null && !(e.ClickedItem is ToolStripSeparator))
     {
         ClickedItem = (DialogToolStripMenuItem)e.ClickedItem;
     }
 }
예제 #2
0
 /// <summary>
 /// Handles the EntryDeactivated event when a dialog entry is deactivated.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EntryEventArgs"/> instance containing the event data.</param>
 void d_EntryDeactivated(object sender, EntryEventArgs e)
 {
     if (e != null && e.Entry != null)
     {
         DialogToolStripMenuItem entry = this.GetDialogToolStripItemWithID(e.Entry.ID);
         if (entry != null)
         {
             entry.Checked = false;
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Handles the EntryUnchecked event when a dialog entry is unchecked.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EntryEventArgs"/> instance containing the event data.</param>
 void d_EntryUnchecked(object sender, EntryEventArgs e)
 {
     if (e != null && e.Entry != null)
     {
         System.Diagnostics.Debug.WriteLine("???? Dialog Entry UCH " + e.Entry.Title);
         DialogToolStripMenuItem item = this.GetDialogToolStripItemWithID(e.Entry.ID);
         if (item != null && item.Checked)
         {
             item.Checked = false;
         }
     }
 }
        /// <summary>
        /// Gets the dialog tool strip item with identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public DialogToolStripMenuItem GetDialogToolStripItemWithID(string id)
        {
            if (id != null)
            {
                if (ID.Equals(id))
                {
                    return(this);
                }

                DialogToolStripMenuItem dsti = null;

                if (this.DropDownItems != null && this.DropDownItems.Count > 0)
                {
                    for (int i = 0; i < this.DropDownItems.Count; i++)
                    {
                        if (!(this.DropDownItems[i] is ToolStripSeparator))
                        {
                            DialogToolStripMenuItem item = (DialogToolStripMenuItem)this.DropDownItems[i];
                            if (item.ID.Equals(id))
                            {
                                return(item);
                            }
                            else
                            {
                                if (dsti == null)
                                {
                                    dsti = item.GetDialogToolStripItemWithID(id);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                return(dsti);
            }

            else
            {
                return(null);
            }
        }
예제 #5
0
        /// <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);
        }