Beispiel #1
0
        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);
        }
Beispiel #2
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;
            }
        }