private void InitCommands()
        {
            #region Commands

            _addMenuEntityCommand = new AddMenuEntityCommand()
            {
                GetArgumentHandler = () =>
                {
                    MenuEntity selectedItem = _controller.GetSelectedData <MenuEntity>();
                    if (selectedItem == null)
                    {
                        return(String.Empty);
                    }
                    else
                    {
                        return(selectedItem.Id);
                    }
                }
            };
            _editMenuEntityCommand = new EditMenuEntityCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <MenuEntity>() != null);
                },
                GetArgumentHandler = () => { return(_controller.GetSelectedData <MenuEntity>()); }
            };
            _deleteMenuEntityCommand = new DeleteMenuEntityCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <MenuEntity>() != null);
                },
                GetArgumentHandler = () =>
                {
                    return(new List <MenuEntity>()
                    {
                        _controller.GetSelectedData <MenuEntity>()
                    });
                }
            };
            _moveBeforeMenuEntityCommand = new MoveBeforeMenuEntityCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <MenuEntity>() != null &&
                           _controller.GetPreSelectedData <MenuEntity>() != null);
                },
                GetMenuId       = () => { return(_controller.GetSelectedData <MenuEntity>().Id); },
                GetBeforeMenuId = () => { return(_controller.GetPreSelectedData <MenuEntity>().Id); }
            };

            _moveAfterMenuEntityCommand = new MoveAfterMenuEntityCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <MenuEntity>(true) != null &&
                           _controller.GetNextSelectedData <MenuEntity>() != null);
                },
                GetMenuId      = () => { return(_controller.GetSelectedData <MenuEntity>().Id); },
                GetAfterMenuId = () => { return(_controller.GetNextSelectedData <MenuEntity>().Id); }
            };

            #endregion
        }
Ejemplo n.º 2
0
        private void InitCommands()
        {
            #region Commands

            #region Page

            _addToolStripPageCommand = new AddToolStripPageCommand();

            _editToolStripPageCommand = new EditToolStripPageCommand()
            {
                GetArgumentHandler = () =>
                {
                    ToolStripPageEntity selectedItem = _controller.GetSelectedData <ToolStripPageEntity>();
                    if (selectedItem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        return(selectedItem);
                    }
                }
            };

            _removeToolStripPageCommand = new RemoveToolStripPageCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripPageEntity>() != null);
                },
                GetArgumentHandler = () =>
                {
                    return(new List <ToolStripPageEntity>()
                    {
                        _controller.GetSelectedData <ToolStripPageEntity>()
                    });
                }
            };

            _moveBeforeToolStripPageCommand = new MoveBeforeToolStripPageCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripPageEntity>() != null &&
                           _controller.GetPreSelectedData <ToolStripPageEntity>() != null);
                },
                GetId       = () => { return(_controller.GetSelectedData <ToolStripPageEntity>().Id); },
                GetBeforeId = () => { return(_controller.GetPreSelectedData <ToolStripPageEntity>().Id); }
            };

            _moveAfterToolStripPageCommand = new MoveAfterToolStripPageCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripPageEntity>(true) != null &&
                           _controller.GetNextSelectedData <ToolStripPageEntity>() != null);
                },
                GetId      = () => { return(_controller.GetSelectedData <ToolStripPageEntity>().Id); },
                GetAfterId = () => { return(_controller.GetNextSelectedData <ToolStripPageEntity>().Id); }
            };

            #endregion

            #region Group

            _addToolStripGroupCommand = new AddToolStripGroupCommand()
            {
                GetArgumentHandler = () =>
                {
                    ToolStripPageEntity selectedItem = _controller.GetSelectedData <ToolStripPageEntity>();
                    if (selectedItem == null)
                    {
                        return(String.Empty);
                    }
                    else
                    {
                        return(selectedItem.Id);
                    }
                }
            };

            _editToolStripGroupCommand = new EditToolStripGroupCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripGroupEntity>() != null);
                },
                GetArgumentHandler = () => { return(_controller.GetSelectedData <ToolStripGroupEntity>()); }
            };

            _removeToolStripGroupCommand = new RemoveToolStripGroupCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripGroupEntity>() != null);
                },
                GetArgumentHandler = () =>
                {
                    return(new List <ToolStripGroupEntity>()
                    {
                        _controller.GetSelectedData <ToolStripGroupEntity>()
                    });
                }
            };

            _moveBeforeToolStripGroupCommand = new MoveBeforeToolStripGroupCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripGroupEntity>() != null &&
                           _controller.GetPreSelectedData <ToolStripGroupEntity>() != null);
                },
                GetId       = () => { return(_controller.GetSelectedData <ToolStripGroupEntity>().Id); },
                GetBeforeId = () => { return(_controller.GetPreSelectedData <ToolStripGroupEntity>().Id); }
            };

            _moveAfterToolStripGroupCommand = new MoveAfterToolStripGroupCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripGroupEntity>(true) != null &&
                           _controller.GetNextSelectedData <ToolStripGroupEntity>() != null);
                },
                GetId      = () => { return(_controller.GetSelectedData <ToolStripGroupEntity>().Id); },
                GetAfterId = () => { return(_controller.GetNextSelectedData <ToolStripGroupEntity>().Id); }
            };

            #endregion

            #region Items

            _addToolStripItemCommand = new AddToolStripItemCommand()
            {
                GetArgumentHandler = () =>
                {
                    ToolStripGroupEntity selectedItem = _controller.GetSelectedData <ToolStripGroupEntity>();
                    if (selectedItem == null)
                    {
                        return(String.Empty);
                    }
                    else
                    {
                        return(selectedItem.Id);
                    }
                }
            };

            _editToolStripItemCommand = new EditToolStripItemCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripItemAbstract>() != null);
                },
                GetArgumentHandler = () => { return(_controller.GetSelectedData <ToolStripItemAbstract>()); }
            };

            _deleteToolStripItemCommand = new DeleteToolStripItemCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripItemAbstract>() != null);
                },
                GetArgumentHandler = () =>
                {
                    return(new List <ToolStripItemAbstract>()
                    {
                        _controller.GetSelectedData <ToolStripItemAbstract>()
                    });
                }
            };

            _moveBeforeToolStripItemCommand = new MoveBeforeToolStripItemCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripItemAbstract>() != null &&
                           _controller.GetPreSelectedData <ToolStripItemAbstract>() != null);
                },
                GetMenuId       = () => { return(_controller.GetSelectedData <ToolStripItemAbstract>().Id); },
                GetBeforeMenuId = () => { return(_controller.GetPreSelectedData <ToolStripItemAbstract>().Id); }
            };

            _moveAfterToolStripItemCommand = new MoveAfterToolStripItemCommand()
            {
                CanExcuteHandler = () =>
                {
                    return(_controller.GetSelectedData <ToolStripItemAbstract>(true) != null &&
                           _controller.GetNextSelectedData <ToolStripItemAbstract>() != null);
                },
                GetMenuId      = () => { return(_controller.GetSelectedData <ToolStripItemAbstract>().Id); },
                GetAfterMenuId = () => { return(_controller.GetNextSelectedData <ToolStripItemAbstract>().Id); }
            };

            #endregion

            #endregion
        }