private void IntegrateMenu()
        {
            FrmMain mainForm = PresentationDomain.MainForm;

            RestrictionNode restrictionAppGroup = new RestrictionNode(DataHelper.ProductName, () => DataHelper.ProductName);

            MoveRestriction("mnuHelpAbout", restrictionAppGroup);
            foreach (string item in AdditionalAppMenus)
            {
                MoveRestriction(item, restrictionAppGroup);
            }
            MoveRestriction("mnuToolsSetup", restrictionAppGroup);
            MoveRestriction("mnuFileExit", restrictionAppGroup);

            BusinessDomain.RestrictionTree.InsertBefore("mnuFile", restrictionAppGroup);

            menuItemSettings = mainForm.MainMenu.FindMenuItem("mnuToolsSetup");
            // TODO: remove when the short-cuts are fixed on the mac
            BusinessDomain.RestrictionTree.RemoveNode("mnuToolsQuickItems");
            mainForm.MainMenu.RemoveItem("mnuToolsQuickItems");

            //Tell the IGE library to use your GTK menu as the Mac main menu
            IgeMacMenu.MenuBar = mainForm.MainMenu.Menu;

            RefreshAppMenu(mainForm);

            //hide the menu bar so it no longer displays within the window
            mainForm.MainMenu.Menu.Hide();
        }
Example #2
0
        public void ReloadRestrictions()
        {
            LoadSubItems();
            RestrictionNode restrictionTree = BusinessDomain.RestrictionTree;

            foreach (ToolItemWrapper item in items)
            {
                if (item.IsSeparator)
                {
                    continue;
                }

                RestrictionNode node = restrictionTree.FindNode(item.RestrictionName);
                if (node == null)
                {
                    throw new ApplicationException(string.Format("No restriction node found item name \"{0}\"", item.Name));
                }

                item.ClearRestrictions();
                foreach (KeyValuePair <long, UserRestriction> restriction in node.Restrictions)
                {
                    item.SetRestriction(restriction.Value);
                }
            }
        }
Example #3
0
        public void ReloadRestrictions()
        {
            LoadSubItems();
            RestrictionNode restrictionTree = BusinessDomain.RestrictionTree;

            foreach (MenuItemWrapper item in items)
            {
                if (item.IsSeparator)
                {
                    continue;
                }

                RestrictionNode node = restrictionTree.FindNode(item.Name);
                if (node == null)
                {
                    continue;
                }

                item.ClearRestrictions();
                foreach (KeyValuePair <long, UserRestriction> restriction in node.Restrictions)
                {
                    item.SetRestriction(restriction.Value);
                }

                item.SubItems.ReloadRestrictions();
            }
        }
Example #4
0
        private static RestrictionNode GetRestrictionTreeFromMenuItem(MenuItemWrapper item)
        {
            RestrictionNode ret = new RestrictionNode(item.Name, item.Translate);

            foreach (MenuItemWrapper subItem in item.SubItems)
            {
                if (subItem.IsSeparator)
                {
                    continue;
                }

                ret.Children.Add(GetRestrictionTreeFromMenuItem(subItem));
            }

            return(ret);
        }
Example #5
0
        public MenuItemWrapper Add(MenuItemWrapper item, bool createRestriction)
        {
            LoadSubItems();
            EnsureMenu();

            items.Add(item);
            if (menu != null)
            {
                menu.Append(item.Item);
            }

            if (!createRestriction)
            {
                return(item);
            }

            RestrictionNode node = BusinessDomain.RestrictionTree.FindNode(parent.Name);

            node.Children.Add(new RestrictionNode(item.Name, item.Translate));
            return(item);
        }
Example #6
0
        public void Translate()
        {
            LoadSubItems();
            RestrictionNode restrictionTree = BusinessDomain.RestrictionTree;

            foreach (MenuItemWrapper item in items)
            {
                if (item.IsSeparator)
                {
                    continue;
                }

                RestrictionNode node = restrictionTree.FindNode(item.Name);
                if (node == null)
                {
                    throw new ApplicationException(string.Format("No restriction node found item name \"{0}\"", item.Name));
                }

                item.Text = node.Value;
                item.SubItems.Translate();

                if (item.SubItems.Sorted && item.Item.Submenu != null)
                {
                    item.SubItems.Sort((m1, m2) => string.Compare(m1.Text, m2.Text));
                    RestrictionNode restrictionNode = BusinessDomain.RestrictionTree.FindNode(item.Name);
                    restrictionNode.Children.Sort((r1, r2) => string.Compare(r1.Value, r2.Value));
                    Container     container = (Container)item.Item.Submenu;
                    List <Widget> children  = new List <Widget> (container.Children);
                    foreach (Widget widget in container.Children)
                    {
                        container.Remove(widget);
                    }
                    children.Sort((w1, w2) => string.Compare(((Label)((Bin)w1).Child).Text, (((Label)((Bin)w2).Child).Text)));
                    foreach (Widget widget in children)
                    {
                        container.Add(widget);
                    }
                }
            }
        }
Example #7
0
        public void Translate()
        {
            LoadSubItems();
            RestrictionNode restrictionTree = BusinessDomain.RestrictionTree;

            foreach (ToolItemWrapper item in items)
            {
                if (item.IsSeparator)
                {
                    continue;
                }

                RestrictionNode node = restrictionTree.FindNode(item.RestrictionName);
                if (node == null)
                {
                    throw new ApplicationException(string.Format("No restriction node found item name \"{0}\"", item.Name));
                }

                string text = node.Value.EndsWith("...") ? node.Value.Substring(0, node.Value.Length - 3) : node.Value;
                item.Text = text.Trim();
            }
        }
        protected void InitilizeTreeView()
        {
            restsTreeStore = new TreeStore(typeof(string), typeof(bool), typeof(string));
            restsRoot      = BusinessDomain.RestrictionTree;
            restsRoot.ReloadRestrictions();

            CreateTreeStore(restsRoot, TreeIter.Zero, true);

            treeView.Model = restsTreeStore;

            CellRendererText textCellRend = new CellRendererText();

            textCellRend.Editable = false;

            TreeViewColumn menuNameColumn = new TreeViewColumn();

            menuNameColumn.PackStart(textCellRend, true);
            menuNameColumn.AddAttribute(textCellRend, "text", 0);
            menuNameColumn.Title  = Translator.GetString("Menu");
            menuNameColumn.Expand = true;

            CellRendererToggle boolCellRend = new CellRendererToggle();

            boolCellRend.Activatable = true;
            boolCellRend.Toggled    += boolCellRend_Toggled;

            TreeViewColumn menuEnabledColumn = new TreeViewColumn();

            menuEnabledColumn.PackStart(boolCellRend, true);
            menuEnabledColumn.AddAttribute(boolCellRend, "active", 1);
            menuEnabledColumn.Title  = Translator.GetString("Enabled");
            menuEnabledColumn.Expand = false;

            treeView.AppendColumn(menuNameColumn);
            treeView.AppendColumn(menuEnabledColumn);
        }
 private static void MoveRestriction(string menuName, RestrictionNode restrictionAppGroup)
 {
     restrictionAppGroup.Children.Add(BusinessDomain.RestrictionTree.FindNode(menuName));
     BusinessDomain.RestrictionTree.RemoveNode(menuName);
 }