Example #1
0
        public void SubMenuClickEvent(object sender, EventArgs e)
        {
            var item = (ToolStripItem)sender;
            var tag  = (int.Parse(item.Tag.ToString()));

            MenuOptionModel option = null;

            //Options[4].SubItems.ForEach(s => {
            //        if (tag == s.Id)
            //        {
            //            option = s;
            //        }
            //    });
            Options[3].SubItems.ForEach(s => {
                if (tag == s.Id)
                {
                    option = s;
                }
            });
            option.SelectedState = !option.SelectedState;
            Options.ForEach(op =>
            {
                if (op.Id != option.Id)
                {
                    op.SelectedState = false;
                }
            });
            item.ForeColor = (option.SelectedState) ? (option.Id <= 3) ? ColorManager.White : ColorManager.Black : ColorManager.Black;
            item.Image     = (option.SelectedState) ? option.Selected : option.UnSelected;
            item.BackColor = (option.SelectedState) ? option.SelectedColor : ColorManager.White;
        }
Example #2
0
        public ToolStripItem UnSelectedSubItems(MenuOptionModel option)
        {
            var size = Size;

            size.Width = 240;
            var toolStripItem = new ToolStripDropDownButton()
            {
                Tag               = option.Id,
                Text              = option.Name,
                ForeColor         = option.UnSelectedColor,
                Image             = option.UnSelected,
                AutoSize          = false,
                TextAlign         = ContentAlignment.MiddleLeft,
                Alignment         = ToolStripItemAlignment.Left,
                Padding           = Padding.Empty,
                Size              = size,
                DropDownDirection = ToolStripDropDownDirection.BelowRight,
                Font              = Font
            };

            toolStripItem.Click += option.ClickEvent;
            var toolStripDropDownItem = new ToolStripDropDown()
            {
                Text        = option.Name,
                ForeColor   = option.UnSelectedColor,
                AutoSize    = true,
                Size        = Size,
                LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow
            };
            var toolStripButtonArray = new List <ToolStripItem>();

            foreach (var suboption in option.SubItems)
            {
                var toolStripSubItem = new ToolStripButton()
                {
                    Tag       = suboption.Id,
                    Text      = suboption.Name,
                    ForeColor = suboption.UnSelectedColor,
                    Image     = suboption.UnSelected,
                    AutoSize  = false,
                    Alignment = ToolStripItemAlignment.Left,
                    Padding   = Padding.Empty,
                    TextAlign = ContentAlignment.MiddleLeft,
                    Size      = Size
                };
                toolStripSubItem.Click += suboption.ClickEvent;
                toolStripButtonArray.Add(toolStripSubItem);
            }
            toolStripDropDownItem.Items.AddRange(toolStripButtonArray.ToArray());
            toolStripItem.DropDown = toolStripDropDownItem;
            return(toolStripItem);
        }
        //------------------------------------------------------------

        private void addMenuOption(List <int> levels, MenuOptionModel menuOptionModel, Dictionary <int, MenuOptionModel> listOpcionMenu)
        {
            if (levels.Count == 1)
            {
                listOpcionMenu.Add(levels[0], menuOptionModel);
            }
            else
            {
                int firstLevel = levels[0];
                levels.RemoveAt(0);
                Dictionary <int, MenuOptionModel> subMenu = listOpcionMenu[firstLevel].SubMenu;
                addMenuOption(levels, menuOptionModel, subMenu);
            }
        }
        //------------------------------------------------------------

        private MenuOptionModel mapMenuOptionModel(OpcionMenu opcionMenu, String userName, String IP)
        {
            MenuOptionModel menuOptionModel = new MenuOptionModel();

            menuOptionModel.Action      = opcionMenu.Accion;
            menuOptionModel.Id          = opcionMenu.Codigo;
            menuOptionModel.Controlller = opcionMenu.Controlador;
            menuOptionModel.OpcionName  = opcionMenu.NombreOpcion;
            menuOptionModel.UserName    = userName;
            menuOptionModel.IP          = IP;
            menuOptionModel.SubMenu     = new Dictionary <int, MenuOptionModel>();

            return(menuOptionModel);
        }
