GithubHelp home page GithubHelp logo

Comments (6)

cyotek avatar cyotek commented on July 19, 2024

Hello,

Thanks for the comment. The issue you refer to was closed and so wasn't visible without searching, but it was #9

However, it's a perfectly reasonably suggestion to implement and given that you're now the third person to ask for it (and truth to tell, I could do with it in one of my core products as well), it makes perfect sense to implement it in the base control.

Assuming I don't get a PR in the next couple of days, I'll look at adding this as a core feature at the weekend.

Thanks again for the feedback!

Regards;
Richard Moss

from cyotek.windows.forms.imagebox.

bkraul avatar bkraul commented on July 19, 2024

I realize it has been a couple years since this was touched, but is there any pointers on how we could approach this? I see there is a protected property called WheelScrollsControl, but I can see no use of it in the control. I have tried to override the MouseWheel event, but I am not sure how to wire it to the ScrollControl class. This functionality is definitely needed.

from cyotek.windows.forms.imagebox.

bkraul avatar bkraul commented on July 19, 2024

So I think I got a workaround for now. I did the following:

  • Inherit the control.
  • Expose the WheelScrollsControl property as public.
  • Override the MouseWheel event, using the WheelScrollsControl property, and execute the scroll code that is found in the base ScrollControl.cs (had to copy it). Otherwise run control's base.
        /// <summary>
        ///   Raises the <see cref="System.Windows.Forms.Control.MouseWheel" /> event.
        /// </summary>
        /// <param name="e">
        ///   A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.
        /// </param>
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            if (this.WheelScrollsControl == true)
            {
                int x;
                int y;
                int delta;

                x = this.HorizontalScroll.Value;
                y = this.VerticalScroll.Value;

                // TODO: Find if we are hovering over a horizontal scrollbar and scroll that instead of the default vertical.
                if (this.VerticalScroll.Visible && this.VerticalScroll.Enabled)
                {
                    if (ModifierKeys == Keys.Control)
                    {
                        delta = this.VerticalScroll.LargeChange;
                    }
                    else
                    {
                        delta = SystemInformation.MouseWheelScrollLines * this.VerticalScroll.SmallChange;
                    }

                    y += (e.Delta > 0) ? -delta : delta;
                }
                else if (this.HorizontalScroll.Visible && this.HorizontalScroll.Enabled)
                {
                    if (ModifierKeys == Keys.Control)
                    {
                        delta = this.HorizontalScroll.LargeChange;
                    }
                    else
                    {
                        delta = SystemInformation.MouseWheelScrollLines * this.HorizontalScroll.SmallChange;
                    }

                    x += (e.Delta > 0) ? -delta : delta;
                }

                this.ScrollTo(x, y);
            }
            else
            {
                base.OnMouseWheel(e);
            }
        }

Seems to be doing the trick, and was simple enough.

from cyotek.windows.forms.imagebox.

cyotek avatar cyotek commented on July 19, 2024

Hello,

Thanks for the comment, I'm glad you found a solution that works for you. It has been some time since I worked on this control and I've complete forgotten what state it currently in is. Despite that, it's by no means abandoned (I use it in a fair few of my projects), I just don't have time to work on this because of other commitments where users are perhaps... more vocal with their displeasure (to put it mildly).

From what I remember though, this approach won't work in the branch I'd been working on to revamp the control as the ScrollControl that the WheelScrollsControl property belongs to was removed as part of a general clean up and simplification.

I don't think I got around to adding this functionality but I do intend on adding it. No promises as I think I've broken pretty much every promise or timescale on the open source code but I'll at least dig out which branch I'm supposed to be working on and try and figure out where I am and jot down some form of plan.

Regards;
Richard Moss

from cyotek.windows.forms.imagebox.

bkraul avatar bkraul commented on July 19, 2024

@cyotek No worries. Because I merely inherited the control with just my few modifications, I am pretty sure I should be able to either revert to your updated one (when and if you choose to release) or adapt my inherited control. Thanks for the work you put into this project over the years. It is still the fastest full-featured open source image box out there. We are using the Gnostice image viewer for some use cases, and your control leaves it in the dust in terms of responsiveness and memory usage.

from cyotek.windows.forms.imagebox.

Fruchtzwerg94 avatar Fruchtzwerg94 commented on July 19, 2024

I've created a pull request facing this by adding a property for the mouse wheel mode:
#48

from cyotek.windows.forms.imagebox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.