예제 #1
0
        public void SetModOn(DataGridViewRow row, ModPack mod)
        {
            DataGridViewComboBoxCell comboBoxCell = ModsSelector.GetComboBoxCell(row);

            if (ModsSelector.GetDataSource(comboBoxCell).Any <ModPack>((ModPack m) => m == mod))
            {
                comboBoxCell.Value = mod;
            }
        }
예제 #2
0
        public void DisableModOnAllRows(string modName)
        {
            IEnumerable <DataGridViewComboBoxCell> rows =
                from DataGridViewRow row in this.gridView.Rows
                select ModsSelector.GetComboBoxCell(row) into comboBox
                let dataSource = ModsSelector.GetDataSource(comboBox)
                                     where dataSource.Any <ModPack>((ModPack p) => p.Name == modName)
                                 select comboBox;

            foreach (DataGridViewComboBoxCell disabledItem in rows)
            {
                disabledItem.Value = ModsSelector.DisabledItem;
            }
        }
예제 #3
0
        private void Remove(string fileName, ModPack pack)
        {
            DataGridViewRow dataGridViewRow = this.gridView.Rows.Cast <DataGridViewRow>().FirstOrDefault <DataGridViewRow>((DataGridViewRow r) => ModsSelector.GetFileName(r).Equals(fileName));

            if (dataGridViewRow == null)
            {
                return;
            }
            BindingList <ModPack> dataSource = ModsSelector.GetDataSource(dataGridViewRow);

            dataSource.Remove(pack);
            if (dataSource.Count == 1)
            {
                this.gridView.Rows.Remove(dataGridViewRow);
            }
        }
예제 #4
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;
                }
            }
        }
예제 #5
0
 private static BindingList <ModPack> GetDataSource(DataGridViewRow row)
 {
     return(ModsSelector.GetDataSource(ModsSelector.GetComboBoxCell(row)));
 }