Example #1
0
        public MainMenuState(
            StateManager manager_,
            GraphicsDevice device_,
            FontManager fontManager_,
            InputController <SimpleMenu> controller_)
            : base(manager_)
        {
            menu             = new SimpleMenu(device_, fontManager_, new Vector2(512.0f, 300.0f));
            menu.OnSelected += new SimpleMenu.MenuEntryCallBack(this.OnMenuSeletection);
            controller       = controller_;

            scrollDirection = new Vector2(1.0f, 0.0f);
            scrollDistance  = 0.0f;

            emitter = new SmokeEmitter
                      (
                Manager.ParticleSystem.Content.Load <Texture2D>("particle_puff"),
                1.5f, Color.Orange, Color.DarkGray, 1.0f, 500
                      );

            Vector2 direction = new Vector2(0.0f, 1.0f);
            Vector2 position  = new Vector2(526.0f, 125.0f);

            emitter.Direction = direction;
            emitter.Position  = position;

            Manager.ParticleSystem.AddEmitter(emitter);
        }
        private static List <SimpleMenu> GetAllMenus(List <SimpleModule> allModule, Configs ConfigInfo)
        {
            var localizer = new ResourceManagerStringLocalizerFactory(Options.Create <LocalizationOptions>(new LocalizationOptions {
                ResourcesPath = "Resources"
            }), new Microsoft.Extensions.Logging.LoggerFactory()).Create(typeof(KnifeZ.Virgo.Core.CoreProgram));
            var menus = new List <SimpleMenu>();

            if (ConfigInfo.IsQuickDebug)
            {
                menus = new List <SimpleMenu>();
                var areas = allModule.Where(x => x.NameSpace != "KnifeZ.Virgo.Admin.Api").Select(x => x.Area?.AreaName).Distinct().ToList();
                foreach (var area in areas)
                {
                    var modelmenu = new SimpleMenu
                    {
                        ID       = Guid.NewGuid(),
                        PageName = area ?? localizer["Sys.DefaultArea"]
                    };
                    menus.Add(modelmenu);
                    var pages = allModule.Where(x => x.NameSpace != "KnifeZ.Virgo.Admin.Api" && x.Area?.AreaName == area).SelectMany(x => x.Actions).Where(x => x.MethodName.ToLower() == "index").ToList();
                    foreach (var page in pages)
                    {
                        var url = page.Url;
                        menus.Add(new SimpleMenu
                        {
                            ID       = Guid.NewGuid(),
                            ParentId = modelmenu.ID,
                            PageName = page.Module.ActionDes == null ? page.Module.ModuleName : page.Module.ActionDes.Description,
                            Url      = url
                        });
                    }
                }
            }
            else
            {
                try
                {
                    using (var dc = ConfigInfo.Connections.Where(x => x.Key.ToLower() == "default").FirstOrDefault().CreateDC())
                    {
                        menus.AddRange(dc?.Set <FrameworkMenu>()
                                       .OrderBy(x => x.DisplayOrder)
                                       .Select(x => new SimpleMenu
                        {
                            ID           = x.ID,
                            ParentId     = x.ParentId,
                            PageName     = x.PageName,
                            Url          = x.Url,
                            DisplayOrder = x.DisplayOrder,
                            ShowOnMenu   = x.ShowOnMenu,
                            Icon         = x.ICon,
                        })
                                       .ToList());
                    }
                }
                catch { }
            }
            return(menus);
        }
