LynnaLab.TileGridViewer.OnMoveMouse C# (CSharp) Method

OnMoveMouse() protected method

protected OnMoveMouse ( object o, Gtk.MotionNotifyEventArgs args ) : void
o object
args Gtk.MotionNotifyEventArgs
return void
        protected void OnMoveMouse(object o, MotionNotifyEventArgs args)
        {
            int x,y;
            Gdk.ModifierType state;
            args.Event.Window.GetPointer(out x, out y, out state);

            int nextHoveringIndex;
            if (x >= 0 && y >= 0 && x<Width*TileWidth*Scale && y<Height*TileHeight*Scale) {
                nextHoveringIndex = (x/TileWidth/Scale) + (y/TileHeight/Scale)*Width;
            }
            else {
                nextHoveringIndex = -1;
            }

            if (nextHoveringIndex != hoveringIndex) {
                this.QueueDrawArea(HoveringX*TileWidth*Scale, HoveringY*TileHeight*Scale,
                        TileWidth*Scale, TileHeight*Scale);
                hoveringIndex = nextHoveringIndex;
                this.QueueDrawArea(HoveringX*TileWidth*Scale, HoveringY*TileHeight*Scale,
                        TileWidth*Scale, TileHeight*Scale);

                if (HoverChangedEvent != null)
                    HoverChangedEvent();
            }
        }