コード例 #1
0
ファイル: SelectablePanel.cs プロジェクト: xdanieldzd/G15Map
        private void HandleRatchetScrolling(ScrollProperties scrollProperties, ScrollEventArgs se)
        {
            if (se.Type == ScrollEventType.ThumbPosition)
            {
                scrollProperties.Value = se.OldValue;
            }
            else if (se.Type == ScrollEventType.ThumbTrack)
            {
                int newStep = (se.NewValue / scrollProperties.SmallChange);
                int oldStep = (se.OldValue / scrollProperties.SmallChange);

                if (newStep != oldStep)
                {
                    scrollProperties.Value = (se.NewValue / scrollProperties.SmallChange) * scrollProperties.SmallChange;
                }
                else
                {
                    scrollProperties.Value = se.OldValue;
                }
            }
            else
            {
                base.OnScroll(se);
            }
        }
コード例 #2
0
        private static bool SideAutoScroll(ScrollProperties sp, int stPos, int size, int mousePos, int mousePosPic)
        {
            if (!sp.Visible)
            {
                return(false);
            }

            const int limit = 20;
            const int step  = 20;
            int       d2    = size - mousePos; // расстояние до второй границы

            if (mousePos < limit && d2 > mousePos && (mousePosPic < stPos || mousePosPic - stPos > limit))
            {
                sp.Value = Math.Max(sp.Minimum, sp.Value - step);
            }
            else if (d2 < limit && d2 < mousePos && (mousePosPic > stPos || stPos - mousePosPic > limit))
            {
                sp.Value = Math.Min(sp.Maximum, sp.Value + step);
            }
            else
            {
                return(false);
            }

            return(true);
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: afhernani/ShowGifs
        /// <summary>
        /// Captura y sobreescribe el manejo de la rueda del raton para el panel
        /// flowLayoutPanel activo en el momento, en su scroll vertical unicamente.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            /* codigo aqui ...*/
            Debug.Write("OnMouseWheel acction ");
            //int ingrementVertical;
            foreach (var item in tabControl1.SelectedTab.Controls)
            {
                Type tipo = typeof(FlowLayoutPanel);
                if (item.GetType() == tipo)
                {
                    FlowLayoutPanel flow = (FlowLayoutPanel)item;
                    if (flow != null)
                    {
                        ScrollProperties Vscroll = flow.VerticalScroll;
                        Debug.WriteLine($"SmalChanges: {Vscroll.SmallChange} , LargeChange: {Vscroll.LargeChange}");
                        Debug.WriteLine($"on flow {e.Delta};");
                        int newValor = Vscroll.Value - e.Delta;
                        if (newValor < Vscroll.Minimum || newValor > Vscroll.Maximum)
                        {
                            Debug.WriteLine("<Out of Minimum and Maximum>");
                            base.OnMouseWheel(e);
                            return;
                        }

                        //habra que depurar mas para no salirse de los limites de los valores
                        //if Value+=e.Deta esta ente el minimo y maximo de los se suma.
                        //analizamos el asunto despues.....
                        flow.VerticalScroll.Value = newValor;
                        flow.Invalidate(true);
                        //flow.Dispose();
                    }
                }
            }
            base.OnMouseWheel(e);
        }
コード例 #4
0
        private void SetValue(ScrollEventType type, ScrollProperties scrollProperties, int newValue)
        {
            Contract.Requires(scrollProperties != null);

            if (newValue < scrollProperties.Minimum)
            {
                newValue = scrollProperties.Minimum;
            }
            if (newValue > scrollProperties.Maximum - scrollProperties.LargeChange)
            {
                newValue = scrollProperties.Maximum - scrollProperties.LargeChange + 1;
            }
            if (scrollProperties.Value != newValue)
            {
                var oldValue = scrollProperties.Value;

                scrollProperties.Value = newValue;

                if (type != ScrollEventType.EndScroll)
                {
                    OnScroll(new ScrollEventArgs(
                                 type,
                                 oldValue,
                                 newValue,
                                 scrollProperties is VScrollProperties ? ScrollOrientation.VerticalScroll : ScrollOrientation.HorizontalScroll
                                 ));
                    Invalidate();
                }
            }
        }
コード例 #5
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.");
        }