Example #3
0
        public IEnumerable <SimpleMenu> PostMenuListV2([FromHeader] string AppCode, [FromHeader] string CompanyCode, [FromHeader] string DeviceSyncDate = "1900-01-01 00:00:00")
        {
            string            UpperCaseCC  = CompanyCode.Trim().ToUpper();
            DateTime          LastSyncDate = DateTime.Parse(DeviceSyncDate);
            List <SimpleMenu> ListOfMenus  = new List <SimpleMenu>();

            CreatorEntities    db     = new CreatorEntities();
            List <ClientMenus> Listcm = db.ClientMenus.Where(c => c.ClientApps.Clients.Code == UpperCaseCC)
                                        .Where(ca => ca.ClientApps.Apps.AppCode == AppCode)
                                        .Where(csc => System.Data.Entity.SqlServer.SqlFunctions.DateDiff("MINUTE", csc.ChangeDate, LastSyncDate) < 0)
                                        .ToList();

            foreach (ClientMenus cmitem in Listcm)
            {
                SimpleMenu cm = new SimpleMenu();
                cm.ID     = cmitem.ID;
                cm.Name   = cmitem.Name;
                cm.Side   = (bool)cmitem.SideMenu;
                cm.Bottom = (bool)cmitem.BottomMenu;
                cm.Slide  = (bool)cmitem.ScrollPage;
                cm.Action = cmitem.MenuAction;
                cm.Order  = (int)cmitem.MenuOrder;

                if ((cmitem.ImageReference != null) && (cmitem.HeadingReference != null))
                {
                    if ((cmitem.ImageReference != "") && (File.Exists(CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + cmitem.ImageReference) == false))
                    {
                        int    StartIndex       = cmitem.ImageReference.IndexOf("_") + 1;
                        int    CopyLenght       = cmitem.ImageReference.Length - (StartIndex);
                        string OriginalFilename = cmitem.ImageReference.Substring(StartIndex, CopyLenght);
                        File.Copy(CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + OriginalFilename, CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + cmitem.ImageReference);
                    }

                    cm.Icon = Convert.ToBase64String(File.ReadAllBytes(CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + cmitem.ImageReference));

                    if ((cmitem.HeadingReference != "") && (File.Exists(CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + cmitem.HeadingReference) == false))
                    {
                        int    StartIndex       = cmitem.HeadingReference.IndexOf("_") + 1;
                        int    CopyLenght       = cmitem.HeadingReference.Length - (StartIndex);
                        string OriginalFilename = cmitem.HeadingReference.Substring(StartIndex, CopyLenght);
                        File.Copy(CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + OriginalFilename, CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + cmitem.HeadingReference);
                    }

                    cm.Header = Convert.ToBase64String(File.ReadAllBytes(CreatorAPI.Properties.Settings.Default.ServerPath + "\\" + cmitem.HeadingReference));
                }
                else
                {
                    cm.Icon   = "";
                    cm.Header = "";
                }

                cm.Updated = ((DateTime)cmitem.ChangeDate).ToString("yyyy-MM-dd HH:mm:ss");

                ListOfMenus.Add(cm);
            }

            return(ListOfMenus);
        }
 public void SetActiveMenu(SimpleMenu menu, bool setHistory)
 {
     //close current menu operation.
     history = currentMenu;
     currentMenu.CloseMenu();
     currentMenu = menu;
     //open new menu
     currentMenu.OpenMenu(history);
 }
Example #5
0
        public void ConstructorShouldCreateList_Input1()
        {
            string option1 = "Menu option one";

            testMenu = new SimpleMenu(
                option1
                );

            Assert.AreEqual(option1, testMenu.menuOptions[0]);
        }
Example #6
0
        public void ConstructorShouldCreateList_Input2()
        {
            testMenu = new SimpleMenu(
                option1,
                option2
                );

            Assert.AreEqual(option1, testMenu.menuOptions[0]);
            Assert.AreEqual(option2, testMenu.menuOptions[1]);
        }
Example #7
0
    public void Init(SimpleMenu menu, GameObject mapCreationCan)
    {
        if (initialized)
        {
            return;
        }

        _menu       = menu;
        enabled     = true;
        initialized = true;
        _map        = new GameObject("map");

        _mapCreationCanGO = mapCreationCan;
    }
Example #8
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         if (menuStack.Count > 0)
         {
             menuStack.Peek().OnBackPressed();
         }
         else
         {
             // TODO: change me
             SimpleMenu.Show();
         }
     }
 }
Example #9
0
        static void Main()
        {
            var meny          = new SimpleMenu(@"main.bgr", ConsoleColor.Black, 1, 1, '*');
            var musicForStart = new Audio(@"Logo.mp3");
            var musicForEnd   = new Audio(@"Game Over.mp3");

            musicForStart.Play();

            Console.Title           = "ITLabs - Checkers v1.0";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WindowWidth     = 90;
            Console.WindowHeight    = 30;

            meny.AddItem(41, 16, "S T A R T");
            meny.AddItem(41, 18, " E X I T");

            var choose = meny.StartMenu();
            var game   = new Game();

            switch (choose)
            {
            case 1:

                Console.Clear();
                musicForStart.Stop();

                game.Start();

                while (!game.IsGameOver())
                {
                    game.FindCheckersWithTakes();
                    game.SetMove();
                    game.SwitchPlayer();
                }
                game.ClearMessageBar();
                Console.SetCursorPosition(50, 10);
                Console.Write("Game Over");
                musicForEnd.Play();
                Console.ReadLine();

                break;

            case 2:
                Environment.Exit(0);
                break;
            }
        }
