Пример #1
0
        public CustomScrollControl()
        {
            SetStyle(ControlStyles.ContainerControl, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, false);

            _horizontalScroll = new ScrollProperties(this, NativeMethods.SB_HORZ);
            _verticalScroll = new ScrollProperties(this, NativeMethods.SB_VERT);
        }
Пример #2
0
        private void ResetScrollProperties(ScrollProperties scrollProperties)
        {
            // Set only these two values as when the ScrollBars are not visible ...
            // there is no meaning of the "value" property.

            scrollProperties.Visible = false;
            scrollProperties.Value = 0;
        }
 void SetScrollPercent(ScrollProperties sb, double percent)
 {
     var v = (int)Math.Round(sb.Minimum + (percent * (double)(sb.Maximum - sb.Minimum)));
     if (v > sb.Maximum)
         v = sb.Maximum;
     if (v < sb.Minimum)
         v = sb.Minimum;
     sb.Value = v;
 }
        int WheelPanelDetail(ScrollOrientation orientation, ScrollProperties scroll, int delta,
          Func<Point, int, Point> newAutoScroll, int remainder)
        {
            if (scroll == null) throw new ArgumentNullException("scroll");
            if (newAutoScroll == null) throw new ArgumentNullException("newAutoScroll");
            const int mouseWheelDelta = 120;

            var scrollLines = SystemInformation.MouseWheelScrollLines;
            var steps = Math.Sign(delta) * ((Math.Abs(delta + remainder) * scrollLines) / mouseWheelDelta);
            remainder = Math.Sign(delta) * ((Math.Abs(delta + remainder) * scrollLines) % mouseWheelDelta);

            if (steps != 0)
            {
                var oldValue = scroll.Value;
                AutoScrollPosition = newAutoScroll(AutoScrollPosition, scroll.SmallChange * steps);
                OnScroll(new ScrollEventArgs(ScrollEventType.ThumbPosition, oldValue, scroll.Value, orientation));
            }
            return remainder;
        }
 double GetScrollPercent(ScrollProperties sb)
 {
     var ret = (double)sb.Value / (double)(sb.Maximum - sb.Minimum);
     if (ret > 1.0)
         ret = 1.0;
     if (ret < 0)
         ret = 0;
     return ret;
 }
Пример #6
0
        public void scrollToFrac(double frac, ScrollProperties prop)
        {
            int temp = (int) (prop.Minimum + frac * (double)(prop.Maximum - prop.Minimum - prop.LargeChange));
            // I have no idea why this shit is necessary, but the scrollbar value property is Lazy!. Sometimes its value
            // doesn't change even when you set it. Kludge solution, attempt to set it 10 times. If it still doesn't work, give up
            // (we don't want to enter an infinite loop)
            for (int i = 0; i < 10; i++)
            {

                prop.Value = temp;
                if (prop.Value == temp)
                    break;
            }

            if (prop.Value != temp)
            {
                messageLog(this, new MessageEvent("Scrollbar issues!!!"));
            }

               //         System.Threading.Thread.Sleep(100);
               //         if (prop.Value != temp)
               //             throw new Exception("Microsoft sucks.");
        }
Пример #7
0
 public double getScrollFraction(ScrollEventArgs e, ScrollProperties prop)
 {
     if (e.Type == ScrollEventType.First)
         return 0;
     if (e.Type == ScrollEventType.Last)
         return 1;
     if (prop.Minimum != prop.Maximum)
     {
         return ((double)(e.NewValue - prop.Minimum)) / ((double)(prop.Maximum - prop.Minimum - prop.LargeChange));
     }
     else return 0;
 }
 private void ResetScrollProperties(ScrollProperties scrollProperties)
 {
     scrollProperties.visible = false;
     scrollProperties.value = 0;
 }
 private void ResetScrollProperties(ScrollProperties scrollProperties)
 {
     scrollProperties.visible = false;
     scrollProperties.value   = 0;
 }