Exemplo n.º 1
0
 private void BindShipListView(IEnumerable <IDesign> designs)
 {
     lstShips.Initialize(32, 32);
     foreach (var design in designs.Where(d => ConstructionQueue.CanConstruct(d)).OrderBy(d => d.Role).ThenBy(d => d.Name).ThenBy(d => d.Iteration))
     {
         var eta = design.Cost.Keys.Max(res => (double)(design.Cost[res]) / (double)ConstructionQueue.Rate[res]);
         var x   = lstShips.AddItemWithImage(design.Role, design.Name, design, design.Icon, null, eta.CeilingString(1));
         if (design.IsObsolete)
         {
             x.ForeColor = Color.Gray;
         }
         else if (design.IsObsolescent)
         {
             x.ForeColor = Color.Yellow;
         }
     }
 }
Exemplo n.º 2
0
        private void BindFacilityListView(IEnumerable <FacilityTemplate> templates)
        {
            int i       = 0;
            var ilFacil = new ImageList();

            ilFacil.ImageSize            = new Size(32, 32);
            lstFacilities.LargeImageList = ilFacil;
            lstFacilities.SmallImageList = ilFacil;
            lstFacilities.Items.Clear();
            foreach (var facil in templates.OrderBy(f => f.Group).ThenBy(f => f.Name))             // TODO - roman numeral sorting
            {
                if (ConstructionQueue.CanConstruct(facil))
                {
                    var group = lstFacilities.Groups.Cast <ListViewGroup>().SingleOrDefault(g => g.Header == facil.Group);
                    if (group == null)
                    {
                        group = new ListViewGroup(facil.Group);
                        lstFacilities.Groups.Add(group);
                    }
                    var item = new ListViewItem(facil.Name, i, group);
                    item.ImageIndex = i;
                    item.Tag        = facil;
                    var eta = facil.Cost.Keys.Max(res => (double)(facil.Cost[res]) / (double)ConstructionQueue.Rate[res]);
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, eta.CeilingString(1)));
                    ilFacil.Images.Add(facil.Icon);
                    lstFacilities.Items.Add(item);
                    if (facil.IsObsolete)
                    {
                        item.ForeColor = Color.Gray;
                    }
                    else if (facil.IsObsolescent)
                    {
                        item.ForeColor = Color.Yellow;
                    }
                    i++;
                }
            }
        }
Exemplo n.º 3
0
        private void BindUpgradeListView(IEnumerable <FacilityTemplate> templates)
        {
            int i       = 0;
            var ilFacil = new ImageList();

            ilFacil.ImageSize          = new Size(32, 32);
            lstUpgrades.LargeImageList = ilFacil;
            lstUpgrades.SmallImageList = ilFacil;
            lstUpgrades.Items.Clear();
            if (ConstructionQueue.Colony != null)
            {
                foreach (var g in ConstructionQueue.Colony.Facilities.GroupBy(f => f.Template).OrderBy(g => g.Key.Group).ThenBy(g => g.Key.Name))                 // TODO - roman numeral sorting
                {
                    var oldf = g.Key;

                    // facilites which are not yet upgraded
                    var count = g.Count() - ConstructionQueue.Orders.OfType <UpgradeFacilityOrder>().Where(o => o.Upgrade.Old == oldf).Count();

                    if (count > 0)
                    {
                        foreach (var newf in templates)
                        {
                            if (ConstructionQueue.CanConstruct(newf))
                            {
                                var group = lstFacilities.Groups.Cast <ListViewGroup>().SingleOrDefault(g2 => g2.Header == newf.Group);
                                if (newf.Family.Value == oldf.Family.Value && newf.ModID != oldf.ModID)
                                {
                                    if (group == null)
                                    {
                                        group = new ListViewGroup(newf.Group);
                                        lstUpgrades.Groups.Add(group);
                                    }
                                    string name;
                                    if (count == 1)
                                    {
                                        name = oldf.Name;
                                    }
                                    else
                                    {
                                        name = count + "x " + oldf.Name;
                                    }
                                    var item = new ListViewItem(name + " to " + newf.Name, i, group);
                                    item.ImageIndex = i;
                                    var fu = new FacilityUpgrade(oldf, newf);
                                    item.Tag = fu;
                                    var cost = newf.Cost * Mod.Current.Settings.UpgradeFacilityPercentCost / 100;
                                    var eta  = cost.Keys.Max(res => (double)(cost[res]) / (double)ConstructionQueue.Rate[res]);
                                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, eta.CeilingString(1)));
                                    ilFacil.Images.Add(newf.Icon);
                                    lstUpgrades.Items.Add(item);
                                    if (fu.IsObsolete)
                                    {
                                        item.ForeColor = Color.Gray;
                                    }
                                    else if (fu.IsObsolescent)
                                    {
                                        item.ForeColor = Color.Yellow;
                                    }
                                    i++;
                                }
                            }
                        }
                    }
                }
            }
        }