More null proofing

This commit is contained in:
JFronny 2020-06-12 15:12:13 +02:00
parent f0400a18bb
commit c5fc9874b1
3 changed files with 10 additions and 7 deletions

View File

@ -19,6 +19,7 @@
<FileVersion>1.0.0.0</FileVersion>
<VersionSuffix>0.0</VersionSuffix>
<PackageVersion>1.1.$(VersionSuffix)</PackageVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

View File

@ -30,8 +30,8 @@ namespace CC_Functions.Commandline.TUI
{
Console.CursorTop = 0;
Console.CursorLeft = 0;
ConsoleColor fcol = Console.ForegroundColor;
ConsoleColor bcol = Console.BackgroundColor;
ConsoleColor fCol = Console.ForegroundColor;
ConsoleColor bCol = Console.BackgroundColor;
int width = Width;
int height = Height;
for (int y = 0; y < height; y++)
@ -53,8 +53,8 @@ namespace CC_Functions.Commandline.TUI
Console.WriteLine();
Console.CursorLeft = 0;
}
Console.ForegroundColor = fcol;
Console.BackgroundColor = bcol;
Console.ForegroundColor = fCol;
Console.BackgroundColor = bCol;
_last = Screen;
}
@ -75,8 +75,8 @@ namespace CC_Functions.Commandline.TUI
{
for (int x = 0; x < width; x++)
{
Pixel tmp1 = Screen[y, x];
if (color)
Pixel? tmp1 = Screen[y, x];
if (tmp1 != null && color)
{
if (Console.ForegroundColor != tmp1.ForeColor)
Console.ForegroundColor = tmp1.ForeColor;
@ -84,7 +84,7 @@ namespace CC_Functions.Commandline.TUI
Console.BackgroundColor = tmp1.BackColor;
}
Console.CursorLeft = x;
Console.Write(tmp1);
Console.Write(tmp1 ?? Pixel.Empty);
}
Console.WriteLine();
Console.CursorLeft = 0;

View File

@ -8,6 +8,8 @@ namespace CC_Functions.Commandline.TUI
/// </summary>
public class Pixel
{
public static readonly Pixel Empty = new Pixel();
/// <summary>
/// This pixels background color
/// </summary>