Ejemplo n.º 1
0
        public void UpdateArmy()
        {
            DebugWatch.Start("UpdateArmy Script");
            string script = ReqBuilder.GetRequestScript(RequestType.getArmyInfo, "");
            string ret    = (string)StaticData.jsExecutor.ExecuteAsyncScript(script);

            DebugWatch.Stop();
            DebugWatch.Start("UpdateArmy Deserialize");
            ArmyRoot ress = JsonConvert.DeserializeObject <ArmyRoot>(ret);

            DebugWatch.Stop();
            ListClass.Army = ress;
            UpdateSortedArmyList();
        }
Ejemplo n.º 2
0
        public void Fill()
        {
            DebugWatch.Start("Fill");
            ListViewGroup group   = null;
            string        lastEra = "";
            var           list    = ArmySelection.UnitList.TakeSome(1, 3);

            Invoker.CallMethode(ArmySelection.lvArmy, () => ArmySelection.lvArmy.Items.Clear());
            Invoker.CallMethode(ArmySelection.lvSelectedArmy, () => ArmySelection.lvSelectedArmy.Items.Clear());
            foreach (KeyValuePair <string, List <Unit> > item in list)
            {
                if (lastEra != item.Key)
                {
                    group = new ListViewGroup(item.Key, HorizontalAlignment.Left);
                }
                foreach (Unit unit in item.Value)
                {
                    ListViewItem lvi = new ListViewItem($"{unit.name} ({unit.count})", $"armyuniticons_50x50_{unit.unit[0].unitTypeId}")
                    {
                        Group = group,
                        Tag   = unit
                    };
                    Invoker.CallMethode(ArmySelection.lvArmy, () => ArmySelection.lvArmy.Items.Add(lvi));
                    if (group != null && group.Header != lastEra)
                    {
                        Invoker.CallMethode(ArmySelection.lvArmy, () => ArmySelection.lvArmy.Groups.Add(group));
                        lastEra = item.Key;
                    }
                }
            }
            foreach (var unitType in ArmySelection.SelectedArmyTypes)
            {
                Unit unit = ListClass.UnitList.Find(u => u.unit[0].unitTypeId == unitType);
                Invoker.CallMethode(ArmySelection.lvSelectedArmy, () => ArmySelection.lvSelectedArmy.Items.Add(unit));
            }
            DebugWatch.Stop();
        }