Example #10
0
        static void Main()
        {
            var meny = new SimpleMenu(@"main.bgr", ConsoleColor.Black, 1, 1, '*');
            var musicForStart = new Audio(@"Logo.mp3");
            var musicForEnd = new Audio(@"Game Over.mp3");
            musicForStart.Play();
            
            Console.Title = "ITLabs - Checkers v1.0";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WindowWidth = 90;
            Console.WindowHeight = 30;
            
            meny.AddItem(41, 16, "S T A R T");
            meny.AddItem(41, 18, " E X I T");

            var choose = meny.StartMenu();
            var game = new Game();

            switch (choose)
            {
                case 1:

                    Console.Clear();
                    musicForStart.Stop();

                    game.Start();

                    while (!game.IsGameOver())
                    {
                        game.FindCheckersWithTakes();
                        game.SetMove();
                        game.SwitchPlayer();
                    }
                    game.ClearMessageBar();
                    Console.SetCursorPosition(50, 10);
                    Console.Write("Game Over");
                    musicForEnd.Play();
                    Console.ReadLine();

                    break;

                case 2:
                    Environment.Exit(0);
                    break;
            }
        }
Example #11
0
 public void OnMenuSeletection(SimpleMenu menu, int itemIndex)
 {
     switch (itemIndex)
     {
     case 2:
     {
         menuVisual.IsVisible = false;
         // call this to avoid exiting previous state
         // we save this state instead to return to it
         Manager.SetRawState(new MessageBoxState(
                                 Manager, "Are you sure you want to exit?", this,
                                 new MessageBoxGamePadController(
                                     new MessageBoxGamePadController.OnAccept(this.OnAcceptExit),
                                     new MessageBoxGamePadController.OnCancel(this.OnCancelExit))),
                             true, false);
         break;
     }
     }
 }
Example #12
0
    public void OpenMenu(SimpleMenu nHistory)
    {
        if (nHistory != null)
        {
            history = nHistory;
        }
        Clamp();
        if (snapToIndexZeroOnEnable)
        {
            cursorIndex = 0;
        }

        SetCursorPosition(true);
        if (!enableOnOpen)
        {
            return;
        }
        this.gameObject.SetActive(true);
    }
Example #13
0
        public override void Load(IContentLoader loader)
        {
            var logoTexture = loader.Load <Texture2D>(ContentPaths.LOGO_START_SCREEN);

            logo = new ImageElement(logoTexture, new ImageElementSettings
            {
                HorizontalAlignment = ImageHorizontalAlignment.Center,
                VerticalAlignment   = ImageVerticalAlignment.Center,
            })
            {
                Position = base.Game.ScreenCenter + new Vector2(0, -100)
            };

            menu = new SimpleMenu(ContentPaths.FONT_UI_GENERAL, new Dictionary <string, Action>()
            {
                { "Start Game", () => StartGame?.Invoke(this, null) },
                { "Exit Game", () => ExitGame?.Invoke(this, null) }
            })
            {
                Position = base.Game.ScreenCenter
            };

            menu.Load(loader);
        }
 public void SetActiveMenu(SimpleMenu menu)
 {
     //record history by default
     SetActiveMenu(menu, true);
 }
Example #15
0
 public PlayerMenuInfo(Player player, SimpleMenu menu)
 {
     Player = player;
     Menu = menu;
 }
Example #16
0
        private static void UseMenu()
        {
            SimpleMenu menu = new SimpleMenu();

            menu.RunCollageMenu();
        }
