public static Company NewCompany()
        {
            string        name    = "";
            string        rut     = "";
            List <string> newComp = new List <string>()
            {
                "Name: ", "Rut: ", "Go!", "Back"
            };
            Company company = null;


            while (true)
            {
                Console.Clear();
                string selComp = RegexUtilities.GetMenu(newComp);
                if (selComp == newComp[0])
                {
                    newComp[0] = newComp[0].Substring(0, 6);
                    Console.Clear();
                    Console.CursorVisible = true;
                    name                  = RegexUtilities.WriteData(newComp[0]);
                    newComp[0]           += name;
                    Console.CursorVisible = false;
                }

                else if (selComp == newComp[1])
                {
                    newComp[1] = newComp[1].Substring(0, 5);
                    Console.Clear();
                    Console.CursorVisible = true;
                    rut                   = RegexUtilities.WriteData(newComp[1]);
                    newComp[1]           += rut;
                    Console.CursorVisible = false;
                }

                else if (selComp == newComp[2])
                {
                    if (name != "" && rut != "")
                    {
                        try { company = new Company(name, rut); }
                        catch (Exception) { }
                        return(company);
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Information missing!");
                        Thread.Sleep(1300);
                    }
                }

                else if (selComp == newComp[3])
                {
                    return(null);
                }
            }
        }
        public static string CompanyMenu(Company company)
        {
            List <string> menu = new List <string>()
            {
                $"Welcome to {company.GetName()}", "Add/Remove Employee",
                "Add/Remove Area", "Add/Remove Department", "Add/Remove section", "Add/Remove Block", "Show Info", "Back"
            };
            string sel = "";

            while (true)
            {
                sel = RegexUtilities.GetMenu(menu);
                if (sel != "")
                {
                    return("");
                }
            }
        }
        public static string Start(List <string> inicio)
        {
            string select = "";

            while (true)
            {
                Console.Clear();
                Console.CursorVisible = false;
                select = RegexUtilities.GetMenu(inicio);

                if (select != "")
                {
                    break;
                }
            }

            return(select);
        }
