public static void CheckDropDate(DataSet ds) { if (ds != null) { DataRow dropRow = ds.Tables[0].Rows[0]; TimeSpan difference = DateTime.Now.Date - DateTime.Parse(dropRow["DropDate"].ToString()); if (difference.TotalDays >= 7) { foreach (DataRow row in ds.Tables[1].Rows) { row["Drop"] = VisualHelper.DropToBitmap((int)VisualHelper.DropStateEnum.NonDrop); } dropRow["DropDate"] = string.Format("{0:dd.MM.yyyy}", GetLastWednesday()); } } }
public static int CheckForNewAccounts(DataSet ds, ProgressBar pBar) { List <string> currentSteamID32List = new List <string>(); List <string> fetchedSteamID32List = new List <string>(SteamHelper.GetAllLocalSteamID32()); foreach (DataRow row in ds.Tables[1].Rows) { currentSteamID32List.Add(row["SteamID32"].ToString()); } List <string> newSteamID32List = fetchedSteamID32List.Except(currentSteamID32List).ToList(); if (newSteamID32List.Count == 0) { return(0); } DataTable accountTable = ds.Tables[1]; int i = accountTable.Rows.Count; pBar.Minimum = i; pBar.Maximum = i + newSteamID32List.Count; foreach (string steamID32 in newSteamID32List) { long _steamID64 = SteamHelper.GetSteamID64BySteamID32(int.Parse(steamID32)); DataRow accountRow = accountTable.NewRow(); accountRow["Nr"] = DataSetHelper.GetDoubleDigitNumber(i); accountRow["Login"] = SteamHelper.GetLoginNameBySteamID64(_steamID64); accountRow["Name"] = SteamHelper.GetNameBySteamID64(_steamID64); accountRow["Rank"] = VisualHelper.RankToBitmap(0); accountRow["Level"] = 1; accountRow["Prime"] = VisualHelper.PrimeToBitmap(0); accountRow["Drop"] = VisualHelper.DropToBitmap(0); accountRow["SteamID32"] = steamID32; accountRow["SteamID64"] = _steamID64; accountTable.Rows.Add(accountRow); pBar.Value = i++; } DataSetHelper.NormalizeForSaving(ds); return(newSteamID32List.Count); }
public static DataSet NormalizeDataSet(DataSet originalDataSet) { DataSet normalizedDataSet = new DataSet(); DataTable settingsTable = normalizedDataSet.Tables.Add("Settings"); settingsTable.Columns.Add("DropDate", typeof(DateTime)); DataRow dropDateRow = settingsTable.NewRow(); DataRow originalRow = originalDataSet.Tables[0].Rows[0]; dropDateRow["DropDate"] = originalRow["DropDate"]; settingsTable.Rows.Add(dropDateRow); DataTable normalizedTable = normalizedDataSet.Tables.Add("Account"); normalizedTable.Columns.Add("Nr", typeof(string)); normalizedTable.Columns.Add("Login", typeof(string)); normalizedTable.Columns.Add("Name", typeof(string)); normalizedTable.Columns.Add("Rank", typeof(Bitmap)); normalizedTable.Columns.Add("Level", typeof(int)); normalizedTable.Columns.Add("Prime", typeof(Bitmap)); normalizedTable.Columns.Add("Drop", typeof(Bitmap)); normalizedTable.Columns.Add("SteamID32", typeof(int)); normalizedTable.Columns.Add("SteamID64", typeof(long)); foreach (DataRow row in originalDataSet.Tables[1].Rows) { DataRow normalizedRow = normalizedTable.NewRow(); normalizedRow["Nr"] = row["Nr"]; normalizedRow["Login"] = row["Login"]; normalizedRow["Name"] = row["Name"]; normalizedRow["Rank"] = VisualHelper.RankToBitmap(int.Parse(row["Rank"].ToString())); normalizedRow["Level"] = row["Level"]; normalizedRow["Prime"] = VisualHelper.PrimeToBitmap(int.Parse(row["Prime"].ToString())); normalizedRow["Drop"] = VisualHelper.DropToBitmap(int.Parse(row["Drop"].ToString())); normalizedRow["SteamID32"] = row["SteamID32"]; normalizedRow["SteamID64"] = row["SteamID64"]; normalizedTable.Rows.Add(normalizedRow); } return(normalizedDataSet); }
public static void MouseDoubleClickEvent(DataGridViewCellMouseEventArgs e, DataGridView dataGrid) { switch (e.Button) { case MouseButtons.Left: if (e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Nr"]) || e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Login"]) || e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Name"])) { SteamHelper.SetLoginName(dataGrid.Rows[e.RowIndex].Cells["Login"].Value.ToString()); SteamHelper.Restart(); break; } else if (e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Rank"])) { dataGrid.Rows[e.RowIndex].Cells["Rank"].Selected = true; int rankNr = VisualHelper.BitmapToRank((dataGrid.CurrentCell.Value as Bitmap).GetHashCode()); if (rankNr == 18) { rankNr = 0; } else { rankNr++; } dataGrid.CurrentCell.Value = VisualHelper.RankToBitmap(rankNr); break; } else if (e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Level"])) { dataGrid.Rows[e.RowIndex].Cells["Level"].Selected = true; int currentLevel = (int)dataGrid.CurrentCell.Value; int level = 0; level = currentLevel == 39 ? 1 : currentLevel + 1; dataGrid.CurrentCell.Value = level; break; } else if (e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Prime"])) { dataGrid.Rows[e.RowIndex].Cells["Prime"].Selected = true; int primeState = 0; primeState = VisualHelper.BitmapToPrime((dataGrid.CurrentCell.Value as Bitmap).GetHashCode()) == 0 ? 1 : 0; dataGrid.CurrentCell.Value = VisualHelper.PrimeToBitmap(primeState); break; } else if (e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Drop"])) { dataGrid.Rows[e.RowIndex].Cells["Drop"].Selected = true; int dropState = 0; dropState = VisualHelper.BitmapToDrop((dataGrid.CurrentCell.Value as Bitmap).GetHashCode()) == 0 ? 1 : 0; dataGrid.CurrentCell.Value = VisualHelper.DropToBitmap(dropState); break; } break; case MouseButtons.Right: if (e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Rank"])) { dataGrid.Rows[e.RowIndex].Cells["Rank"].Selected = true; int rankNr = VisualHelper.BitmapToRank((dataGrid.CurrentCell.Value as Bitmap).GetHashCode()); if (rankNr == 0) { rankNr = 18; } else { rankNr--; } dataGrid.CurrentCell.Value = VisualHelper.RankToBitmap(rankNr); break; } else if (e.ColumnIndex == dataGrid.Columns.IndexOf(dataGrid.Columns["Level"])) { dataGrid.Rows[e.RowIndex].Cells["Level"].Selected = true; int currentLevel = (int)dataGrid.CurrentCell.Value; int level = 0; level = currentLevel == 1 ? 39 : currentLevel - 1; dataGrid.CurrentCell.Value = level; break; } break; } }