Exemplo n.º 1
0
        private void AddFile(ModFile file, ModPack pack)
        {
            DataGridViewRow item = this.gridView.Rows.Cast <DataGridViewRow>().FirstOrDefault <DataGridViewRow>((DataGridViewRow r) => ModsSelector.GetFileName(r).Equals(file.FileName));

            if (item == null)
            {
                DataGridViewRowCollection rows = this.gridView.Rows;
                object[] objArray = new object[] { (file.Blocked ? Images16px.Warning : new Bitmap(1, 1)), file.FileName, file.Description, null, ModsSelector.DisabledItem };
                int      num      = rows.Add(objArray);
                item = this.gridView.Rows[num];
                if (file.Blocked)
                {
                    DataGridViewImageCell imageCell = ModsSelector.GetImageCell(item);
                    imageCell.ToolTipText = string.Format(gPatcher.Localization.Text.ModsSelector_FileBlockedInServers, ModsSelector.GetFileName(item), file.BlockedServers);
                }
                ModsSelector.GetPlayCell(item).ValueIsIcon = false;
                DataGridViewComboBoxCell      comboBoxCell        = ModsSelector.GetComboBoxCell(item);
                SortableBindingList <ModPack> sortableBindingList = new SortableBindingList <ModPack>()
                {
                    ModsSelector.DisabledItem,
                    pack
                };
                sortableBindingList.Sort <ModPack>((ModPack t) => t);
                comboBoxCell.DisplayMember = "Name";
                comboBoxCell.ValueMember   = "Self";
                comboBoxCell.ValueType     = typeof(ModPack);
                comboBoxCell.DataSource    = sortableBindingList;
                this.Sort();
            }
            else
            {
                BindingList <ModPack> dataSource = ModsSelector.GetDataSource(item);
                if (!dataSource.Contains(pack))
                {
                    dataSource.AddSorted <ModPack>(pack);
                    return;
                }
            }
        }