示例#1
0
        public void BytGarage()
        {
            var query = from item in kommandolista
                        where item.Category == "Byt garage"
                        orderby item.ID
                        select item;

            activeMenu  = query.ToList <UIItem>();
            active      = activeMenu.First();
            activeindex = 0;
        }
示例#2
0
        private void SetToMainMenu()
        {
            var query = from item in kommandolista
                        where item.Category == "Huvudmeny"
                        orderby item.ID
                        select item;

            activeMenu  = query.ToList <UIItem>();
            active      = activeMenu.ElementAt(0);
            activeindex = 0;
        }
示例#3
0
        private void ValjGarage()
        {
            List <UIItem> tempmeny = new List <UIItem>();

            for (int i = 0; i < garages.Count(); i++)
            {
                tempmeny.Add(new UIItem(garages.ElementAt(i).Name, "Alla garage", garages.ElementAt(i).Max.ToString(), AllaGarage, i + 1));
            }
            activeMenu  = tempmeny;
            activeindex = 0;
            active      = activeMenu.First();
        }
示例#4
0
        private void TaBortVehicle()
        {
            List <UIItem> tempmeny = new List <UIItem>();

            foreach (Vehicle vehicle in garage)
            {
                tempmeny.Add(new UIItem(vehicle.Type, "TaBortMig", vehicle.REG_NR, TaBortMig, 0));
            }
            tempmeny.Add(new UIItem("Return to main menu", "Return", SetToMainMenu, tempmeny.Count()));
            activeMenu  = tempmeny.OrderBy(b => b.Command).ToList();
            active      = activeMenu.First();
            activeindex = 0;
        }
示例#5
0
        private void FyllTyp()
        {
            var query = from item in kommandolista
                        where item.Category == "Fill Type" || item.Category == "Return"
                        orderby item.ID
                        select item;

            activeMenu = query.ToList <UIItem>();

            active = activeMenu.ElementAt(0);

            activeindex = 0;
        }
示例#6
0
        private void ListaTyper()
        {
            List <UIItem> nyMeny = new List <UIItem>();
            var           types  = from vehicle in garage
                                   group vehicle by vehicle.Type into type
                                   select type;

            foreach (var type in types)
            {
                nyMeny.Add(new UIItem(type.Key, "Type List", type.Count().ToString(), ShowType, 1));
            }
            nyMeny.Add(new UIItem("Return to main menu", "Type List", SetToMainMenu, types.Count()));
            activeMenu  = nyMeny;
            active      = activeMenu.First();
            activeindex = 0;
        }
示例#7
0
        public void SokPaOlikaVariabler()
        {
            var typeQuery = (from item in kommandolista
                             where item.Command == "Type" && item.Category == "Sök på olika variabler"
                             select item).First();

            typeQuery.Additional = (active.Category == "Search Type")? active.Command : " ";

            var query = from item in kommandolista
                        where item.Category == "Sök på olika variabler"
                        orderby item.ID
                        select item;

            activeMenu  = query.ToList <UIItem>();
            active      = activeMenu.First();
            activeindex = 0;
        }
示例#8
0
        private void CreateBuss()
        {
            UIItem typ = kommandolista.Where(item => item.Command == "Type" && item.Category == "Create Vehicle")
                         //.Select (item => item)
                         //.ToArray()
                         .First();

            typ.Additional = "Buss";
            var query = from item in kommandolista
                        where item.Category == "Create Buss" || item.Category == "Create LandVehicle" || item.Category == "Create Vehicle" || item.Category == "Return"
                        orderby item.ID
                        select item;

            activeMenu = query.ToList <UIItem>();

            active = activeMenu.ElementAt(0);

            activeindex = 0;
        }
示例#9
0
        private void ListaTyper2()
        {
            List <UIItem> nyMeny = new List <UIItem>();
            var           types  = (from vehicle in garage
                                    group vehicle by vehicle.Type into typ
                                    select typ.Key).ToArray();
            var antal = (from vehicle in garage
                         group vehicle by vehicle.Type into ant
                         select ant.Count()).ToArray();

            for (int i = 0; i < types.Length; i++)
            {
                nyMeny.Add(new UIItem(types[i], "Type List", antal[i].ToString(), ShowType, i));
            }
            nyMeny.Add(new UIItem("Return to main menu", "Type List", SetToMainMenu, types.Count()));
            activeMenu  = nyMeny;
            active      = activeMenu.First();
            activeindex = 0;
        }