Example #5
0
        void addOptions(int menuId,
                        MenuModel topMenu,
                        MenuModel leftMenu,
                        MenuBreadCrumbModel breadCrumb,
                        MenuOptionModel parentOption,
                        Dictionary <string, string> dict)
        {
            foreach (var menuOption in findOptions(menuId))
            {
                var newOption = new MenuOptionModel {
                    OptionType = (menuOption.Name == "-" ? MenuOptionModel.SeparatorOption : menuOption.OptionType.Value), // Models.MenuOptionModel.TextOption),
                    OptionText = menuOption.Name.DoSubstitutions(dict),
                    Tooltip    = menuOption.Tooltip.DoSubstitutions(dict),
                    Image      = menuOption.Image,
                    Alignment  = menuOption.Alignment,
                    URL        = menuOption.Url.DoSubstitutions(dict),
                    WindowName = menuOption.WindowName,
                    Active     = (menuOption.Active == 1 ? true : false)
                };
                if (newOption.Active)
                {
                    breadCrumb.Items.Add(new MenuBreadCrumbItemModel {
                        OptionText = newOption.OptionText,
                        Tooltip    = newOption.Tooltip,
                        URL        = newOption.URL
                    });
                }

                if (parentOption == null)
                {
                    // Root menu options
                    topMenu.Options.Add(newOption);
                    addOptions(menuOption.Id.Value, topMenu, leftMenu, breadCrumb, newOption, dict);
                }
                else
                {
                    // Non-root menu options or left menu options
                    if (menuOption.OptionType == OptionType_LeftOption)
                    {
                        leftMenu.Options.Add(newOption);
                    }
                    else
                    {
                        parentOption.Options.Add(newOption);
                    }
                    addOptions(menuOption.Id.Value, topMenu, leftMenu, breadCrumb, newOption, dict);
                }
            }
        }
        //------------------------------------------------------------

        public Dictionary <string, Dictionary <int, MenuOptionModel> > getMenuOptions(string userName, string IP)
        {
            Dictionary <string, Dictionary <int, MenuOptionModel> > dictionaryMenuOptions = new Dictionary <string, Dictionary <int, MenuOptionModel> >();

            dictionaryMenuOptions.Add(MENU_SALES, new Dictionary <int, MenuOptionModel>());
            dictionaryMenuOptions.Add(MENU_FINANCING, new Dictionary <int, MenuOptionModel>());
            dictionaryMenuOptions.Add(MENU_BANK, new Dictionary <int, MenuOptionModel>());
            dictionaryMenuOptions.Add(MENU_CONFIGURATION, new Dictionary <int, MenuOptionModel>());
            dictionaryMenuOptions.Add(MENU_USER, new Dictionary <int, MenuOptionModel>());

            Usuario user = new Usuario();

            user.setearAuditoria(userName, IP);
            user.Username = userName;
            List <OpcionMenu> listOpcionMenu = user.OpcionesHabilitadas();
            var orderedListOpcionMenu        =
                from m in listOpcionMenu
                orderby m.Nivel ascending
                select m;

            foreach (OpcionMenu opcionMenu in orderedListOpcionMenu)
            {
                MenuOptionModel menuOptionModel = this.mapMenuOptionModel(opcionMenu, userName, IP);
                if (opcionMenu.NombreMenu.Equals("Ventas"))
                {
                    this.addMenuOption(parseLevel(opcionMenu.Nivel), menuOptionModel, dictionaryMenuOptions[MENU_SALES]);
                }
                else if (opcionMenu.NombreMenu.Equals("Financiaciones"))
                {
                    this.addMenuOption(parseLevel(opcionMenu.Nivel), menuOptionModel, dictionaryMenuOptions[MENU_FINANCING]);
                }
                else if (opcionMenu.NombreMenu.Equals("Banco"))
                {
                    this.addMenuOption(parseLevel(opcionMenu.Nivel), menuOptionModel, dictionaryMenuOptions[MENU_BANK]);
                }
                else if (opcionMenu.NombreMenu.Equals("Configuracion"))
                {
                    this.addMenuOption(parseLevel(opcionMenu.Nivel), menuOptionModel, dictionaryMenuOptions[MENU_CONFIGURATION]);
                }
                else if (opcionMenu.NombreMenu.Equals("Usuario"))
                {
                    this.addMenuOption(parseLevel(opcionMenu.Nivel), menuOptionModel, dictionaryMenuOptions[MENU_USER]);
                }
            }

            return(dictionaryMenuOptions);
        }
