private void columnsToolStripMenuItem_Click(object sender, EventArgs e) { SaveDo(() => { var shownRawColumns = _settings.ActiveColumnSet.Columns; Dialogs.ChooseColumnsDialog ccd = new Dialogs.ChooseColumnsDialog( CalculatorFactory.GetAllCalulators().Except(shownRawColumns).Select(calc => CalculatorToTaggedObject(calc)), shownRawColumns.Select(calc => CalculatorToTaggedObject(calc)), _settings.ActiveColumnSet.Name); ccd.Translate(_translator); if (ccd.ShowDialog() == DialogResult.OK) { IList <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > > myList = GetCalculatorsListFromDialog(ccd); _settings.ActiveColumnSet.Name = ccd.MyName; _settings.ActiveColumnSet.Columns = myList; _settings.ColumnSets = _settings.ColumnSets; // TODO: force save another way _settings.ActiveColumnSet = _settings.ActiveColumnSet; // TODO: force save another way RefreshColumnSetComboBox(); SetColumns(_settings.ActiveColumnSet); } }); }
private void CreateNewColumnSet() { SaveDo(() => { Dialogs.ChooseColumnsDialog ccd = new Dialogs.ChooseColumnsDialog( CalculatorFactory.GetAllCalulators().Select(calc => CalculatorToTaggedObject(calc)), null, String.Format("Custom set #{0}", comboBoxColumnSets.Items.Count + 1)); ccd.Translate(_translator); if (ccd.ShowDialog() == DialogResult.OK) { IList <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > > myList = GetCalculatorsListFromDialog(ccd); ColumnSet set = new ColumnSet(ccd.MyName, myList); _settings.ColumnSets.Add(set); _settings.ActiveColumnSet = set; RefreshColumnSetComboBox(); SetColumns(_settings.ActiveColumnSet); } }); }
private static IList <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > > GetCalculatorsListFromDialog(Dialogs.ChooseColumnsDialog ccd) { IList <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > > myList = new List <IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > >(); foreach (object o in ccd.Right.SafeEnum()) { TaggedObject to = o as TaggedObject; if (to != null) { IPlayerStatisticCalculator <IEnumerable <MatchAppearance> > c = to.Tag as IPlayerStatisticCalculator <IEnumerable <MatchAppearance> >; if (c != null) { myList.Add(c); } } } return(myList); }