コード例 #6
0
        int odrediPomakScrolla(int sirinaKlijenta, int sirinaPrikaza, ScrollProperties scroll, int zeljenaPozicija, double brzina)
        {
            if (sirinaPrikaza >= sirinaKlijenta)
            {
                return(0);
            }

            double skala           = (sirinaKlijenta - sirinaPrikaza) / (double)(scroll.Maximum - scroll.LargeChange);
            int    pozicijaPrikaza = sirinaPrikaza / 2 + (int)(scroll.Value * skala);

            zeljenaPozicija = Fje.Ogranici(zeljenaPozicija, sirinaPrikaza / 2 + 1, sirinaKlijenta - sirinaPrikaza / 2 - 1);
            double delta = zeljenaPozicija - pozicijaPrikaza;

            if (brzina == 0)
            {
                return((int)delta);
            }

            if (Math.Abs(delta) < brzina + 2)
            {
                if (Math.Abs(delta) < 2)
                {
                    return((int)(delta * skala));
                }
                else
                {
                    return(Math.Sign(delta));
                }
            }
            else
            {
                return((int)(delta / (brzina * skala)));
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
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);
        }
コード例 #9
0
 private void DoScroll(ScrollProperties scrollProperties, int value)
 {
     // perform the scroll operation if possible and within bounds
     if (scrollProperties.Enabled)
     {
         scrollProperties.Value = Math.Min(scrollProperties.Maximum, Math.Max(scrollProperties.Minimum, value));
     }
 }
コード例 #10
0
        public void PropertyValue()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.VerticalScroll;

            sp.Value = 10;
            Assert.AreEqual(10, sp.Value, "B1");
        }
コード例 #11
0
        public void PropertyVisible()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.VerticalScroll;

            sp.Visible = true;
            Assert.AreEqual(true, sp.Visible, "B1");
        }
コード例 #12
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;
        }
コード例 #13
0
        public void PropertyEnabled()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.VerticalScroll;

            sp.Enabled = false;
            Assert.AreEqual(false, sp.Enabled, "B1");
        }
コード例 #14
0
        public void PropertyLargeChange()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.VerticalScroll;

            sp.LargeChange = 25;
            Assert.AreEqual(25, sp.LargeChange, "B1");
        }
コード例 #15
0
        public void PropertyMaximum()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.HorizontalScroll;

            sp.Maximum = 200;
            Assert.AreEqual(200, sp.Maximum, "B1");
        }
コード例 #16
0
        public void PropertySmallChange()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.VerticalScroll;

            sp.SmallChange = 5;
            Assert.AreEqual(5, sp.SmallChange, "B1");
        }
コード例 #17
0
        public void PropertyMinimum()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.VerticalScroll;

            sp.Minimum = 20;
            Assert.AreEqual(20, sp.Minimum, "B1");
        }
コード例 #18
0
        private static void ScaleScroll(ScrollProperties sp, decimal kOld, decimal kNew, int picPos, int oldScrollPos)
        {
            if (!sp.Visible)
            {
                return;
            }

            decimal val = (picPos) * kOld / kNew - (picPos - oldScrollPos);

            sp.Value = Math.Min(Math.Max((int)val, sp.Minimum), sp.Maximum);
        }
コード例 #19
0
        /// <summary>TODO</summary>
        private void ScrollPanelCommon(ScrollEventType type, int sign, ScrollProperties scroll)
        {
            if (sign == 0)
            {
                return;
            }
            Func <Point, int, Point> func = (p, step) => new Point(-p.X, -p.Y + step * sign);

            AutoScrollPosition = func(AutoScrollPosition,
                                      type.Hasflag(ScrollEventType.LargeDecrement) ? scroll.LargeChange : scroll.SmallChange);
        }
コード例 #20
0
        public void Constructor()
        {
            ScrollableControl sc = new ScrollableControl();
            ScrollProperties  sp = sc.VerticalScroll;

            Assert.AreEqual(true, sp.Enabled, "A1");
            Assert.AreEqual(10, sp.LargeChange, "A2");
            Assert.AreEqual(100, sp.Maximum, "A3");
            Assert.AreEqual(0, sp.Minimum, "A4");
            Assert.AreEqual(1, sp.SmallChange, "A5");
            Assert.AreEqual(0, sp.Value, "A6");
            Assert.AreEqual(false, sp.Visible, "A7");
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        private static void AdjustScroll(ScrollProperties scroll, int max, int size, int additionalScrollSize)
        {
            var visible = max > size;

            if (visible)
            {
                scroll.Minimum     = 0;
                scroll.Maximum     = max - additionalScrollSize;
                scroll.LargeChange = size;
                scroll.SmallChange = size / 10;
            }

            scroll.Visible = scroll.Enabled = visible;
        }
コード例 #23
0
        private void SetScrollBarMove(ScrollProperties scroll, int moveDistanse)
        {
            int moveResult = scroll.Value - moveDistanse;

            if (moveResult < 0)
            {
                moveResult = 0;
            }
            else if (moveResult > scroll.Maximum)
            {
                moveResult = scroll.Maximum;
            }
            scroll.Value = moveResult;
        }
コード例 #24
0
ファイル: Recibo_Nomina.cs プロジェクト: MarDiiaz/Internom-v1
        private void doc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            // crea un rectangulo del tamaño del panel para poder imprimirlo
            int width            = panel1.Width;
            int height           = panel1.Height;
            ScrollProperties p   = this.VerticalScroll;
            Bitmap           bmp = new Bitmap(width, height, panel1.CreateGraphics());

            panel1.DrawToBitmap(bmp, new Rectangle(0, 0, width, height));
            RectangleF bounds = e.PageSettings.PrintableArea;
            float      factor = ((float)bmp.Height / (float)bmp.Width);

            e.Graphics.DrawImage(bmp, bounds.Left, bounds.Top, bounds.Width, factor * bounds.Width);
        }
