コード例 #1
0
        static void Main()
        {
            // Check for previous data
            if (!LoadData())
            {
                IOUser.ConsoleOutput("No previous data");
                characters = new List <Character>();
            }
            else
            {
                IOUser.ConsoleOutput("Characters loaded...");
            }

            int option = -1;

            while (option != options.Count - 1)
            {
                IOUser.ConsoleListOutput("Please select one option", options);
                option = IOUser.ConsoleReadInput();
                switch (option)
                {
                case 0:
                    IOUser.ConsoleOutput("Testing send message...");
                    break;

                case 1:
                    IOUser.ConsoleError("Testing error message...");
                    break;

                case 2:
                    IOUser.ConsoleOutput("Loading file...");
                    string       s      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Files/Characters.txt");
                    StreamReader reader = new StreamReader(s);

                    while (!reader.EndOfStream)
                    {
                        string    line            = reader.ReadLine();
                        string [] characterParams = line.Split(',');
                        switch (characterParams[0])
                        {
                        case "Warrior":
                            characters.Add(new Warrior(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Knight":
                            characters.Add(new Knight(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Assassin":
                            characters.Add(new Assassin(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Mage":
                            characters.Add(new Mage(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Druid":
                            characters.Add(new Druid(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Necromancer":
                            characters.Add(new Necromancer(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        default:
                            break;
                        }
                    }
                    foreach (Character character in characters)
                    {
                        System.Console.WriteLine($"Character class: {character.GetType().Name}, Character Name: {character.Name}");
                    }
                    break;

                case 3:
                    foreach (Character character in characters)
                    {
                        System.Console.WriteLine($"Character class: {character.GetType().Name}, Character Name: {character.Name}");
                    }
                    break;

                case 4:
                    characters.Add(new Warrior());
                    break;

                default:
                    SaveData();
                    break;
                }
            }
        }
コード例 #2
0
        public List <string> MoreImages(int op, List <string> fusionImgs)
        {
            List <string> backOP = new List <string>()
            {
                "/%void%/"
            };

            switch (op)
            {
            case 0:
                return(backOP);

            case 1:
                bool valid = false;

                int moreOption = -1;
                while (!valid)
                {
                    while (moreOption == -1)
                    {
                        IOUser.ClearConsole();
                        string path = IOUser.ConsoleReadFileName(importDirectory, extensionTypes, "Enter the image name to select from import folder:\n");
                        if (path != "/%void%/" && !fusionImgs.Contains(path))
                        {
                            fusionImgs.Add(path);
                            break;
                        }
                        if (fusionImgs.Contains(path))
                        {
                            IOUser.ConsoleError("Image already selected...\n");
                            Thread.Sleep(1000);
                        }
                        else
                        {
                            IOUser.ClearConsole();
                            IOUser.ConsoleListOutput("Go back to image production menu?", YNListI);
                            moreOption = IOUser.ConsoleReadInput(YNListI) - 1;
                            if (moreOption == 0)
                            {
                                return(new List <string>()
                                {
                                    "/%void%/"
                                });
                            }
                        }
                    }

                    IOUser.ClearConsole();
                    IOUser.ConsoleListOutput("Use another image?", YNListI);
                    moreOption = IOUser.ConsoleReadInput(YNListI);
                    if (moreOption == 0)
                    {
                        return(fusionImgs);
                    }
                    else
                    {
                        IOUser.ClearConsole();
                        string path = IOUser.ConsoleReadFileName(importDirectory, extensionTypes, "Enter the image name to select from import folder:\n");
                        if (path != "/%void%/" && !fusionImgs.Contains(path))
                        {
                            fusionImgs.Add(path);
                            continue;
                        }
                        if (fusionImgs.Contains(path))
                        {
                            IOUser.ConsoleError("Image already selected...\n");
                            Thread.Sleep(1000);
                        }
                        continue;
                    }
                }
                return(backOP);

                //MORE CASES
            }

            return(backOP);
        }
コード例 #3
0
        static void Main()
        {
            /*
             * //Tipos por valor y por referencia
             *
             * //Por valor
             * int firstNumber = 4;
             * int secondNumber = firstNumber;
             * System.Console.WriteLine($"firstNumber: {firstNumber}, secondNumber: {secondNumber}");
             * firstNumber += 1;
             * System.Console.WriteLine($"firstNumber: {firstNumber}, secondNumber: {secondNumber}");
             *
             *
             * //Por referencia
             * List<int> firstList = new List<int> { firstNumber, secondNumber };
             * List<int> secondList = firstList;
             * for (int i = 0; i < firstList.Count; i++)
             * {
             *  System.Console.WriteLine($"{firstList[i]}, {secondList[i]}");
             * }
             * firstList[0] = firstNumber * 2;
             * for (int i = 0; i < firstList.Count; i++)
             * {
             *  System.Console.WriteLine($"{firstList[i]}, {secondList[i]}");
             * }
             *
             * //Otro Ejemplo con objetos, las clases creadas son por referencia
             * Warrior warrior1 = new Warrior();
             * System.Console.WriteLine(warrior1.Name);
             * changeWarriorName(warrior1);
             * System.Console.WriteLine(warrior1.Name);
             *
             * //Que pasa si cambio el valor de un int en un metodo?
             * System.Console.WriteLine(PlusOne(firstNumber)); // Esto deberia mostrar 6
             * System.Console.WriteLine(firstNumber); //Esto mostrara 5 porque es por valor!!
             */

            // I/O
            List <Character> characters = new List <Character>();
            List <string>    options    = new List <string>()
            {
                "Test send message",
                "Test error message",
                "Test load file",
                "Exit"
            };
            int option = -1;

            while (option != options.Count - 1)
            {
                IOUser.ConsoleListOutput("Please select one option", options);
                option = IOUser.ConsoleReadInput();
                switch (option)
                {
                case 0:
                    IOUser.ConsoleOutput("Testing send message...");
                    break;

                case 1:
                    IOUser.ConsoleError("Testing error message...");
                    break;

                case 2:
                    IOUser.ConsoleOutput("Loading file...");
                    string       s      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Files/Characters.txt");
                    StreamReader reader = new StreamReader(s);

                    while (!reader.EndOfStream)
                    {
                        string    line            = reader.ReadLine();
                        string [] characterParams = line.Split(',');
                        switch (characterParams[0])
                        {
                        case "Warrior":
                            characters.Add(new Warrior(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Knight":
                            characters.Add(new Knight(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Assassin":
                            characters.Add(new Assassin(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Mage":
                            characters.Add(new Mage(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Druid":
                            characters.Add(new Druid(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        case "Necromancer":
                            characters.Add(new Necromancer(characterParams[1], int.Parse(characterParams[2])));
                            break;

                        default:
                            break;
                        }
                    }
                    foreach (Character character in characters)
                    {
                        System.Console.WriteLine($"Character class: {character.GetType().Name}, Character Name: {character.Name}");
                    }
                    break;

                default:
                    break;
                }
            }
        }
コード例 #4
0
        public void Launch()
        {
            IOUser.ConsoleWelcome();

            Importer importer = new Importer();

            if (!Directory.Exists(importer.importDirectory))
            {
                FileSystem.CreateDirectory(importer.importDirectory);
            }
            SaveEXIFData();

            SaveData saveData = new SaveData();

            if (!Directory.Exists(saveData.saveDirectory))
            {
                FileSystem.CreateDirectory(saveData.saveDirectory);
            }

            List <ImageFile> imageFilesImportFolder = LoadEXIFData();

            int searchOption = -1;

            while (searchOption != 0)
            {
                IOUser.ConsoleListOutput("Select one of the following options:", importer.ImportList);
                searchOption = IOUser.ConsoleReadInput(importer.ImportList);
                IOUser.ClearConsole();

                if (searchOption == 0)
                {
                    IOUser.ConsoleExit(); Thread.Sleep(2500); break;
                }

                string path = importer.ImportPath(searchOption);

                if (path == "/%void%/")
                {
                    IOUser.ClearConsole(); continue;
                }
                SaveEXIFData();

                ImageFile imageFile = new ImageFile(path);



                int editingOption = -1;
                while (editingOption != 0)
                {
                    IOUser.ClearConsole();
                    IOUser.ConsoleListOutput("Select one of the following options:", EditingList);
                    editingOption = IOUser.ConsoleReadInput(EditingList);

                    switch (editingOption)  //PHOTO EDITING OPTIONS
                    {
                    case 0:
                        break;

                    case 1:      //IMAGE FILTERS

                        int saveDataOption1 = 1;
                        while ((saveDataOption1 == 1) || (saveDataOption1 == 3))
                        {
                            IOUser.ClearConsole();
                            IOUser.ConsoleListOutput("Select one of the following filters:", FilterList);
                            int filterOption = IOUser.ConsoleReadInput(FilterList);

                            Bitmap filter = imageFile.Bpm;     //

                            switch (filterOption)
                            {
                            case 0:
                                break;

                            case 1:         //GRAY SCALE

                                filter = Filters.GreyScale(imageFile.Bpm);
                                IOUser.ConsoleOutput("Filter applied successfully!");
                                IOUser.ConsoleError("SHOW IMAGE");         //SHOW
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();
                                break;

                            case 2:         //NEGATIVE

                                filter = Filters.Negative(imageFile.Bpm);
                                IOUser.ConsoleOutput("Filter applied successfully!");
                                IOUser.ConsoleError("SHOW IMAGE");         //SHOW
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();
                                break;

                            case 3:         //SEPIA

                                filter = Filters.Sepia(imageFile.Bpm);
                                IOUser.ConsoleOutput("Filter applied successfully!");
                                IOUser.ConsoleError("SHOW IMAGE");         //SHOW
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();
                                break;

                            case 4:         //BLOSSOM

                                filter = Filters.Blossom(imageFile.Bpm);
                                IOUser.ConsoleOutput("Filter applied successfully!");
                                IOUser.ConsoleError("SHOW IMAGE");         //SHOW
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();
                                break;

                            case 5:         //OLD MOVIE

                                filter = Filters.OldMovie(imageFile.Bpm);
                                IOUser.ConsoleOutput("Filter applied successfully!");
                                IOUser.ConsoleError("SHOW IMAGE");         //SHOW
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();
                                break;
                            }

                            if (filterOption == 0)
                            {
                                break;
                            }

                            IOUser.ClearConsole();
                            IOUser.ConsoleListOutput("Apply changes?", saveData.FilterSaveDataList);
                            saveDataOption1 = saveData.FilterSaveDataOptions(imageFile, filter);
                            IOUser.ClearConsole();
                        }
                        break;

                    case 2:
                        int productionOption = -1;
                        while (productionOption != 0)
                        {
                            IOUser.ClearConsole();
                            IOUser.ConsoleListOutput("Select one of the following production options:", ProductionList);
                            productionOption = IOUser.ConsoleReadInput(ProductionList);

                            switch (productionOption)     //IMAGE PRODUCTION
                            {
                            case 0:
                                break;

                            case 1:         //FUSION

                                IOUser.ClearConsole();
                                IOUser.ConsoleListOutput("Select one of the following options:", importer.SelectMoreImages);
                                int moreImgOp = IOUser.ConsoleReadInput(importer.SelectMoreImages);
                                if (moreImgOp == 0)
                                {
                                    break;
                                }

                                List <string> fusionList = new List <string> {
                                    imageFile.Origin
                                };
                                fusionList = importer.MoreImages(moreImgOp, fusionList);
                                if (fusionList[0] == "/%void%/")
                                {
                                    break;
                                }


                                List <Bitmap> fusionListBMP = new List <Bitmap>();
                                fusionListBMP.Add(imageFile.Bpm);
                                foreach (string f in fusionList)
                                {
                                    fusionListBMP.Add(new Bitmap(f));
                                }

                                string productionBase = Editor.getSmallerImage(fusionList);
                                Bitmap fusionBMP      = Editor.Fusion(fusionListBMP);

                                IOUser.ConsoleError("SHOW IMAGE");         //SHOW
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();

                                IOUser.ClearConsole();
                                IOUser.ConsoleListOutput("Apply changes?", saveData.ProductionSaveDataList);
                                saveData.ProductionSaveDataOptions(productionBase, fusionBMP);
                                IOUser.ClearConsole();

                                productionOption = 0;
                                break;

                            case 2:         //MOSAIC

                                IOUser.ClearConsole();
                                IOUser.ConsoleError("NOT YET IMPLEMENTED");
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();

                                productionOption = 0;
                                break;

                            case 3:         //COLLAGE

                                IOUser.ClearConsole();
                                IOUser.ConsoleError("NOT YET IMPLEMENTED");
                                Console.WriteLine("\nPress any key to continue");
                                Console.ReadLine();

                                productionOption = 0;
                                break;
                            }
                        }
                        break;


                    case 3:       //TEXT INSERTER

                        IOUser.ClearConsole();
                        IOUser.ConsoleOutput("Write the text you want to insert:\n");
                        string itText = Console.ReadLine();

                        List <string> ColorList = new List <string>()
                        {
                            "Black", "White", "Red", "Green", "Blue", "Gray"
                        };
                        IOUser.ConsoleListOutput("Select a color:", ColorList);
                        int colorOption = IOUser.ConsoleReadInput(ColorList);

                        IOUser.ConsoleOutput("Insert font size (bigger font is recomended for large images):\n");
                        int itFontSize = IOUser.ConsoleReadNumber();

                        IOUser.ConsoleOutput($"Select x coordinates (for reference your image has {imageFile.Bpm.Width} of width):\n");
                        int itXCoordinates = IOUser.ConsoleReadNumber();

                        IOUser.ConsoleOutput($"Select y coordinates (for reference your image has {imageFile.Bpm.Height} of height):\n");
                        int itYCoordinates = IOUser.ConsoleReadNumber();

                        Bitmap textBMP = Editor.TEXT(imageFile.Bpm, itText, ColorList[colorOption], itFontSize, itXCoordinates, itYCoordinates);

                        IOUser.ClearConsole();
                        IOUser.ConsoleOutput("Text inserted successfully!");
                        IOUser.ConsoleError("SHOW IMAGE");     //SHOW
                        Console.WriteLine("\nPress any key to continue");
                        Console.ReadLine();

                        IOUser.ClearConsole();
                        IOUser.ConsoleListOutput("Apply changes?", saveData.ProductionAlterSaveDataList);
                        saveData.ProductionAlterSaveDataOptions(imageFile, textBMP);
                        IOUser.ClearConsole();

                        break;

                    case 4:        //IMAGE ROTATOR

                        IOUser.ClearConsole();
                        List <string> RotateList = new List <string>()
                        {
                            "By 270°", "By 90°", "By 180°"
                        };

                        IOUser.ConsoleListOutput("By how many degrees you want to rotate the image (clockwise)?", RotateList);
                        int rotateOption = IOUser.ConsoleReadInput(RotateList);

                        RotateFlipType applyRotate = RotateFlipType.RotateNoneFlipNone;     //BASE
                        if (rotateOption == 1)
                        {
                            applyRotate = RotateFlipType.Rotate90FlipNone;
                        }
                        if (rotateOption == 2)
                        {
                            applyRotate = RotateFlipType.Rotate180FlipNone;
                        }
                        if (rotateOption == 0)
                        {
                            applyRotate = RotateFlipType.Rotate270FlipNone;
                        }

                        Bitmap rotate = imageFile.Bpm;     //
                        rotate.RotateFlip(applyRotate);


                        IOUser.ConsoleOutput("Image rotated successfully!");
                        IOUser.ConsoleError("SHOW IMAGE");     //SHOW
                        Console.WriteLine("\nPress any key to continue");
                        Console.ReadLine();

                        IOUser.ClearConsole();
                        IOUser.ConsoleListOutput("Apply changes?", saveData.ProductionAlterSaveDataList);
                        saveData.ProductionAlterSaveDataOptions(imageFile, rotate);
                        IOUser.ClearConsole();

                        break;

                        //MORE CASES
                    }
                    IOUser.ClearConsole();
                }
            }
        }