예제 #4
0
        public static void Register()
        {
            string username       = null;
            string password       = null;
            string password2      = null;
            string email          = null;
            bool   privateAccount = true;
            bool   premium        = false;
            string a          = null;
            string b          = null;
            string c          = null;
            string d          = null;
            bool   usertaken  = false;
            bool   emailtaken = false;
            string pvt        = "";
            string prem       = "";

            List <string> registrationForm = new List <string>()
            {
                "Username: "******"Email: ",
                "Password: "******"Confirm password: "******"Private account? y/n",
                "Premium user? y/n",
                "Ready!",
                "Back"
            };

            List <string> yesNo = new List <string>()
            {
                "Yes", "No"
            };

            while (true)
            {
                string sel = RegexUtilities.GetMenu(registrationForm);

                if (sel == registrationForm[0])
                {
                    registrationForm[0] = registrationForm[0].Substring(0, 10);
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    Console.CursorVisible = true;
                    username = RegexUtilities.WriteData(registrationForm[0]);
                    Console.CursorVisible = false;
                    usertaken             = UserDB.ContainsKey(username);
                    if (usertaken == true)
                    {
                        usertaken = true;
                        Console.Clear();
                        RegexUtilities.LoadingScreen();
                        Console.WriteLine("Username taken, please choose a different one.");
                        Thread.Sleep(1000);
                        Console.Clear();
                    }
                    else
                    {
                        registrationForm[0] += username;
                        usertaken            = false;
                    }

                    Console.Clear(); RegexUtilities.LoadingScreen();
                }
                else if (sel == registrationForm[1])
                {
                    registrationForm[1] = registrationForm[1].Substring(0, 7);
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    Console.CursorVisible = true;
                    email = RegexUtilities.WriteData(registrationForm[1]);
                    foreach (User user in UserDB.Values)
                    {
                        if (user.GetEmail() == email)
                        {
                            emailtaken = true;
                            break;
                        }
                        else
                        {
                            emailtaken = false;
                        }
                    }

                    Console.CursorVisible = false;

                    if (RegexUtilities.IsValidEmail(email) == true && emailtaken == false)
                    {
                        registrationForm[1] += email;
                    }
                    else
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("Invalid email or email already in use!");
                        Thread.Sleep(1000);
                        Console.Clear();
                        email = null;
                    }


                    Console.Clear(); RegexUtilities.LoadingScreen();
                }

                else if (sel == registrationForm[2])
                {
                    registrationForm[2] = registrationForm[2].Substring(0, 10);
                    Console.Clear(); RegexUtilities.LoadingScreen();
                    Console.CursorVisible = true;
                    Console.Write(registrationForm[2]);
                    password = RegexUtilities.HidePassword();
                    Console.CursorVisible = false;
                    Console.Clear(); RegexUtilities.LoadingScreen();
                    a = "";
                    foreach (char item in password)
                    {
                        a += "•";
                    }
                    registrationForm[2] = $"Password: {a}";
                }
                else if (sel == registrationForm[3] && password == null)
                {
                    Console.Clear(); RegexUtilities.LoadingScreen();
                    Console.WriteLine("You must enter a password first!");
                    Thread.Sleep(1000);
                    Console.Clear(); RegexUtilities.LoadingScreen();
                }
                else if (sel == registrationForm[3] && password != null)
                {
                    registrationForm[3] = registrationForm[3].Substring(0, 18);
                    Console.Clear(); RegexUtilities.LoadingScreen();
                    Console.CursorVisible = true;
                    Console.Write(registrationForm[3]);
                    password2 = RegexUtilities.HidePassword();
                    b         = "";
                    foreach (char item in password2)
                    {
                        b += "•";
                    }
                    registrationForm[3]   = $"Confirm password: {b}";
                    Console.CursorVisible = false;
                    Console.Clear(); RegexUtilities.LoadingScreen();
                }

                else if (sel == registrationForm[4])
                {
                    c = "x";
                    while (true)
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("Do you want your account to be private?");
                        pvt = RegexUtilities.GetMenu(yesNo);
                        if (pvt == "Yes")
                        {
                            privateAccount       = true;
                            registrationForm[4]  = registrationForm[4].Substring(0, 15);
                            registrationForm[4] += ": Yes";
                            break;
                        }
                        else if (pvt == "No")
                        {
                            privateAccount       = false;
                            registrationForm[4]  = registrationForm[4].Substring(0, 15);
                            registrationForm[4] += ": No";
                            break;
                        }
                    }
                    Console.Clear();
                }

                else if (sel == registrationForm[5])
                {
                    d = "x";
                    while (true)
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("Do you want to get our premium service for only $3.990/month?"); // Que incluye...?
                        prem = RegexUtilities.GetMenu(yesNo);
                        if (prem == "Yes")
                        {
                            premium              = true;
                            registrationForm[5]  = registrationForm[5].Substring(0, 12);
                            registrationForm[5] += ": Yes";
                            break;
                        }
                        else if (prem == "No")
                        {
                            premium              = false;
                            registrationForm[5]  = registrationForm[5].Substring(0, 12);
                            registrationForm[5] += ": No";
                            break;
                        }
                    }
                    Console.Clear(); RegexUtilities.LoadingScreen();
                }

                else if (sel == registrationForm[6])
                {
                    if (username == null | usertaken == true)
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("Username in already taken or empty!");
                        Thread.Sleep(1000);
                        Console.Clear(); RegexUtilities.LoadingScreen();
                    }

                    else if (password != password2 | password == null | password2 == null | password == "" | password2 == "")
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("Password doesn't match or empty!");
                        Thread.Sleep(1000);
                        Console.Clear(); RegexUtilities.LoadingScreen();
                    }

                    else if (email == null | emailtaken == true | email == "")
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("Please enter a valid email address!");
                        Thread.Sleep(1000);
                        Console.Clear(); RegexUtilities.LoadingScreen();
                    }

                    else if (c == null)
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("You have to select if you want your account to be private!");
                        Thread.Sleep(1000);
                        Console.Clear(); RegexUtilities.LoadingScreen();
                    }

                    else if (d == null)
                    {
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        Console.WriteLine("You have to select if you want a premium account!");
                        Thread.Sleep(1000);
                        Console.Clear(); RegexUtilities.LoadingScreen();
                    }
                    else
                    {
                        User user = new User(username, email, password, privateAccount, premium, false);
                        UserDB.Add(username, user);
                        Console.Clear();
                        Console.WriteLine("User created successfully!");
                        Console.WriteLine("Now you can log in with your username and password.");
                        Thread.Sleep(1000);
                        Console.Clear(); RegexUtilities.LoadingScreen();
                        return;
                    }
                }

                else if (sel == registrationForm[7])
                {
                    return;
                }

                if (password == password2 && password != null)
                {
                    registrationForm[2] = $"Password: {a} ✔";
                    registrationForm[3] = $"Confirm password: {b} ✔";
                }
                else if (password != password2 && password != null && password2 != null)
                {
                    registrationForm[2] = $"Password: {a} ✗";
                    registrationForm[3] = $"Confirm password: {b} ✗";
                }
            }
        }
예제 #5
0
        public static string LogIn()
        {
            string username = "";
            string password = "";
            string a        = "";

            List <string> opt = new List <string>()
            {
                "Welcome back!", "Username: "******"Password: "******"Log In ->", "Back"
            };

            while (true)
            {
                Console.Clear();
                RegexUtilities.LoadingScreen();
                string selected = RegexUtilities.GetMenu(opt);
                if (selected == "Back")
                {
                    Console.Clear();
                    return("");
                }

                else if (selected == opt[1])
                {
                    Console.CursorVisible = true;
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    opt[1]   = opt[1].Substring(0, 10);
                    username = RegexUtilities.WriteData(opt[1]);
                    opt[1]  += username;
                    Console.CursorVisible = false;
                }

                else if (selected == opt[2])
                {
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    Console.CursorVisible = true;
                    opt[2] = opt[2].Substring(0, 10);
                    Console.Write(opt[2]);
                    password = RegexUtilities.HidePassword();
                    a        = "";
                    foreach (char item in password)
                    {
                        a += "•";
                    }
                    opt[2] = $"Password: {a}";
                    Console.CursorVisible = false;
                }

                else if (selected == "Log In ->")
                {
                    try
                    {
                        User user = UserDB[username];
                        if (user.GetPassword() == password)
                        {
                            Console.WriteLine("Login successful!");
                            Console.WriteLine($"Welcome {username}");
                            Thread.Sleep(1000);
                            Console.Clear();
                            return(username);
                        }
                        else
                        {
                            Console.Clear();
                            Console.WriteLine("Wrong password!");
                            Thread.Sleep(1000);
                            Console.Clear();
                        }
                    }
                    catch (Exception)
                    {
                        Console.Clear();
                        RegexUtilities.LoadingScreen();
                        Console.WriteLine("Username doesn't exist!");
                        Thread.Sleep(1000);
                        Console.Clear();
                    }
                }
            }
        }
