Example #1
0
 private object AddTopMenuItem(MenuAction c)
 {
     if (m_BarManager != null)
     {
         var category = new BarSubItem {
             ImageIndex = c.SmallIconIndex, Caption = c.Caption
         };
         category.Tag = c;
         MenuItemsInfo.Add(category, c);
         m_BarManager.Items.Add(category);
         if (c.ShowInToolbar)
         {
             var toolbarButton = new BarLargeButtonItem(m_BarManager, c.Caption);
             toolbarButton.Hint             = GetToolTipText(toolbarButton.Caption);
             toolbarButton.ImageIndex       = c.SmallIconIndex;
             toolbarButton.LargeImageIndex  = c.BigIconIndex;
             toolbarButton.ButtonStyle      = BarButtonStyle.DropDown;
             toolbarButton.DropDownControl  = new PopupMenu();
             toolbarButton.ShowCaptionOnBar = m_ShowButtonCaption;
             toolbarButton.CaptionAlignment = BarItemCaptionAlignment.Bottom;
             toolbarButton.PaintStyle       = BarItemPaintStyle.CaptionInMenu;
             m_CategoryInToolbar.Add(category, toolbarButton);
             var bl = m_Bar.AddItem(toolbarButton);
             if (m_IsGroup || c.BeginGroup)
             {
                 bl.BeginGroup = true;
             }
         }
         return(category);
     }
     return(null);
 }
Example #2
0
        public MenuAction FindAction(string resourceKey, IMenuAction parent, int order, int smallImageIndex, int bigImageIndex)
        {
            MenuAction action = FindAction(MenuItems, resourceKey) as MenuAction ?? new MenuAction(this, parent, resourceKey, order);

            if (bigImageIndex >= 0 && action.BigIconIndex != bigImageIndex)
            {
                action.BigIconIndex = bigImageIndex;
            }
            if (smallImageIndex >= 0 && action.SmallIconIndex != smallImageIndex)
            {
                action.SmallIconIndex = smallImageIndex;
            }
            return(action);
        }
Example #3
0
 public void DisplayActions()
 {
     PrepareActions();
     m_CategoryInToolbar.Clear();
     foreach (MenuAction category in MenuItems)
     {
         object     categoryItem = AddTopMenuItem(category);
         MenuAction prevAction   = null;
         foreach (MenuAction a in category.Items)
         {
             AddAction(categoryItem, a, prevAction);
             prevAction = a;
         }
         var mi = categoryItem as MenuItem;
         if (mi != null && mi.MenuItems.Count == 0)
         {
             mi.Dispose();
         }
         var barItem = categoryItem as BarSubItem;
         if (barItem != null)
         {
             if (ClearEmptyItems(barItem) != null)
             {
                 m_BarManager.MainMenu.AddItem(barItem);
             }
         }
         if (m_Bar != null)
         {
             for (int i = m_Bar.ItemLinks.Count - 1; i >= 0; i--)
             {
                 BarItemLink li = m_Bar.ItemLinks[i];
                 if ((li.Item) is BarLargeButtonItem &&
                     ((BarLargeButtonItem)li.Item).ButtonStyle == BarButtonStyle.DropDown &&
                     (((BarLargeButtonItem)li.Item).DropDownControl == null ||
                      ((PopupMenu)(((BarLargeButtonItem)li.Item).DropDownControl)).ItemLinks.Count == 0))
                 {
                     m_Bar.ItemLinks[i].Dispose();
                 }
             }
         }
     }
 }
