public void ToggleSelection(SomeInterval t) { var s = _drawerSettings.selection ?? new SomeInterval[] { }; int count = s.Length; s = s.Where(i => !i.Equals(t)).ToArray(); // try to remove if (s.Length == count) // otherwise add { s = s.Concat(new SomeInterval[] { t }).ToArray(); } _drawerSettings.selection = s; // Update 'selection' control _settingInternally = true; textBoxSelection.Text = DS.FormatIntervals(s); _settingInternally = false; // Update drawer _gridDrawer.SetSelection(_drawerSettings.selection); }
// Set settings to controls protected void SetSettingsToControls() { DrawerSettings s = _drawerSettings; _settingInternally = true; // base upDownLimit.Value = s.limitPrimeIndex; textBoxSubgroup.Text = DS.FormatSubgroup(s.subgroup, s.narrows); // temperament _temperamentControls.SetTemperament(s.temperament); sliderTemperament.Value = (int)Math.Round(s.temperamentMeasure * 100); // slope textBoxSlopeOrigin.Text = s.slopeOrigin.FormatFraction(); upDownChainTurns.Value = s.slopeChainTurns; // degrees //upDownDegreeCount.Value = s.degreeCount; upDownDegreeThreshold.Value = s.degreeThreshold; // selection textBoxSelection.Text = DS.FormatIntervals(s.selection); // grids textBoxEDGrids.Text = GridDrawer.EDGrid.Format(s.edGrids); // drawing if (!String.IsNullOrEmpty(s.harmonicityName)) { comboBoxDistance.SelectedItem = s.harmonicityName; } upDownCountLimit.Value = s.rationalCountLimit; // //if (s.temperament != null) { // UpdateTemperamentRowsAfterValidation(); // validate temperament //} // -- ValidateControlsByDrawer() will be called later _settingInternally = false; }