Esempio n. 1
0
        private void OnModeSelect(object sender, ItemCheckEventArgs e)
        {
            listBox1.ClearSelected();
            listBox1.Items.Clear();

            var visibilityMask = checkedListBox1.CheckedItems.Cast <object>().Aggregate(0, (current, item) => current | 1 << (int)(CurveInterpolationMode)item);

            if (e.NewValue == CheckState.Checked)
            {
                visibilityMask |= 1 << (int)(CurveInterpolationMode)checkedListBox1.Items[e.Index];
            }
            else
            {
                visibilityMask &= ~(1 << (int)(CurveInterpolationMode)checkedListBox1.Items[e.Index]);
            }

            // e.NewValue
            foreach (var curveInfo in _curves.OrderBy(c => c.Points.Count))
            {
                var mask = 1 << (int)Curve.DetermineInterpolationMode(curveInfo);
                if ((visibilityMask & mask) != 0)
                {
                    listBox1.Items.Add(new ListBoxEntry()
                    {
                        Entry = curveInfo.ID,
                        Name  = $@"Curve #{curveInfo.ID} ({curveInfo.Points.Count} points)"
                    });
                }
                else
                {
                    CurveManager.RemoveCurve(curveInfo.ID);
                }
            }
        }
Esempio n. 2
0
 private void OnItemSelected(object sender, ItemCheckEventArgs e)
 {
     if (e.NewValue == CheckState.Checked)
     {
         var listBoxEntry = (ListBoxEntry)listBox1.Items[e.Index];
         var curveInfo    = _curves.FirstOrDefault(c => c.ID == listBoxEntry.Entry);
         if (curveInfo != null)
         {
             CurveManager.AddCurve(curveInfo);
         }
     }
     else if (e.NewValue == CheckState.Unchecked)
     {
         var listBoxEntry = (ListBoxEntry)listBox1.Items[e.Index];
         CurveManager.RemoveCurve(listBoxEntry.Entry);
     }
 }