示例#10
0
        public bool RunMenu()
        {
            Console.Clear();
            bool avsluta = false;

            Console.SetWindowSize(80, activeMenu.Count() + 5);
            foreach (string argument in arguments)
            {
                Console.WriteLine(argument);
            }
            foreach (UIItem punkt in activeMenu)
            {
                if (punkt == active)
                {
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.WriteLine(punkt.Command + ((punkt.Additional != "")? ": " + punkt.Additional : ""));
                    Console.ResetColor();
                }
                else
                {
                    Console.WriteLine(punkt.Command + ((punkt.Additional != "") ? ": " + punkt.Additional : ""));
                }
            }
            ConsoleKeyInfo svar = Console.ReadKey();

            switch (svar.Key)
            {
            case ConsoleKey.UpArrow:
                if (activeindex > 0)
                {
                    activeindex -= 1;
                }
                else
                {
                    activeindex = activeMenu.Count - 1;
                }
                active = activeMenu.ElementAt(activeindex);
                break;

            case ConsoleKey.DownArrow:
                if (activeindex < activeMenu.Count - 1)
                {
                    activeindex += 1;
                }
                else
                {
                    activeindex = 0;
                }
                active = activeMenu.ElementAt(activeindex);
                break;

            case ConsoleKey.Enter:
                Console.Clear();
                if (active.Command == "Exit")
                {
                    avsluta = true;
                }
                else
                {
                    active.Invoke();
                }
                //avsluta = true;
                break;

            case ConsoleKey.Escape:
                avsluta = true;
                break;

            default:
                break;
            }
            return(!avsluta);
        }
