System.Console.Clear()

Here are the examples of the csharp api System.Console.Clear() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

646 Examples 7

19 View Source File : Program.cs
License : MIT License
Project Creator : 13xforever

internal static async Task Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    Console.WriteLine("Drag .pkg files and/or folders onto this .exe to verify the packages.");
                    var isFirstChar = true;
                    var completedPath = false;
                    var path = new StringBuilder();
                    do
                    {
                        var keyInfo = Console.ReadKey(true);
                        if (isFirstChar)
                        {
                            isFirstChar = false;
                            if (keyInfo.KeyChar != '"')
                                return;
                        }
                        else
                        {
                            if (keyInfo.KeyChar == '"')
                            {
                                completedPath = true;
                                args = new[] {path.ToString()};
                            }
                            else
                                path.Append(keyInfo.KeyChar);
                        }
                    } while (!completedPath);
                    Console.Clear();
                }

                Console.OutputEncoding = new UTF8Encoding(false);
                Console.replacedle = replacedle;
                Console.CursorVisible = false;
                Console.WriteLine("Scanning for PKGs...");
                var pkgList = new List<FileInfo>();
                Console.ForegroundColor = ConsoleColor.Yellow;
                foreach (var item in args)
                {
                    var path = item.Trim('"');
                    if (File.Exists(path))
                        pkgList.Add(new FileInfo(path));
                    else if (Directory.Exists(path))
                        pkgList.AddRange(GetFilePaths(path, "*.pkg", SearchOption.AllDirectories).Select(p => new FileInfo(p)));
                    else
                        Console.WriteLine("Unknown path: " + path);
                }
                Console.ResetColor();
                if (pkgList.Count == 0)
                {
                    Console.WriteLine("No packages were found. Check paths, and try again.");
                    return;
                }

                var longestFilename = Math.Max(pkgList.Max(i => i.Name.Length), HeaderPkgName.Length);
                var sigWidth = Math.Max(HeaderSignature.Length, 8);
                var csumWidth = Math.Max(HeaderChecksum.Length, 5);
                var csumsWidth = 1 + sigWidth + 1 + csumWidth + 1;
                var idealWidth = longestFilename + csumsWidth;
                try
                {
                    if (idealWidth > Console.LargestWindowWidth)
                    {
                        longestFilename = Console.LargestWindowWidth - csumsWidth;
                        idealWidth = Console.LargestWindowWidth;
                    }
                    if (idealWidth > Console.WindowWidth)
                    {
                        Console.BufferWidth = Math.Max(Console.BufferWidth, idealWidth);
                        Console.WindowWidth = idealWidth;
                    }
                    Console.BufferHeight = Math.Max(Console.BufferHeight, Math.Min(9999, pkgList.Count + 10));
                }
                catch (PlatformNotSupportedException) { }
                Console.WriteLine($"{HeaderPkgName.Trim(longestFilename).PadRight(longestFilename)} {HeaderSignature.PadLeft(sigWidth)} {HeaderChecksum.PadLeft(csumWidth)}");
                using var cts = new CancellationTokenSource();
                Console.CancelKeyPress += (sender, eventArgs) => { cts.Cancel(); };
                var t = new Thread(() =>
                                   {
                                       try
                                       {
                                           var indicatorIdx = 0;
                                           while (!cts.Token.IsCancellationRequested)
                                           {
                                               Task.Delay(1000, cts.Token).ConfigureAwait(false).GetAwaiter().GetResult();
                                               if (cts.Token.IsCancellationRequested)
                                                   return;

                                               PkgChecker.Sync.Wait(cts.Token);
                                               try
                                               {
                                                   var frame = Animation[(indicatorIdx++) % Animation.Length];
                                                   var currentProgress = PkgChecker.CurrentFileProcessedBytes;
                                                   Console.replacedle = $"{replacedle} [{(double)(PkgChecker.ProcessedBytes + currentProgress) / PkgChecker.TotalFileSize * 100:0.00}%] {frame}";
                                                   if (PkgChecker.CurrentPadding > 0)
                                                   {
                                                       Console.CursorVisible = false;
                                                       var (top, left) = (Console.CursorTop, Console.CursorLeft);
                                                       Console.Write($"{(double)currentProgress / PkgChecker.CurrentFileSize * 100:0}%".PadLeft(PkgChecker.CurrentPadding));
                                                       Console.CursorTop = top;
                                                       Console.CursorLeft = left;
                                                       Console.CursorVisible = false;
                                                   }
                                               }
                                               finally
                                               {
                                                   PkgChecker.Sync.Release();
                                               }
                                           }
                                       }
                                       catch (TaskCanceledException)
                                       {
                                       }
                                   });
                t.Start();
                await PkgChecker.CheckAsync(pkgList, longestFilename, sigWidth, csumWidth, csumsWidth-2, cts.Token).ConfigureAwait(false);
                cts.Cancel(false);
                t.Join();
            }
            finally
            {
                Console.replacedle = replacedle;
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
                Console.WriteLine();
                Console.CursorVisible = true;
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 4egod

static void Main(string[] args)
        {
            if (RawDebug)
            {
                bot.PostReceived += Bot_PostReceived;            
            }
            bot.InvalidPostReceived += Bot_InvalidPostReceived;

            bot.OnMessage += Bot_OnMessage;
            bot.OnFollow += Bot_OnFollow;
            bot.OnUnFollow += Bot_OnUnFollow;
            bot.OnTweet += Bot_OnTweet; 
            bot.OnRetweet += Bot_OnRetweet;
            bot.OnQuote += Bot_OnQuote;
            bot.OnComment += Bot_OnComment;
            bot.OnMention += Bot_OnMention;
            bot.OnLike += Bot_OnLike;

            bot.StartReceivingAsync();

            while (true)
            {
                Console.ReadLine();
                Console.Clear();
            }
        }

19 View Source File : ToolsMain.cs
License : Apache License 2.0
Project Creator : 91270

static void Main(string[] args)
        {
            do
            {
                try
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    Console.WriteLine("=============================================================================");
                    Console.WriteLine("*            1      -      生成模型");
                    Console.WriteLine("=============================================================================");
                    Console.Write("请选择要执行的程序 : ");
                    Console.ResetColor();

                    switch (Int32.Parse(Console.ReadLine()))
                    {
                        case 1:

                            #region  生成模型
                            Task001.Execute();
                            #endregion

                            Console.ReadKey();

                            break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.ReadKey();
                }
            } while (true);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : 8bitbytes

static void PrintMenu(SdkWrapper wrapper)
        {
            var done = false;

            //wrapper.BaseActions.CommandMode().Execute();
            while (!done)
            {
                TelloSdkCoreNet.actions.Action action = null;
                Console.Clear();
                Console.WriteLine("1.TakeOff");
                Console.WriteLine("2.Land");
                Console.WriteLine("3.Flip");
                Console.WriteLine("4.Fly forward");
                Console.WriteLine("5.Fly back");
                Console.WriteLine("6.Rotate");
                Console.WriteLine("7.Battery %");
                Console.WriteLine("8.Execute flight plan");
                Console.WriteLine("9.Exit");
                var choice = Console.ReadLine();
                try
                {
                    switch (choice)
                    {
                        case "1":
                            {
                                action = wrapper.BaseActions.TakeOff();
                                break;
                            }
                        case "2":
                            {
                                action = wrapper.BaseActions.Land();
                                break;
                            }
                        case "3":
                            {
                                action = wrapper.FlipActions.FlipBackLeft();
                                break;
                            }
                        case "4":
                            {
                                action = wrapper.FlyActions.FlyForward(50);
                                break;
                            }
                        case "5":
                            {
                                action = wrapper.FlyActions.FlyBack(50);
                                break;
                            }
                        case "6":
                            {
                                action = wrapper.RotationActions.RotateClockwise(360);
                                break;
                            }
                        case "7":
                            {
                                var resp = wrapper.BaseActions.QueryBattery().Execute();
                                if (resp == SdkWrapper.SdkReponses.OK)
                                {
                                    Console.WriteLine($"Battery percentage is {wrapper.BaseActions.QueryBattery().ServerResponse}%");
                                    Console.ReadLine();
                                }
                                break;
                            }
                        case "8":
                            {
                                ExecuteFlightPlan(wrapper);
                                break;
                            }
                        case "9":
                            {
                                done = true;
                                break;
                            }

                    }
                    if (action != null)
                    {
                        var resp1 = action.Execute();
                        if (resp1 == SdkWrapper.SdkReponses.FAIL)
                        {
                            if (action.LastException != null)
                            {
                                throw action.LastException;
                            }
                        }
                    }

                }
                catch (Exception ex)
                {
                    WriteError(ex.Message);
                    Console.ReadLine();
                }
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : a-luna

private static async Task Main()
        {
            Console.Clear();
            await Task.Delay(2000);
            await ConsoleProgressBars();
            Console.WriteLine();

            await FileTransferProgressBars();
            Console.WriteLine();
        }

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : aaaddress1

static void printMenu(bool showMenu = false, string loadXlsPath = "")
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Cyan; ;
            Console.WriteLine(xlsKami.Properties.Resources.banner);
            Console.WriteLine("   xlsKami [v1.]");
            Console.WriteLine("   Out-of-the-Box Tool to Obfuscate Excel 97-2003 XLS");
            Console.ResetColor();
            Console.WriteLine(@">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            if (showMenu)
            {
                log("[v] Selected File: {0}\n", ConsoleColor.Magenta, loadXlsPath);
                log("[+] Menu \n", ConsoleColor.Cyan);
                log("\t[1] Masquerade Cell Labels\n", ConsoleColor.Cyan);
                log("\t[2] Masquerade Workbook Sheets\n", ConsoleColor.Cyan);
                log("\t[3] Save & Exit\n", ConsoleColor.Cyan);
                log("\t[4] Exit\n", ConsoleColor.Cyan);
                foreach (var szLog in historyList) log(szLog, ConsoleColor.Green);
                Console.WriteLine(@">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

                log("[?] choose action (index): ", ConsoleColor.Cyan);
            }

        }

19 View Source File : PerformanceTest.cs
License : Apache License 2.0
Project Creator : aadreja

public void Run()
        {

            CreateTable();

            int iteration = 5;
            int count = 1000;

            Dictionary<string, Dictionary<int, long>> insertTimings = new Dictionary<string, Dictionary<int, long>>();
            Dictionary<string, Dictionary<int, long>> updateTimings = new Dictionary<string, Dictionary<int, long>>();
            Dictionary<string, Dictionary<int, long>> selectTimings = new Dictionary<string, Dictionary<int, long>>();
            Dictionary<string, Dictionary<int, long>> selectListTimings = new Dictionary<string, Dictionary<int, long>>();

            insertTimings.Add("ADO", new Dictionary<int, long>());
            insertTimings.Add("Vega", new Dictionary<int, long>());
            insertTimings.Add("Dapper", new Dictionary<int, long>());

            updateTimings.Add("ADO", new Dictionary<int, long>());
            updateTimings.Add("Vega", new Dictionary<int, long>());
            updateTimings.Add("Dapper", new Dictionary<int, long>());

            selectTimings.Add("ADO", new Dictionary<int, long>());
            selectTimings.Add("Vega", new Dictionary<int, long>());
            selectTimings.Add("Dapper", new Dictionary<int, long>());

            selectListTimings.Add("ADO", new Dictionary<int, long>());
            selectListTimings.Add("Vega", new Dictionary<int, long>());
            selectListTimings.Add("Dapper", new Dictionary<int, long>());

            for (int i = 1; i <= iteration; i++)
            {
                WriteLine("Iteration " + i, ConsoleColor.Yellow);

                ADOTest adoTest = new ADOTest();
                VegaTest vegaTest = new VegaTest();
                DapperTest dapperTest = new DapperTest();

                insertTimings["ADO"].Add(i, adoTest.InsertTest(count));
                insertTimings["Vega"].Add(i, vegaTest.InsertTest(count));
                insertTimings["Dapper"].Add(i, dapperTest.InsertTest(count));

                updateTimings["ADO"].Add(i, adoTest.UpdateTest(count));
                updateTimings["Vega"].Add(i, vegaTest.UpdateTest(count));
                updateTimings["Dapper"].Add(i, dapperTest.UpdateTest(count));

                selectTimings["ADO"].Add(i, adoTest.SelectTest(count));
                selectTimings["Vega"].Add(i, vegaTest.SelectTest(count));
                selectTimings["Dapper"].Add(i, dapperTest.SelectTest(count));

                selectListTimings["ADO"].Add(i, adoTest.SelectListTest(count));
                selectListTimings["Vega"].Add(i, vegaTest.SelectListTest(count));
                selectListTimings["Dapper"].Add(i, dapperTest.SelectListTest(count));
            }

            //show results
            Console.Clear();
            WriteLine($"Results for {count} records {iteration} iteration", ConsoleColor.Yellow);
            WriteLine("--------" + new string('-',10 * iteration), ConsoleColor.Green);
            Write("Iteration\t", ConsoleColor.Green);
            for (int i = 1; i <= iteration; i++)
            {
                Write($"{i}\t", ConsoleColor.Green);
            }
            Write("Mean\t", ConsoleColor.Green);
            Write("stDEV\t", ConsoleColor.Green);
            WriteLine("");
            WriteLine("--------" + new string('-', 10 * iteration), ConsoleColor.Green);

            WriteStatus("Insert Tests", insertTimings);
            WriteStatus("Update Tests", updateTimings);
            WriteStatus("Select Tests", selectTimings);
            WriteStatus("Select List Tests", selectListTimings);
            
            Console.ReadLine();
        }

19 View Source File : TargetCollectionExtensions.cs
License : Apache License 2.0
Project Creator : adamralph

private static async Task RunAsync(
            this TargetCollection targets,
            IReadOnlyCollection<string> args,
            IReadOnlyCollection<string> names,
            IOptions options,
            IReadOnlyCollection<string> unknownOptions,
            bool showHelp,
            Func<Exception, bool> messageOnly,
            string messagePrefix,
            TextWriter outputWriter,
            TextWriter diagnosticsWriter)
        {
            if (options.Clear)
            {
                try
                {
                    Console.Clear();
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    await diagnosticsWriter.WriteLineAsync($"{messagePrefix}: Failed to clear the console: {ex}").Tax();
                }
            }

            var noColor = options.NoColor;

            if (Environment.GetEnvironmentVariable("NO_COLOR") != null)
            {
                if (options.Verbose)
                {
                    await diagnosticsWriter.WriteLineAsync($"{messagePrefix}: NO_COLOR environment variable is set. Colored output is disabled.").Tax();
                }

                noColor = true;
            }

            var host = options.Host.DetectIfNull();

            var operatingSystem =
                RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                    ? OperatingSystem.Windows
                    : RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
                        ? OperatingSystem.Linux
                        : RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
                            ? OperatingSystem.MacOS
                            : OperatingSystem.Unknown;

            var output = new Output(
                outputWriter,
                args,
                options.DryRun,
                host,
                options.Host.HasValue,
                noColor,
                options.NoExtendedChars,
                operatingSystem,
                options.Parallel,
                messagePrefix,
                options.SkipDependencies,
                options.Verbose);

            var outputState = await output.Initialize(options.Verbose ? diagnosticsWriter : TextWriter.Null).Tax();

            try
            {
                await output.Header(() => typeof(TargetCollection).replacedembly.GetVersion()).Tax();

                await targets.RunAsync(
                    names,
                    options.DryRun,
                    options.ListDependencies,
                    options.ListInputs,
                    options.ListTargets,
                    options.ListTree,
                    options.Parallel,
                    options.SkipDependencies,
                    unknownOptions,
                    showHelp,
                    messageOnly,
                    output).Tax();
            }
            finally
            {
                await outputState.DisposeAsync().Tax();
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : ADeltaX

private static void PrintCurrentSession()
        {
            if (session != null)
            {
                lock (lockObject)
                {
                    Console.Clear();

                    var mediaDetails = src.GetMediaObjectInfo();
                    var mediaPlaybackInfo = src.GetMediaPlaybackInfo();
                    var mediaTimeline = src.GetMediaTimelineProperties();

                    Console.WriteLine("replacedle: " + mediaDetails.replacedle);
                    Console.WriteLine("Artist: " + mediaDetails.Artist);
                    Console.WriteLine("Subreplacedle: " + mediaDetails.Subreplacedle);
                    Console.WriteLine("Album replacedle: " + mediaDetails.Albumreplacedle);
                    Console.WriteLine("Media type: " + MediaPlaybackDataSource.MediaSchemaToMediaPlaybackMode(mediaDetails.MediaClreplacedPrimaryID));
                    Console.WriteLine("Source App Id: " + session?.SourceAppId);
                    Console.WriteLine("Source Device Id: " + session?.SourceDeviceId);
                    Console.WriteLine("Render Device Id: " + session?.RenderDeviceId);
                    Console.WriteLine("HWND: 0x" + session?.Hwnd.ToString("X"));
                    Console.WriteLine("PID: 0x" + session?.PID.ToString("X"));
                    Console.WriteLine();
                    Console.WriteLine("Playback state: " + mediaPlaybackInfo.PlaybackState);
                    Console.WriteLine("Playback rate: " + mediaPlaybackInfo.PlaybackRate);
                    Console.WriteLine("Playback mode: " + mediaPlaybackInfo.PlaybackMode);
                    Console.WriteLine("Shuffle enabled: " + mediaPlaybackInfo.ShuffleEnabled);
                    Console.WriteLine("Repeat mode: " + mediaPlaybackInfo.RepeatMode);
                    Console.WriteLine("Playback CAPS: " + mediaPlaybackInfo.PlaybackCaps);
                    Console.WriteLine("Playback PROPS: " + mediaPlaybackInfo.PropsValid);
                    Console.WriteLine();
                    Console.WriteLine("Start time: " + mediaTimeline.StartTime);
                    Console.WriteLine("End time: " + mediaTimeline.EndTime);
                    Console.WriteLine("Min seek time: " + mediaTimeline.MinSeekTime);
                    Console.WriteLine("Max seek time: " + mediaTimeline.MaxSeekTime);
                    Console.WriteLine("Position: " + mediaTimeline.Position);
                    Console.WriteLine("---------------------------------");
                }
            }
            else
            {
                lock (lockObject)
                {
                    Console.Clear();
                    Console.WriteLine("There are no active sessions.");
                }
            }
        }

19 View Source File : DisplayErrorCompnent.cs
License : GNU General Public License v3.0
Project Creator : agolaszewski

public void Render(string errorMessage)
        {
            Console.Clear();
            _console.WriteError(errorMessage);
            Console.ReadKey();
        }

19 View Source File : AppConsole.cs
License : GNU General Public License v3.0
Project Creator : agolaszewski

public void Clear()
        {
            Console.Clear();
        }

19 View Source File : CmdHandler.cs
License : Apache License 2.0
Project Creator : airbus-cert

internal static bool ExecuteCmd(string command)
        {
            bool isManagedCmd = false;
            string[] commands = command.Split(' ');

            string cmdName = commands.First();
            string[] args = commands.Skip(1).ToArray();

            switch (cmdName)
            {
                case "exit":
                    Environment.Exit(0);
                    break;
                case "clear":
                    Console.Clear();
                    isManagedCmd = true;
                    break;
                case "yadd":
                    isManagedCmd = true;
                    CmdAddRules(args);
                    break;
                case "sadd":
                    isManagedCmd = true;
                    CmdAddSamples(args);
                    break;
                case "ycompile":
                    isManagedCmd = true;

                    using (var compiler = new Compiler())
                    {
                        foreach (var yara in yaras.Distinct())
                        {
                            var err = ScanHelper.CheckRule(yara);

                            if (err == YARA_ERROR.SUCCESS)
                            {
                                try
                                {
                                    compiler.AddRuleFile(yara);
                                    Console.WriteLine($":Added {yara}");
                                } catch (Exception e)
                                {
                                    Console.WriteLine($"!Exception adding \"{yara}\": {e.Message}");
                                }
                            }
                            else
                                Console.WriteLine($"!Exception adding \"{yara}\": {err}");
                        }

                        try
                        {
                            rules = compiler.Compile();
                            Console.WriteLine($"* Compiled");
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine($"!Exception compiling rules: {e.Message}");
                        }
                    }

                    break;
                case "run":
                    isManagedCmd = true;
                    CmdRun();
                    break;
            }


            return isManagedCmd;
        }

19 View Source File : Render.cs
License : MIT License
Project Creator : AiursoftWeb

public static async Task StartGame(Game game)
        {
            // Add Remote Repository
            await game.AddRemote(Constants.EndPointUrl);
            
            Console.Clear();
            
            // Draw Items
            game.Draw();
            
            while (!game.IsGameEnd)
            {
                game.UpdateDirection();
                game.UpdateFrame();
                if (game.NeedSpeedUp())
                {
                    _gameSpeed *= 0.95m;
                }
                
                // Listening input command
                game.ListenInput();

                await Task.Delay((int)_gameSpeed);
            }
        }

19 View Source File : ClearCommandHandler.cs
License : MIT License
Project Creator : AiursoftWeb

public Task<bool> Execute(string command)
        {
            Console.Clear();
            return Task.FromResult(true);
        }

19 View Source File : Render.cs
License : MIT License
Project Creator : AiursoftWeb

public static async Task StartGameWithObserver(Game game, Game observer)
        {
            // Add Remote Repository
            await game.AddRemote(Constants.EndPointUrl);
            await observer.AddRemote(Constants.EndPointUrl);
            
            observer.GenerateRecurrent();
            
            Console.Clear();
            
            // Draw Items
            game.Draw();
            observer.Draw();

            // Wait the input to start the game.
            game.ListenInput(true);

            while (!game.IsGameEnd)
            {
                // Player's panel
                game.UpdateDirection();
                game.UpdateFrame();
                if (game.NeedSpeedUp())
                {
                    _gameSpeed *= 0.95m;
                }
                
                // Observer's panel
                observer.RecurrentFromRepo();
                observer.UpdateFrame();
                
                // Listening input command
                game.ListenInput();
                
                await Task.Delay(Convert.ToInt32(_gameSpeed));
            }

            while (!observer.IsGameEnd)
            {
                observer.RecurrentFromRepo();
                observer.UpdateFrame();
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : Alan-FGR

static void Main(string[] args)
    {
        //warmup
        Benchmark(1000, BufferType.Dense, true);
        Benchmark(1000, BufferType.Sparse, true);
        Console.Clear();

        state = 42;

        Benchmark(100000, BufferType.Dense, false);
        Benchmark(100000, BufferType.Sparse, false);

        Benchmark(100000, BufferType.Dense, true);
        Benchmark(100000, BufferType.Sparse, true);

        Console.ReadKey();

    }

19 View Source File : Program.cs
License : MIT License
Project Creator : AlenToma

static void Main(string[] args)
        {
            //GlobalConfiguration.Log = new Logger((object sender, EventArgs arg) =>
            //{
            //    //Console.WriteLine((arg as Args).Data);
            //});
            Code();
            //DynamicLinq();
            //SaveJson();
            //PackageTest();
            //TestSave();
            //ExpressionTest();
            Console.ReadLine();
            Console.Clear();
            Main(null);

        }

19 View Source File : Program.cs
License : MIT License
Project Creator : altskop

static void UpdateCheat()
        {
            /*while (true)
            {
                Console.Clear();
                AmongUsClient resultInst = HamsterCheese.AmongUsMemory.Cheese.getAmongUsClient();
                //Console.WriteLine(resultInst.timer + " | " + resultInst.IsGamePublic + " | " + resultInst.GameState + " | " + resultInst.SpawnRadius + " | " + resultInst.mode);
                System.Threading.Thread.Sleep(2000);
            }*/
            
            while (true)
            {
                Console.Clear();
                ShipStatus shipStatus = HamsterCheese.AmongUsMemory.Cheese.shipStatus;
                //PrintRow($"Timer: {shipStatus.Timer}", $"EmergencyCooldown: {shipStatus.EmergencyCooldown}", $"Type: {shipStatus.Type}");

                GameDataContainer gameData = new GameDataContainer();
                gameData.emergencyCooldown = shipStatus.EmergencyCooldown;
                List<PlayerInformation> players = new List<PlayerInformation>();
                
                Console.WriteLine("Test Read Player Datas..");
                PrintRow("Name", "Position", "Color", "isDead", "Emergencies", "inVent", "isImposter", "killTimer");
                PrintLine();

                foreach (var data in playerDatas)
                {
                    var Name = HamsterCheese.AmongUsMemory.Utils.ReadString(data.PlayerInfo.Value.PlayerName);
                    if (data.IsLocalPlayer)
                    {
                        gameData.botPlayer = new PlayerInformation(data.Position, Name, data.PlayerInfo.Value.ColorId, data.PlayerInfo.Value.IsDead, data.remainingEmergencies(), data.inVent(), data.PlayerInfo.Value.IsImpostor, data.getKillTimer());
                        LightSource ls = data.LightSource;
                        gameData.lightRadius = ls.LightRadius;
                    }
                    else
                    {
                        PlayerInformation player = new PlayerInformation(data.Position, Name, data.PlayerInfo.Value.ColorId, data.PlayerInfo.Value.IsDead, data.remainingEmergencies(), data.inVent(), data.PlayerInfo.Value.IsImpostor, data.getKillTimer());
                        players.Add(player);
                    }

                    //PrintRow($"{(data.IsLocalPlayer == true ? "Me->" : "")}{data.PlayerControllPTROffset}", $"{Name}", $"{data.Instance.OwnerId}", $"{data.Instance.PlayerId}", $"{data.Instance.SpawnId}", $"{data.Instance.SpawnFlags}");
                }

                gameData.players = players;

                Console.ForegroundColor = ConsoleColor.Green;
                PrintRow($"{gameData.botPlayer.name}", $"{gameData.botPlayer.position.x},{gameData.botPlayer.position.y}", $"{gameData.botPlayer.color}", $"{gameData.botPlayer.isDead.ToString()}", $"{gameData.botPlayer.remainingEmergencies.ToString()}", $"{gameData.botPlayer.inVent.ToString()}", $"{gameData.botPlayer.isImposter.ToString()}", $"{gameData.botPlayer.killTimer.ToString()}");
                Console.ForegroundColor = ConsoleColor.White;

                foreach (var player in players)
                {
                    PrintRow($"{player.name}", $"{player.position.x},{player.position.y}", $"{player.color}", $"{player.isDead.ToString()}", $"{player.remainingEmergencies.ToString()}", $"{player.inVent.ToString()}", $"{player.isImposter.ToString()}",$"{player.killTimer.ToString()}");
                    Console.ForegroundColor = ConsoleColor.White;

                    PrintLine();
                }
                PrintRow($"Light level: {gameData.lightRadius}");
                PrintRow($"OriginalPos: {gameData.botPlayer.position.x},{gameData.botPlayer.position.y}");
                Vector2 meshPos = skeld.gamePosToMeshPos(gameData.botPlayer.position);
                PrintRow($"MeshPos: {meshPos.x},{meshPos.y}");
                Vector2 gaemPos = skeld.meshPosToGamePos(meshPos);
                PrintRow($"GaemPos: {gaemPos.x},{gaemPos.y}");
                PrintRow($"Region: {skeld.getLocationRegionName(meshPos)}");
                PrintRow($"Timer: {shipStatus.Timer}");

                GameUpdate gameUpdate = eventGenerator.getGameUpdate(gameData);
                if (gameUpdate.gameDataContainer != null && gameData.players.Count > 0)
                    behaviorDriver.update(gameUpdate);
                botStatusForm.update(behaviorDriver);

                System.Threading.Thread.Sleep(MEMORY_POLLING_PERIOD);
            }
        }

19 View Source File : TunnelDashboard.cs
License : MIT License
Project Creator : angelobreuer

public static async Task Show(Tunnel tunnel, BaseConfiguration configuration, CancellationToken cancellationToken = default)
        {
            var connectionHistory = new Stack<TunnelConnection>();
            var stringBuilder = new StringBuilder();
            var version = replacedembly.GetExecutingreplacedembly().GetName().Version;
            var startTime = DateTimeOffset.UtcNow;
            var previousWidth = -1;

            Console.CursorVisible = false;
            Console.Clear();

            while (!cancellationToken.IsCancellationRequested)
            {
                if (previousWidth != Console.WindowWidth)
                {
                    // console resized or started, perform repaint
                    Console.Clear();
                    SetStatus(ConsoleColor.Green, $"({Resources.TunnelOnline} {version!.ToString(3)})", 0);
                    SetStatus(ConsoleColor.Blue, $"https://github.com/angelobreuer/localtunnel-client", 1);
                    previousWidth = Console.WindowWidth;
                }

                Update(tunnel, stringBuilder, startTime);
                UpdateConnections(tunnel, connectionHistory);
                await Task.Delay(100, CancellationToken.None);
            }

            // update status and run last update
            Console.Clear();
            SetStatus(ConsoleColor.Red, Resources.TunnelOffline, 0);
            Update(tunnel, stringBuilder, startTime);

            Console.CursorVisible = true;
        }

19 View Source File : Host.cs
License : Apache License 2.0
Project Creator : AppMetrics

public static async Task Main()
        {
            Init();

            var cancellationTokenSource = new CancellationTokenSource();

            await WriteMetricsAsync(cancellationTokenSource);

            PressAnyKeyToContinue();

            await RunUntilEscAsync(
                TimeSpan.FromSeconds(5),
                cancellationTokenSource,
                async () =>
                {
                    Clear();
                    RecordMetrics();
                    await Task.WhenAll(Reporter.RunAllAsync(cancellationTokenSource.Token));
                });
        }

19 View Source File : Host.cs
License : Apache License 2.0
Project Creator : AppMetrics

public static async Task Main()
        {
            Init();

            var cancellationTokenSource = new CancellationTokenSource();

            await RunUntilEscAsync(
                TimeSpan.FromSeconds(20),
                cancellationTokenSource,
                async () =>
                {
                    Clear();

                    var healthStatus = await Health.HealthCheckRunner.ReadAsync(cancellationTokenSource.Token);

                    foreach (var formatter in Health.OutputHealthFormatters)
                    {
                        WriteLine($"Formatter: {formatter.GetType().FullName}");
                        WriteLine("-------------------------------------------");

                        using (var stream = new MemoryStream())
                        {
                            await formatter.WriteAsync(stream, healthStatus, cancellationTokenSource.Token);

                            var result = Encoding.UTF8.GetString(stream.ToArray());

                            WriteLine(result);
                        }
                    }

                    foreach (var reporter in Health.Reporters)
                    {
                        WriteLine($"Reporter: {reporter.GetType().FullName}");
                        WriteLine("-------------------------------------------");

                        await reporter.ReportAsync(Health.Options, healthStatus, cancellationTokenSource.Token);
                    }
                });
        }

19 View Source File : Host.cs
License : Apache License 2.0
Project Creator : AppMetrics

private static void PressAnyKeyToContinue()
        {
            WriteLine();
            BackgroundColor = ConsoleColor.White;
            ForegroundColor = ConsoleColor.Blue;
            WriteLine("Press any key to continue...");
            ResetColor();
            ReadKey();
            Clear();
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : approved

public static void Main(string[] args)
        {
            if (!File.Exists(SettingsFile))
            {
                Directory.CreateDirectory("settings");
                CurrentSettings.CreateNew(SettingsFile);
            }
            else
            {
                CurrentSettings.Load(SettingsFile);
            }

            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            Client.Proxy = null;

            Console.Clear();
            Console.CursorVisible = false;

            InputManager.Initialize();
            InputManager.OnKeyboardEvent += InputManager_OnKeyboardEvent;
            InputManager.OnMouseEvent += InputManager_OnMouseEvent;

            OrbWalkTimer.Elapsed += OrbWalkTimer_Elapsed;
#if DEBUG
            Timer callbackTimer = new Timer(16.66);
            callbackTimer.Elapsed += Timer_CallbackLog;
#endif

            Timer attackSpeedCacheTimer = new Timer(OrderTickRate);
            attackSpeedCacheTimer.Elapsed += AttackSpeedCacheTimer_Elapsed;

            attackSpeedCacheTimer.Start();
            Console.WriteLine($"Press and hold '{(VirtualKeyCode)CurrentSettings.ActivationKey}' to activate the Orb Walker");

            CheckLeagueProcess();

            Console.ReadLine();
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : ardalis

static void Main(string[] args)
        {

#if SupportUndo
            // MEMENTO NOTES:
            // HangmanGameWithUndo == ORIGINATOR
            // This Main Program   == CARETAKER
            // HangmanMemento      == MEMENTO
            var game = new HangmanGameWithUndo();
            var gameHistory = new Stack<HangmanMemento>();
            gameHistory.Push(game.CreateSetPoint());
#else
            var game = new HangmanGame();
#endif

            while (!game.IsOver)
            {
                Console.Clear();
                Console.SetCursorPosition(0, 0);
                Console.WriteLine("Welcome to Hangman");

                Console.WriteLine(game.CurrentMaskedWord);
                Console.WriteLine($"Previous Guesses: {String.Join(',', game.PreviousGuesses.ToArray())}");
                Console.WriteLine($"Guesses Left: {game.GuessesRemaining}");

#if SupportUndo
                Console.WriteLine("Guess (a-z or '-' to undo last guess): ");
#else
                Console.WriteLine("Guess (a-z): ");
#endif

                var entry = char.ToUpperInvariant(Console.ReadKey().KeyChar);

#if SupportUndo
                if(entry == '-')
                {
                    if(gameHistory.Count > 1)
                    {
                        gameHistory.Pop();
                        game.ResumeFrom(gameHistory.Peek());
                        Console.WriteLine();
                        continue;
                    }
                }
#endif
                try
                {
                    game.Guess(entry);
#if SupportUndo
                    gameHistory.Push(game.CreateSetPoint());
#endif
                    Console.WriteLine();
                }
                catch (DuplicateGuessException)
                {
                    OutputError("You already guessed that.");
                    continue;
                }
                catch (InvalidGuessException)
                {
                    OutputError("Sorry, invalid guess.");
                    continue;
                }
            }

            if (game.Result == GameResult.Won)
            {
                Console.WriteLine("CONGRATS! YOU WON!");
            }

            if (game.Result == GameResult.Lost)
            {
                Console.WriteLine("SORRY, You lost this time. Try again!");
            }
        }

19 View Source File : Program.cs
License : GNU General Public License v2.0
Project Creator : ArgusMagnus

static void Main(string[] args)
		{
			/// Make sure either libfftw3-3-x86.dll or libfftw3-3-x64.dll
			/// (according to <see cref="Environment.Is64BitProcess"/>)
			/// is in the output directory

			DFT.Wisdom.Import("wisdom.txt");

			Example1D();

			Console.ReadKey();
			Console.Clear();

			Example2D();

			Console.ReadKey();
			Console.Clear();

			ExampleR2C();

			Console.ReadKey();
			Console.Clear();

			ExampleUsePlanDirectly();

			DFT.Wisdom.Export("wisdom.txt");
			Console.WriteLine(DFT.Wisdom.Current);
			Console.ReadKey();
		}

19 View Source File : ConsoleWrapper.cs
License : GNU Affero General Public License v3.0
Project Creator : arklumpus

public static void Clear()
        {
            if (ConsoleEnabled && !Console.IsOutputRedirected)
            {
                Console.Clear();
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : arthurvaverko

private static void DirectoryCallback(DirectoryInfo selectedDirInfo)
		{
			Console.Clear();
			OpenDirectoryBrowserConsole(selectedDirInfo.FullName);
		}

19 View Source File : Program.cs
License : MIT License
Project Creator : arthurvaverko

private static void ItemCallback(string itemClicked)
		{
			Console.Clear();
			Console.WriteLine(itemClicked);
		}

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : asynkron

private static async Task Main()
    {
        Log.SetLoggerFactory(LoggerFactory.Create(c => c
                .SetMinimumLevel(LogLevel.Information)
                .AddConsole()
            )
        );

        var logger = Log.CreateLogger<Program>();
#if NETCORE
        AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif

        Console.WriteLine("Enter 0 to use GrpcCore provider");
        Console.WriteLine("Enter 1 to use GrpcNet provider");
        if (!int.TryParse(Console.ReadLine(), out var provider))
            provider = 0;

        Console.WriteLine("Enter client advertised host (Enter = localhost)");
        var advertisedHost = Console.ReadLine().Trim();
        if (string.IsNullOrEmpty(advertisedHost))
            advertisedHost = "127.0.0.1";

        Console.WriteLine("Enter remote advertised host (Enter = localhost)");
        var remoteAddress = Console.ReadLine().Trim();

        if (string.IsNullOrEmpty(remoteAddress)) remoteAddress = "127.0.0.1";

        var actorSystemConfig = new ActorSystemConfig()
            .WithDeadLetterThrottleCount(10)
            .WithDeadLetterThrottleInterval(TimeSpan.FromSeconds(2));
        var system = new ActorSystem(actorSystemConfig);
        var context = new RootContext(system);

        IRemote remote;

        if (provider == 0)
        {
            var remoteConfig = GrpcCoreRemoteConfig
                .BindTo(advertisedHost)
                .WithProtoMessages(ProtosReflection.Descriptor);
            remote = new GrpcCoreRemote(system, remoteConfig);
        }
        else
        {
            var remoteConfig = GrpcNetRemoteConfig
                .BindTo(advertisedHost)
                .WithChannelOptions(new GrpcChannelOptions
                    {
                        CompressionProviders = new[]
                        {
                            new GzipCompressionProvider(CompressionLevel.Fastest)
                        }
                    }
                )
                .WithProtoMessages(ProtosReflection.Descriptor);
            remote = new GrpcNetRemote(system, remoteConfig);
        }

        await remote.StartAsync();

        var messageCount = 1000000;
        var cancellationTokenSource = new CancellationTokenSource();
        _ = SafeTask.Run(async () => {
                while (!cancellationTokenSource.IsCancellationRequested)
                {
                    var semapreplaced = new SemapreplacedSlim(0);
                    var props = Props.FromProducer(() => new LocalActor(0, messageCount, semapreplaced));

                    var pid = context.Spawn(props);

                    try
                    {
                        var actorPidResponse =
                            await remote.SpawnAsync($"{remoteAddress}:12000", "echo", TimeSpan.FromSeconds(1));

                        if (actorPidResponse.StatusCode == (int) ResponseStatusCode.OK)
                        {
                            var remotePid = actorPidResponse.Pid;
                            await context.RequestAsync<Start>(remotePid, new StartRemote {Sender = pid},
                                TimeSpan.FromSeconds(1)
                            );
                            var stopWatch = new Stopwatch();
                            stopWatch.Start();
                            Console.WriteLine("Starting to send");
                            var msg = new Ping();

                            for (var i = 0; i < messageCount; i++)
                            {
                                context.Send(remotePid, msg);
                            }

                            var linkedTokenSource =
                                CancellationTokenSource.CreateLinkedTokenSource(cancellationTokenSource.Token,
                                    new CancellationTokenSource(2000).Token
                                );
                            await semapreplaced.WaitAsync(linkedTokenSource.Token);
                            stopWatch.Stop();
                            var elapsed = stopWatch.Elapsed;
                            Console.WriteLine("Elapsed {0}", elapsed);

                            var t = messageCount * 2.0 / elapsed.TotalMilliseconds * 1000;
                            Console.Clear();
                            Console.WriteLine("Throughput {0} msg / sec", t);
                            await context.StopAsync(remotePid);
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        await Task.Delay(1000);
                    }
                    catch (Exception e)
                    {
                        logger?.LogError(e, "Error");
                        await Task.Delay(5000);
                    }

                    await context.PoisonAsync(pid);
                }
            }, cancellationTokenSource.Token
        );

        Console.ReadLine();
        cancellationTokenSource.Cancel();
        await Task.Delay(1000);
        Console.WriteLine("Press enter to quit");
        Console.ReadLine();
        await remote.ShutdownAsync();
    }

19 View Source File : Exemplo7.4.cs
License : MIT License
Project Creator : atrigo

static void Main(string[] args)
        {
            int op = 0;
            do
            {
                Console.WriteLine("Saudacoes em portugues:");
                Console.WriteLine("1 - Ola.");
                Console.WriteLine("2 - Bom dia");
                Console.WriteLine("3 - Como esta");
                Console.WriteLine("0 - Sair");
                op = Convert.ToInt32(Console.ReadLine());
                Console.Clear();
                switch (op)
                {
                    case 1:
                        Ola();
                        break;
                    case 2:
                        BomDia();
                        break;
                    case 3:
                        ComoEsta();
                        break;
                }
                if (op != 0)
                {
                    Console.WriteLine("Prima enter para voltar ao menu...");
                    Console.ReadLine();
                    Console.Clear();
                }
            } while (op != 0);
        }

19 View Source File : Exemplo7.5.cs
License : MIT License
Project Creator : atrigo

static void Main(string[] args)
        {
            ConsoleKeyInfo cki;
            do
            {
                Console.WriteLine("Saudacoes em portugues:");
                Console.WriteLine("1 - Ola.");
                Console.WriteLine("2 - Bom dia");
                Console.WriteLine("3 - Como esta");
                Console.WriteLine("0 - Sair");
                cki = Console.ReadKey();
                Console.Clear();
                switch (cki.Key)
                {
                    case ConsoleKey.D1:
                        Ola();
                        break;
                    case ConsoleKey.D2:
                        BomDia();
                        break;
                    case ConsoleKey.D3:
                        ComoEsta();
                        break;
                }
                if (cki.Key != ConsoleKey.D0)
                {
                    Console.WriteLine("Prima enter para voltar ao menu...");
                    Console.ReadLine();
                    Console.Clear();
                }
            } while (cki.Key != ConsoleKey.D0);
        }

19 View Source File : Exercicio9.18.cs
License : MIT License
Project Creator : atrigo

static void validaUtilizador(string[,] U)
        {
            char c;
            int tentativas = 0, tamanho = 10, nCarat, i;
            char[] p = new char[tamanho];
            string preplaced,user;
            do
            {
                Console.Clear();
                Console.Write("Introduza o username: ");
                user=Console.ReadLine();
                p.Initialize();
                preplaced = "";
                nCarat = 0;
                Console.Write("Introduza a preplacedword (letras maiúsculas/minúsculas e números - máx 10 caract): ");
                do
                {
                    c = Console.ReadKey(true).KeyChar;
                    if (c == 8)
                    {
                        if (nCarat > 0)
                        {
                            p[--nCarat] = (char)0;
                            Console.Write(c + " " + c);
                        }
                    }
                    else
                        if ((c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9') && nCarat < tamanho)
                    {
                        p[nCarat++] = c;
                        Console.Write("*");
                    }
                } while (c != 13);
                tentativas++;
                i = 0;
                while (i < tamanho && p[i] != 0)
                {
                    preplaced += p[i];
                    i++;
                }
            } while ((user!=U[0,0] || preplaced != U[0,1]) && tentativas < 3);
            if (preplaced == U[0,1] && user==U[0,0])
                Console.WriteLine("\nValidação correta");
            else
                Console.WriteLine("\nExcedeu o número de tentativas");
        }

19 View Source File : Exercicio10.6.cs
License : MIT License
Project Creator : atrigo

static void Main(string[] args)
        {
            char c;
            int tentativas = 0, tamanho = 10, nCarat, i,tenta=0;
            bool continua;
            do
            {
                try
                {
                    Console.Write("Quantas tentativas: ");
                    tenta = Convert.ToInt32(Console.ReadLine());
                    continua = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continua = true;
                }
            } while (continua);

            char[] p = new char[tamanho];
            string preplaced, pwd = "luar";
            do
            {
                Console.Clear();
                p.Initialize();
                preplaced = "";
                nCarat = 0;
                Console.Write("Introduza a preplacedword (letras maiúsculas/minúsculas e números - máx 10 caract): ");
                do
                {
                    c = Console.ReadKey(true).KeyChar;
                    if (c == 8)
                    {
                        if (nCarat > 0)
                        {
                            p[--nCarat] = (char)0;
                            Console.Write(c + " " + c);
                        }
                    }
                    else
                        if ((c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9') && nCarat < tamanho)
                    {
                        p[nCarat++] = c;
                        Console.Write("*");
                    }
                } while (c != 13);
                tentativas++;
                i = 0;
                while (i < tamanho && p[i] != 0)
                {
                    preplaced += p[i];
                    i++;
                }
            } while (preplaced != pwd && tentativas < tenta);
            if (preplaced == pwd)
                Console.WriteLine("\nPreplacedword correta");
            else
                Console.WriteLine("\nExcedeu o número de tentativas");
        }

19 View Source File : Example1.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "1: A Static Map Example";
            var layout = new MapGen<MapGenContext>();

            // Initialize a 30x25 blank map full of Wall tiles
            InitTilesStep<MapGenContext> startStep = new InitTilesStep<MapGenContext>(30, 25);
            layout.GenSteps.Add(0, startStep);

            // Draw a specific array of tiles onto the map at offset X2,Y3
            string[] level =
            {
                ".........................",
                ".........................",
                "...........#.............",
                "....###...###...###......",
                "...#.#.....#.....#.#.....",
                "...####...###...####.....",
                "...#.#############.#.....",
                "......##.......##........",
                "......#..#####..#........",
                "......#.#######.#........",
                "...#.##.#######.##.#.....",
                "..#####.###.###.#####....",
                "...#.##.#######.##.#.....",
                "......#.#######.#........",
                "......#..#####..#........",
                "......##.......##........",
                "...#.#############.#.....",
                "...####...###...####.....",
                "...#.#.....#.....#.#.....",
                "....###...###...###......",
                "...........#.............",
            };
            ITile[][] tiles = new ITile[level[0].Length][];
            for (int xx = 0; xx < level[0].Length; xx++)
            {
                tiles[xx] = new ITile[level.Length];
                for (int yy = 0; yy < level.Length; yy++)
                {
                    int id = Map.WALL_TERRAIN_ID;
                    if (level[yy][xx] == '.')
                        id = Map.ROOM_TERRAIN_ID;
                    tiles[xx][yy] = new Tile(id);
                }
            }

            var drawStep = new SpecificTilesStep<MapGenContext>(tiles, new Loc(2, 3));
            layout.GenSteps.Add(0, drawStep);

            // Run the generator and print
            MapGenContext context = layout.GenMap(MathUtils.Rand.NextUInt64());
            Print(context.Map, replacedle);
        }

19 View Source File : Example2.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "2: A Map Made with Rooms and Halls";

            var layout = new MapGen<MapGenContext>();

            // Initialize a 54x40 floorplan with which to populate with rectangular floor and halls.
            InitFloorPlanStep<MapGenContext> startGen = new InitFloorPlanStep<MapGenContext>(54, 40);
            layout.GenSteps.Add(-2, startGen);

            // Create some room types to place
            var genericRooms = new SpawnList<RoomGen<MapGenContext>>
            {
                { new RoomGenSquare<MapGenContext>(new RandRange(4, 8), new RandRange(4, 8)), 10 }, // cross
                { new RoomGenRound<MapGenContext>(new RandRange(5, 9), new RandRange(5, 9)), 10 }, // round
            };

            // Create some hall types to place
            var genericHalls = new SpawnList<PermissiveRoomGen<MapGenContext>>
            {
                { new RoomGenAngledHall<MapGenContext>(0, new RandRange(3, 7), new RandRange(3, 7)), 10 },
                { new RoomGenSquare<MapGenContext>(new RandRange(1), new RandRange(1)), 20 },
            };

            // Feed the room and hall types to a path that is composed of a branching tree
            FloorPathBranch<MapGenContext> path = new FloorPathBranch<MapGenContext>(genericRooms, genericHalls)
            {
                HallPercent = 50,
                FillPercent = new RandRange(45),
                BranchRatio = new RandRange(0, 25),
            };

            layout.GenSteps.Add(-1, path);

            // Draw the rooms onto the tiled map, with 1 TILE padded on each side
            layout.GenSteps.Add(0, new DrawFloorToTileStep<MapGenContext>(1));

            // Run the generator and print
            MapGenContext context = layout.GenMap(MathUtils.Rand.NextUInt64());
            Print(context.Map, replacedle);
        }

19 View Source File : Example4.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "4: A Map with Stairs Up and Down";
            var layout = new MapGen<MapGenContext>();

            // Initialize a 3x2 grid of 10x10 cells.
            var startGen = new InitGridPlanStep<MapGenContext>(1)
            {
                CellX = 3,
                CellY = 2,
                CellWidth = 9,
                CellHeight = 9,
            };
            layout.GenSteps.Add(-4, startGen);

            // Create a path that is composed of a ring around the edge
            var path = new GridPathBranch<MapGenContext>
            {
                RoomRatio = new RandRange(70),
                BranchRatio = new RandRange(0, 50),
            };

            var genericRooms = new SpawnList<RoomGen<MapGenContext>>
            {
                { new RoomGenSquare<MapGenContext>(new RandRange(4, 8), new RandRange(4, 8)), 10 }, // cross
                { new RoomGenRound<MapGenContext>(new RandRange(5, 9), new RandRange(5, 9)), 10 }, // round
            };
            path.GenericRooms = genericRooms;

            var genericHalls = new SpawnList<PermissiveRoomGen<MapGenContext>>
            {
                { new RoomGenAngledHall<MapGenContext>(50), 10 },
            };
            path.GenericHalls = genericHalls;

            layout.GenSteps.Add(-4, path);

            // Output the rooms into a FloorPlan
            layout.GenSteps.Add(-2, new DrawGridToFloorStep<MapGenContext>());

            // Draw the rooms of the FloorPlan onto the tiled map, with 1 TILE padded on each side
            layout.GenSteps.Add(0, new DrawFloorToTileStep<MapGenContext>(1));

            // Add the stairs up and down
            layout.GenSteps.Add(2, new FloorStairsStep<MapGenContext, StairsUp, StairsDown>(new StairsUp(), new StairsDown()));

            // Run the generator and print
            MapGenContext context = layout.GenMap(MathUtils.Rand.NextUInt64());
            Print(context.Map, replacedle);
        }

19 View Source File : Example7.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "7: A Map with Special Rooms";

            var layout = new MapGen<MapGenContext>();

            // Initialize a 54x40 floorplan with which to populate with rectangular floor and halls.
            InitFloorPlanStep<MapGenContext> startGen = new InitFloorPlanStep<MapGenContext>(54, 40);
            layout.GenSteps.Add(-2, startGen);

            // Create some room types to place
            SpawnList<RoomGen<MapGenContext>> genericRooms = new SpawnList<RoomGen<MapGenContext>>
            {
                { new RoomGenSquare<MapGenContext>(new RandRange(7, 9), new RandRange(7, 9)), 10 }, // square
                { new RoomGenRound<MapGenContext>(new RandRange(6, 10), new RandRange(6, 10)), 10 }, // round
            };

            // Create some hall types to place
            var genericHalls = new SpawnList<PermissiveRoomGen<MapGenContext>>
            {
                { new RoomGenAngledHall<MapGenContext>(0, new RandRange(3, 7), new RandRange(3, 7)), 10 },
            };

            // Feed the room and hall types to a path that is composed of a branching tree
            FloorPathBranch<MapGenContext> path = new FloorPathBranch<MapGenContext>(genericRooms, genericHalls)
            {
                HallPercent = 50,
                FillPercent = new RandRange(40),
                BranchRatio = new RandRange(0, 25),
            };

            path.RoomComponents.Set(new MainRoomComponent());
            path.HallComponents.Set(new MainHallComponent());

            layout.GenSteps.Add(-1, path);

            string[] custom = new string[]
            {
                                             "~~~..~~~",
                                             "~~~..~~~",
                                             "~~#..#~~",
                                             "........",
                                             "........",
                                             "~~#..#~~",
                                             "~~~..~~~",
                                             "~~~..~~~",
            };

            SetSpecialRoomStep<MapGenContext> listSpecialStep = new SetSpecialRoomStep<MapGenContext>
            {
                Rooms = new PresetPicker<RoomGen<MapGenContext>>(CreateRoomGenSpecific<MapGenContext>(custom)),
            };
            listSpecialStep.RoomComponents.Set(new TreasureRoomComponent());
            PresetPicker<PermissiveRoomGen<MapGenContext>> picker = new PresetPicker<PermissiveRoomGen<MapGenContext>>
            {
                ToSpawn = new RoomGenAngledHall<MapGenContext>(0),
            };
            listSpecialStep.Halls = picker;
            layout.GenSteps.Add(-1, listSpecialStep);

            // Draw the rooms of the FloorPlan onto the tiled map, with 1 TILE padded on each side
            layout.GenSteps.Add(0, new DrawFloorToTileStep<MapGenContext>(1));

            // Add the stairs up and down
            layout.GenSteps.Add(2, new FloorStairsStep<MapGenContext, StairsUp, StairsDown>(new StairsUp(), new StairsDown()));

            // Apply Items
            var itemSpawns = new SpawnList<Item>
            {
                { new Item((int)'!'), 10 },
                { new Item((int)']'), 10 },
                { new Item((int)'='), 10 },
                { new Item((int)'?'), 10 },
                { new Item((int)'$'), 10 },
                { new Item((int)'/'), 10 },
                { new Item((int)'*'), 50 },
            };
            RandomRoomSpawnStep<MapGenContext, Item> itemPlacement = new RandomRoomSpawnStep<MapGenContext, Item>(new PickerSpawner<MapGenContext, Item>(new LoopedRand<Item>(itemSpawns, new RandRange(10, 19))));
            layout.GenSteps.Add(6, itemPlacement);

            // Apply Treasure Items
            var treasureSpawns = new SpawnList<Item>
            {
                { new Item((int)'!'), 10 },
                { new Item((int)'*'), 50 },
            };
            RandomRoomSpawnStep<MapGenContext, Item> treasurePlacement = new RandomRoomSpawnStep<MapGenContext, Item>(new PickerSpawner<MapGenContext, Item>(new LoopedRand<Item>(treasureSpawns, new RandRange(7, 10))));
            treasurePlacement.Filters.Add(new RoomFilterComponent(false, new TreasureRoomComponent()));
            layout.GenSteps.Add(6, treasurePlacement);

            // Run the generator and print
            MapGenContext context = layout.GenMap(MathUtils.Rand.NextUInt64());
            Print(context.Map, replacedle);
        }

19 View Source File : ExampleDebug.cs
License : MIT License
Project Creator : audinowho

public static ConsoleKey PrintListRoomHalls(IGenContext map, string msg, bool printDebug, bool printViewer)
        {
            if (!(map is IFloorPlanGenContext context))
                return ConsoleKey.Enter;

            var str = new StringBuilder();
            FloorPlan plan = context.RoomPlan;
            if (plan == null)
                return ConsoleKey.Enter;

            for (int yy = 0; yy < plan.DrawRect.Bottom; yy++)
            {
                for (int xx = 0; xx < plan.DrawRect.Right; xx++)
                {
                    str.Append(' ');
                }
            }

            for (int ii = 0; ii < plan.RoomCount; ii++)
            {
                char chosenChar = (char)('A' + (ii % 26));
                IRoomGen gen = plan.GetRoom(ii);
                for (int xx = gen.Draw.Left; xx < gen.Draw.Right; xx++)
                {
                    for (int yy = gen.Draw.Top; yy < gen.Draw.Bottom; yy++)
                    {
                        int index = (yy * plan.DrawRect.Right) + xx;

                        if (str[index] == ' ')
                            str[index] = chosenChar;
                        else
                            str[index] = '!';
                    }
                }
            }

            for (int ii = 0; ii < plan.HallCount; ii++)
            {
                char chosenChar = (char)('a' + (ii % 26));

                IRoomGen gen = plan.GetHall(ii);

                for (int xx = gen.Draw.Left; xx < gen.Draw.Right; xx++)
                {
                    for (int yy = gen.Draw.Top; yy < gen.Draw.Bottom; yy++)
                    {
                        int index = (yy * plan.DrawRect.Right) + xx;

                        if (str[index] == ' ')
                            str[index] = chosenChar;
                        else if ((str[index] >= 'a' && str[index] <= 'z') || str[index] == '#')
                            str[index] = '+';
                        else
                            str[index] = '!';
                    }
                }
            }

            for (int yy = plan.DrawRect.Bottom - 1; yy > 0; yy--)
                str.Insert(plan.DrawRect.Right * yy, '\n');

            string newStr = str.ToString();
            if (listDebugString[currentDepth].MapString == newStr)
                return ConsoleKey.Enter;

            listDebugString[currentDepth].MapString = newStr;

            if (printDebug)
            {
                Debug.WriteLine(msg);
                Debug.Print(newStr);
            }

            if (printViewer)
            {
                SteppingIn = false;
                Console.Clear();
                Console.WriteLine(msg);
                Loc start = new Loc(Console.CursorLeft, Console.CursorTop);
                Console.Write(newStr);
                Loc end = new Loc(Console.CursorLeft, Console.CursorTop + 1);
                Console.SetCursorPosition(start.X, start.Y);
                int prevFarthestPrint = end.Y;

                while (true)
                {
                    int farthestPrint = end.Y;
                    Loc mapLoc = new Loc(Console.CursorLeft, Console.CursorTop) - start;
                    RewriteLine(farthestPrint, $"X:{mapLoc.X:D3}  Y:{mapLoc.Y:D3}");
                    farthestPrint++;

                    for (int ii = 0; ii < plan.RoomCount; ii++)
                    {
                        FloorRoomPlan roomPlan = plan.GetRoomPlan(ii);
                        if (roomPlan.RoomGen.Draw.Contains(mapLoc))
                        {
                            // stats
                            string roomString = $"Room #{ii}: {roomPlan.RoomGen.Draw.X}x{roomPlan.RoomGen.Draw.Y} {roomPlan.RoomGen}";
                            RewriteLine(farthestPrint, roomString);
                            farthestPrint++;
                            string componentString = string.Format("Components: {0}", string.Join(", ", roomPlan.Components));
                            RewriteLine(farthestPrint, componentString);
                            farthestPrint++;

                            // borders
                            var lineString = new StringBuilder(" ");
                            for (int xx = 0; xx < roomPlan.RoomGen.Draw.Width; xx++)
                                lineString.Append(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Up, xx) ? "^" : " ");
                            RewriteLine(farthestPrint, lineString.ToString());
                            farthestPrint++;
                            for (int yy = 0; yy < roomPlan.RoomGen.Draw.Height; yy++)
                            {
                                lineString = new StringBuilder(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Left, yy) ? "<" : " ");
                                for (int xx = 0; xx < roomPlan.RoomGen.Draw.Width; xx++)
                                    lineString.Append("#");
                                lineString.Append(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Right, yy) ? ">" : " ");
                                RewriteLine(farthestPrint, lineString.ToString());
                                farthestPrint++;
                            }

                            lineString = new StringBuilder(" ");
                            for (int xx = 0; xx < roomPlan.RoomGen.Draw.Width; xx++)
                                lineString.Append(roomPlan.RoomGen.GetFulfillableBorder(Dir4.Down, xx) ? "V" : " ");
                            RewriteLine(farthestPrint, lineString.ToString());
                            farthestPrint++;
                        }
                    }

                    for (int ii = 0; ii < plan.HallCount; ii++)
                    {
                        FloorHallPlan hallPlan = plan.GetHallPlan(ii);
                        if (hallPlan.RoomGen.Draw.Contains(mapLoc))
                        {
                            string roomString = $"Hall #{ii}: {hallPlan.RoomGen.Draw.X}x{hallPlan.RoomGen.Draw.Y} {hallPlan.RoomGen}";
                            RewriteLine(farthestPrint, roomString);
                            farthestPrint++;
                            string componentString = string.Format("Components: {0}", string.Join(", ", hallPlan.Components));
                            RewriteLine(farthestPrint, componentString);
                            farthestPrint++;
                        }
                    }

                    for (int ii = farthestPrint; ii < prevFarthestPrint; ii++)
                        ClearLine(ii);
                    prevFarthestPrint = farthestPrint;
                    Console.SetCursorPosition(start.X + mapLoc.X, start.Y + mapLoc.Y);

                    ConsoleKeyInfo key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.UpArrow)
                        Console.SetCursorPosition(Console.CursorLeft, Math.Max(start.Y, Console.CursorTop - 1));
                    else if (key.Key == ConsoleKey.DownArrow)
                        Console.SetCursorPosition(Console.CursorLeft, Math.Min(Console.CursorTop + 1, end.Y - 1));
                    else if (key.Key == ConsoleKey.LeftArrow)
                        Console.SetCursorPosition(Math.Max(start.X, Console.CursorLeft - 1), Console.CursorTop);
                    else if (key.Key == ConsoleKey.RightArrow)
                        Console.SetCursorPosition(Math.Min(Console.CursorLeft + 1, end.X - 1), Console.CursorTop);
                    else
                        return key.Key;
                }
            }
            else
            {
                return ConsoleKey.Enter;
            }
        }

19 View Source File : ExampleDebug.cs
License : MIT License
Project Creator : audinowho

public static ConsoleKey PrintGridRoomHalls(IGenContext map, string msg, bool printDebug, bool printViewer)
        {
            if (!(map is IRoomGridGenContext context))
                return ConsoleKey.Enter;

            var str = new StringBuilder();
            GridPlan plan = context.GridPlan;
            if (plan == null)
                return ConsoleKey.Enter;

            for (int yy = 0; yy < plan.GridHeight; yy++)
            {
                if (yy > 0)
                    str.Append('\n');

                for (int xx = 0; xx < plan.GridWidth; xx++)
                {
                    int roomIndex = plan.GetRoomIndex(new Loc(xx, yy));
                    if (roomIndex == -1)
                        str.Append('0');
                    else // if (roomIndex < 26)
                        str.Append((char)('A' + (roomIndex % 26)));
                    /* else
                           str.Append('@');
                    */

                    if (xx < plan.GridWidth - 1)
                    {
                        if (plan.GetHall(new LocRay4(xx, yy, Dir4.Right)) != null)
                            str.Append('#');
                        else
                            str.Append('.');
                    }
                }

                if (yy < plan.GridHeight - 1)
                {
                    str.Append('\n');
                    for (int xx = 0; xx < plan.GridWidth; xx++)
                    {
                        if (plan.GetHall(new LocRay4(xx, yy, Dir4.Down)) != null)
                            str.Append('#');
                        else
                            str.Append('.');

                        if (xx < plan.GridWidth - 1)
                        {
                            str.Append(' ');
                        }
                    }
                }
            }

            string newStr = str.ToString();
            if (gridDebugString[currentDepth].MapString == newStr)
                return ConsoleKey.Enter;

            gridDebugString[currentDepth].MapString = newStr;

            if (printDebug)
            {
                Debug.WriteLine(msg);
                Debug.Print(newStr);
            }

            if (printViewer)
            {
                SteppingIn = false;
                Console.Clear();
                Console.WriteLine(msg);
                Loc start = new Loc(Console.CursorLeft, Console.CursorTop);
                Console.Write(newStr);
                Loc end = new Loc(Console.CursorLeft, Console.CursorTop + 1);
                Console.SetCursorPosition(start.X, start.Y);
                int prevFarthestPrint = end.Y;

                while (true)
                {
                    int farthestPrint = end.Y;
                    Loc gridLoc = new Loc(Console.CursorLeft, Console.CursorTop) - start;
                    Loc mapLoc = gridLoc / 2;
                    RewriteLine(farthestPrint, $"X:{gridLoc.X / 2f:0.0}  Y:{gridLoc.Y / 2f:0.0}");
                    farthestPrint++;

                    bool alignX = gridLoc.X % 2 == 0;
                    bool alignY = gridLoc.Y % 2 == 0;

                    if (alignX && alignY)
                    {
                        int index = plan.GetRoomIndex(mapLoc);
                        GridRoomPlan roomPlan = plan.GetRoomPlan(mapLoc);
                        if (roomPlan != null)
                        {
                            string roomString = $"Room #{index}: {roomPlan.RoomGen}";
                            if (roomPlan.PreferHall)
                                roomString += " [Hall]";
                            RewriteLine(farthestPrint, roomString);
                            farthestPrint++;
                            string componentString = string.Format("Components: {0}", string.Join(", ", roomPlan.Components));
                            RewriteLine(farthestPrint, componentString);
                            farthestPrint++;
                        }
                    }
                    else if (alignX)
                    {
                        GridHallPlan hall = plan.GetHall(new LocRay4(mapLoc, Dir4.Down));
                        if (hall != null)
                        {
                            RewriteLine(farthestPrint, "Hall: " + hall.RoomGen);
                            farthestPrint++;
                            string componentString = string.Format("Components: {0}", string.Join(", ", hall.Components));
                            RewriteLine(farthestPrint, componentString);
                            farthestPrint++;
                        }
                    }
                    else if (alignY)
                    {
                        GridHallPlan hall = plan.GetHall(new LocRay4(mapLoc, Dir4.Right));
                        if (hall != null)
                        {
                            RewriteLine(farthestPrint, "Hall: " + hall.RoomGen);
                            farthestPrint++;
                        }
                    }

                    for (int ii = farthestPrint; ii < prevFarthestPrint; ii++)
                        ClearLine(ii);
                    prevFarthestPrint = farthestPrint;
                    Console.SetCursorPosition(start.X + gridLoc.X, start.Y + gridLoc.Y);

                    ConsoleKeyInfo key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.UpArrow)
                        Console.SetCursorPosition(Console.CursorLeft, Math.Max(start.Y, Console.CursorTop - 1));
                    else if (key.Key == ConsoleKey.DownArrow)
                        Console.SetCursorPosition(Console.CursorLeft, Math.Min(Console.CursorTop + 1, end.Y - 1));
                    else if (key.Key == ConsoleKey.LeftArrow)
                        Console.SetCursorPosition(Math.Max(start.X, Console.CursorLeft - 1), Console.CursorTop);
                    else if (key.Key == ConsoleKey.RightArrow)
                        Console.SetCursorPosition(Math.Min(Console.CursorLeft + 1, end.X - 1), Console.CursorTop);
                    else
                        return key.Key;
                }
            }
            else
            {
                return ConsoleKey.Enter;
            }
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : audinowho

public static void Main()
        {
#if DEBUG
            GenContextDebug.OnInit += ExampleDebug.Init;
            GenContextDebug.OnStep += ExampleDebug.OnStep;
            GenContextDebug.OnStepIn += ExampleDebug.StepIn;
            GenContextDebug.OnStepOut += ExampleDebug.StepOut;
#endif
            ConsoleKey lastKey = ConsoleKey.Enter;
            bool wasNonAction = false;
            bool done = false;
            while (!done)
            {
                ConsoleKey key = ConsoleKey.Enter;
                if (!wasNonAction)
                {
                    if (lastKey != ConsoleKey.Enter)
                    {
                        Console.WriteLine("Press a key 1-8 | F4=Debug");
                        Console.WriteLine("While debugging: F5=Step-In | F6=Step-Out | ESC=Exit Debug");
                    }
                    else
                    {
                        Console.WriteLine("Press a key 1-8:");
                    }
                }

                key = Console.ReadKey(true).Key;

                if (key == ConsoleKey.F2)
                {
                    while (true)
                    {
                        Console.Clear();
                        Console.WriteLine(">Bulk Gen");
                        Console.WriteLine("Specify amount to generate");
                        int amt = GetInt(false);
                        if (amt > -1)
                        {
                            Console.WriteLine("Stress Test WIP.");
                            ConsoleKeyInfo afterKey = Console.ReadKey();
                            if (afterKey.Key == ConsoleKey.Escape)
                                break;
                        }
                        else if (amt == -1)
                        {
                            break;
                        }
                    }
                }
                else if (key == ConsoleKey.F4)
                {
                    ExampleDebug.SteppingIn = true;
                    key = lastKey;
                }

                bool keepKey = true;
                wasNonAction = false;
                switch (key)
                {
                    case ConsoleKey.D1:
                        Ex1_Tiles.Example1.Run();
                        break;
                    case ConsoleKey.D2:
                        Ex2_Rooms.Example2.Run();
                        break;
                    case ConsoleKey.D3:
                        Ex3_Grid.Example3.Run();
                        break;
                    case ConsoleKey.D4:
                        Ex4_Stairs.Example4.Run();
                        break;
                    case ConsoleKey.D5:
                        Ex5_Terrain.Example5.Run();
                        break;
                    case ConsoleKey.D6:
                        Ex6_Items.Example6.Run();
                        break;
                    case ConsoleKey.D7:
                        Ex7_Special.Example7.Run();
                        break;
                    case ConsoleKey.D8:
                        Ex8_Integration.Example8.Run();
                        break;
                    case ConsoleKey.Escape:
                        done = true;
                        break;
                    default:
                        keepKey = false;
                        wasNonAction = true;
                        break;
                }

                if (keepKey)
                    lastKey = key;

                ExampleDebug.SteppingIn = false;
            }

            Console.WriteLine("Bye.");
            Console.ReadKey();
        }

19 View Source File : Example3.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "3: A Map made with Rooms and Halls arranged in a grid.";

            var layout = new MapGen<MapGenContext>();

            // Initialize a 6x4 grid of 10x10 cells.
            var startGen = new InitGridPlanStep<MapGenContext>(1)
            {
                CellX = 6,
                CellY = 4,
                CellWidth = 9,
                CellHeight = 9,
            };
            layout.GenSteps.Add(-4, startGen);

            // Create a path that is composed of branches in grid lock
            var path = new GridPathBranch<MapGenContext>
            {
                RoomRatio = new RandRange(70),
                BranchRatio = new RandRange(0, 50),
            };

            var genericRooms = new SpawnList<RoomGen<MapGenContext>>
            {
                { new RoomGenSquare<MapGenContext>(new RandRange(4, 8), new RandRange(4, 8)), 10 }, // cross
                { new RoomGenRound<MapGenContext>(new RandRange(5, 9), new RandRange(5, 9)), 10 }, // round
            };
            path.GenericRooms = genericRooms;

            var genericHalls = new SpawnList<PermissiveRoomGen<MapGenContext>> { { new RoomGenAngledHall<MapGenContext>(50), 10 } };
            path.GenericHalls = genericHalls;

            layout.GenSteps.Add(-4, path);

            // Output the rooms into a FloorPlan
            layout.GenSteps.Add(-2, new DrawGridToFloorStep<MapGenContext>());

            // Draw the rooms of the FloorPlan onto the tiled map, with 1 TILE padded on each side
            layout.GenSteps.Add(0, new DrawFloorToTileStep<MapGenContext>(1));

            // Run the generator and print
            MapGenContext context = layout.GenMap(MathUtils.Rand.NextUInt64());
            Print(context.Map, replacedle);
        }

19 View Source File : Example5.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "5: A Map with Terrain Features";
            var layout = new MapGen<MapGenContext>();

            // Initialize a 6x4 grid of 10x10 cells.
            var startGen = new InitGridPlanStep<MapGenContext>(1)
            {
                CellX = 6,
                CellY = 4,
                CellWidth = 9,
                CellHeight = 9,
            };
            layout.GenSteps.Add(-4, startGen);

            // Create a path that is composed of a ring around the edge
            var path = new GridPathBranch<MapGenContext>
            {
                RoomRatio = new RandRange(70),
                BranchRatio = new RandRange(0, 50),
            };

            var genericRooms = new SpawnList<RoomGen<MapGenContext>>
            {
                { new RoomGenSquare<MapGenContext>(new RandRange(4, 8), new RandRange(4, 8)), 10 }, // cross
                { new RoomGenRound<MapGenContext>(new RandRange(5, 9), new RandRange(5, 9)), 10 }, // round
            };
            path.GenericRooms = genericRooms;

            var genericHalls = new SpawnList<PermissiveRoomGen<MapGenContext>>
            {
                { new RoomGenAngledHall<MapGenContext>(50), 10 },
            };
            path.GenericHalls = genericHalls;

            layout.GenSteps.Add(-4, path);

            // Output the rooms into a FloorPlan
            layout.GenSteps.Add(-2, new DrawGridToFloorStep<MapGenContext>());

            // Draw the rooms of the FloorPlan onto the tiled map, with 1 TILE padded on each side
            layout.GenSteps.Add(0, new DrawFloorToTileStep<MapGenContext>(1));

            // Add the stairs up and down
            layout.GenSteps.Add(2, new FloorStairsStep<MapGenContext, StairsUp, StairsDown>(new StairsUp(), new StairsDown()));

            // Generate water (specified by user as Terrain 2) with a frequency of 35%, using Perlin Noise in an order of 3, softness 1.
            const int terrain = 2;
            var waterPostProc = new PerlinWaterStep<MapGenContext>(new RandRange(35), 3, new Tile(terrain), 1, false);
            layout.GenSteps.Add(3, waterPostProc);

            // Remove walls where diagonals of water exist and replace with water
            layout.GenSteps.Add(4, new DropDiagonalBlockStep<MapGenContext>(new Tile(terrain)));

            // Remove water stuck in the walls
            layout.GenSteps.Add(4, new EraseIsolatedStep<MapGenContext>(new Tile(terrain)));

            // Run the generator and print
            MapGenContext context = layout.GenMap(MathUtils.Rand.NextUInt64());
            Print(context.Map, replacedle);
        }

19 View Source File : Example6.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "6: A Map with Randomly Placed Items/Mobs";
            var layout = new MapGen<MapGenContext>();

            // Initialize a 6x4 grid of 10x10 cells.
            var startGen = new InitGridPlanStep<MapGenContext>(1)
            {
                CellX = 6,
                CellY = 4,
                CellWidth = 9,
                CellHeight = 9,
            };
            layout.GenSteps.Add(-4, startGen);

            // Create a path that is composed of a ring around the edge
            var path = new GridPathBranch<MapGenContext>
            {
                RoomRatio = new RandRange(70),
                BranchRatio = new RandRange(0, 50),
            };

            var genericRooms = new SpawnList<RoomGen<MapGenContext>>
            {
                { new RoomGenSquare<MapGenContext>(new RandRange(4, 8), new RandRange(4, 8)), 10 }, // cross
                { new RoomGenRound<MapGenContext>(new RandRange(5, 9), new RandRange(5, 9)), 10 }, // round
            };
            path.GenericRooms = genericRooms;

            var genericHalls = new SpawnList<PermissiveRoomGen<MapGenContext>>
            {
                { new RoomGenAngledHall<MapGenContext>(50), 10 },
            };
            path.GenericHalls = genericHalls;

            layout.GenSteps.Add(-4, path);

            // Output the rooms into a FloorPlan
            layout.GenSteps.Add(-2, new DrawGridToFloorStep<MapGenContext>());

            // Draw the rooms of the FloorPlan onto the tiled map, with 1 TILE padded on each side
            layout.GenSteps.Add(0, new DrawFloorToTileStep<MapGenContext>(1));

            // Add the stairs up and down
            layout.GenSteps.Add(2, new FloorStairsStep<MapGenContext, StairsUp, StairsDown>(new StairsUp(), new StairsDown()));

            // Generate water (specified by user as Terrain 2) with a frequency of 35%, using Perlin Noise in an order of 3, softness 1.
            const int terrain = 2;
            var waterPostProc = new PerlinWaterStep<MapGenContext>(new RandRange(35), 3, new Tile(terrain), 1, false);
            layout.GenSteps.Add(3, waterPostProc);

            // Remove walls where diagonals of water exist and replace with water
            layout.GenSteps.Add(4, new DropDiagonalBlockStep<MapGenContext>(new Tile(terrain)));

            // Remove water stuck in the walls
            layout.GenSteps.Add(4, new EraseIsolatedStep<MapGenContext>(new Tile(terrain)));

            // Apply Items
            var itemSpawns = new SpawnList<Item>
            {
                { new Item((int)'!'), 10 },
                { new Item((int)']'), 10 },
                { new Item((int)'='), 10 },
                { new Item((int)'?'), 10 },
                { new Item((int)'$'), 10 },
                { new Item((int)'/'), 10 },
                { new Item((int)'*'), 50 },
            };
            RandomSpawnStep<MapGenContext, Item> itemPlacement = new RandomSpawnStep<MapGenContext, Item>(new PickerSpawner<MapGenContext, Item>(new LoopedRand<Item>(itemSpawns, new RandRange(10, 19))));
            layout.GenSteps.Add(6, itemPlacement);

            // Apply Mobs
            var mobSpawns = new SpawnList<Mob>
            {
                { new Mob((int)'r'), 20 },
                { new Mob((int)'T'), 10 },
                { new Mob((int)'D'), 5 },
            };
            RandomSpawnStep<MapGenContext, Mob> mobPlacement = new RandomSpawnStep<MapGenContext, Mob>(new PickerSpawner<MapGenContext, Mob>(new LoopedRand<Mob>(mobSpawns, new RandRange(10, 19))));
            layout.GenSteps.Add(6, mobPlacement);

            // Run the generator and print
            MapGenContext context = layout.GenMap(MathUtils.Rand.NextUInt64());
            Print(context.Map, replacedle);
        }

19 View Source File : Example8.cs
License : MIT License
Project Creator : audinowho

public static void Run()
        {
            Console.Clear();
            const string replacedle = "8: Implementation as a MapCreationStrategy in RogueSharp";
            ExampleCreationStrategy<Map> exampleCreation = new ExampleCreationStrategy<Map>();

            // Initialize a 6x4 grid of 10x10 cells.
            var startGen = new InitGridPlanStep<MapGenContext>(1)
            {
                CellX = 6,
                CellY = 4,
                CellWidth = 9,
                CellHeight = 9,
            };
            exampleCreation.Layout.GenSteps.Add(-4, startGen);

            // Create a path that is composed of a ring around the edge
            var path = new GridPathBranch<MapGenContext>
            {
                RoomRatio = new RandRange(70),
                BranchRatio = new RandRange(0, 50),
            };

            var genericRooms = new SpawnList<RoomGen<MapGenContext>>
            {
                { new RoomGenSquare<MapGenContext>(new RandRange(4, 8), new RandRange(4, 8)), 10 }, // cross
                { new RoomGenRound<MapGenContext>(new RandRange(5, 9), new RandRange(5, 9)), 10 }, // round
            };
            path.GenericRooms = genericRooms;

            var genericHalls = new SpawnList<PermissiveRoomGen<MapGenContext>>
            {
                { new RoomGenAngledHall<MapGenContext>(50), 10 },
            };
            path.GenericHalls = genericHalls;

            exampleCreation.Layout.GenSteps.Add(-4, path);

            // Output the rooms into a FloorPlan
            exampleCreation.Layout.GenSteps.Add(-2, new DrawGridToFloorStep<MapGenContext>());

            // Draw the rooms of the FloorPlan onto the tiled map, with 1 TILE padded on each side
            exampleCreation.Layout.GenSteps.Add(0, new DrawFloorToTileStep<MapGenContext>(1));

            // Run the generator and print
            exampleCreation.Seed = MathUtils.Rand.NextUInt64();
            Map map = Map.Create(exampleCreation);
            Print(map, replacedle);
        }

19 View Source File : ExampleDebug.cs
License : MIT License
Project Creator : audinowho

public static ConsoleKey PrintTiles(IGenContext map, string msg, bool printDebug, bool printViewer)
        {
            if (!(map is ITiledGenContext context))
                return ConsoleKey.Enter;
            if (!context.TilesInitialized)
                return ConsoleKey.Enter;

            var str = new StringBuilder();

            for (int yy = 0; yy < context.Height; yy++)
            {
                if (yy > 0)
                    str.Append('\n');
                for (int xx = 0; xx < context.Width; xx++)
                {
                    if (context.GetTile(new Loc(xx, yy)).TileEquivalent(context.RoomTerrain))
                    {
                        str.Append('.');
                    }
                    else if (context.GetTile(new Loc(xx, yy)).TileEquivalent(context.WallTerrain))
                    {
                        str.Append('#');
                    }
                    else
                    {
                        if (context.TileBlocked(new Loc(xx, yy)))
                            str.Append('+');
                        else
                            str.Append('_');
                    }
                }
            }

            string newStr = str.ToString();
            if (tileDebugString[currentDepth].MapString == newStr)
                return ConsoleKey.Enter;

            tileDebugString[currentDepth].MapString = newStr;

            if (printDebug)
            {
                Debug.WriteLine(msg);
                Debug.Print(newStr);
            }

            if (printViewer)
            {
                // TODO: print with highlighting (use the bounds variable)
                // TODO: print with color
                SteppingIn = false;
                Console.Clear();
                Console.WriteLine(msg);
                Loc start = new Loc(Console.CursorLeft, Console.CursorTop);
                Console.Write(newStr);
                Loc end = new Loc(Console.CursorLeft, Console.CursorTop + 1);
                Console.SetCursorPosition(start.X, start.Y);
                int prevFarthestPrint = end.Y;

                while (true)
                {
                    int farthestPrint = end.Y;
                    Loc mapLoc = new Loc(Console.CursorLeft, Console.CursorTop) - start;
                    RewriteLine(farthestPrint, $"X:{mapLoc.X:D3}  Y:{mapLoc.Y:D3}");
                    farthestPrint++;
                    ITile tile = context.GetTile(mapLoc);
                    RewriteLine(farthestPrint, $"Tile: {tile}");
                    farthestPrint++;

                    for (int ii = farthestPrint; ii < prevFarthestPrint; ii++)
                        ClearLine(ii);
                    prevFarthestPrint = farthestPrint;
                    Console.SetCursorPosition(start.X + mapLoc.X, start.Y + mapLoc.Y);

                    ConsoleKeyInfo key = Console.ReadKey(true);
                    if (key.Key == ConsoleKey.UpArrow)
                        Console.SetCursorPosition(Console.CursorLeft, Math.Max(start.Y, Console.CursorTop - 1));
                    else if (key.Key == ConsoleKey.DownArrow)
                        Console.SetCursorPosition(Console.CursorLeft, Math.Min(Console.CursorTop + 1, end.Y - 1));
                    else if (key.Key == ConsoleKey.LeftArrow)
                        Console.SetCursorPosition(Math.Max(start.X, Console.CursorLeft - 1), Console.CursorTop);
                    else if (key.Key == ConsoleKey.RightArrow)
                        Console.SetCursorPosition(Math.Min(Console.CursorLeft + 1, end.X - 1), Console.CursorTop);
                    else
                        return key.Key;
                }
            }
            else
            {
                return ConsoleKey.Enter;
            }
        }

19 View Source File : Editor.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : aura-systems

internal void Start(string filename, string currentdirectory)
        {
            if (File.Exists(currentdirectory + filename))
            {
                Console.Clear();
                drawTopBar();
                Console.SetCursorPosition(0, 1);
                ConsoleKeyInfo c; cleanArray(line);

                List<string> text = new List<string>();
                text.Add(File.ReadAllText(currentdirectory + filename));

                string file = "";

                foreach (string value in text)
                {
                    file = file + value;
                }

                Console.Write(file);

                while ((c = Console.ReadKey(true)) != null)
                {
                    drawTopBar();
                    char ch = c.KeyChar;
                    if (c.Key == ConsoleKey.Escape)
                        break;

                    else if (c.Key == ConsoleKey.F1)
                    {
                        Console.Clear();
                        Console.BackgroundColor = ConsoleColor.Gray;
                        Console.ForegroundColor = ConsoleColor.Black;
                        Text.Display("liquideditor", prgm_version);
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.BackgroundColor = ConsoleColor.Black;

                        lines.Add(new string(line).TrimEnd());

                        final = lines.ToArray();
                        string foo = concatString(final);
                        File.Create(currentdirectory + filename);
                        File.WriteAllText(currentdirectory + filename, file + foo);
                        Console.ForegroundColor = ConsoleColor.Green;
                        Text.Display("saved", filename, currentdirectory);
                        Console.ForegroundColor = ConsoleColor.White;

                        Console.ReadKey();
                        break;
                    }

                    else if (c.Key == ConsoleKey.F2)
                    {
                        filepath(Kernel.current_directory);
                        break;
                    }

                    switch (c.Key)
                    {
                        case ConsoleKey.Home: break;
                        case ConsoleKey.PageUp: break;
                        case ConsoleKey.PageDown: break;
                        case ConsoleKey.End: break;
                        case ConsoleKey.UpArrow:
                            if (Console.CursorTop > 1)
                            {
                                Console.CursorTop = Console.CursorTop - 1;
                            }
                            break;
                        case ConsoleKey.DownArrow:
                            if (Console.CursorTop < 24)
                            {
                                Console.CursorTop = Console.CursorTop + 1;
                            }
                            break;
                        case ConsoleKey.LeftArrow: if (pointer > 0) { pointer--; Console.CursorLeft--; } break;
                        case ConsoleKey.RightArrow: if (pointer < 80) { pointer++; Console.CursorLeft++; if (line[pointer] == 0) line[pointer] = ' '; } break;
                        case ConsoleKey.Backspace: deleteChar(); break;
                        case ConsoleKey.Delete: deleteChar(); break;
                        case ConsoleKey.Enter:
                            lines.Add(new string(line).TrimEnd()); cleanArray(line); Console.CursorLeft = 0; Console.CursorTop++; pointer = 0;
                            break;
                        default: line[pointer] = ch; pointer++; Console.Write(ch); break;
                    }
                }
                Console.Clear();

            }
            else
            {
            Console.Clear();
            drawTopBar();
            Console.SetCursorPosition(0, 1);
            ConsoleKeyInfo c; cleanArray(line);
            while ((c = Console.ReadKey(true)) != null)
            {
                drawTopBar();
                char ch = c.KeyChar;
                if (c.Key == ConsoleKey.Escape)
                    break;
                else if (c.Key == ConsoleKey.F1)
                {
                    Console.Clear();
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Text.Display("liquideditor", prgm_version);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.BackgroundColor = ConsoleColor.Black;

                    lines.Add(new string(line).TrimEnd());

                    final = lines.ToArray();
                    string foo = concatString(final);
                    File.Create(currentdirectory + filename);
                    File.WriteAllText(currentdirectory + filename, foo); 
                    Console.ForegroundColor = ConsoleColor.Green;
                    Text.Display("saved", filename, currentdirectory);
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.ReadKey();
                    break;
                }
                else if (c.Key == ConsoleKey.F2)
                {
                    filepath(Kernel.current_directory);
                    break;
                }
                    switch (c.Key)
                {
                    case ConsoleKey.Home: break;
                    case ConsoleKey.PageUp: break;
                    case ConsoleKey.PageDown: break;
                    case ConsoleKey.End: break;
                    case ConsoleKey.UpArrow:
                        if (Console.CursorTop > 1)
                        {
                            Console.CursorTop = Console.CursorTop - 1;
                        }
                        break;
                    case ConsoleKey.DownArrow:
                        if (Console.CursorTop < 23)
                        {
                            Console.CursorTop = Console.CursorTop + 1;
                        }
                        break;
                    case ConsoleKey.LeftArrow: if (pointer > 0) { pointer--; Console.CursorLeft--; } break;
                    case ConsoleKey.RightArrow: if (pointer < 80) { pointer++; Console.CursorLeft++; if (line[pointer] == 0) line[pointer] = ' '; } break;
                    case ConsoleKey.Backspace: deleteChar(); break;
                    case ConsoleKey.Delete: deleteChar(); break;
                    case ConsoleKey.Enter:
                        lines.Add(new string(line).TrimEnd()); cleanArray(line); Console.CursorLeft = 0; Console.CursorTop++; pointer = 0;
                        break;
                    default: line[pointer] = ch; pointer++; Console.Write(ch); break;
                }
            }
            Console.Clear();
            }
        }

19 View Source File : Menu.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : aura-systems

public static void DispInstallationDialog(int percent)
        {
            int x = (Kernel.AConsole.Width / 2) - (64 / 2);
            int y = (Kernel.AConsole.Height / 2) - (10 / 2);

            if (percent == 0)
            {
                Console.Clear();

                Console.BackgroundColor = ConsoleColor.DarkBlue;

                switch (Kernel.langSelected)
                {
                    case "en_US":
                        Console.SetCursorPosition(x, y);
                        Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
                        Console.SetCursorPosition(x, y);
                        Console.SetCursorPosition(x, y+1);
                        Console.WriteLine("║ Installation in Progress...                                  ║");
                        Console.SetCursorPosition(x, y);
                        break;

                    case "fr_FR":
                        Console.SetCursorPosition(x, y);
                        Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
                        Console.SetCursorPosition(x, y);
                        Console.SetCursorPosition(x, y+1);
                        Console.WriteLine("║ Installation en cours...                                     ║");
                        Console.SetCursorPosition(x, y);
                        break;

                    case "nl_NL":
                        Console.SetCursorPosition(x, y);
                        Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
                        Console.SetCursorPosition(x, y);
                        Console.SetCursorPosition(x, y+1);
                        Console.WriteLine("║ Installatie wordt uitgevoerd...                              ║");
                        Console.SetCursorPosition(x, y);
                        break;

                    case "it_IT":
                        Console.SetCursorPosition(x, y);
                        Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
                        Console.SetCursorPosition(x, y);
                        Console.SetCursorPosition(x, y+1);
                        Console.WriteLine("║ Installazione in corso...                                    ║");
                        Console.SetCursorPosition(x, y);
                        break;
                        
                    case "pl_PL":
                        Console.SetCursorPosition(x, y);
                        Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
                        Console.SetCursorPosition(x, y);
                        Console.SetCursorPosition(x, y+1);
                        Console.WriteLine("║ Instalacja trwa...                                           ║");
                        Console.SetCursorPosition(x, y);
                        break;
                }


                Console.SetCursorPosition(x, y+2);
                Console.WriteLine("╠══════════════════════════════════════════════════════════════╣");

                Console.SetCursorPosition(x, y+3);
                Console.WriteLine("║                                                              ║");
                Console.SetCursorPosition(x, y);

                Console.SetCursorPosition(x, y+4);
                Console.WriteLine("║                                                              ║");
                Console.SetCursorPosition(x, y);

                Console.SetCursorPosition(x, y+5);
                Console.WriteLine("║                                                              ║");
                Console.SetCursorPosition(x, y);

                Console.SetCursorPosition(x, y+6);
                Console.WriteLine("║                                                              ║");
                Console.SetCursorPosition(x, y);

                Console.SetCursorPosition(x, y+7);
                Console.WriteLine("║                                                              ║");
                Console.SetCursorPosition(x, y);

                Console.SetCursorPosition(x, y+8);
                Console.WriteLine("╚══════════════════════════════════════════════════════════════╝");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 5)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+5);
                Console.WriteLine("###");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+60, y+1);
                Console.WriteLine("5%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 10)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("######");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("10%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 15)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("#########");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("15%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 20)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("############");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("20%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 25)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("###############");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("25%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 30)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("##################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("30%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 35)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("#####################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("35%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 40)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("########################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("40%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 45)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("###########################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("45%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 50)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("##############################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("50%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 55)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("#################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("55%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 60)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("####################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("60%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 65)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("#######################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("65%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 70)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("##########################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("70%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 75)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("#############################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("75%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 80)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("################################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("80%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 85)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("###################################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("85%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 90)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("######################################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("90%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 95)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("#########################################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("95%");
                Console.SetCursorPosition(x, y);
            }
            else if (percent == 100)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("############################################################");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(x+59, y+1);
                Console.WriteLine("100%");
                Console.SetCursorPosition(x, y);
            }
            else
            {
                Console.SetCursorPosition(x+2, y+ 5);
                Console.WriteLine("                                                            ");
                Console.SetCursorPosition(x, y);
                Console.ForegroundColor = ConsoleColor.White;
            }
        }

19 View Source File : Menu.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : aura-systems

public static string DispDialogOneArg(string replacedle, string input)
        {
            Console.Clear();

            replacedle = "║ " + replacedle;
            input = "║ " + input;

            int x = (Kernel.AConsole.Width / 2) - (64 / 2);
            int y = (Kernel.AConsole.Height / 2) - (10 / 2);

            Console.BackgroundColor = ConsoleColor.DarkBlue;

            Console.SetCursorPosition(x, y);
            Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
            Console.SetCursorPosition(x, y);
            Console.SetCursorPosition(x, y+1);
            Console.WriteLine("║                                                              ║");
            Console.SetCursorPosition(x, y);
            Console.SetCursorPosition(x, y+1);
            Console.WriteLine(replacedle);
            Console.SetCursorPosition(x, y);
            Console.SetCursorPosition(x, y+2);
            Console.WriteLine("╠══════════════════════════════════════════════════════════════╣");

            Console.SetCursorPosition(x, y+3);
            Console.WriteLine("║                                                              ║");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+4);
            Console.WriteLine("║                                                              ║");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+5);
            Console.WriteLine("║                                                              ║");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+6);
            Console.WriteLine("║                                                              ║");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+7);
            Console.WriteLine("║                                                              ║");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+8);
            Console.WriteLine("╚══════════════════════════════════════════════════════════════╝");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+5);
            Console.Write(input);
            string name = Console.ReadLine();
            Console.SetCursorPosition(x, y);

            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();
            return name;
        }

19 View Source File : Clear.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : aura-systems

public override ReturnInfo Execute()
        {
            Console.Clear();
            return new ReturnInfo(this, ReturnCode.OK);
        }

19 View Source File : Menu.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : aura-systems

public static void DispErrorDialog(string error)
        {
            Console.Clear();

            int x = (Kernel.AConsole.Width / 2) - (64 / 2);
            int y = (Kernel.AConsole.Height / 2) - (4 / 2);

            Console.BackgroundColor = ConsoleColor.DarkRed;

            Console.SetCursorPosition(x, y);
            Console.WriteLine("╔══════════════════════════════════════════════════════════════╗");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+1);
            Console.WriteLine("║                                                              ║");
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+1);
            Console.WriteLine("║ " + error);
            Console.SetCursorPosition(x, y);

            Console.SetCursorPosition(x, y+2);
            Console.WriteLine("╚══════════════════════════════════════════════════════════════╝");
            Console.SetCursorPosition(x, y);

            Console.BackgroundColor = ConsoleColor.Black;
            Console.ReadKey();

            Console.Clear();
        }

See More Examples