Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="action"></param>
        /// <param name="needAddAction"></param>
        public void AddAction(ActionMetaItem action, bool needAddAction)
        {
            int index = Actions.Count;
            var image = ImagesStorage.Get(action.IconId(BusinessObject, Permissions));

            if (action.ActionType == ActionTypes.Container)
            {
                m_ButtonMain.Tag  = action;
                m_ButtonMain.Text = GetCaption(action.CaptionId(BusinessObject, Permissions));
                m_ButtonMain.Name = String.Format("btn{0}", action.Name);
                if (image != null)
                {
                    m_ButtonMain.Image = image;
                }
                if (!string.IsNullOrEmpty(action.TooltipId(BusinessObject, Permissions)))
                {
                    var superToolTip = new SuperToolTip();
                    //TODO получать текст специальным методом
                    superToolTip.Items.Add(GetCaption(action.TooltipId(BusinessObject, Permissions)));
                    m_ButtonMain.SuperTip = superToolTip;
                }
                return;
            }
            var button = new BarButtonItem(m_PopupActions.Manager, GetCaption(action.CaptionId(BusinessObject, Permissions)))
            {
                Id = index, Tag = action
            };

            if (image != null)
            {
                button.Glyph = image;
            }
            button.ItemClick += OnButtonItemClick;
            button.Enabled    = action.IsEnable(BusinessObject, BusinessObject.GetPermissions());

            ButtonLinks.Add(action, m_PopupActions.AddItem(button));
            if (needAddAction)
            {
                Actions.Add(action);
            }

            //TODO правильно ли следующее
            if (String.IsNullOrEmpty(m_ButtonMain.Text) && Actions.Count >= 1)
            {
                m_ButtonMain.Tag  = Actions[0];
                m_ButtonMain.Text = GetCaption(Actions[0].Container);
            }
        }
Esempio n. 2
0
 protected void SetButtonEnbabled(Control button, IObject bo, ActionMetaItem action)
 {
     button.Enabled = action.IsEnable(bo, bo.GetPermissions());
 }