Example #4
0
        //public static void Restrict(string[] arrActions)
        //{
        //    bool find;
        //    int nIndexA;
        //    int nIndexC;
        //    MenuAction a;
        //    MenuCategory c;

        //    for (nIndexC = m_MenuItems.Count - 1; nIndexC >= 0; nIndexC--)
        //    {
        //        c = (MenuCategory)(m_MenuItems[nIndexC]);
        //        for (nIndexA = c.Items.Count - 1; nIndexA >= 0; nIndexA--)
        //        {
        //            a = (MenuAction)(c.Items[nIndexA]);
        //            find = RestrictAction(arrActions, a);
        //            if (find == false)
        //            {
        //                c.Items.RemoveAt(nIndexA);
        //            }
        //        }
        //        if (c.Items.Count == 0)
        //        {
        //            //m_MenuItems.RemoveAt(nIndexC)
        //        }
        //    }
        //}

        //protected static bool RestrictAction(string[] arrActions, MenuAction action)
        //{
        //    bool find;
        //    bool findSubaction;
        //    int nIndex;
        //    MenuAction subAction;

        //    find = false;

        //    foreach (string actionName in arrActions)
        //    {
        //        if (actionName.CompareTo(action.Caption) == 0)
        //        {
        //            find = true;
        //            break;
        //        }
        //    }

        //    //>>>> Added by Andrey 25-Sep-2007
        //    if (action.Name.IndexOf(".rpt") != -1)
        //    {
        //        find = true;
        //    }
        //    //<<<< Added by Andrey 25-Sep-2007

        //    if ((find == true) && (action.Items != null) && (action.Items.Count > 0))
        //    {
        //        for (nIndex = action.Items.Count - 1; nIndex >= 0; nIndex--)
        //        {
        //            subAction = (MenuAction)(action.Items[nIndex]);
        //            findSubaction = RestrictAction(arrActions, subAction);
        //            if (findSubaction == false)
        //            {
        //                action.Items.RemoveAt(nIndex);
        //            }
        //        }
        //    }
        //    return (find);
        //}

        #endregion

        #region Private methods

        public void Clear()
        {
            MenuItems.Clear();
            m_File       = new MenuAction(this, null, "MenuFile", 1);
            m_Edit       = new MenuAction(this, null, "MenuEdit", 100);
            m_View       = new MenuAction(this, null, "MenuView", 200);
            m_Journals   = new MenuAction(this, null, "MenuCatalogs", 300);
            m_Operations = new MenuAction(this, null, "MenuOperations", 400);
            m_Create     = new MenuAction(this, null, "MenuCreate", 450);
            m_Search     = new MenuAction(this, null, "MenuSearch", 500);
            m_Reports    = new MenuAction(this, null, "MenuReports", 600);
            m_Maps       = new MenuAction(this, null, "MenuMaps", 650);

            m_Documents         = new MenuAction(this, null, "MenuDocuments", 700);
            m_Options           = new MenuAction(this, null, "MenuOptions", 800);
            m_System            = new MenuAction(this, null, "MenuSystem", 900);
            m_Avr               = new MenuAction(this, null, "MenuRAM", 950);
            m_Security          = new MenuAction(this, null, "MenuSecurity", 1000);
            m_DataExport        = new MenuAction(this, null, "MenuDataExport", 1100);
            m_Window            = new MenuAction(this, null, "MenuWindow", 999900);
            m_Help              = new MenuAction(this, null, "MenuHelp", 1000000);
            m_ShowButtonCaption = BaseSettings.ShowCaptionOnToolbar;
            //If Not m_Toolbar Is Nothing Then m_Toolbar.Buttons.Clear()
            //If Not m_MainMenu Is Nothing Then m_MainMenu.MenuItems.Clear()
            if (m_BarManager != null)
            {
                for (var i = m_BarManager.Items.Count - 1; i >= 0; i--)
                {
                    var item = m_BarManager.Items[i];
                    if (
                        !(item.Links.Count > 0 && item.Links[0].LinkedObject is Bar &&
                          ((Bar)item.Links[0].LinkedObject).IsStatusBar))
                    {
                        item.Dispose();
                    }
                }
                //m_BarManager.Items.Clear()
            }
            //If Not m_Bar Is Nothing Then m_Bar.ClearLinks()
        }
