コード例 #1
0
ファイル: Win_regex.xaml.cs プロジェクト: Mnuzz/sc2dsstats
        private void dg_games_DClick(object sender, RoutedEventArgs e)
        {
            List <dsplayer>          temp    = new List <dsplayer>();
            Dictionary <string, int> units   = new Dictionary <string, int>();
            List <rxunit>            rxunits = new List <rxunit>();
            dsplayer pltemp = new dsplayer();

            foreach (var dataItem in dg_games.SelectedItems)
            {
                //myGame game = dataItem as myGame;
                dsreplay game = dataItem as dsreplay;
                pltemp.RACE = game.REPLAY;
                temp.Add(pltemp);
                foreach (dsplayer pl in game.PLAYERS)
                {
                    temp.Add(pl);
                    if (pl.UNITS.ContainsKey("ALL"))
                    {
                        foreach (string unit in pl.UNITS["ALL"].Keys)
                        {
                            if (units.ContainsKey(unit))
                            {
                                units[unit] += pl.UNITS["ALL"][unit];
                            }
                            else
                            {
                                units.Add(unit, pl.UNITS["ALL"][unit]);
                            }
                        }
                    }
                }
            }
            foreach (string unit in units.Keys)
            {
                rxunits.Add(new rxunit(unit, units[unit]));
            }

            dg_units.ItemsSource = rxunits.OrderByDescending(o => o.COUNT);

            if (temp.Count > 300)
            {
                pltemp.RACE = "Visibility limit is 300. Sorry.";
                List <dsplayer> bab = new List <dsplayer>();
                bab.Add(pltemp);

                dg_player.ItemsSource = bab;
            }
            else
            {
                dg_player.ItemsSource = temp;
            }

            if (temp.Count < 120)
            {
                dg_player.EnableRowVirtualization = false;

                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, new Action(ProcessRows_player));
            }
            //ProcessRows_player();
        }
コード例 #2
0
ファイル: Win_mmselect.xaml.cs プロジェクト: Mnuzz/sc2dsstats
 public void bt_send_Click(object sender, RoutedEventArgs e)
 {
     foreach (var dataItem in dg_games.SelectedItems)
     {
         dsreplay game = dataItem as dsreplay;
         game.MMID = tb_rep_mmid.Text;
         if (int.Parse(game.MMID) > 0)
         {
             SendRep(game);
         }
         else
         {
             MessageBox.Show("No MMID found - you might want to enter it manually in the MMID Textbox)", "sc2dsmm");
         }
     }
 }
コード例 #3
0
ファイル: Win_mmselect.xaml.cs プロジェクト: Mnuzz/sc2dsstats
        private void dg_games_DClick(object sender, RoutedEventArgs e)
        {
            List <dsplayer> temp   = new List <dsplayer>();
            dsplayer        pltemp = new dsplayer();

            foreach (var dataItem in dg_games.SelectedItems)
            {
                //myGame game = dataItem as myGame;
                dsreplay game = dataItem as dsreplay;
                pltemp.RACE = game.REPLAY;
                temp.Add(pltemp);
                foreach (dsplayer pl in game.PLAYERS)
                {
                    temp.Add(pl);
                }
            }

            if (temp.Count > 300)
            {
                pltemp.RACE = "Visibility ilmit is 300. Sorry.";
                List <dsplayer> bab = new List <dsplayer>();
                bab.Add(pltemp);

                dg_player.ItemsSource = bab;
            }
            else
            {
                dg_player.ItemsSource = temp;
            }

            if (temp.Count < 120)
            {
                dg_player.EnableRowVirtualization = false;

                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, new Action(ProcessRows_player));
            }
            //ProcessRows_player();
        }
コード例 #4
0
ファイル: Win_mmselect.xaml.cs プロジェクト: Mnuzz/sc2dsstats
        public void SendRep(dsreplay game)
        {
            string result1 = "";
            string result2 = "";
            string result  = "unknown";

            if (game != null)
            {
                if (game.REPORTED == 0)
                {
                    int mmid = 0;
                    try
                    {
                        mmid = int.Parse(tb_rep_mmid.Text);
                    } catch { }


                    if (mmid > 0 && WM.MMIDS.Count > 0)
                    {
                        if (WM.MMIDS.ContainsKey(mmid) == true)
                        {
                        }
                        else
                        {
                            dsmmid id = new dsmmid();
                            id.MMID = mmid;
                            WM.MMIDS.Add(mmid, id);
                        }
                    }
                    else
                    {
                        dsmmid id = new dsmmid();
                        id.MMID = mmid;
                        WM.MMIDS.Add(mmid, id);
                    }

                    foreach (dsplayer player in game.PLAYERS)
                    {
                        if (player.POS <= game.PLAYERCOUNT / 2)
                        {
                            result1 += "(" + player.NAME + ", " + player.RACE + ", " + player.KILLSUM + ")";
                            if (player.POS != 3)
                            {
                                result1 += ", ";
                            }
                        }
                        else if (player.POS > game.PLAYERCOUNT / 2)
                        {
                            result2 += "(" + player.NAME + ", " + player.RACE + ", " + player.KILLSUM + ")";
                            if (player.POS != 6)
                            {
                                result2 += ", ";
                            }
                        }

                        dsplayer        plid  = new dsplayer();
                        List <dsplayer> ltemp = new List <dsplayer>(WM.MMIDS[mmid].REPORTS.Where(x => x.NAME == player.NAME).ToList());
                        if (ltemp.Count > 0)
                        {
                            plid           = ltemp.ElementAt(0);
                            plid.ARMY      = player.ARMY;
                            plid.INCOME    = player.INCOME;
                            plid.PDURATION = player.PDURATION;
                            plid.POS       = player.POS;
                            //plid.WINNER = player.WINNER;
                        }
                        else
                        {
                            WM.MMIDS[mmid].REPORTS.Add(player);
                        }
                    }
                    if (game.WINNER == 0)
                    {
                        result = result1 + " vs " + result2;
                    }
                    else if (game.WINNER == 1)
                    {
                        result = result2 + " vs " + result1;
                    }
                    result1 = "";
                    result2 = "";

                    WM.MMIDS[mmid].REPLAY   = game;
                    WM.MMIDS[mmid].DURATION = game.DURATION;

                    string smmid = game.MMID;
                    if (smmid == "0")
                    {
                        smmid = tb_rep_mmid.Text;
                    }
                    string response = WM.SendResult("mmid: " + mmid + "; result: " + result, game);
                    if (response == "sc2dsmm: Result: 0")
                    {
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
        }