Beispiel #1
0
        /// <summary>
        ///   Create/Delete menu item on visibility = true/false
        /// </summary>
        /// <param name = "visible">
        /// </param>
        /// <param name = "setPropOnly">-
        ///   only initialize the property - do not try to create\deleet the matching objects This should be
        ///   true when we initialize the menu entry object data through the
        /// </param>
        public void setVisible(bool visible, bool setPropOnly, bool pullDownMenu, TaskBase topMostTask,
                               MgFormBase sendForm)
        {
            bool prevState = _menuState.Visible;

            _menuState.Visible = visible;
            if (!pullDownMenu)
            {
                return;
            }
            MenuReference menuReference = null;

            if (!setPropOnly)
            {
                if (topMostTask == null || topMostTask.isMainProg())
                {
                    //eventTask can be null, if we are here from TP/TS of MP. In that case, topMostTask should MP.
                    TaskBase eventTask = (TaskBase)Events.GetCurrentTask();
                    if (eventTask != null)
                    {
                        topMostTask = eventTask;
                    }
                }

                MgFormBase formOrg = null;
                MgFormBase form    = null;
                if (sendForm == null)
                {
                    formOrg = topMostTask.getTopMostForm();
                    form    = topMostTask.getTopMostForm().getTopMostFrameForm();
                    // fixed bug#:773382, when there is no SDI\MDI need to get the corg form (for the context menu)
                    form = (form != null
                          ? form
                          : formOrg);
                }
                else
                {
                    formOrg = form = sendForm;
                }

                if (!prevState && visible)
                {
                    resetIndexes();
                    if (ParentMenuEntry != null)
                    {
                        if (pullDownMenu)
                        {
                            menuReference = ParentMenuEntry.getInstantiatedMenu(form, MenuStyle.MENU_STYLE_PULLDOWN);
                            createMenuEntryObject(menuReference, MenuStyle.MENU_STYLE_PULLDOWN, form, true);
                        }
                    }
                    else
                    {
                        if (pullDownMenu)
                        {
                            createMenuEntryObject(_parentMgMenu, MenuStyle.MENU_STYLE_PULLDOWN, form, true);
                        }
                    }
                }
                else if (prevState && !visible)
                {
                    resetIndexes();
                    if (pullDownMenu)
                    {
                        deleteMenuEntryObject(form, MenuStyle.MENU_STYLE_PULLDOWN);
                    }
                }

                if (pullDownMenu)
                {
                    Commands.addAsync(CommandType.UPDATE_MENU_VISIBILITY, form);
                }
            }
        }