internal XWPMenuItem(string Caption, string TableName, XWPMenuItem [] Children)
        {
            _caption = Caption;

            _tableName = TableName;

            _children = Children;
        }
        public XOMenuItem(XWPMenuItem MenuItem, XSPApplication XSPApplication)
        {
            _xwpMenuItem = MenuItem;

            _xspTable = XSPApplication != null ? XSPApplication.Tables.FirstOrDefault(p=>p.TableName == MenuItem.TableName) : null;

            _menuItems = MenuItem.Children.Select(p => new XOMenuItem(p, XSPApplication)).ToArray();
        }
        private void BuildMenuItem(DevExpress.XtraBars.BarSubItem ParentBarSubItem, XWPMenuItem MenuItem)
        {
            if (MenuItem.Children.Length > 0)
            {
                DevExpress.XtraBars.BarSubItem barSubItem = AddMenuSubItem(ParentBarSubItem, MenuItem);

                foreach (XWPMenuItem menuItem in MenuItem.Children)
                    BuildMenuItem(barSubItem, menuItem);
            }
            else
            {
                _menuButtons.Add(MenuItem.TableName, AddMenuButtonItem(ParentBarSubItem, MenuItem));
            }
        }
        private DevExpress.XtraBars.BarButtonItem AddMenuButtonItem(DevExpress.XtraBars.BarSubItem ParentBarSubItem, XWPMenuItem MenuItem)
        {
            DevExpress.XtraBars.BarButtonItem barButtonItem = new DevExpress.XtraBars.BarButtonItem();

            barButtonItem.Caption = MenuItem.Caption;

        //    barButtonItem.Hint = MenuItem.Hint;

            barButtonItem.Name = "barSubItem" + MenuItem.Caption;

            /*
            if (MenuItem.Key != null)
            {
                Keys key = GetKeys(MenuItem.Key);

                if (key != Keys.None)
                    barButtonItem.ItemShortcut = new DevExpress.XtraBars.BarShortcut(key);
            }
             */

            this.barManager1.Items.Add(barButtonItem);

            if (ParentBarSubItem != null)
            {
                ParentBarSubItem.LinksPersistInfo.Add(new DevExpress.XtraBars.LinkPersistInfo(barButtonItem));
            }
            else
            {
                this.barManager1.MainMenu.LinksPersistInfo.Add(new DevExpress.XtraBars.LinkPersistInfo(barButtonItem));
            }

            DataAvail.XtraBinding.Controllers.Controller appItemController = Controllers.FirstOrDefault(p => p.TableContext.Name == MenuItem.TableName);

            if (appItemController != null)
            {
                appItemController.Commands.AddCommandItem(new DXBarButtonCommandItem(DataAvail.XtraBinding.Controllers.Commands.ControllerCommandTypes.ListShow, barButtonItem));

                appItemController.UpdateStates();
            }

            return barButtonItem;
        }
        private static Keys GetKeys(XWPMenuItem XWPMenuItem)
        {
            /*nimpl
            object k = Enum.Parse(typeof(Keys), ModelViewAppKey.key, true);

            if (k != null)
            {
                Keys key = (Keys)k;

                foreach (string str in ModelViewAppKey.modifyers)
                {
                    switch (str.ToUpper())
                    {
                        case "ALT":
                            key |= Keys.Alt;
                            break;
                        case "CTL":
                            key |= Keys.Control;
                            break;
                        case "SHIFT":
                            key |= Keys.Shift;
                            break;
                    }
                }

                return key;
            }
            else
            {
                return Keys.None;
            }
             */

            return Keys.None;
        }
        private DevExpress.XtraBars.BarSubItem AddMenuSubItem(DevExpress.XtraBars.BarSubItem ParentBarSubItem, XWPMenuItem MenuItem)
        {
            DevExpress.XtraBars.BarSubItem barSubItem = new DevExpress.XtraBars.BarSubItem();

            barSubItem.Caption = MenuItem.Caption;

            //barSubItem.Hint = MenuItem.Hint;

            barSubItem.Name = "barSubItem" + MenuItem.Caption;

            this.barManager1.Items.AddRange(new DevExpress.XtraBars.BarItem[] {barSubItem});

            if (ParentBarSubItem != null)
            {
                ParentBarSubItem.LinksPersistInfo.AddRange(new DevExpress.XtraBars.LinkPersistInfo[] {
                   new DevExpress.XtraBars.LinkPersistInfo(barSubItem)});
            }
            else
            {
                this.barManager1.MainMenu.LinksPersistInfo.AddRange(new DevExpress.XtraBars.LinkPersistInfo[] {
                    new DevExpress.XtraBars.LinkPersistInfo(barSubItem)});
            }

            return barSubItem;
        }
        private static Keys GetKeys(XWPMenuItem XWPMenuItem)
        {
            XWPKeyCommand keyCommand = XWPMenuItem.KeyCommand;

            if (keyCommand.Keys.Length > 0)
            {
                object k = Enum.Parse(typeof(Keys), keyCommand.Keys[0].Key, true);

                if (k != null)
                {
                    Keys key = (Keys)k;

                    foreach (string str in keyCommand.Keys[0].Modifyers)
                    {
                        switch (str.ToUpper())
                        {
                            case "ALT":
                                key |= Keys.Alt;
                                break;
                            case "CTL":
                                key |= Keys.Control;
                                break;
                            case "SHIFT":
                                key |= Keys.Shift;
                                break;
                        }
                    }

                    return key;
                }
            }
            return Keys.None;
        }