예제 #6
0
        public static void Main(string[] args)
        {
            Console.CursorVisible = false;
            RegexUtilities.LoadingScreen();
            Thread.Sleep(3000);
            List<string> start = new List<string>() { "Hello, and welcome to Spotflix!", "Log In" , "Register" ,"Admin Log In", "Exit"};
            List<string> mainMenu = new List<string>() { "Menu", "Search", "Profile", "play", "Log out" };
            List<string> searchMenu = new List<string>() {"Search: ", "Filters", "Go!", "Back" };
            Console.Clear();
            while (true)
            {
                RegexUtilities.LoadingScreen();
                string selectedMenuItem = RegexUtilities.GetMenu(start);
                if (selectedMenuItem == "Log In")
                {
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    string username = Spotflix.LogIn();

                    if (username != "")
                    {
                        User activeUser = Spotflix.GetUserDB[username];
                        while (true)
                        {
                            Console.Clear();
                            RegexUtilities.LoadingScreen();
                            selectedMenuItem = RegexUtilities.GetMenu(mainMenu);
                            if (selectedMenuItem == "Log out") { username = ""; break; }

                            else if (selectedMenuItem == "Search")
                            {
                                while (true)
                                {
                                    Console.Clear();
                                    RegexUtilities.LoadingScreen();
                                    selectedMenuItem = RegexUtilities.GetMenu(searchMenu);
                                    string searchKey = "";
                                    if (selectedMenuItem == searchMenu[0])
                                    {
                                        Console.Clear();
                                        RegexUtilities.LoadingScreen();
                                        searchMenu[0] = searchMenu[0].Substring(0, 8);
                                        searchKey = RegexUtilities.WriteData(searchMenu[0]);
                                        searchMenu[0] += searchKey;
                                        Console.Clear();

                                    }

                                    else if (selectedMenuItem == searchMenu[2])
                                    {
                                        Filter fil = new Filter();
                                        List<Media> results = fil.Search(searchKey);
                                        if (results.Count > 0)
                                        {
                                            List<string> lsSe = new List<string>();
                                            foreach (Media media in results)
                                            {
                                                lsSe.Add(media.GetMetadata().GetName());
                                            }
                                            lsSe.Add("Back");
                                            while (true)
                                            {
                                                string selectMedia = RegexUtilities.GetMenu(lsSe);
                                                if (selectMedia != "" && selectMedia != "Back")
                                                {
                                                    int ind = lsSe.IndexOf(selectMedia);
                                                    Media media = results[ind];
                                                    if (media.GetType() == typeof(Song))
                                                    {
                                                        //display info
                                                        media.Play();
                                                    }
                                                }
                                                else if (selectMedia == "Back")
                                                {
                                                    break;
                                                }

                                            }
                                        }
                                    }
                                    else if (selectedMenuItem == searchMenu[3])
                                    {
                                        Console.Clear();
                                        break;
                                    }
                                }
                            }

                            else if (selectedMenuItem == "play")
                            {


                                //SoundPlayer player = new SoundPlayer();
                                //player.SoundLocation = "CSI.wav";
                                //player.Play();
                                //Player player = new Player();
                                //player.Open("CSI.wav");
                                //Thread.Sleep(30000);
                                //player.End();
                                


                            }
                        }
                    }
                    
                   
                }

                else if (selectedMenuItem == "Register")
                {
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    Spotflix.Register();
                    Save(Spotflix.GetUserDB , Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                }

                else if (selectedMenuItem == "Admin Log In")
                {
                    
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    string adm = Spotflix.AdminLogIn();
                    if (adm != "")
                    {
                        User administrator = Spotflix.GetUserDB[adm];



                        List<string> admMenu = new List<string>() { "Add Media", "a", "b", "c", "Log out" };
                        while (true)
                        {
                            Console.Clear();
                            selectedMenuItem = RegexUtilities.GetMenu(admMenu);

                            if (selectedMenuItem == "Add Media")
                            {
                                Console.Clear();
                                RegexUtilities.LoadingScreen();
                                administrator.AddMedia();
                                Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                                Console.WriteLine("Ready");
                                Thread.Sleep(1000);
                                Console.Clear();
                            }

                            else if (selectedMenuItem == "Log out")
                            {
                                adm = "";
                                break;
                            }

                            else if (selectedMenuItem == "a")
                            {
                                

                            }

                            Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                        }



                    }

                    else
                    {
                        Console.Clear();
                        RegexUtilities.LoadingScreen();
                        Console.WriteLine("You are not an administrator.");
                        break;
                    }
                        
                    
                Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                }



                else if (selectedMenuItem == "Exit")
                {
                    Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                    Environment.Exit(0);
                }
                

                
                Console.Clear();
            }
예제 #7
0
        public void Add()
        {
            List <string> metaMenu = new List <string>()
            {
                "Name: ", "Artist: ", "Album: ", "Genre: ", "Release Year: ", "Record Label: ",
                "Done!", "Back"
            };
            string name   = "";
            string artist = "";
            string genre  = "";
            string album  = "";
            string label  = "";
            string rYear  = "";

            Artist artObj   = null;
            Album  alObj    = null;
            int    relYear  = 0;
            bool   artExist = false;



            while (true)
            {
                string sel = RegexUtilities.GetMenu(metaMenu);

                if (sel == metaMenu[0]) //Name[0]
                {
                    metaMenu[0] = metaMenu[0].Substring(0, 6);
                    Console.Clear();
                    Console.CursorVisible = true;
                    name = RegexUtilities.WriteData(metaMenu[0]);
                    Console.CursorVisible = false;
                    metaMenu[0]          += name;
                    Console.Clear();
                }

                else if (sel == metaMenu[1]) //Artist[1]
                {
                    metaMenu[1] = metaMenu[1].Substring(0, 8);
                    Console.Clear();
                    Console.CursorVisible = true;
                    artist = RegexUtilities.WriteData(metaMenu[1]);
                    Console.CursorVisible = false;
                    metaMenu[1]          += artist;
                    Console.Clear();
                }

                else if (sel == metaMenu[2]) //Album[2]
                {
                    metaMenu[2] = metaMenu[2].Substring(0, 7);
                    Console.Clear();
                    Console.CursorVisible = true;
                    album = RegexUtilities.WriteData(metaMenu[2]);
                    Console.CursorVisible = false;
                    metaMenu[2]          += album;
                    Console.Clear();
                }

                else if (sel == metaMenu[3]) //Genre[3]
                {
                    metaMenu[3] = metaMenu[3].Substring(0, 7);
                    Console.Clear();
                    Console.CursorVisible = true;
                    genre = RegexUtilities.WriteData(metaMenu[3]);
                    Console.CursorVisible = false;
                    metaMenu[3]          += genre;
                    Console.Clear();
                }


                else if (sel == metaMenu[4]) //Release Year[4]int
                {
                    metaMenu[4] = metaMenu[4].Substring(0, 14);
                    Console.Clear();
                    Console.CursorVisible = true;
                    while (true)
                    {
                        rYear = RegexUtilities.WriteData(metaMenu[4]);
                        try
                        {
                            relYear = Convert.ToInt32(rYear);
                            break;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please write a valid number");
                            Console.Clear();
                        }
                    }
                    Console.CursorVisible = false;
                    metaMenu[4]          += rYear;
                    Console.Clear();
                }

                else if (sel == metaMenu[5]) //Label[5]
                {
                    metaMenu[5] = metaMenu[5].Substring(0, 14);
                    Console.Clear();
                    Console.CursorVisible = true;
                    label = RegexUtilities.WriteData(metaMenu[5]);
                    Console.CursorVisible = false;
                    metaMenu[5]          += label;
                    Console.Clear();
                }



                else if (sel == metaMenu[6]) //Done[6]
                {
                    if (name != "" && artist != "" && genre != "" && album != "" && label != "" &&
                        relYear > 0)
                    {
                        foreach (Artist ar in Spotflix.GetPeopleDB)
                        {
                            if (ar.GetName() == artist)
                            {
                                artExist = true;
                                artObj   = ar;
                                break;
                            }
                        }
                        if (artExist == false)
                        {
                            artObj = new Artist(artist);
                            Spotflix.AddPerson(artObj);
                            alObj = new Album(album);
                            artObj.AddAlbum(alObj);
                        }

                        else if (artExist == true)
                        {
                            foreach (Album item in artObj.GetAlbums())
                            {
                                if (item.GetName() == album)
                                {
                                    alObj = item;
                                    break;
                                }
                            }

                            if (alObj == null)
                            {
                                alObj = new Album(album);
                                artObj.AddAlbum(alObj);
                            }
                        }
                        Name            = name;
                        Artist          = artObj;
                        Album           = alObj;
                        Genre           = genre;
                        RecordLabel     = label;
                        PublicationYear = relYear;
                        return;
                    }


                    else
                    {
                        Console.Clear();
                        Console.WriteLine("There is missing information, please fill all the fields.");
                    }
                }
                else if (sel == metaMenu[7]) //Back[7]
                {
                    return;
                }
            }
        }
예제 #8
0
        public void AddInfo(string fileName)
        {
            string        format     = "";
            string        duration   = ""; //segundos
            double        durNum     = 0;
            FileInfo      fi         = new FileInfo(fileName);
            long          size       = fi.Length;
            string        fileSize   = $"{size}bytes";
            string        sel        = "";
            List <string> formatList = new List <string>()
            {
                "AAC	Audio",
                "AVI	Video",
                "MKV	Video",
                "MOV	Video",
                "MP3	Audio",
                "MP4	Video",
                "OOG	Audio",
                "QT		Video",
                "VCD	Video",
                "WAV	Audio",
                "WMA	Audio",
                "WMV	Video"
            };

            List <string> infoOp = new List <string>()
            {
                "Duration: hh:mm:ss", "Format: ", "Done!"
            };

            while (true)
            {
                sel = RegexUtilities.GetMenu(infoOp);

                if (sel == infoOp[0])
                {
                    infoOp[0] = infoOp[0].Substring(0, 18);
                    Console.Clear();
                    Console.CursorVisible = true;
                    while (true)
                    {
                        duration = RegexUtilities.WriteData(infoOp[0]);
                        try
                        {
                            string[] hms  = duration.Split(':');
                            int      hrs  = Convert.ToInt32(hms[0]);
                            int      min  = Convert.ToInt32(hms[1]);
                            int      sec  = Convert.ToInt32(hms[2]);
                            TimeSpan time = new TimeSpan(hrs, min, sec);
                            durNum = time.TotalSeconds;
                            break;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please write a valid duration of hours, minutes and seconds, separated by :");
                            Thread.Sleep(3000);
                            Console.Clear();
                        }
                    }
                    infoOp[0]             = infoOp[0].Substring(0, 14);
                    Console.CursorVisible = false;
                    infoOp[0]            += duration;
                    Console.Clear();
                }

                else if (sel == infoOp[1])
                {
                    infoOp[1] = infoOp[1].Substring(0, 8);
                    Console.Clear();
                    format = "";
                    while (format == "")
                    {
                        format = RegexUtilities.GetMenu(formatList);
                    }
                    Console.CursorVisible = false;
                    infoOp[1]            += format;
                    Console.Clear();
                }

                else if (sel == infoOp[2])
                {
                    if (format != "" && duration != "")
                    {
                        Dictionary <string, string> info = new Dictionary <string, string>();
                        info.Add("format", format);
                        duration = $"{durNum}";
                        info.Add("duration", duration);
                        Duration    = durNum;
                        Information = info;
                        return;
                    }

                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Information missing!");
                        Thread.Sleep(1200);
                    }
                }
            }
        }
예제 #9
0
        public void Add()
        {
            List <string> metaMenu = new List <string>()
            {
                "Name: ", "Creator: ", "Genre: ", "Category: ", "Actors: ", "Director: ",
                "Studio: ", "Release Year: ", "Description: ", "Resolution: ", "Aspect Ratio: ", "Done!", "Back"
            };
            string        name        = "";
            string        creator     = "";
            string        genre       = "";
            string        category    = "";
            string        studio      = "";
            string        rYear       = "";
            string        description = "";
            Person        dirObj      = null;
            int           relYear     = 0;
            bool          dirExist    = false;
            string        director    = "";
            string        resolution  = "";
            string        aspectRatio = "";
            List <string> resList     = new List <string>()
            {
                "480p (720 x 480)", "720p (1280 x 720)", "1080p (1920 x 1080)",
                "1440p (2560 x 1440)", "4K (3840 x 2160)", "8K (7680 x 4320)"
            };
            List <string> ratioList = new List <string>()
            {
                "Standard (4:3)", "Widescrenn 16:9", "Ultra Widescreen 21:9"
            };
            List <string> actors = new List <string>();

            while (true)
            {
                string sel = RegexUtilities.GetMenu(metaMenu);

                if (sel == metaMenu[0]) //Name[0]
                {
                    metaMenu[0] = metaMenu[0].Substring(0, 6);
                    Console.Clear();
                    Console.CursorVisible = true;
                    name = RegexUtilities.WriteData(metaMenu[0]);
                    Console.CursorVisible = false;
                    metaMenu[0]          += name;
                    Console.Clear();
                }

                else if (sel == metaMenu[1]) //Creator[1]
                {
                    metaMenu[1] = metaMenu[1].Substring(0, 9);
                    Console.Clear();
                    Console.CursorVisible = true;
                    creator = RegexUtilities.WriteData(metaMenu[1]);
                    Console.CursorVisible = false;
                    metaMenu[1]          += creator;
                    Console.Clear();
                }

                else if (sel == metaMenu[2]) //Genre[2]
                {
                    metaMenu[2] = metaMenu[2].Substring(0, 7);
                    Console.Clear();
                    Console.CursorVisible = true;
                    genre = RegexUtilities.WriteData(metaMenu[2]);
                    Console.CursorVisible = false;
                    metaMenu[2]          += genre;
                    Console.Clear();
                }

                else if (sel == metaMenu[3]) //Category[3]
                {
                    metaMenu[3] = metaMenu[3].Substring(0, 10);
                    Console.Clear();
                    Console.CursorVisible = true;
                    category = RegexUtilities.WriteData(metaMenu[3]);
                    Console.CursorVisible = false;
                    metaMenu[3]          += category;
                    Console.Clear();
                }

                else if (sel == metaMenu[4])//Actors[4] list<person>
                {
                    metaMenu[4] = metaMenu[4].Substring(0, 8);
                    Console.Clear();
                    Console.CursorVisible = true;
                    actors = RegexUtilities.WriteList(metaMenu[4].Substring(0, 5));
                    Console.CursorVisible = false;
                    metaMenu[4]          += "✔";
                    Console.Clear();
                }

                else if (sel == metaMenu[5]) //Director[5] Person
                {
                    metaMenu[5] = metaMenu[5].Substring(0, 10);
                    Console.Clear();
                    Console.CursorVisible = true;
                    director = RegexUtilities.WriteData(metaMenu[5]);

                    foreach (Person person in Spotflix.GetPeopleDB)
                    {
                        if (person.GetName() == director)
                        {
                            dirExist = true;
                            dirObj   = person;
                            break;
                        }
                    }
                    Console.CursorVisible = false;
                    metaMenu[5]          += director;
                    Console.Clear();
                }

                else if (sel == metaMenu[6]) //Studio[6]
                {
                    metaMenu[6] = metaMenu[6].Substring(0, 8);
                    Console.Clear();
                    Console.CursorVisible = true;
                    studio = RegexUtilities.WriteData(metaMenu[6]);
                    Console.CursorVisible = false;
                    metaMenu[6]          += studio;
                    Console.Clear();
                }

                else if (sel == metaMenu[7]) //Release Year[7]int
                {
                    metaMenu[7] = metaMenu[7].Substring(0, 14);
                    Console.Clear();
                    Console.CursorVisible = true;
                    while (true)
                    {
                        rYear = RegexUtilities.WriteData(metaMenu[7]);
                        try
                        {
                            relYear = Convert.ToInt32(rYear);
                            break;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please write a valid number");
                            Console.Clear();
                        }
                    }
                    Console.CursorVisible = false;
                    metaMenu[7]          += rYear;
                    Console.Clear();
                }

                else if (sel == metaMenu[8]) //Description[8]
                {
                    metaMenu[8] = metaMenu[8].Substring(0, 13);
                    Console.Clear();
                    Console.CursorVisible = true;
                    description           = RegexUtilities.WriteData(metaMenu[8]);
                    Console.CursorVisible = false;
                    metaMenu[8]          += description;
                    Console.Clear();
                }

                else if (sel == metaMenu[9]) //Res[9]
                {
                    metaMenu[9] = metaMenu[9].Substring(0, 12);
                    Console.Clear();
                    resolution = "";
                    while (resolution == "")
                    {
                        resolution = RegexUtilities.GetMenu(resList);
                    }
                    Console.CursorVisible = false;
                    metaMenu[9]          += resolution;
                    Console.Clear();
                }

                else if (sel == metaMenu[10]) //ratio[10]
                {
                    metaMenu[10] = metaMenu[10].Substring(0, 14);
                    Console.Clear();
                    aspectRatio = "";
                    while (aspectRatio == "")
                    {
                        aspectRatio = RegexUtilities.GetMenu(ratioList);
                    }
                    Console.CursorVisible = false;
                    metaMenu[10]         += aspectRatio;
                    Console.Clear();
                }
                else if (sel == metaMenu[11]) //Done[11]
                {
                    if (dirExist == true)
                    {
                        dirObj.AddProfession("Director");
                    }
                    else
                    {
                        dirObj = new Person(director);
                        Spotflix.AddPerson(dirObj);
                    }

                    List <Person> actrs = new List <Person>();
                    Person        actr  = null;
                    foreach (string act in actors)
                    {
                        bool actExist = false;
                        foreach (Person ppl in Spotflix.GetPeopleDB)
                        {
                            if (ppl.GetName() == act)
                            {
                                ppl.AddProfession("Actor");
                                actExist = true;
                                actrs.Add(ppl);
                                break;
                            }
                        }
                        if (actExist == false)
                        {
                            actr = new Person(act);
                            Spotflix.AddPerson(actr);
                            actrs.Add(actr);
                        }
                    }


                    if (name != "" && creator != "" && genre != "" && category != "" && actrs.Count > 0 && director != "" && studio != "" &&
                        relYear > 0 && description != "" && resolution != "" && aspectRatio != "")
                    {
                        Console.Clear();
                        Name        = name;
                        Creator     = creator;
                        Genre       = genre;
                        Category    = category;
                        Actors      = actrs;
                        Director    = dirObj;
                        Studio      = studio;
                        PubYear     = relYear;
                        Description = description;
                        Resolution  = resolution;
                        AspectRatio = aspectRatio;
                        return;
                    }
                    Console.Clear();
                }

                else if (sel == metaMenu[12]) //Back[12]
                {
                    return;
                }
            }
        }
        public static void Main(string[] args)
        {
            Console.CursorVisible = false;
            RegexUtilities.LoadingScreen();
            Thread.Sleep(3000);
            List <string> start = new List <string>()
            {
                "Hello, and welcome to Spotflix!", "Log In", "Register", "Admin Log In", "Exit"
            };
            List <string> mainMenu = new List <string>()
            {
                "Menu", "Search", "Profile", "play", "Log out"
            };
            List <string> searchMenu = new List <string>()
            {
                "Search: ", "Filters", "Go!", "Back"
            };

            Console.Clear();
            while (true)
            {
                RegexUtilities.LoadingScreen();
                string selectedMenuItem = RegexUtilities.GetMenu(start);
                if (selectedMenuItem == "Log In")
                {
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    string username = Spotflix.LogIn();

                    if (username != "")
                    {
                        User activeUser = Spotflix.GetUserDB[username];
                        while (true)
                        {
                            Console.Clear();
                            RegexUtilities.LoadingScreen();
                            selectedMenuItem = RegexUtilities.GetMenu(mainMenu);
                            if (selectedMenuItem == "Log out")
                            {
                                username = ""; break;
                            }

                            else if (selectedMenuItem == "Search")
                            {
                                while (true)
                                {
                                    Console.Clear();
                                    RegexUtilities.LoadingScreen();
                                    selectedMenuItem = RegexUtilities.GetMenu(searchMenu);
                                    string searchKey = "";
                                    if (selectedMenuItem == searchMenu[0])
                                    {
                                        Console.Clear();
                                        RegexUtilities.LoadingScreen();
                                        searchMenu[0]  = searchMenu[0].Substring(0, 8);
                                        searchKey      = RegexUtilities.WriteData(searchMenu[0]);
                                        searchMenu[0] += searchKey;
                                        Console.Clear();
                                    }

                                    else if (selectedMenuItem == searchMenu[2])
                                    {
                                        Filter       fil     = new Filter();
                                        List <Media> results = fil.Search(searchKey);
                                        if (results.Count > 0)
                                        {
                                            List <string> lsSe = new List <string>();
                                            foreach (Media media in results)
                                            {
                                                lsSe.Add(media.GetMetadata().GetName());
                                            }
                                            lsSe.Add("Back");
                                            while (true)
                                            {
                                                string selectMedia = RegexUtilities.GetMenu(lsSe);
                                                if (selectMedia != "" && selectMedia != "Back")
                                                {
                                                    int   ind   = lsSe.IndexOf(selectMedia);
                                                    Media media = results[ind];
                                                    if (media.GetType() == typeof(Song))
                                                    {
                                                        //display info
                                                        media.Play();
                                                    }
                                                }
                                                else if (selectMedia == "Back")
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    else if (selectedMenuItem == searchMenu[3])
                                    {
                                        Console.Clear();
                                        break;
                                    }
                                }
                            }

                            else if (selectedMenuItem == "play")
                            {
                                //SoundPlayer player = new SoundPlayer();
                                //player.SoundLocation = "CSI.wav";
                                //player.Play();
                                //Player player = new Player();
                                //player.Open("CSI.wav");
                                //Thread.Sleep(30000);
                                //player.End();
                            }
                        }
                    }
                }

                else if (selectedMenuItem == "Register")
                {
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    Spotflix.Register();
                    Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                }

                else if (selectedMenuItem == "Admin Log In")
                {
                    Console.Clear();
                    RegexUtilities.LoadingScreen();
                    string adm = Spotflix.AdminLogIn();
                    if (adm != "")
                    {
                        User administrator = Spotflix.GetUserDB[adm];



                        List <string> admMenu = new List <string>()
                        {
                            "Add Media", "a", "b", "c", "Log out"
                        };
                        while (true)
                        {
                            Console.Clear();
                            selectedMenuItem = RegexUtilities.GetMenu(admMenu);

                            if (selectedMenuItem == "Add Media")
                            {
                                Console.Clear();
                                RegexUtilities.LoadingScreen();
                                administrator.AddMedia();
                                Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                                Console.WriteLine("Ready");
                                Thread.Sleep(1000);
                                Console.Clear();
                            }

                            else if (selectedMenuItem == "Log out")
                            {
                                adm = "";
                                break;
                            }

                            else if (selectedMenuItem == "a")
                            {
                            }

                            Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                        }
                    }

                    else
                    {
                        Console.Clear();
                        RegexUtilities.LoadingScreen();
                        Console.WriteLine("You are not an administrator.");
                        break;
                    }


                    Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                }



                else if (selectedMenuItem == "Exit")
                {
                    Save(Spotflix.GetUserDB, Spotflix.GetMediaDB, Spotflix.GetPeopleDB, fileName);
                    Environment.Exit(0);
                }



                Console.Clear();
            }


            /*
             *
             * string ans = Console.ReadLine();
             *
             * if (ans == "new")
             * {
             *  Spotflix.Register();
             * }
             *
             * else if (ans == "returning")
             * {
             *  Console.WriteLine("Please write your username and password");
             *  Console.WriteLine("Username: "******"Password: "******"What do you want to do?");
             *          Console.WriteLine("a) Search for music or videos");
             *          Console.WriteLine("b) Go to playlists");
             *          Console.WriteLine("c) Look for other profiles");
             *          Console.WriteLine("");
             *          Console.WriteLine("d) Exit");
             *
             *          string Ans = Console.ReadLine();
             *
             *          if (Ans == "a")
             *          {
             *              Console.WriteLine("Please write the name of the song or video that you are looking for");
             *              string search = Console.ReadLine();
             *
             *              Console.WriteLine("Do you wish to apply any filters? y/n");
             *              string a = Console.ReadLine();
             *
             *              if (a == "y")
             *              {
             *                  Console.WriteLine("Please choose one or more of the following filters:");
             *                  Console.WriteLine("For songs:");
             *                  Console.WriteLine("1) Name");
             *                  Console.WriteLine("2) Artist");
             *                  Console.WriteLine("3) Album");
             *                  Console.WriteLine("4) Genre");
             *                  Console.WriteLine("");
             *                  Console.WriteLine("For videos:");
             *                  Console.WriteLine("5) Name");
             *                  Console.WriteLine("6) Creator");
             *                  Console.WriteLine("7) Genre");
             *                  Console.WriteLine("8) Category");
             *                  Console.WriteLine("9) Director");
             *                  Console.WriteLine("10) Studio");
             *
             *                  Console.WriteLine("Please type the numbers next to the desired filters");
             *                  List<int> FilterList = new List<int>();
             *
             *                  string b1 = "y";
             *
             *                  while (b1 == "y")
             *                  {
             *                      Console.WriteLine("Filter:");
             *
             *                      int f1 = Convert.ToInt32(Console.ReadLine());
             *                      FilterList.Add(f1);
             *
             *                      Console.WriteLine("Do you wish to add another filter? y/n");
             *                      b1 = Console.ReadLine();
             *
             *                      if (FilterList.Count >= 9) //Security measure, so that nobody can write filters forever.
             *                      {
             *                          b1 = "n";
             *                      }
             *                  }
             *
             *                  Filter f2 = new Filter();
             *
             *                  foreach(object o in f2.FilteredSearch(FilterList, a))
             *                  {
             *                      Console.WriteLine(o);
             *                  }
             *              }
             *
             *
             *              else if (a == "n")
             *              {
             *                  Filter f2 = new Filter();
             *
             *                  foreach(object o in f2.Search(a))
             *                  {
             *                      Console.WriteLine(o);
             *                  }
             *              }
             *
             *
             *              Console.WriteLine("What do you want to search for?");
             *              string a1 = Console.ReadLine();
             *
             *              Filter f = new Filter();
             *              List<object> filtered = f.Search(a1);
             *
             *              foreach (object o in filtered)
             *              {
             *                  Console.WriteLine(o);
             *              }
             *          }
             *
             *
             *          else if (Ans == "B" || Ans == "b")
             *          {
             *              User u = Spotflix.GetUserDB[userN];
             *              Console.WriteLine("Do you wish to:");
             *              Console.WriteLine("A) Access your existing playlists?");
             *              Console.WriteLine("B) Create a new one?");
             *              string a1 = Console.ReadLine();
             *
             *              if (a1 == "A" || a1 == "a")
             *              {
             *                  foreach(Playlist p in u.GetPlaylist())
             *                  {
             *                      Console.WriteLine(p);
             *                  }
             *
             *              }
             *
             *              else if(a1 == "B" || a1 == "b")
             *              {
             *                  u.NewPlaylist();
             *              }
             *
             *              else
             *              {
             *                  Console.WriteLine("Invalid answer");
             *              }
             *
             *          }
             *
             *          else if (Ans == "C" || Ans == "c")
             *          {
             *              Console.WriteLine("Please state the name of the user you are looking for");
             *              string userSearch = Console.ReadLine();
             *              User u2 = Spotflix.GetUserDB[userSearch];
             *
             *              try
             *              {
             *                  u2 = Spotflix.GetUserDB[userSearch];
             *
             *              }
             *
             *              catch(Exception e)
             *              {
             *                  Console.WriteLine("User not found");
             *                  Console.WriteLine(e.Message);
             *              }
             *
             *              Console.WriteLine("Here's the public info in the account");
             *              Console.WriteLine(" ");
             *
             *              Console.WriteLine("Account name: ");
             *              Console.Write(u2.GetUsername());
             *              Console.WriteLine(" ");
             *
             *              Console.WriteLine("List of playlists: ");
             *              Console.Write(u2.GetPlaylist());
             *              Console.WriteLine(" ");
             *
             *              Console.WriteLine("List of people who follow this account: ");
             *              Console.Write(u2.GetFollowers());
             *              Console.WriteLine(" ");
             *
             *              Console.WriteLine("List of people that this account follows: ");
             *              Console.WriteLine(u2.GetFollowing());
             *              Console.WriteLine(" ");
             *          }
             *
             *          else
             *          {
             *              Console.WriteLine("Invalid Answer");
             *          }
             *
             *      }
             *
             *
             *      else
             *      {
             *          Console.WriteLine("Wrong password");
             *      }
             *  }
             *
             *
             *  else
             *  {
             *      Console.WriteLine("User not found");
             *  }
             *
             * }
             *
             */
        }
예제 #11
0
        public void AddMedia()
        {
            List <string> opts = new List <string>()
            {
                "Song", "Video", "Back"
            };
            string sel = null;

            while (true)
            {
                Console.Clear();
                sel = RegexUtilities.GetMenu(opts);
                if (sel == opts[2])
                {
                    return;
                }

                else if (sel == opts[0])
                {
                    Console.Clear();
                    string fName = RegexUtilities.WriteData("File Name(with extension):  ");
                    Console.Clear();

                    try
                    {
                        Song song = new Song(fName);


                        Spotflix.SaveMedia(song);
                        Console.WriteLine("Win");
                        Thread.Sleep(2000);
                        return;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Fail");
                        Thread.Sleep(2000);
                    }
                }

                else if (sel == opts[1])
                {
                    Console.Clear();
                    string fName = RegexUtilities.WriteData("File Name(with extension):  ");
                    Console.Clear();


                    try
                    {
                        Video video = new Video(fName);
                        Spotflix.SaveMedia(video);
                        return;
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Fail");
                        Thread.Sleep(2000);
                    }
                }
            }
        }