示例#11
0
        public GarageUI(List <Garage <Vehicle> > gar)
        {
            arguments = new string[0];
            garages   = gar;

            garage        = garages.First();
            kommandolista = new List <UIItem>();
            kommandolista.Add(new UIItem("List vehicles", "Huvudmeny", ListaVehicle, 0));
            kommandolista.Add(new UIItem("List types of vehicle", "Huvudmeny", ListaTyper, 1));
            kommandolista.Add(new UIItem("Create new vehicle", "Huvudmeny", FyllTyp, 2));
            kommandolista.Add(new UIItem("Remove vehicle", "Huvudmeny", TaBortVehicle, 3));
            kommandolista.Add(new UIItem("Change garage", "Huvudmeny", BytGarage, 3));
            kommandolista.Add(new UIItem("Search on Regnr", "Huvudmeny", SokPaRegnr, 4));
            kommandolista.Add(new UIItem("Search on different variables", "Huvudmeny", SokPaOlikaVariabler, 5));
            kommandolista.Add(new UIItem("Save garages to disc", "Huvudmeny", SparaTillDisk, 6));
            kommandolista.Add(new UIItem("Exit", "Huvudmeny", SparaTillDisk, 7));
            kommandolista.Add(new UIItem("Return to main menu", "Return", SetToMainMenu, 100));

            kommandolista.Add(new UIItem("Skapa bil", "Skapa vehicle", SkapaBil, 1));
            kommandolista.Add(new UIItem("Skapa båt", "Skapa vehicle", SkapaBat, 2));
            kommandolista.Add(new UIItem("Skapa buss", "Skapa vehicle", SkapaBuss, 3));
            kommandolista.Add(new UIItem("Skapa motorcykel", "Skapa vehicle", SkapaMC, 4));
            kommandolista.Add(new UIItem("Skapa flygplan", "Skapa vehicle", SkapaFlygplan, 5));

            kommandolista.Add(new UIItem("Create new garage", "Byt garage", SkapaGarage, 1));
            kommandolista.Add(new UIItem("Choose garage", "Byt garage", ValjGarage, 2));

            kommandolista.Add(new UIItem("REG_NR", "Sök på olika variabler", " ", "string", SokFras, 1));
            kommandolista.Add(new UIItem("Color", "Sök på olika variabler", " ", "string", SokFras, 1));
            kommandolista.Add(new UIItem("Construction year", "Sök på olika variabler", " ", "int", SokFras, 1));
            kommandolista.Add(new UIItem("Number of wheels", "Sök på olika variabler", " ", "int", SokFras, 1));
            kommandolista.Add(new UIItem("Type", "Sök på olika variabler", " ", "string", FyllTypSok, 0));
            kommandolista.Add(new UIItem("Mileage", "Sök på olika variabler", " ", "int", SokFras, 1));
            kommandolista.Add(new UIItem("License requirement", "Sök på olika variabler", " ", "string", SokFras, 1));
            kommandolista.Add(new UIItem("Search", "Sök på olika variabler", SokMig, 2));

            kommandolista.Add(new UIItem("Type", "Create Vehicle", " ", "string", FyllTyp, 1));
            kommandolista.Add(new UIItem("REG_NR", "Create Vehicle", " ", "string", Fyll, 2));
            kommandolista.Add(new UIItem("Color", "Create Vehicle", " ", "string", Fyll, 3));
            kommandolista.Add(new UIItem("Number of wheels", "Create Vehicle", " ", "int", Fyll, 4));
            kommandolista.Add(new UIItem("Construction year", "Create Vehicle", " ", "int", Fyll, 5));

            kommandolista.Add(new UIItem("Mileage", "Create LandVehicle", " ", "int", Fyll, 6));
            kommandolista.Add(new UIItem("License requirement", "Create LandVehicle", " ", "string", Fyll, 7));

            kommandolista.Add(new UIItem("Brand", "Create Motorcycle", " ", "string", Fyll, 8));
            kommandolista.Add(new UIItem("Category", "Create Motorcycle", " ", "string", Fyll, 9));

            kommandolista.Add(new UIItem("Baggage volume", "Create Car", " ", "double", Fyll, 10));
            kommandolista.Add(new UIItem("Fuel type", "Create Car", " ", "string", Fyll, 11));

            kommandolista.Add(new UIItem("Number of seats", "Create Buss", " ", "int", Fyll, 12));
            kommandolista.Add(new UIItem("Line", "Create Buss", " ", "int", Fyll, 13));

            kommandolista.Add(new UIItem("Buoyancy", "Create Boat", " ", "int", Fyll, 14));
            kommandolista.Add(new UIItem("Length", "Create Boat", " ", "int", Fyll, 15));

            kommandolista.Add(new UIItem("Maximum altitude", "Create Airplane", " ", "int", Fyll, 16));
            kommandolista.Add(new UIItem("Airline", "Create Airplane", " ", "int", Fyll, 17));

            kommandolista.Add(new UIItem("Finish", "Create Vehicle", Create, 18));

            kommandolista.Add(new UIItem("Car", "Fill Type", CreateCar, 1));
            kommandolista.Add(new UIItem("Buss", "Fill Type", CreateBuss, 2));
            kommandolista.Add(new UIItem("Motorcycle", "Fill Type", CreateMC, 3));
            kommandolista.Add(new UIItem("Boat", "Fill Type", CreateBoat, 4));
            kommandolista.Add(new UIItem("Airplane", "Fill Type", CreateAirplane, 5));

            kommandolista.Add(new UIItem("Car", "Search Type", SokPaOlikaVariabler, 1));
            kommandolista.Add(new UIItem("Buss", "Search Type", SokPaOlikaVariabler, 2));
            kommandolista.Add(new UIItem("Motorcycle", "Search Type", SokPaOlikaVariabler, 3));
            kommandolista.Add(new UIItem("Boat", "Search Type", SokPaOlikaVariabler, 4));
            kommandolista.Add(new UIItem("Airplane", "Search Type", SokPaOlikaVariabler, 5));
            var query = from item in kommandolista
                        where item.Category == "Huvudmeny"
                        orderby item.ID
                        select item;

            activeMenu = query.ToList <UIItem>();

            active = activeMenu.ElementAt(0);

            activeindex = 0;
        }