Example #17
0
        static void Main(string[] args)
        {
            SimpleMenu mainMenu = new SimpleMenu(
                "Add",
                "Quit"
                );

            SimpleMenu delimeterOptions = new SimpleMenu(
                "No customer delimeter",
                "Custom char delimeter",
                "Custom delimeter of variable length"
                );

            bool flag = true;

            while (flag)
            {
                Console.WriteLine();
                mainMenu.ShowMenuOptions();
                string selection = Console.ReadLine();

                switch (selection)
                {
                case "1":     // Selected Add
                    Console.WriteLine();
                    Console.Write("Please enter two numbers to add: ");
                    string input = Console.ReadLine();

                    Console.WriteLine();
                    delimeterOptions.ShowMenuOptions();
                    string delimMenuOption = Console.ReadLine();
                    Console.WriteLine();

                    switch (delimMenuOption)
                    {
                    case "1":          // No Delim option
                        try
                        {
                            List <double> nums   = InputParser.ParseTextToDouble(input);
                            double        result = Operation.Add(nums);
                            Console.WriteLine($"Result: {result:N2}\n");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        break;

                    default:
                        Console.Write("Please enter delimeter(s) separated by a space: ");

                        string   delimString  = Console.ReadLine();
                        string[] delimOptions = delimString.Split(' ');
                        Console.WriteLine();

                        try
                        {
                            List <double> nums = InputParser.ParseTextToDouble(input, delimOptions);

                            double result = Operation.Add(nums);
                            Console.WriteLine($"Result: {result:N2}\n");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        break;
                    }
                    break;

                default:
                    flag = false;
                    Console.WriteLine();
                    break;
                }
            }
        }
Example #18
0
 public MenuVisual(SimpleMenu menu_)
     : base(null)
 {
     menu = menu_;
 }
Example #19
0
        public OptionsMenu()
        {
            AdminUser manager = new AdminUser();

            bool firstChoise = true;
            int  select;

            while (firstChoise)
            {
                bool correctNum = false;
                do
                {
                    Console.WriteLine("1.Application Login\n2.Login As Super Admin\n3.Create Account\n0.Close Application");
                    Console.WriteLine("=================");
                    Console.WriteLine("Select from Menu:");



                    bool isNum = int.TryParse(Console.ReadLine(), out select);
                    if (select < 0 || select > 3)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkYellow;
                        Console.WriteLine("Your choose it's out of range.");
                        Console.ResetColor();
                        break;
                    }
                    else
                    {
                        correctNum = true;
                    }
                } while (!correctNum);

                switch (select)
                {
                case 1:
                    //This bool become true only if username and pass it's correct
                    //otherwise still ask insert username and pass
                    bool c = false;

                    do
                    {
                        string   user = CreateUser("Give", "username");
                        string   pass = CreateUser("Give", "password");
                        AccessId x    = manager.Login(user, pass);
                        if (x != 0 && x != AccessId.Admin)
                        {
                            Console.WriteLine($"Welcome {user}");

                            switch (x)
                            {
                            case AccessId.Simple:
                                SimpleMenu simpleMenu = new SimpleMenu(user);
                                break;

                            case AccessId.Basic:
                                BasicMenu basicMenu = new BasicMenu(user);
                                break;

                            case AccessId.Edit:
                                EditMenu editMenu = new EditMenu(user);
                                break;

                            case AccessId.Delete:
                                DeleteMenu deleteMenu = new DeleteMenu(user);
                                break;
                            }
                            c = true;
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.DarkRed;
                            Console.WriteLine("Your username or password it's incorrect.Try again.");
                            Console.ResetColor();
                        }
                    } while (!c);
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine(String.Format("{0," + Console.WindowWidth / 2 + "}", "Admin Login Form"));
                    string   userAdmin = CreateUser("Give", "username");
                    string   password  = CreateUser("Give", "password");
                    AccessId adm       = manager.Login(userAdmin, password);
                    if (adm == AccessId.Admin)
                    {
                        Console.WriteLine($"Welcome {userAdmin}\n");
                        bool take = false;
                        do
                        {
                            Console.Clear();
                            Console.WriteLine("1.Create a user\n2.View the user of system\n3.Delete a user\n4.Update a user\n0.Log Out");
                            int    val;
                            string email;
                            bool   n = int.TryParse(Console.ReadLine(), out val);
                            switch (val)
                            {
                            case 1:
                                try
                                {
                                    userAdmin = CreateUser("Give", "username");
                                    password  = CreateUser("Give", "password");
                                    email     = CreateUser("Give", "email");
                                    manager.Register(userAdmin, password, email);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine("Press any button to exit.");
                                    Console.ReadKey();
                                    return;
                                }

                                break;

                            case 2:
                                manager.ViewUser();
                                break;

                            case 3:
                                try
                                {
                                    int  userId;
                                    bool id = int.TryParse(CreateUser("Give", "user id"), out userId);
                                    User a  = new User()
                                    {
                                        Id = userId
                                    };
                                    manager.DeleteUser(a);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine("Press any button to exit.");
                                    Console.ReadKey();
                                    return;
                                }
                                break;

                            case 4:
                                Console.WriteLine("1.Change Password\n2.Change Access id\n3.Change email");
                                int      takeVal, _id;
                                bool     _take = int.TryParse(Console.ReadLine(), out takeVal);
                                string   success, _email;
                                AccessId e;
                                switch (takeVal)
                                {
                                case 1:
                                    try
                                    {
                                        _take    = int.TryParse(CreateUser("Give", "user id"), out _id);
                                        password = CreateUser("Give", "password");
                                        manager.UpdateUser(_id, password);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        Console.WriteLine("Press any button to exit.");
                                        Console.ReadKey();
                                        return;
                                    }

                                    break;

                                case 2:
                                    try
                                    {
                                        bool _successBool = false;
                                        _take = int.TryParse(CreateUser("Give", "user id"), out _id);
                                        do
                                        {
                                            success = CreateUser("Give", "access id");
                                            if (!ValidAccessId(success))
                                            {
                                                Console.WriteLine("Not valid access id");
                                            }
                                            else
                                            {
                                                _successBool = true;
                                            }
                                        } while (!_successBool);
                                        e = (AccessId)Enum.Parse(typeof(AccessId), success);
                                        manager.UpdateUser(_id, e);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        Console.WriteLine("Press any button to exit.");
                                        Console.ReadKey();
                                        return;
                                    }

                                    break;

                                case 3:
                                    try
                                    {
                                        _take  = int.TryParse(CreateUser("Give", "user id"), out _id);
                                        _email = CreateUser("Give", "email");
                                        manager.UpdateEmail(_id, _email);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        Console.WriteLine("Press any button to exit.");
                                        Console.ReadKey();
                                        return;
                                    }
                                    break;
                                }
                                break;

                            case 0:
                                Environment.Exit(0);
                                break;
                            }

                            Console.WriteLine("Do you want to continue?(Y/N)");
                            string answer = Console.ReadLine();

                            if (answer == "Y" || answer == "y")
                            {
                                take = false;
                            }
                            else
                            {
                                take = true;
                                manager.Logout();
                            }
                        } while (!take);
                    }
                    else
                    {
                        Console.WriteLine("You enter invalid details!");
                        Environment.Exit(0);
                    }

                    break;

                case 3:
                    string usernameOne, passOne, emailOne;
                    bool   first  = false;
                    bool   second = false;
                    bool   third  = false;

                    do
                    {
                        usernameOne = CreateUser("Give", "username").Trim();
                        var x = manager.ExistUser(usernameOne);
                        if (!x)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The username already exist.");
                            Console.ResetColor();
                        }
                        else if (usernameOne == "" || usernameOne.Length < 6 || usernameOne.Length > 12 || !x)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The username must be between 6 and 12 characters.");
                            Console.ResetColor();
                            first = false;
                        }
                        else
                        {
                            first = true;
                        }
                    } while (!first);

                    do
                    {
                        passOne = CreateUser("Give", "password");
                        bool isValidPass = Regex.IsMatch(passOne, passPattern);
                        if (!isValidPass)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The password must contain between 8 and 15 characters." +
                                              "Also must contain 2 letters,one special character and one number.");
                            Console.ResetColor();
                            second = false;
                        }
                        else
                        {
                            second = true;
                        }
                    } while (!second);

                    do
                    {
                        emailOne = CreateUser("Give", "email").Trim();
                        bool isValidEmail = Regex.IsMatch(emailOne, emailPattern);
                        if (!isValidEmail)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The email doesn't have the correct format.");
                            Console.ResetColor();
                        }
                        else
                        {
                            third = true;
                        }
                    } while (!third);

                    try
                    {
                        bool p = manager.Register(usernameOne, passOne, emailOne);
                        if (p)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.WriteLine("Your account create succesfully.");
                            Console.ResetColor();
                            Console.WriteLine($"Your username: {usernameOne}");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Press any button to exit.");
                        Console.ReadKey();
                        return;
                    }

                    Console.WriteLine("Do you want to continue? Y/N");
                    string yourChoose = Console.ReadLine();
                    if (yourChoose == "Y" || yourChoose == "y")
                    {
                        firstChoise = true;
                    }
                    else
                    {
                        firstChoise = false;
                        manager.Logout();
                    }
                    break;

                case 0:
                    Environment.Exit(0);
                    break;
                }
            }
            Console.ReadKey();
        }