示例#1
0
        public static void Create(ProgressBar pBar)
        {
            DataSet ds = new DataSet();

            DataTable settingTable = ds.Tables.Add("Settings");

            settingTable.Columns.Add("DropDate");
            DataRow settingRow = settingTable.NewRow();

            settingRow["DropDate"] = DataSetHelper.GetLastWednesday();
            settingTable.Rows.Add(settingRow);

            DataTable accountTable = ds.Tables.Add("Account");

            accountTable.Columns.Add("Nr");
            accountTable.Columns.Add("Login");
            accountTable.Columns.Add("Name");
            accountTable.Columns.Add("Rank");
            accountTable.Columns.Add("Level");
            accountTable.Columns.Add("Prime");
            accountTable.Columns.Add("Drop");
            accountTable.Columns.Add("SteamID32");
            accountTable.Columns.Add("SteamID64");

            int i = 0;

            pBar.Minimum = i;
            pBar.Maximum = SteamHelper.GetAllLocalSteamID32().Length;

            foreach (string steamID32 in SteamHelper.GetAllLocalSteamID32())
            {
                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"]      = 0;
                accountRow["Level"]     = 1;
                accountRow["Prime"]     = 0;
                accountRow["Drop"]      = 0;
                accountRow["SteamID32"] = steamID32;
                accountRow["SteamID64"] = _steamID64;
                accountTable.Rows.Add(accountRow);
                pBar.Value = i++;
            }

            Save(ds);
        }
示例#2
0
        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);
        }
示例#3
0
        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;
            }
        }
示例#4
0
 public static void RefreshEvent(DataGridView dataGrid)
 {
     dataGrid.CurrentCell.Value = SteamHelper.GetNameBySteamID64((long)dataGrid.Rows[dataGrid.CurrentCell.RowIndex].Cells["SteamID64"].Value);
 }