SaveRestoreConsoleColor() public static method

public static SaveRestoreConsoleColor ( ConsoleColor Color, System.Action Action ) : void
Color ConsoleColor
Action System.Action
return void
Exemplo n.º 1
0
		public void Print()
		{
			ConsoleColor Color;
			switch (Action)
			{
				case ActionEnum.Keep: Color = ConsoleColor.White; break;
				case ActionEnum.Delete: Color = ConsoleColor.Red; break;
				case ActionEnum.Insert: Color = ConsoleColor.DarkRed; break;
				default: throw(new NotImplementedException());
			}
			ConsoleUtils.SaveRestoreConsoleColor(Color, () =>
			{
				Console.WriteLine("{0}", this);
			});
		}
Exemplo n.º 2
0
            /// <summary>
            /// 
            /// </summary>
            /// <param name="avoidKeep"></param>
            /// <exception cref="NotImplementedException"></exception>
            public void Print(bool avoidKeep)
            {
                if (avoidKeep && Action == ActionEnum.Keep) return;

                ConsoleColor color;
                switch (Action)
                {
                    case ActionEnum.Keep:
                        color = ConsoleColor.White;
                        break;
                    case ActionEnum.Delete:
                        color = ConsoleColor.Red;
                        break;
                    case ActionEnum.Insert:
                        color = ConsoleColor.DarkRed;
                        break;
                    default: throw new NotImplementedException();
                }
                ConsoleUtils.SaveRestoreConsoleColor(color, () => { Console.WriteLine("{0}", this); });
            }