Пример #1
0
 private void dg_revenue_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.Value != null && (dg_revenue.Columns[e.ColumnIndex].Name == "Column14" || dg_revenue.Columns[e.ColumnIndex].Name == "Column5"))
     {
         ViewHelpers.SetMomentFormatForTimeSpanCell(e);
     }
 }
Пример #2
0
 private void dg_match_history_view_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (e.Value != null && dg_match_history_view.Columns[e.ColumnIndex].Name == "match_round_duration")
     {
         ViewHelpers.SetMomentFormatForTimeSpanCell(e);
     }
 }
Пример #3
0
        private void populate_revenue_review_screen_elements()
        {
            dg_revenue.Rows.Clear();
            dg_revenue.AllowUserToAddRows = true;

            total_games          = 0;
            total_queue_duration = 0.0;
            total_match_duration = 0.0;
            total_coins          = 0.0;

            dg_revenue.Columns[7].DefaultCellStyle.Format = "N2";
            dg_revenue.Columns[8].DefaultCellStyle.Format = "N2";

            foreach (revenue_grouping group in master_groupings)
            {
                TimeSpan        t2  = TimeSpan.FromSeconds(group.total_queue_time / (double)group.games);
                TimeSpan        t3  = TimeSpan.FromSeconds(group.total_match_time / (double)group.games);
                TimeSpan        t4  = TimeSpan.FromSeconds(group.total_queue_time);
                TimeSpan        t5  = TimeSpan.FromSeconds(group.total_match_time);
                DataGridViewRow row = (DataGridViewRow)dg_revenue.Rows[0].Clone();
                int             default_row_height = row.Height;
                double          coin_value         = 0.0;
                row.Cells[0].Value = group.gamemode;
                row.Cells[1].Value = group.game_result;
                row.Cells[2].Value = group.games;

                if (show_average)
                {
                    row.Cells[3].Value = t2;
                    row.Cells[4].Value = t3;
                    row.Cells[5].Value = (group.fuel_cost / group.games).ToString();
                }
                else
                {
                    row.Cells[3].Value = t4;
                    row.Cells[4].Value = t5;

                    row.Cells[5].Value = group.fuel_cost.ToString();
                }

                if (chk_free_fuel.Checked)
                {
                    row.Cells[5].Value = "";
                }

                row.Cells[6].Value = "";

                if (group.match_rewards.ContainsKey("expFactionTotal"))
                {
                    bool first = true;

                    foreach (KeyValuePair <string, int> reward in group.match_rewards)
                    {
                        if (reward.Key.ToLower().Contains("xp"))
                        {
                            continue;
                        }
                        if (reward.Key.ToLower().Contains("score"))
                        {
                            continue;
                        }
                        if (reward.Key.ToLower().Contains("badge") && reward.Value == 0)
                        {
                            continue;
                        }

                        if (show_average)
                        {
                            row.Cells[6].Value += string.Format(@"{0}{1}:{2}", first ? "" : Environment.NewLine, Translate.TranslateString(reward.Key, session, translations), Math.Round(((double)reward.Value / (double)group.games), 2).ToString());
                        }
                        else
                        {
                            row.Cells[6].Value += string.Format(@"{0}{1}:{2}", first ? "" : Environment.NewLine, Translate.TranslateString(reward.Key, session, translations), reward.Value.ToString());
                        }

                        first = false;

                        foreach (market_values value in master_values)
                        {
                            if (Translate.TranslateString(reward.Key, session, translations) == value.resource)
                            {
                                coin_value  += ((double)reward.Value / (double)value.ammount) * value.sell_price;
                                total_coins += ((double)reward.Value / (double)value.ammount) * value.sell_price;
                            }
                        }
                    }

                    if (!chk_free_fuel.Checked)
                    {
                        coin_value  -= ((double)group.fuel_cost / (double)master_values.FirstOrDefault(x => x.resource == "Fuel").ammount) * master_values.FirstOrDefault(x => x.resource == "Fuel").sell_price;
                        total_coins -= ((double)group.fuel_cost / (double)master_values.FirstOrDefault(x => x.resource == "Fuel").ammount) * master_values.FirstOrDefault(x => x.resource == "Fuel").sell_price;
                    }
                }
                if (show_average)
                {
                    row.Cells[7].Value = (double)coin_value / (double)group.games;
                }
                else
                {
                    row.Cells[7].Value = coin_value;
                }



                row.Cells[8].Value = (double)coin_value / ((double)group.total_game_duration / 3600.0);

                total_games += group.games;

                if (coin_value != 0.0)
                {
                    total_queue_duration += group.total_queue_time;
                    total_match_duration += group.total_match_time;
                }

                dg_revenue.Rows.Add(row);
            }

            dg_revenue.AllowUserToAddRows = false;
            dg_revenue.Sort(dg_revenue.SortedColumn ?? dg_revenue.Columns[2], ((int)dg_revenue.SortOrder) != 1 ? ListSortDirection.Descending : ListSortDirection.Ascending);

            lb_queue_time.Text = ViewHelpers.GetMomentFormatFromSeconds(total_queue_duration);
            lb_match_time.Text = ViewHelpers.GetMomentFormatFromSeconds(total_match_duration);
            lb_total_game.Text = total_games.ToString();
            lb_coins.Text      = string.Format("{0:n0}", total_coins);
            lb_coins_rate.Text = Math.Round((double)total_coins / ((double)((total_queue_duration + total_match_duration) / 3600.0)), 2).ToString();
        }