void SelectionRangeSlider_MouseDown(object sender, MouseEventArgs e) { if (Sliders.Count < 1) return; int contMin = 255; Slider contrSlider = Sliders[0]; foreach (var slider in Sliders) { int pointedValue = slider.Min + e.X * (slider.Max - slider.Min) / Width; int distMin = Math.Abs(pointedValue - slider.SelectedMin); int distMax = Math.Abs(pointedValue - slider.SelectedMax); int minDist = Math.Min(distMin, distMax); if (minDist < contMin) { contMin = minDist; contrSlider = slider; currentSlider = slider; } else continue; if (minDist == distMin) movingMode = MovingMode.MovingMin; else movingMode = MovingMode.MovingMax; } SelectionRangeSlider_MouseMove(sender, e); }
private void SuperSliderAddeder(SelectionRangeSlider Slider, Int32 SliderNumber) { Brush b = new SolidBrush(pictureBoxPick.BackColor); int m_min = 0; int m_max = 255; foreach (var sli in Slider.Sliders) { if (sli.SelectedMin == 0 && sli.SelectedMax == 255) { MessageBox.Show("You wonna add slider to full slider's range, realy?", "Error"); } if (sli.SelectedMax != 255) if (sli.SelectedMax > m_min) { m_min = sli.SelectedMax + 1; continue; } if (sli.SelectedMin != 0) if (sli.SelectedMin < m_max) { m_max = sli.SelectedMin - 1; continue; } } var slide = new Slider(Slider.Width, Slider.Height, b, m_max, m_min); Slider.Sliders.Add(slide); if (SliderNumber == 0) { slide.SelectionChanged += selectionRangeSlider_SelectionChanged; selectionRangeSlider_SelectionChanged(slide, null); selectionRangeSlider.Invalidate(); } if (SliderNumber == 1) { slide.SelectionChanged += selectionRangeSlider1_SelectionChanged; selectionRangeSlider1_SelectionChanged(slide, null); selectionRangeSlider1.Invalidate(); } if (SliderNumber == 2) { slide.SelectionChanged += selectionRangeSlider2_SelectionChanged; selectionRangeSlider2_SelectionChanged(slide, null); selectionRangeSlider2.Invalidate(); } }