public MapColor ( ConsoleColor oldColor, Color newColor ) : void | ||
oldColor | ConsoleColor | The color to be replaced. |
newColor | Color | The color to be mapped. |
Результат | void |
/// <summary> /// Replaces one System.Drawing.Color in the ColorManager with another. /// </summary> /// <param name="oldColor">The color to be replaced.</param> /// <param name="newColor">The replacement color.</param> public void ReplaceColor(Color oldColor, Color newColor) { if (!IsInCompatibilityMode) { ConsoleColor consoleColor = colorStore.Replace(oldColor, newColor); colorMapper.MapColor(consoleColor, newColor); } }
/// <summary> /// Replaces one System.Drawing.Color in the ColorManager with another. /// </summary> /// <param name="oldColor">The color to be replaced.</param> /// <param name="newColor">The replacement color.</param> public void ReplaceColor(Color oldColor, Color newColor) { // If the console exists and Colorful.Console is running on Windows. if (!IsInCompatibilityMode && IsWindows()) { ConsoleColor consoleColor = colorStore.Replace(oldColor, newColor); colorMapper.MapColor(consoleColor, newColor); } }
/// <summary> /// Gets the ConsoleColor mapped to the System.Drawing.Color provided as an argument. /// </summary> /// <param name="color">The System.Drawing.Color whose ConsoleColor alias should be retrieved.</param> /// <returns>The corresponding ConsoleColor.</returns> public ConsoleColor GetConsoleColor(Color color) { if (!CanChangeColor()) { return(colorStore.Colors.Last().Value); } else { if (colorStore.RequiresUpdate(color)) { ConsoleColor oldColor = (ConsoleColor)colorChangeCount; colorMapper.MapColor(oldColor, color); colorStore.Update(color, oldColor); colorChangeCount++; } return(colorStore.Colors[color]); } }
public void MapColor_ThrowsException_WhenCalledAndConsoleWindowIsntOpen() { ColorMapper mapper = new ColorMapper(); Assert.Throws<ColorMappingException>(() => mapper.MapColor(ColorStoreTests.TEST_CONSOLE_COLOR, ColorStoreTests.TEST_COLOR)); }