public static void DeserialColors() { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); try { List <UserSettings> settings = new List <UserSettings>(); var xDoc = XDocument.Load("../../cmn/UserSettings.xml"); settings = xDoc.Element("userSettings").Elements("settings").Select(x => new UserSettings { Foreground = colors[int.Parse(x.Element("foreground").Value)], Background = colors[int.Parse(x.Element("background").Value)], SelectedRow = colors[int.Parse(x.Element("selectedRow").Value)] }).ToList(); CurrentColor.Foreground = settings[0].Foreground; CurrentColor.Background = settings[0].Background; CurrentColor.SelectedRow = settings[0].SelectedRow; } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(ex.Message); Console.Read(); } }
static void Print(object lineNumber) { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); while (true) { foreach (var color in colors) { if (color == ConsoleColor.Black) { continue; } Console.ForegroundColor = color; lock (locker) // курсор то разделяемый ресурс { Console.SetCursorPosition(0, (int)lineNumber); for (int i = 0; i <= 10; i++) { Console.Write('.'); Thread.Sleep(1); } Console.Write('|'); Console.SetCursorPosition(0, (int)lineNumber); } } } }
static void Main(string[] args) { Console.SetWindowSize(120, 40); Console.CursorVisible = false; for (int p = 0; p <= 40; p++) { Console.SetCursorPosition(0, p); Console.Write(p); } ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); Random randColor = new Random(); Rain[] theRain = new Rain[25]; for (int i = 0; i < theRain.Length; i++) { theRain[i] = new Rain(colors[randColor.Next(2, 15)]); } do { for (int r = 0; r < theRain.Length; r++) { theRain[r].RainMoves(); Thread.Sleep(1); } }while (true); }
// Cambia el color de la pantalla de forma aleatoria. static void PantallaPintada() { // Declaración de objetos tipo random. Random rand = new Random(); // Inicialización de un arreglo de objetos tipo color con todos sus valores. ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); // Variable que almacenará un número aleatorio para designar un color aleatorio. int bgColor = rand.Next(0, 15); // Contado que permitirá recuperar el color aleatorio. int counter = 0; // Recuperar un colo aleatorio en base al número aleatorio que se recupero. foreach (var iter in colors) { if (counter == bgColor) { Console.BackgroundColor = iter; } counter++; } // En base al color de la pantalla se determina el color de la letra. if (bgColor < 7) { Console.ForegroundColor = ConsoleColor.White; } else { Console.ForegroundColor = ConsoleColor.Black; } }
/// <summary> /// Устанавливает цвет символов для консоли /// </summary> private static void SetRandomColourForConsole() { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); int numberOfColour = random.Next(1, 16); Console.ForegroundColor = colors[numberOfColour]; }
static void Main(string[] args) { Random rnd = new Random(); ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); ConsoleColor currentBackground = Console.BackgroundColor; ConsoleColor currentForeground = Console.ForegroundColor; for (int i = 0; i < 24; i++) { for (int j = 0; j < 80; j++) { char[] caracter = { 'a', 'b', 'c', 'd' }; foreach (var color in colors) { if (color == currentBackground) { continue; } Console.ForegroundColor = color; Console.SetCursorPosition(rnd.Next(80), rnd.Next(24)); Console.WriteLine(caracter[rnd.Next(4)]); } } Console.SetCursorPosition(81, 25); } }
//Stand-alone method that returns rainbow text to console public static void RainbowPrint(string text) { char[] rainbowArray = text.ToCharArray(); ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); int i = 1; Console.BackgroundColor = ConsoleColor.Black; foreach (char letter in rainbowArray) { if (i < 15) { Console.ForegroundColor = colors[i]; Console.Write(letter); i++; } else { i = 1; Console.ForegroundColor = colors[i]; Console.Write(letter); } } Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(""); }
private static void ConsoleColorTextTest() //Test to see all the different colors available on the console { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); Console.ResetColor(); int i = 0; foreach (var color in colors) { Console.BackgroundColor = color; if (Console.BackgroundColor == Console.ForegroundColor) { Console.ForegroundColor = colors[i + 3]; } Console.WriteLine($"This background is color #{i} {color}"); i++; Console.ResetColor(); } i = 0; foreach (var color in colors) { Console.ForegroundColor = color; if (Console.BackgroundColor == Console.ForegroundColor) { Console.BackgroundColor = colors[i + 3]; } Console.WriteLine($"This text is color #{i} {color}"); i++; Console.ResetColor(); } }
public static void ColorAlternate(string msg, ConsoleColor color = ConsoleColor.Blue) { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); Random rand = new Random((int)DateTime.Now.Ticks); int colorIndex = 0; for (int i = 0; i < msg.Length; i += 2) { colorIndex = rand.Next(colors.Length); if (i + 2 < msg.Length) { ConsoleColor currentIndex = colors[colorIndex]; if (currentIndex == Console.BackgroundColor) { if (colorIndex >= colors.Length - 1) { colorIndex++; } } ColorWrite(msg.Substring(i, 2), colors[colorIndex]); colorIndex++; } else { ColorWrite(msg.Substring(i)); i = msg.Length; } } }
private static void DisplayScreenHeader(string headerForeground) { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); ConsoleColor currentForeground = Console.ForegroundColor; Console.Clear(); Console.Write("\t\t"); foreach (var color in colors) { Console.ForegroundColor = color; Console.Write('\u002B'); Console.Write(" "); Console.ForegroundColor = currentForeground; } Console.WriteLine(); Console.WriteLine("\t\t" + headerForeground); Console.Write("\t\t"); foreach (var color in colors) { Console.ForegroundColor = color; Console.Write('\u002B'); Console.Write(" "); Console.ForegroundColor = currentForeground; } Console.WriteLine(); }
static void Main(string[] args) { using IClockController ctrl = Logic.Factory.Create(); List <IClockView> clockViews = new List <IClockView>(); clockViews.Add(ctrl.CreateClockView("London")); clockViews.Add(ctrl.CreateClockView("Wien", 2)); clockViews.Add(ctrl.CreateClockView("New York", -5)); clockViews.Add(ctrl.CreateClockView("Isfahan", 4, 30)); clockViews.Add(ctrl.CreateClockView("Vadodara", 5, 30)); colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); while (true) { Header(); int i = 1; foreach (var clock in clockViews) { Console.ForegroundColor = GetNextForegroundColor(i); Console.Write($"{clock.TimeString} \n"); i++; } System.Threading.Thread.Sleep(1000); Console.Clear(); } }
static void LoadingBars() // Exercise 7, C64 loading bars { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); var random = new Random(); int additive = 0; int stop = 10; while (stop > 0) { for (int i = 0; i < 30; i++) { additive = random.Next(5, 30); foreach (var c in colors) { Console.BackgroundColor = c; for (int j = 0; j < (120 + additive); j++) { Console.Write(" "); } } System.Threading.Thread.Sleep(50); } stop--; } }
public static void Main() { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); ConsoleColor currentBackground = Console.BackgroundColor; ConsoleColor currentForeground = Console.ForegroundColor; Console.WriteLine("All the foreground colors except {0}, the background color:", currentBackground); foreach (var color in colors) { if (color == currentBackground) { continue; } Console.ForegroundColor = color; Console.WriteLine(" The foreground color is {0}.", color); } Console.WriteLine(); Console.ForegroundColor = currentForeground; Console.WriteLine("All the background colors except {0}, the foreground color:", currentForeground); foreach (var color in colors) { if (color == currentForeground) { continue; } Console.BackgroundColor = color; Console.WriteLine(" The background color is {0}.", color); } Console.ResetColor(); Console.WriteLine("\nOriginal colors restored..."); }
static ConsoleColor GetConsoleColorFromUser(string property) { ConsoleColor consoleColor; bool validConsoleColor; ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); ConsoleColor currentBackground = Console.BackgroundColor; ConsoleColor currentForeground = Console.ForegroundColor; do { Console.WriteLine(); Console.WriteLine("\tAvailable Console Colors:"); Console.WriteLine(); foreach (var color in colors) { if (color == currentBackground) { Console.ForegroundColor = color; Console.Write("\t "); Console.Write('\u2588'); Console.Write('\u2588'); Console.Write('\u2588'); Console.ForegroundColor = currentForeground; Console.WriteLine(" {0} - See Background Color", color); continue; } Console.ForegroundColor = color; Console.Write("\t "); Console.Write('\u2588'); Console.Write('\u2588'); Console.Write('\u2588'); Console.ForegroundColor = currentForeground; Console.Write(" {0} - ", color); Console.ForegroundColor = color; Console.WriteLine("SAMPLE "); } Console.ForegroundColor = currentForeground; Console.WriteLine(); Console.Write($"\tEnter a value for the {property}:"); validConsoleColor = Enum.TryParse <ConsoleColor>(Console.ReadLine(), true, out consoleColor); Console.Clear(); if (!validConsoleColor) { Console.WriteLine("\n\tERROR: Please provide a valid console color. \n"); } else { validConsoleColor = true; } } while (!validConsoleColor); return(consoleColor); }
private static void changeColour(int colour) { ConsoleColor[] colours = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); if (colour >= 0 && colour <= 15) { Console.ForegroundColor = colours[colour]; } }
public static void GetRandomColor() { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); var colorLength = colors.Length; Random rnd = new Random(); int colorNum = rnd.Next(colorLength); Console.ForegroundColor = colors[colorNum]; }
public Box(Random random, int maxX, int maxY) { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); Width = random.Next(_minimumSize, maxX); Height = random.Next(_minimumSize, maxY); X = random.Next(1, maxX - Width); Y = random.Next(1, maxY - Height); color = colors[random.Next(1, 15)]; }
//constructor public Fish(Random rand) { rgen = rand; name = rgen.Next(1, 101).ToString(); shape = " <C>< "; price = 5; ConsoleColor[] colors = ((ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor))); color = colors[rgen.Next(0, colors.Length)]; }
static void Main(string[] args) { //Parte 1 int fila; int columna; Random filaAleatoria = new Random(); Random columnaAleatoria = new Random(); //Parte 2 char[] caracteres = { '$', '@', '%', '#' }; Random indiceAleatorio = new Random(); //Parte 3 ConsoleColor[] colores = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor));//Colores de la consola. Random indiceColorCaracter = new Random(); Random indiceColorFondo = new Random(); ConsoleColor colorCaracter; //Color del caracter. ConsoleColor colorFondo; //Color de fondo del caracter. int contador = 0; //Situa los carácteres de forma aleatoria y pinta los caracteres de forma aleatoria. while (contador != 3000) { fila = filaAleatoria.Next(24); columna = columnaAleatoria.Next(80); Console.SetCursorPosition(columna, fila); colorCaracter = colores[indiceColorCaracter.Next(14)]; colorFondo = colores[indiceColorFondo.Next(14)]; Console.ForegroundColor = colorCaracter; Console.BackgroundColor = colorFondo; Console.WriteLine(caracteres[indiceAleatorio.Next(4)]); contador++; } //Resetea el color de la consola. Console.ResetColor(); //Posiciona el cursor en la ultima posición de la consola. Console.SetCursorPosition(1, 24); //Suspende la pantalla. Console.ReadKey(); }
public static void PrintColors() { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); foreach (ConsoleColor color in colors) { Console.ForegroundColor = color; Console.WriteLine($"{color}"); } Console.ResetColor(); }
{ //Program // static void Main(string[] args) { Thread getCPUFrequency = new Thread(getCPUFreq); Thread windowSize = new Thread(windowSizer); Thread timeWriter = new Thread(writeTime); Thread ipUpdate = new Thread(writePing); //Create threads. xdd Console.Title = ("System Monitor"); Console.WindowWidth = 43; Console.WindowHeight = 25; Console.SetBufferSize(Console.WindowWidth, Console.WindowHeight); Console.CursorVisible = false; //Set-up Console Window. ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); double counter = 0; for (int i = 3; i > 0; i--) { counter = 0; foreach (var color in colors) { Console.ForegroundColor = color; if (counter > 3) { Console.WriteLine("\n\n\n\n\n Loading...\n"); } else if (counter > 1.5) { Console.WriteLine("\n\n\n\n\n Loading.."); } else { Console.WriteLine("\n\n\n\n\n Loading."); } counter += 0.3; Thread.Sleep(60); Console.Clear(); } } //Loading Screen windowSize.Start(); Thread.Sleep(400); timeWriter.Start(); Thread.Sleep(2000); ipUpdate.Start(); Thread.Sleep(400); getCPUFrequency.Start(); //Start tasks, with intervals. } //Main.
public Point CreateFood() { int x = random.Next(2, mapWidht - 2); int y = random.Next(2, mapHeight - 2); Random rand = new Random(); Console.SetCursorPosition(2, 2); ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); int i = rand.Next(0, colors.Length - 1); Console.ForegroundColor = colors[i]; return(new Point(x, y, sym)); }
static void Main(string[] args) { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); ConsoleColor currentBackground = Console.BackgroundColor; ConsoleColor currentForeground = Console.ForegroundColor; for (int j = 0; j < 3000; j++) { WriteAt(colors); } Console.SetCursorPosition(80, 24); Console.ResetColor(); }
public static void ChangeFgColor(string command) { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); foreach (var color in colors) { if (Convert.ToString(color) == command) { Console.ForegroundColor = color; return; } } Console.WriteLine("La couleur ou la syntaxe n'existe pas, taper 'color' pour voir la liste des couleurs disponible"); }
static void Main(string[] args) { ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); Console.ForegroundColor = colors[12]; Console.Title = "Tabbed"; Program program = new Program(); program.table.TableResized += table_TableResized; while (program.flag) { program.ShowMenu(); program.ChooseOption(); } }
static void Main(string[] args) { ColorConsole.WriteLine("\t\t\t@a Hello $MC$Go$Bl$Yo$cr @R$G Console! "); ColorConsole.WriteLine(); char[] tags = new[] { 'A', 'b', 'g', 'c', 'r', 'm', 'y', 'w', 'a', 'B', 'G', 'C', 'R', 'M', 'Y', 'W' }; // Get an array with the values of ConsoleColor enumeration members. ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); // Save the current background and foreground colors. ConsoleColor currentBackground = Console.BackgroundColor; ConsoleColor currentForeground = Console.ForegroundColor; // Display all foreground colors except the one that matches the background. Console.WriteLine("All the foreground colors except {0}, the background color:", currentBackground); foreach (var color in colors) { if (color == currentBackground) { continue; } ColorConsole.WriteLine(" {0}{0}{1} => {0}{1}The foreground color is {2}. ", ColorConsole.ForegroundColorTag, tags[(int)color], color.ToString()); } Console.WriteLine(); // Display each background color except the one that matches the current foreground color. Console.WriteLine("All the background colors except {0}, the foreground color:", currentForeground); foreach (var color in colors) { if (color == currentForeground) { continue; } ColorConsole.WriteLine(" {0}{0}{1} => {0}{1}The background color is {2}. ", ColorConsole.BackgroundColorTag, tags[(int)color], color.ToString()); } Console.WriteLine(string.Empty.PadRight(20, '-')); Console.WriteLine("$R sets the foreground color to red, which is invalid before injection!"); ColorConsole.Inject(); Console.WriteLine("$R After injection, it takes effect!Like this!"); Console.WriteLine("@@R @R sets the background color to red."); Console.ReadKey(); }
static void Forth() { // slumba box storlek 0-15 (x = y * 2) // slumpa en färg // slumpa en x-position, om förstor, minska ner den // slumpa en y-position, om förstor, minska ner den // Upprepa till tidens ände. ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); int boxHeight = 0; int boxWidth = 0; int boxYPos = 0; int boxXPos = 0; var random = new Random(); int boxColor = 0; while (true) { System.Threading.Thread.Sleep(50); boxHeight = random.Next(2, 12); boxWidth = boxHeight * 2; boxYPos = random.Next(0, Console.WindowHeight); boxXPos = random.Next(0, Console.WindowWidth); boxColor = random.Next(1, (colors.Length - 1)); if ((boxYPos + boxHeight) >= (Console.WindowHeight - 1)) { boxYPos -= boxHeight; } if ((boxXPos + boxWidth) >= Console.WindowWidth) { boxXPos -= boxWidth; } Console.BackgroundColor = colors[boxColor]; var box = new Box( boxWidth, boxHeight, boxXPos, boxYPos, colors[boxColor] ); box.Draw(); } }
static void Ebanuty() { char[] Text = "ti che, ebanuty?".ToCharArray(); ConsoleColor[] Colors = ((ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor))) .Where(x => x.ToString("G") != "Black" && !x.ToString("G").Contains("Dark")).ToArray <ConsoleColor>(); Random Rand = new Random((int)DateTime.UtcNow.Ticks); foreach (char C in Text) { Console.ForegroundColor = Colors[Rand.Next(0, Colors.Length - 1)]; Console.Write(C); } Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Gray; }
public CanvasColorBlockList(string text, ConsoleColor initialValue = ConsoleColor.Yellow) : base(text) { InitialValue = initialValue; foreach (ConsoleColor c in ConsoleColor.GetValues(typeof(ConsoleColor))) { ColorInput radio = new ColorInput(Enum.GetName(typeof(ConsoleColor), c)); if (c.Equals(initialValue)) { radio.Checked = true; } Items.Add(radio); Values.Add(c); } }
static void ContenuMemo(Fenetre maFenetre) { int j = 0; ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); if (maFenetre.Content.Count > 0) { foreach (string text in maFenetre.Content) { Console.ForegroundColor = colors[GenereRandom()]; Console.SetCursorPosition(1, j + 1); Console.WriteLine("═╡ n° " + j + " ║ " + text); j++; } } }