private void CompareVersions() { if (newVersion > currentVersion) { DialogResult updateDialog = MessageBox.Show(string.Format("A new version is available! Would you like to update now?\nYou will update from version {0} to {1}", Application.ProductVersion, newVersion.ToString()), "New Version", MessageBoxButtons.YesNo); if (updateDialog == DialogResult.Yes) { ProgressBar pBar = VisualHelper.CreateNewProgressBar(this, "Updating..."); UpdateHelper.DownloadFileToTempPath(pBar, updateUrl); } } else if (!startupUpdateCheck) { if (newVersion < currentVersion) { MessageBox.Show(string.Format("You are using the beta version: {0}", Application.ProductVersion)); } else { MessageBox.Show(string.Format("You are using the latest version: {0}", Application.ProductVersion)); } } newVersion = null; startupUpdateCheck = false; }
private void VisualizeInactiveAccounts() { try { VisualHelper.VisualizeInactiveAccounts(DataGrid); } catch (Exception ex) { MessageBox.Show("Error visualizing inactive accounts: " + ex.Message); } }
private void VisualizeLoggedInAccount() { try { VisualHelper.VisualizeLoggedInAccount(DataGrid); } catch (Exception ex) { MessageBox.Show("Error visualizing logged in account: " + ex.Message); } }
private void DeleteToolStripMenuItem_Click(object sender, EventArgs e) { try { ContextHelper.DeleteEvent(DataGrid); DataSetHelper.CorrectAccountNumbers((DataSet)DataGrid.DataSource); DataSetHelper.NormalizeForSaving((DataSet)DataGrid.DataSource); LoadLayout(); VisualHelper.VisualizeLoggedInAccount(DataGrid); } catch (Exception ex) { MessageBox.Show("Error while deleting account: " + ex.Message); } }
private void CheckForNewAccountsToolStripMenuItem_Click(object sender, EventArgs e) { try { ProgressBar pBar = VisualHelper.CreateNewProgressBar(this, "Looking for new accounts..."); int newAccounts = Config.CheckForNewAccounts((DataSet)DataGrid.DataSource, pBar); pBar.Dispose(); LoadDataGrid(); LoadLayout(); VisualizeInactiveAccounts(); VisualizeLoggedInAccount(); MessageBox.Show(string.Format("{0} account(s) added", newAccounts)); } catch (Exception ex) { MessageBox.Show("Error checking for new accounts: " + ex.Message); } }
private void DataGrid_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { try { DataGridHelper.MouseDoubleClickEvent(e, DataGrid); if (e.Button == MouseButtons.Left && e.ColumnIndex == DataGrid.Columns.IndexOf(DataGrid.Columns["Nr"]) || e.ColumnIndex == DataGrid.Columns.IndexOf(DataGrid.Columns["Login"]) || e.ColumnIndex == DataGrid.Columns.IndexOf(DataGrid.Columns["Name"])) { VisualHelper.VisualizeLoggedInAccount(DataGrid); } } catch (Exception ex) { MessageBox.Show("Error changing value while double clicking: " + ex.Message); } }
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); }
private void ReloadConfigToolStripMenuItem_Click(object sender, EventArgs e) { try { DialogResult reloadConfig = MessageBox.Show("Are you sure you want to reload the config?\nSettings like level, rank, prime and drop will be lost.", "Reload config", MessageBoxButtons.YesNo); if (reloadConfig == DialogResult.Yes) { ProgressBar pBar = VisualHelper.CreateNewProgressBar(this, "Reloading config..."); Config.Create(pBar); pBar.Dispose(); LoadDataGrid(); LoadLayout(); DataSetHelper.CheckDropDate((DataSet)DataGrid.DataSource); VisualizeInactiveAccounts(); VisualizeLoggedInAccount(); } } catch (Exception ex) { MessageBox.Show("Error reloading config: " + ex.Message); } }
public static void NormalizeForSaving(DataSet originalDataSet) { DataSet normalizedDataSet = new DataSet(); DataTable settingTable = normalizedDataSet.Tables.Add("Settings"); settingTable.Columns.Add("DropDate", typeof(DateTime)); DataRow settingRow = settingTable.NewRow(); DataRow originalRow = originalDataSet.Tables[0].Rows[0]; settingRow["DropDate"] = originalRow["DropDate"]; settingTable.Rows.Add(settingRow); 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(int)); normalizedTable.Columns.Add("Level", typeof(int)); normalizedTable.Columns.Add("Prime", typeof(int)); normalizedTable.Columns.Add("Drop", typeof(int)); 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.BitmapToRank((row["Rank"] as Bitmap).GetHashCode()); normalizedRow["Level"] = row["Level"]; normalizedRow["Prime"] = VisualHelper.BitmapToPrime((row["Prime"] as Bitmap).GetHashCode()); normalizedRow["Drop"] = VisualHelper.BitmapToDrop((row["Drop"] as Bitmap).GetHashCode()); normalizedRow["SteamID32"] = row["SteamID32"]; normalizedRow["SteamID64"] = row["SteamID64"]; normalizedTable.Rows.Add(normalizedRow); } Config.Save(normalizedDataSet); }
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); }
private void MainForm_Shown(object sender, EventArgs e) { try { if (!Config.DoesExists()) { ProgressBar pBar = VisualHelper.CreateNewProgressBar(this, "Creating config..."); Config.Create(pBar); pBar.Dispose(); } LoadDataGrid(); LoadLayout(); CheckDropDate(); VisualizeInactiveAccounts(); VisualizeLoggedInAccount(); CheckForUpdates(); CleanUpAfterUpdate(); } catch (Exception ex) { MessageBox.Show("Error showing Kwikly: " + ex.Message); } }
private void DataGrid_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { switch (e.Button) { case MouseButtons.Middle: try { if (e.ColumnIndex == DataGrid.Columns.IndexOf(DataGrid.Columns["Rank"])) { DataGrid.Rows[e.RowIndex].Cells["Rank"].Selected = true; DataGrid.CurrentCell.Value = VisualHelper.RankToBitmap(0); break; } } catch (Exception ex) { MessageBox.Show("Error changing value while single clicking: " + ex.Message); } break; case MouseButtons.Right: try { if (e.RowIndex == -1) { DataGrid.ContextMenuStrip = GetColumnContext(DataGrid); } else { DataGrid.ContextMenuStrip = GetRightClickContext(DataGrid); } DataGrid.ContextMenuStrip.Show(new Point(MousePosition.X, MousePosition.Y)); } catch (Exception ex) { MessageBox.Show("Error showing context menu: " + ex.Message); } break; } }
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; } }