Ejemplo n.º 1
0
        /// <summary>
        /// Given a break slider's new position, this will update the category related to that break.
        /// </summary>
        /// <param name="slider">The break slider.</param>
        public void UpdateCategory(BreakSlider slider)
        {
            slider.Category.Maximum = slider.Value;
            slider.Category.ApplyMinMax(_scheme.EditorSettings);
            int index = Breaks.IndexOf(slider);

            if (index < 0)
            {
                return;
            }
            if (index < Breaks.Count - 1)
            {
                Breaks[index + 1].Category.Minimum = slider.Value;
                Breaks[index + 1].Category.ApplyMinMax(_scheme.EditorSettings);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the mouse move event.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (_isDragging)
            {
                Region    rg = new Region();
                Rectangle gb = _graph.GetGraphBounds();
                if (_selectedSlider != null)
                {
                    rg.Union(_selectedSlider.Bounds);
                    int x     = e.X;
                    int index = Breaks.IndexOf(_selectedSlider);
                    if (x > gb.Right)
                    {
                        x = gb.Right;
                    }
                    if (x < gb.Left)
                    {
                        x = gb.Left;
                    }
                    if (index > 0)
                    {
                        if (x < Breaks[index - 1].Position + 2)
                        {
                            x = (int)Breaks[index - 1].Position + 2;
                        }
                    }

                    if (index < Breaks.Count - 1)
                    {
                        if (x > Breaks[index + 1].Position - 2)
                        {
                            x = (int)Breaks[index + 1].Position - 2;
                        }
                    }

                    _selectedSlider.Position = x;
                    rg.Union(_selectedSlider.Bounds);
                    Invalidate(rg);
                }

                return;
            }

            bool overSlider = false;

            foreach (BreakSlider slider in Breaks)
            {
                if (slider.Bounds.Contains(e.Location) || slider.HandleBounds.Contains(e.Location))
                {
                    overSlider = true;
                }
            }

            if (_dragCursor && !overSlider)
            {
                Cursor      = Cursors.Arrow;
                _dragCursor = false;
            }

            if (!_dragCursor && overSlider)
            {
                _dragCursor = true;
                Cursor      = Cursors.SizeWE;
            }

            base.OnMouseMove(e);
        }