Example #7
0
 public ToolStripItem UnSelectedSubItems(MenuOptionModel option)
 {
     throw new NotImplementedException();
 }
        public async Task <IActionResult> Get()
        {
            var options = new List <MenuOptionModel>();

            if (this.workContext.CurrentUser.IsAdmin())
            {
                options.Add(new MenuOptionModel()
                {
                    Id = 1, Name = "Hostales", Key = "Hostels", Url = "/hostels", Icon = "fa-building-o", DisplayOrder = 2
                });
                options.Add(new MenuOptionModel()
                {
                    Id = 4, Name = "Usuarios", Key = "Users", Url = "/users", Icon = "fa-users", DisplayOrder = 4
                });

                var settings = new MenuOptionModel()
                {
                    Id = 5, Name = "Configuracion", Key = "SettingsParent", Icon = "fa-cogs", Children = new List <MenuOptionModel>(), Url = "#", DisplayOrder = 5
                };
                options.Add(settings);
                settings.Children.Add(new MenuOptionModel()
                {
                    Id = 6, Name = "Notificaciones", Key = "Notifications", Url = "/notifications", Icon = "fa-tasks", DisplayOrder = 6
                });
                settings.Children.Add(new MenuOptionModel()
                {
                    Id = 7, Name = "Ajustes", Key = "Settings", Url = "/systemsettings", Icon = "fa-cogs", DisplayOrder = 7
                });
                settings.Children.Add(new MenuOptionModel()
                {
                    Id = 8, Name = "Recursos", Key = "TextResources", Url = "/textresources", Icon = "fa-font", DisplayOrder = 8
                });
                settings.Children.Add(new MenuOptionModel()
                {
                    Id = 9, Name = "Notificaciones Correo", Key = "EmailNotifications", Url = "/emailnotifications", Icon = "fa-send", DisplayOrder = 9
                });
                settings.Children.Add(new MenuOptionModel()
                {
                    Id = 10, Name = "Log de errores", Key = "Logs", Url = "/logs", Icon = "fa-list", DisplayOrder = 10
                });
            }

            options.Add(new MenuOptionModel()
            {
                Id = 3, Name = "Inicio", Key = "Dashboard", Url = "/", Icon = "fa-home", DisplayOrder = 0
            });
            options.Add(new MenuOptionModel()
            {
                Id = 2, Name = "Habitaciones", Key = "Rooms", Url = "/rooms", Icon = "fa-hotel", DisplayOrder = 3
            });
            options.Add(new MenuOptionModel()
            {
                Id = 11, Name = "Calendario", Key = "Calendar", Url = "/calendar", Icon = "fa-calendar", DisplayOrder = 1
            });
            options.Add(new MenuOptionModel()
            {
                Id = 11, Name = "Disponibilidad", Key = "Booking", Url = "/bookings", Icon = "fa-check", DisplayOrder = 2
            });

            await Task.FromResult(0);

            return(this.Ok(options.OrderBy(c => c.DisplayOrder)));
        }