Example #5
0
        private void AddAction(object parentMenuItem, MenuAction a, MenuAction prevAction)
        {
            if (!m_User.HasPermission(a.SelectPermission))
            {
                return;
            }
            BarItem btn = null;

            if (parentMenuItem == null)
            {
                return;
            }
            if (m_BarManager != null)
            {
                var parentBarItem = parentMenuItem as BarSubItem;
                if (a.ResourceKey == "MenuSeparator")
                {
                    m_IsGroup = true;
                    return;
                }
                if (prevAction != null && prevAction.Group != a.Group)
                {
                    m_IsGroup = true;
                }

                if (a.Items != null && a.Items.Count > 0 || a.IsCategory)
                {
                    btn = new BarSubItem(m_BarManager, a.Caption);
                }
                else
                {
                    if (a.ResourceKey == "MenuWindows")
                    {
                        btn       = new BarMdiChildrenListItem();
                        m_IsGroup = true;
                    }
                    else if (a.IsCheckBoxAction)
                    {
                        btn = new BarCheckItem(m_BarManager, false)
                        {
                            Caption = a.Caption
                        };
                        btn.ItemClick += a.BarClick;
                    }
                    else
                    {
                        btn = new BarLargeButtonItem(m_BarManager, a.Caption)
                        {
                            LargeImageIndex = a.BigIconIndex,
                            ImageIndex      = a.SmallIconIndex,
                        };
                        ((BarLargeButtonItem)btn).ShowCaptionOnBar = m_ShowButtonCaption;
                        if (btn.Width > 100)
                        {
                            btn.Width = 100;
                        }
                        btn.ItemClick += a.BarClick;
                    }
                }
                btn.ImageIndex  = a.SmallIconIndex;
                btn.Description = btn.Caption;
                btn.Hint        = GetToolTipText(btn.Caption);
                BarItemLink bl;
                if (BaseSettings.TranslationMode)
                {
                    btn.Tag = a;
                }
                if (a.ShowInMenu)
                {
                    m_BarManager.Items.Add(btn);
                    a.MenuItem = btn;
                    if (parentBarItem != null)
                    {
                        bl = parentBarItem.AddItem(btn);
                        if (m_CategoryInToolbar.ContainsKey(parentBarItem))
                        {
                            var cat1 = m_CategoryInToolbar[parentBarItem];
                            var bl1  = ((PopupMenu)cat1.DropDownControl).ItemLinks.Add(btn);
                            if (m_IsGroup)
                            {
                                bl1.BeginGroup = true;
                            }
                        }
                        if (m_IsGroup || a.BeginGroup)
                        {
                            bl.BeginGroup = true;
                        }
                    }
                }
                if (a.ShowInToolbar && m_Bar != null)
                {
                    if (btn is BarSubItem)
                    {
                        var btn1 = new BarLargeButtonItem(m_BarManager, a.Caption);
                        btn1.Hint             = GetToolTipText(btn1.Caption);
                        btn1.ImageIndex       = a.SmallIconIndex;
                        btn1.LargeImageIndex  = a.BigIconIndex;
                        btn1.ButtonStyle      = BarButtonStyle.DropDown;
                        btn1.DropDownControl  = new PopupMenu();
                        btn1.ShowCaptionOnBar = m_ShowButtonCaption;
                        btn1.CaptionAlignment = BarItemCaptionAlignment.Bottom;
                        m_CategoryInToolbar.Add((BarSubItem)btn, btn1);
                        bl            = m_Bar.AddItem(btn1);
                        a.ToolbarItem = btn1;
                        if (m_IsGroup || a.BeginGroup)
                        {
                            bl.BeginGroup = true;
                        }
                    }
                    else
                    {
                        bl = m_Bar.AddItem(btn);
                        if (m_IsGroup || a.BeginGroup)
                        {
                            bl.BeginGroup = true;
                        }
                    }
                }
                m_IsGroup = false;
            }
            if (a.Items != null && a.Items.Count > 0)
            {
                MenuAction prevAction1 = null;
                foreach (MenuAction a1 in a.Items)
                {
                    AddAction(btn, a1, prevAction1);
                    prevAction1 = a1;
                }
            }
        }
Example #6
0
        public MenuAction FindAction(string resourceKey, IMenuAction parent, int order)
        {
            MenuAction action = FindAction(MenuItems, resourceKey) as MenuAction ?? new MenuAction(this, parent, resourceKey, order);

            return(action);
        }