Beispiel #1
0
 public MenuItem(int id, int?menuId = null, MenuItemTypes menuItemType = MenuItemTypes.Default)
 {
     Id           = id;
     MenuId       = menuId ?? int.MinValue;
     MenuItemType = menuItemType;
     IsReadOnly   = true;
 }
 public BudgetMenuItemViewModel(MenuItemTypes itemType, string label, object payload)
 {
     MenuItemType = itemType;
     _label       = label;
     Payload      = payload;
     _isSelected  = false;
 }
Beispiel #3
0
 public MenuItemTypeViewModel(MenuItemTypes model)
 {
     this.Id         = model.Id;
     this.Type       = model.Type;
     this.Active     = model.Active;
     this.DtCreated  = model.DtCreated;
     this.CreatedBy  = model.CreatedBy;
     this.DtModified = model.DtModified;
     this.ModifiedBy = model.ModifiedBy;
 }
Beispiel #4
0
 public MenuComponent(Game game, ContentManager content, SpriteBatch spriteBatch, string imagePath, MenuItemTypes componentType)
 {
     this.componentType = componentType;
     this.spriteBatch   = spriteBatch;
     this.content       = content;
     this.game          = game;
     screenWidth        = game.Window.ClientBounds.Width;
     screenHeight       = game.Window.ClientBounds.Height;
     this.imagePath     = imagePath;
     LoadContent();
     imageRectangle = new Rectangle(0, 0, (int)screenWidth, (int)screenHeight);
     Hide();
 }
Beispiel #5
0
 public MenuItemViewModel(MenuItems model)
 {
     this.Id             = model.Id;
     this.MenuId         = model.MenuId;
     this.MenuItemTypeId = model.MenuItemTypeId;
     this.Name           = model.Name;
     this.Quantifiable   = model.Quantifiable == "Y" ? true : false;
     this.Active         = model.Active == "Y" ? true : false;
     this.DtCreated      = model.DtCreated;
     this.CreatedBy      = model.CreatedBy;
     this.DtModified     = model.DtModified;
     this.ModifiedBy     = model.ModifiedBy;
     this.MenuItemType   = model.MenuItemType;
 }
Beispiel #6
0
        public MenuItemTypes ConvertToMenus()
        {
            var menuItemTypes = new MenuItemTypes
            {
                Id         = this.Id,
                Type       = this.Type,
                Active     = this.Active,
                DtCreated  = this.DtCreated,
                CreatedBy  = this.CreatedBy,
                DtModified = this.DtModified,
                ModifiedBy = this.ModifiedBy
            };

            return(menuItemTypes);
        }
Beispiel #7
0
        public MenuItem Add(string name, MenuItemTypes type = MenuItemTypes.Common, Action <IntPtr> click = null)
        {
            var handler = IntPtr.Zero;
            var nb      = StringUtil.GetBytes(name);

            switch (type)
            {
            case MenuItemTypes.Common:
                handler = NativeMethods.MenuAppendItem(handle, nb);
                break;

            case MenuItemTypes.Check:
                handler = NativeMethods.MenuAppendCheckItem(handle, nb);
                break;

            case MenuItemTypes.Quit:
                handler = NativeMethods.MenuAppendQuitItem(handle);
                break;

            case MenuItemTypes.Preferences:
                handler = NativeMethods.MenuAppendPreferencesItem(handle);
                break;

            case MenuItemTypes.About:
                handler = NativeMethods.MenuAppendAboutItem(handle);
                break;
            }
            var item = new MenuItem(handler, type);

            if (click != null)
            {
                item.Click += (sender, e) =>
                {
                    var args = e as DataEventArgs;
                    if (args != null)
                    {
                        click(args.Data);
                    }
                };
            }
            Items.Add(item);
            return(item);
        }
Beispiel #8
0
        public MenuItem Add(MenuItemTypes type = MenuItemTypes.Quit, Action <IntPtr> click = null)
        {
            var handler = IntPtr.Zero;

            switch (type)
            {
            case MenuItemTypes.Quit:
                handler = NativeMethods.MenuAppendQuitItem(handle);
                break;

            case MenuItemTypes.Preferences:
                handler = NativeMethods.MenuAppendPreferencesItem(handle);
                break;

            case MenuItemTypes.About:
                handler = NativeMethods.MenuAppendAboutItem(handle);
                break;

            default:
                throw new InvalidOperationException("Cannot add Common or Check Menu without name");
            }
            var item = new MenuItem(handler, type);

            if (click != null)
            {
                item.Click += (sender, e) =>
                {
                    var args = e as DataEventArgs;
                    if (args != null)
                    {
                        click(args.Data);
                    }
                };
            }
            Items.Add(item);
            return(item);
        }
Beispiel #9
0
 internal MenuItem(IntPtr handle, MenuItemTypes type)
 {
     this.handle = handle;
     Type        = type;
     InitializeEvents();
 }
Beispiel #10
0
 public MainMenu(Game game, ContentManager content, SpriteBatch spriteBatch, string imagePath, MenuItemTypes componentType) : base(game, content, spriteBatch, imagePath, componentType)
 {
     this.name = "Main Menu";
     menuItems = new string[]
     {
         "Start new game",
         "   Instructions",
         "      Controls",
         "       Credits",
         "          Exit"
     };
     lineSpacing = 5;
     MeasureMenu();
 }
Beispiel #11
0
 public MenuItem(Game game, ContentManager content, SpriteBatch spriteBatch, string imagePath, MenuItemTypes componentType) : base(game, content, spriteBatch, imagePath, componentType)
 {
     this.name = componentType.ToString();
     textItem  = "Return to Main Menu";
     itemColor = normalColor;
     itemSize  = spriteFontNormal.MeasureString(textItem);
 }
Beispiel #12
0
 public void ShowMenuComponent(MenuItemTypes itemToShow)
 {
     activeMenu.Hide();
     activeMenu = menuComponents[(int)itemToShow];
     activeMenu.Show();
 }