A Little Code cleanup in FrmMain, and set Version to 2.2.1 for public release.

This commit is contained in:
gjefferyes
2015-01-27 09:09:24 -06:00
parent 48ea11ab2e
commit b368f33351
3 changed files with 91 additions and 98 deletions

View File

@@ -7,7 +7,6 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Globalization; using System.Globalization;
using System.ServiceModel;
using System.Windows.Forms; using System.Windows.Forms;
using ROMVault2.Properties; using ROMVault2.Properties;
using ROMVault2.RvDB; using ROMVault2.RvDB;
@@ -18,7 +17,6 @@ namespace ROMVault2
{ {
public partial class FrmMain : Form public partial class FrmMain : Form
{ {
private static readonly Color CBlue = Color.FromArgb(214, 214, 255); private static readonly Color CBlue = Color.FromArgb(214, 214, 255);
private static readonly Color CGreyBlue = Color.FromArgb(214, 224, 255); private static readonly Color CGreyBlue = Color.FromArgb(214, 224, 255);
private static readonly Color CRed = Color.FromArgb(255, 214, 214); private static readonly Color CRed = Color.FromArgb(255, 214, 214);
@@ -38,10 +36,9 @@ namespace ROMVault2
private bool _updatingGameGrid; private bool _updatingGameGrid;
private int GameGridSortColumnIndex = 0; private int _gameGridSortColumnIndex;
private SortOrder GameGridSortOrder = SortOrder.Descending; private SortOrder _gameGridSortOrder = SortOrder.Descending;
private static int[] _gameGridColumnXPositions;
public static int[] GameGridColumnXPositions;
private FrmKey _fk; private FrmKey _fk;
@@ -104,7 +101,7 @@ namespace ROMVault2
_displayColor[(int)RepStatus.Deleted] = CWhite; _displayColor[(int)RepStatus.Deleted] = CWhite;
GameGridColumnXPositions = new int[(int)RepStatus.EndValue]; _gameGridColumnXPositions = new int[(int)RepStatus.EndValue];
DirTree.Setup(ref DB.DirTree); DirTree.Setup(ref DB.DirTree);
@@ -413,33 +410,33 @@ namespace ROMVault2
if (cf != DirTree.GetSelected()) if (cf != DirTree.GetSelected())
DatSetSelected(cf); DatSetSelected(cf);
if (e.Button == MouseButtons.Right) if (e.Button != MouseButtons.Right)
return;
RvDir tn = (RvDir)sender;
ContextMenu mnuContext = new ContextMenu();
MenuItem mnuFile = new MenuItem
{ {
RvDir tn = (RvDir)sender; Index = 0,
Text = Resources.FrmMain_DirTreeRvSelected_Set_ROM_DIR,
Tag = tn.TreeFullName
};
mnuFile.Click += MnuFileClick;
mnuContext.MenuItems.Add(mnuFile);
ContextMenu mnuContext = new ContextMenu(); MenuItem mnuMakeDat = new MenuItem
{
MenuItem mnuFile = new MenuItem Index = 1,
{ Text = @"Make Dat",
Index = 0, Tag = tn
Text = Resources.FrmMain_DirTreeRvSelected_Set_ROM_DIR, };
Tag = tn.TreeFullName mnuMakeDat.Click += MnuMakeDatClick;
}; mnuContext.MenuItems.Add(mnuMakeDat);
mnuFile.Click += MnuFileClick;
mnuContext.MenuItems.Add(mnuFile); mnuContext.Show(DirTree, e.Location);
MenuItem mnuMakeDat = new MenuItem
{
Index = 1,
Text = @"Make Dat",
Tag = tn
};
mnuMakeDat.Click += MnuMakeDatClick;
mnuContext.MenuItems.Add(mnuMakeDat);
mnuContext.Show(DirTree, e.Location);
}
} }
#region "DAT display code" #region "DAT display code"
@@ -460,9 +457,9 @@ namespace ROMVault2
RomGrid.Rows.Clear(); RomGrid.Rows.Clear();
// clear sorting // clear sorting
GameGrid.Columns[GameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None; GameGrid.Columns[_gameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None;
GameGridSortColumnIndex = 0; _gameGridSortColumnIndex = 0;
GameGridSortOrder = SortOrder.Descending; _gameGridSortOrder = SortOrder.Descending;
if (cf == null) if (cf == null)
return; return;
@@ -609,14 +606,14 @@ namespace ROMVault2
RomGrid.Rows.Clear(); RomGrid.Rows.Clear();
// clear sorting // clear sorting
GameGrid.Columns[GameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None; GameGrid.Columns[_gameGridSortColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None;
GameGridSortColumnIndex = 0; _gameGridSortColumnIndex = 0;
GameGridSortOrder = SortOrder.Descending; _gameGridSortOrder = SortOrder.Descending;
ReportStatus tDirStat; ReportStatus tDirStat;
GameGridColumnXPositions = new int[(int)RepStatus.EndValue]; _gameGridColumnXPositions = new int[(int)RepStatus.EndValue];
int rowCount = 0; int rowCount = 0;
for (int j = 0; j < tDir.ChildCount; j++) for (int j = 0; j < tDir.ChildCount; j++)
@@ -653,8 +650,8 @@ namespace ROMVault2
if (tDirStat.Get(RepairStatus.DisplayOrder[l]) <= 0) continue; if (tDirStat.Get(RepairStatus.DisplayOrder[l]) <= 0) continue;
int len = DigitLength(tDirStat.Get(RepairStatus.DisplayOrder[l])) * 7 + 26; int len = DigitLength(tDirStat.Get(RepairStatus.DisplayOrder[l])) * 7 + 26;
if (len > GameGridColumnXPositions[columnIndex]) if (len > _gameGridColumnXPositions[columnIndex])
GameGridColumnXPositions[columnIndex] = len; _gameGridColumnXPositions[columnIndex] = len;
columnIndex++; columnIndex++;
} }
} }
@@ -663,8 +660,8 @@ namespace ROMVault2
int t = 0; int t = 0;
for (int l = 0; l < (int)RepStatus.EndValue; l++) for (int l = 0; l < (int)RepStatus.EndValue; l++)
{ {
int colWidth = GameGridColumnXPositions[l]; int colWidth = _gameGridColumnXPositions[l];
GameGridColumnXPositions[l] = t; _gameGridColumnXPositions[l] = t;
t += colWidth; t += colWidth;
} }
@@ -738,14 +735,14 @@ namespace ROMVault2
} }
} }
private void GameGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e) private void GameGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{ {
if (_updatingGameGrid) if (_updatingGameGrid)
return; return;
Rectangle cellBounds = GameGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false); Rectangle cellBounds = GameGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
RvDir tRvDir = (ROMVault2.RvDB.RvDir)GameGrid.Rows[e.RowIndex].Tag; RvDir tRvDir = (RvDir)GameGrid.Rows[e.RowIndex].Tag;
ReportStatus tDirStat = tRvDir.DirStatus; ReportStatus tDirStat = tRvDir.DirStatus;
Color bgCol = Color.FromArgb(255, 255, 255); Color bgCol = Color.FromArgb(255, 255, 255);
@@ -834,7 +831,7 @@ namespace ROMVault2
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) <= 0) continue; if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) <= 0) continue;
gOff = FrmMain.GameGridColumnXPositions[columnIndex]; gOff = _gameGridColumnXPositions[columnIndex];
Bitmap bm = rvImages.GetBitmap(@"G_" + RepairStatus.DisplayOrder[l]); Bitmap bm = rvImages.GetBitmap(@"G_" + RepairStatus.DisplayOrder[l]);
if (bm != null) if (bm != null)
{ {
@@ -855,7 +852,7 @@ namespace ROMVault2
if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) > 0) if (tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]) > 0)
{ {
gOff = FrmMain.GameGridColumnXPositions[columnIndex]; gOff = _gameGridColumnXPositions[columnIndex];
g.DrawString(tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]).ToString(CultureInfo.InvariantCulture), drawFont, drawBrushBlack, new PointF(gOff + 20, 3)); g.DrawString(tRvDir.DirStatus.Get(RepairStatus.DisplayOrder[l]).ToString(CultureInfo.InvariantCulture), drawFont, drawBrushBlack, new PointF(gOff + 20, 3));
columnIndex++; columnIndex++;
} }
@@ -876,37 +873,34 @@ namespace ROMVault2
return; return;
DataGridViewColumn newColumn = GameGrid.Columns[e.ColumnIndex]; DataGridViewColumn newColumn = GameGrid.Columns[e.ColumnIndex];
DataGridViewColumn oldColumn = GameGrid.Columns[GameGridSortColumnIndex]; DataGridViewColumn oldColumn = GameGrid.Columns[_gameGridSortColumnIndex];
if (newColumn == oldColumn) if (newColumn == oldColumn)
{ {
if (GameGridSortOrder == SortOrder.Ascending) _gameGridSortOrder = _gameGridSortOrder == SortOrder.Ascending ? SortOrder.Descending : SortOrder.Ascending;
GameGridSortOrder = SortOrder.Descending;
else
GameGridSortOrder = SortOrder.Ascending;
} }
else else
{ {
oldColumn.HeaderCell.SortGlyphDirection = SortOrder.None; oldColumn.HeaderCell.SortGlyphDirection = SortOrder.None;
GameGridSortOrder = SortOrder.Ascending; _gameGridSortOrder = SortOrder.Ascending;
} }
GameGrid.Sort(new GameGridRowComparer(GameGridSortOrder, e.ColumnIndex)); GameGrid.Sort(new GameGridRowComparer(_gameGridSortOrder, e.ColumnIndex));
newColumn.HeaderCell.SortGlyphDirection = GameGridSortOrder; newColumn.HeaderCell.SortGlyphDirection = _gameGridSortOrder;
GameGridSortColumnIndex = e.ColumnIndex; _gameGridSortColumnIndex = e.ColumnIndex;
} }
private class GameGridRowComparer : System.Collections.IComparer private class GameGridRowComparer : System.Collections.IComparer
{ {
private int sortMod = 1; private readonly int _sortMod = 1;
private int columnIndex; private readonly int _columnIndex;
public GameGridRowComparer(SortOrder sortOrder, int index) public GameGridRowComparer(SortOrder sortOrder, int index)
{ {
columnIndex = index; _columnIndex = index;
if (sortOrder == SortOrder.Descending) if (sortOrder == SortOrder.Descending)
sortMod = -1; _sortMod = -1;
} }
public int Compare(object a, object b) public int Compare(object a, object b)
@@ -914,14 +908,14 @@ namespace ROMVault2
DataGridViewRow aRow = (DataGridViewRow)a; DataGridViewRow aRow = (DataGridViewRow)a;
DataGridViewRow bRow = (DataGridViewRow)b; DataGridViewRow bRow = (DataGridViewRow)b;
RvDir aRvDir = (ROMVault2.RvDB.RvDir)aRow.Tag; RvDir aRvDir = (RvDir)aRow.Tag;
RvDir bRvDir = (ROMVault2.RvDB.RvDir)bRow.Tag; RvDir bRvDir = (RvDir)bRow.Tag;
int result = 0; int result = 0;
switch (columnIndex) switch (_columnIndex)
{ {
case 1: // CGame case 1: // CGame
result = System.String.Compare(aRvDir.Name, bRvDir.Name); result = String.CompareOrdinal(aRvDir.Name, bRvDir.Name);
break; break;
case 2: // CDescription case 2: // CDescription
String aDes = ""; String aDes = "";
@@ -931,18 +925,18 @@ namespace ROMVault2
if (bRvDir.Game != null) if (bRvDir.Game != null)
bDes = bRvDir.Game.GetData(RvGame.GameData.Description); bDes = bRvDir.Game.GetData(RvGame.GameData.Description);
result = System.String.Compare(aDes, bDes); result = String.CompareOrdinal(aDes, bDes);
// if desciptions match, fall through to sorting by name // if desciptions match, fall through to sorting by name
if (result == 0) if (result == 0)
result = System.String.Compare(aRvDir.Name, bRvDir.Name); result = String.CompareOrdinal(aRvDir.Name, bRvDir.Name);
break; break;
default: default:
Console.WriteLine("WARN: GameGridRowComparer::Compare() Invalid columnIndex: {0}", columnIndex); Console.WriteLine("WARN: GameGridRowComparer::Compare() Invalid columnIndex: {0}", _columnIndex);
break; break;
} }
return sortMod * result; return _sortMod * result;
} }
} }
#endregion #endregion
@@ -969,7 +963,7 @@ namespace ROMVault2
private void gbSetInfo_Resize(object sender, EventArgs e) private void gbSetInfo_Resize(object sender, EventArgs e)
{ {
int leftPos = 84; const int leftPos = 84;
int rightPos = gbSetInfo.Width - 15; int rightPos = gbSetInfo.Width - 15;
if (rightPos > 750) rightPos = 750; if (rightPos > 750) rightPos = 750;
int width = rightPos - leftPos; int width = rightPos - leftPos;
@@ -999,14 +993,14 @@ namespace ROMVault2
lblSITDeveloper.Width = width; lblSITDeveloper.Width = width;
int width3 = (int)((double)width * 0.24); int width3 = (int)((double)width * 0.24);
int P2 = (int)((double)width * 0.38); int p2 = (int)((double)width * 0.38);
int width4 = (int) ((double) width*0.24); int width4 = (int) ((double) width*0.24);
lblSITEdition.Width = width3; lblSITEdition.Width = width3;
lblSIVersion.Left = leftPos + P2 - 78; lblSIVersion.Left = leftPos + p2 - 78;
lblSITVersion.Left = leftPos + P2; lblSITVersion.Left = leftPos + p2;
lblSITVersion.Width = width3; lblSITVersion.Width = width3;
lblSIType.Left = leftPos + width - width3 - 78; lblSIType.Left = leftPos + width - width3 - 78;
@@ -1016,8 +1010,8 @@ namespace ROMVault2
lblSITMedia.Width = width3; lblSITMedia.Width = width3;
lblSILanguage.Left = leftPos + P2 - 78; lblSILanguage.Left = leftPos + p2 - 78;
lblSITLanguage.Left = leftPos + P2; lblSITLanguage.Left = leftPos + p2;
lblSITLanguage.Width = width3; lblSITLanguage.Width = width3;
lblSIPlayers.Left = leftPos + width - width3 - 78; lblSIPlayers.Left = leftPos + width - width3 - 78;
@@ -1026,8 +1020,8 @@ namespace ROMVault2
lblSITRatings.Width = width3; lblSITRatings.Width = width3;
lblSIGenre.Left = leftPos + P2 - 78; lblSIGenre.Left = leftPos + p2 - 78;
lblSITGenre.Left = leftPos + P2; lblSITGenre.Left = leftPos + p2;
lblSITGenre.Width = width3; lblSITGenre.Width = width3;
lblSIPeripheral.Left = leftPos + width - width3 - 78; lblSIPeripheral.Left = leftPos + width - width3 - 78;
@@ -1387,14 +1381,14 @@ namespace ROMVault2
} }
} }
private void RomGrid_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e) private void RomGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{ {
if (_updatingGameGrid) if (_updatingGameGrid)
return; return;
Rectangle cellBounds = RomGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false); Rectangle cellBounds = RomGrid.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
RvFile tRvFile = (ROMVault2.RvDB.RvFile)RomGrid.Rows[e.RowIndex].Tag; RvFile tRvFile = (RvFile)RomGrid.Rows[e.RowIndex].Tag;
if (cellBounds.Width == 0 || cellBounds.Height == 0) if (cellBounds.Width == 0 || cellBounds.Height == 0)
return; return;
@@ -1516,27 +1510,26 @@ namespace ROMVault2
private void GameGrid_MouseUp(object sender, MouseEventArgs e) private void GameGrid_MouseUp(object sender, MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Right) if (e.Button != MouseButtons.Right)
{ return;
int currentMouseOverRow = GameGrid.HitTest(e.X, e.Y).RowIndex;
if (currentMouseOverRow >= 0)
{
object r1 = GameGrid.Rows[currentMouseOverRow].Cells[1].Value;
string filename = r1 != null ? r1.ToString() : "";
object r2 = GameGrid.Rows[currentMouseOverRow].Cells[2].Value;
string description = r2 != null ? r2.ToString() : "";
try int currentMouseOverRow = GameGrid.HitTest(e.X, e.Y).RowIndex;
{ if (currentMouseOverRow >= 0)
Clipboard.Clear(); {
Clipboard.SetText("Name : " + filename + Environment.NewLine + "Desc : " + description + Environment.NewLine); object r1 = GameGrid.Rows[currentMouseOverRow].Cells[1].Value;
} string filename = r1 != null ? r1.ToString() : "";
catch object r2 = GameGrid.Rows[currentMouseOverRow].Cells[2].Value;
{ string description = r2 != null ? r2.ToString() : "";
}
try
{
Clipboard.Clear();
Clipboard.SetText("Name : " + filename + Environment.NewLine + "Desc : " + description + Environment.NewLine);
}
catch
{
} }
} }
} }
} }

View File

@@ -15,7 +15,7 @@ namespace ROMVault2
//public static UsernamePassword Up; //public static UsernamePassword Up;
public static readonly Encoding Enc = Encoding.GetEncoding(28591); public static readonly Encoding Enc = Encoding.GetEncoding(28591);
public const string Version = "2.2"; public const string Version = "2.2";
public const int SubVersion = 0; public const int SubVersion = 1;
public static string ErrorMessage; public static string ErrorMessage;
public static string URL; public static string URL;

View File

@@ -9,7 +9,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ROMVault2</RootNamespace> <RootNamespace>ROMVault2</RootNamespace>
<AssemblyName>ROMVault21</AssemblyName> <AssemblyName>ROMVault22</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>