Move (Rom|Game)Grid CellFormatting functions to be in the right #region sections

This commit is contained in:
Jim Westfall
2014-10-26 19:58:01 -07:00
parent d5fb529b7b
commit bb4b77a6d7

View File

@@ -478,108 +478,6 @@ namespace ROMVault2
DatMaker.MakeDatFromDir(thisDir);
}
private void GameGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
Rectangle cellBounds = GameGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
RvDir tRvDir = (ROMVault2.RvDB.RvDir)GameGrid.Rows[e.RowIndex].Tag;
if (GameGrid.Columns[e.ColumnIndex].Name == "Type")
{
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
Graphics g = Graphics.FromImage(bmp);
string bitmapName;
switch (tRvDir.FileType)
{
case FileType.Zip:
if (tRvDir.RepStatus == RepStatus.DirCorrect && tRvDir.ZipStatus == ZipStatus.TrrntZip)
bitmapName = "ZipTZ";
else
bitmapName = "Zip" + tRvDir.RepStatus;
break;
default:
// hack because DirDirInToSort image doesnt exist.
if (tRvDir.RepStatus == RepStatus.DirInToSort)
bitmapName = "Dir" + RepStatus.DirUnknown;
else
bitmapName = "Dir" + tRvDir.RepStatus;
break;
}
Bitmap bm = rvImages.GetBitmap(bitmapName);
if (bm != null)
{
g.DrawImage(bm, (cellBounds.Width - cellBounds.Height) / 2, 0, 18, 18);
bm.Dispose();
}
else
Debug.WriteLine("Missing Graphic for " + bitmapName);
e.Value = bmp;
} else if (GameGrid.Columns[e.ColumnIndex].Name == "CCorrect") {
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
Graphics g = Graphics.FromImage(bmp);
Font drawFont = new Font("Arial", 9);
SolidBrush drawBrushBlack = new SolidBrush(Color.Black);
int gOff;
int columnIndex = 0;
for (int l = 0; l < RepairStatus.DisplayOrder.Length; l++)
{
if (l >= 13) columnIndex = l;
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) <= 0) continue;
gOff = FrmMain.GameGridColumnXPositions[columnIndex];
Bitmap bm = rvImages.GetBitmap(@"G_" + RepairStatus.DisplayOrder[l]);
if (bm != null)
{
g.DrawImage(bm, gOff, 0, 21, 18);
bm.Dispose();
}
else
Debug.WriteLine("Missing Graphics for " + "G_" + RepairStatus.DisplayOrder[l]);
columnIndex++;
}
columnIndex = 0;
for (int l = 0; l < RepairStatus.DisplayOrder.Length; l++)
{
if (l >= 13)
columnIndex = l;
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) > 0)
{
gOff = FrmMain.GameGridColumnXPositions[columnIndex];
g.DrawString(tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]).ToString(CultureInfo.InvariantCulture), drawFont, drawBrushBlack, new PointF(gOff + 20, 3));
columnIndex++;
}
}
drawBrushBlack.Dispose();
drawFont.Dispose();
e.Value = bmp;
}
}
private void RomGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
Rectangle cellBounds = RomGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
RvFile tRvFile = (ROMVault2.RvDB.RvFile)RomGrid.Rows[e.RowIndex].Tag;
if (RomGrid.Columns[e.ColumnIndex].Name == "CGot")
{
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
Graphics g = Graphics.FromImage(bmp);
string bitmapName = "R_" + tRvFile.DatStatus + "_" + tRvFile.RepStatus;
g.DrawImage(rvImages.GetBitmap(bitmapName), 0, 0, 54, 18);
e.Value = bmp;
}
}
private void splitContainer3_Panel1_Resize(object sender, EventArgs e)
{
gbDatInfo.Width = splitContainer3.Panel1.Width - (gbDatInfo.Left * 2);
@@ -829,6 +727,92 @@ namespace ROMVault2
}
}
private void GameGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
Rectangle cellBounds = GameGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
RvDir tRvDir = (ROMVault2.RvDB.RvDir)GameGrid.Rows[e.RowIndex].Tag;
if (GameGrid.Columns[e.ColumnIndex].Name == "Type")
{
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
Graphics g = Graphics.FromImage(bmp);
string bitmapName;
switch (tRvDir.FileType)
{
case FileType.Zip:
if (tRvDir.RepStatus == RepStatus.DirCorrect && tRvDir.ZipStatus == ZipStatus.TrrntZip)
bitmapName = "ZipTZ";
else
bitmapName = "Zip" + tRvDir.RepStatus;
break;
default:
// hack because DirDirInToSort image doesnt exist.
if (tRvDir.RepStatus == RepStatus.DirInToSort)
bitmapName = "Dir" + RepStatus.DirUnknown;
else
bitmapName = "Dir" + tRvDir.RepStatus;
break;
}
Bitmap bm = rvImages.GetBitmap(bitmapName);
if (bm != null)
{
g.DrawImage(bm, (cellBounds.Width - cellBounds.Height) / 2, 0, 18, 18);
bm.Dispose();
}
else
Debug.WriteLine("Missing Graphic for " + bitmapName);
e.Value = bmp;
} else if (GameGrid.Columns[e.ColumnIndex].Name == "CCorrect") {
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
Graphics g = Graphics.FromImage(bmp);
Font drawFont = new Font("Arial", 9);
SolidBrush drawBrushBlack = new SolidBrush(Color.Black);
int gOff;
int columnIndex = 0;
for (int l = 0; l < RepairStatus.DisplayOrder.Length; l++)
{
if (l >= 13) columnIndex = l;
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) <= 0) continue;
gOff = FrmMain.GameGridColumnXPositions[columnIndex];
Bitmap bm = rvImages.GetBitmap(@"G_" + RepairStatus.DisplayOrder[l]);
if (bm != null)
{
g.DrawImage(bm, gOff, 0, 21, 18);
bm.Dispose();
}
else
Debug.WriteLine("Missing Graphics for " + "G_" + RepairStatus.DisplayOrder[l]);
columnIndex++;
}
columnIndex = 0;
for (int l = 0; l < RepairStatus.DisplayOrder.Length; l++)
{
if (l >= 13)
columnIndex = l;
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) > 0)
{
gOff = FrmMain.GameGridColumnXPositions[columnIndex];
g.DrawString(tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]).ToString(CultureInfo.InvariantCulture), drawFont, drawBrushBlack, new PointF(gOff + 20, 3));
columnIndex++;
}
}
drawBrushBlack.Dispose();
drawFont.Dispose();
e.Value = bmp;
}
}
#endregion
@@ -1265,6 +1249,22 @@ namespace ROMVault2
}
}
}
private void RomGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
Rectangle cellBounds = RomGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
RvFile tRvFile = (ROMVault2.RvDB.RvFile)RomGrid.Rows[e.RowIndex].Tag;
if (RomGrid.Columns[e.ColumnIndex].Name == "CGot")
{
Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
Graphics g = Graphics.FromImage(bmp);
string bitmapName = "R_" + tRvFile.DatStatus + "_" + tRvFile.RepStatus;
g.DrawImage(rvImages.GetBitmap(bitmapName), 0, 0, 54, 18);
e.Value = bmp;
}
}
#endregion
private void RomGridSelectionChanged(object sender, EventArgs e)