コード例 #25
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;
        }
コード例 #26
0
        /// <summary>
        /// Sets the scroll value of a scroll bar control based on the percentage passed in
        /// </summary>
        /// <param name="scroll">ScrollProperties attribute from a scroll bar control</param>
        /// <param name="scrollpercent">Percent of scrolling to set. 0 indicated all the way left.</param>
        private void SetScrollPercent(ScrollProperties scroll, float scrollpercent)
        {
            scrollpercent = (scrollpercent > 1) ? 1 : (scrollpercent < 0) ? 0 : scrollpercent;

            int MaxScroll = scroll.Maximum - scroll.LargeChange - 1;

            if (scrollpercent < 0f)
            {
                scrollpercent = 0f;
            }
            else if (scrollpercent > 100f)
            {
                scrollpercent = 100f;
            }
            scroll.Value = (int)(scrollpercent * MaxScroll);
        }
コード例 #27
0
 private void SynchronizeScrollbarCore(
     int value,
     RadScrollBar scrollbar,
     ScrollState scrollbarState,
     ScrollProperties scrollProperties)
 {
     if (!this.IsValueInRange(scrollbar, value))
     {
         return;
     }
     this.synchronizing    = true;
     scrollbar.Minimum     = scrollProperties.Minimum;
     scrollbar.Maximum     = scrollProperties.Maximum;
     scrollbar.SmallChange = scrollProperties.SmallChange;
     scrollbar.Value       = value;
     scrollbar.LargeChange = scrollProperties.Visible || scrollbarState != ScrollState.AlwaysShow ? scrollProperties.LargeChange : scrollProperties.Maximum;
     this.synchronizing    = false;
 }
コード例 #28
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);
     }
 }
コード例 #29
0
        public static void ScrollToPosition(
            ScrollProperties scrollBar, int targetPosition, double totalTimeMs)
        {
            if (totalTimeMs <= 0.0)
            {
                throw new ArgumentException();
            }

            int initPos = scrollBar.Value;

            if (targetPosition == initPos)
            {
                return;
            }
            var sw    = new Stopwatch();
            var timer = new Timer();

            timer.Interval = 5;
            timer.Tick    += (s, e) =>
            {
                long t = sw.ElapsedMilliseconds;

                if (t >= totalTimeMs)
                {
                    sw.Stop();
                    timer.Stop();
                    timer.Dispose();
                    scrollBar.Value = targetPosition;
                }
                else
                {
                    var stepTarget = (Sin(t / totalTimeMs * PI - PI / 2.0) + 1)
                                     / 2.0 * (targetPosition - initPos) + initPos;
                    scrollBar.Value = (int)stepTarget;
                }
            };

            timer.Start();
            sw.Start();
        }
コード例 #30
0
        /// <summary>
        /// This function is necessary because Microsoft, in all its wisdom, decided that certain scroll-causing
        /// actions do not raise a scroll event, and thus allows the multiple horiz scrollbars to get out of sync. Calling this
        /// function scrolls all of the horizontal bars to the value of the timesteps panel bar. It also forces the analog and digital
        /// vertical bars back into sync.
        /// </summary>
        public void forceUpdateAllScrollbars()
        {
            if (timeStepsPanel != null)
            {
                ScrollProperties prop = timeStepsPanel.HorizontalScroll;
                double           frac = ((double)(prop.Value - prop.Minimum)) / ((double)(prop.Maximum - prop.Minimum - prop.LargeChange));
                handleHorizScroll(frac);
            }

            if (digitalChannelLabelsPanel != null)
            {
                ScrollProperties prop = digitalChannelLabelsPanel.VerticalScroll;
                double           frac = ((double)(prop.Value - prop.Minimum)) / ((double)(prop.Maximum - prop.Minimum - prop.LargeChange));
                handleDigitalVerticalScroll(frac);
            }

            if (analogChannelLabelsPanel != null)
            {
                ScrollProperties prop = analogChannelLabelsPanel.VerticalScroll;
                double           frac = ((double)(prop.Value - prop.Minimum)) / ((double)(prop.Maximum - prop.Minimum - prop.LargeChange));
                handleAnalogVerticalScroll(frac);
            }
        }