private void gridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 3 || e.RowIndex == -1)
            {
                return;
            }
            DataGridViewRow item         = this.gridView.Rows[e.RowIndex];
            string          fileName     = ModsSelector.GetFileName(item);
            ModPack         selectedPack = ModsSelector.GetSelectedPack(item);

            try
            {
                if (!this.IsDisabled(item))
                {
                    ModPlayer.Play(selectedPack.Files.FindByName(fileName));
                }
                else
                {
                    ModPlayer.Play(GlobalData.ElswordFilesInfo.FindByName(fileName));
                }
            }
            catch (Exception exception)
            {
                MsgBox.Error(exception.Message);
            }
        }
        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;
            }
        }
 public IEnumerable <Preset> GetPreset()
 {
     return((
                from DataGridViewRow row in this.gridView.Rows
                where !this.IsDisabled(row)
                let m = ModsSelector.GetSelectedPack(row)
                        where !m.IsDummy
                        select new Preset()
     {
         File = m.Files.FindByName(ModsSelector.GetFileName(row)),
         Mod = GlobalData.ModPacksManager.FindByName(ModsSelector.GetSelectedName(row))
     }).ToList <Preset>());
 }
        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;
            }
        }
        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);
            }
        }
        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;
                }
            }
        }
 public void CancelChanges()
 {
     foreach (DataGridViewRow dataGridViewRow in this.gridView.Rows.Cast <DataGridViewRow>())
     {
         bool flag = true;
         using (IEnumerator <Preset> enumerator = (
                    from u in GlobalData.PresetsManager
                    where ModsSelector.GetFileName(dataGridViewRow).Equals(u.File.FileName, StringComparison.OrdinalIgnoreCase)
                    select u).GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 this.SetModOn(dataGridViewRow, enumerator.Current.Mod);
                 flag = false;
             }
         }
         if (!flag)
         {
             continue;
         }
         this.DisableRow(dataGridViewRow);
     }
 }
 public bool IsDisabled(DataGridViewRow row)
 {
     return(ModsSelector.GetComboBoxCell(row).Value == ModsSelector.DisabledItem);
 }
 private static string GetSelectedName(DataGridViewRow row)
 {
     return(ModsSelector.GetSelectedPack(row).Name);
 }
 private static string GetFileName(DataGridViewRow row)
 {
     return(ModsSelector.GetString(row, ModsSelector.Columns.Name));
 }
 private static string GetDescription(DataGridViewRow row)
 {
     return(ModsSelector.GetString(row, ModsSelector.Columns.Description));
 }
 private static BindingList <ModPack> GetDataSource(DataGridViewRow row)
 {
     return(ModsSelector.GetDataSource(ModsSelector.GetComboBoxCell(row)));
 }
 public void Filter(string filter)
 {
     this.gridView.RowFilter = (DataGridViewRow row) => (new string[] { ModsSelector.GetFileName(row), ModsSelector.GetDescription(row) }).Any <string>((string s) => s.Contains(filter, true));
 }
 protected void DisableRow(DataGridViewRow row)
 {
     ModsSelector.GetComboBoxCell(row).Value = ModsSelector.DisabledItem;
 }