Esempio n. 1
0
        void myBrowser_WBMouseMove(object sender, csExWB.HTMLMouseEventArgs e)
        {
            if (dragging)
            {
                //e.Handled = true;
                System.Diagnostics.Debug.WriteLine("myBrowser_WBMouseMove");
                Graphics g = myBrowser.CreateGraphics();

                // erase frame
                DrawSelectionFrame(g);

                // get selection end point
                GetImageAndScreenPoints(new Point(e.ClientX, e.ClientY), out end, out endW);

                // draw frame
                DrawSelectionFrame(g);

                g.Dispose();

                if (SelectionChanged != null)
                {
                    Point sp = start;
                    Point ep = end;

                    // normalize start and end points
                    NormalizePoints(ref sp, ref ep);

                    SelectionChanged(this, new SelectionEventArgs(
                                         sp, new Size(ep.X - sp.X + 1, ep.Y - sp.Y + 1)));
                }
            }
            else
            {
                if (MouseImagePosition != null)
                {
                    Rectangle rc        = myBrowser.ClientRectangle;
                    int       width     = (int)(this.width * zoom);
                    int       height    = (int)(this.height * zoom);
                    Point     scrollPos = myBrowser.GetScroll();
                    int       x         = (rc.Width < width) ? scrollPos.X : (rc.Width - width) / 2;
                    int       y         = (rc.Height < height) ? scrollPos.Y : (rc.Height - height) / 2;

                    if ((e.ClientX >= x) && (e.ClientY >= y) &&
                        (e.ClientX < x + width) && (e.ClientY < y + height))
                    {
                        // mouse is over the image
                        MouseImagePosition(this, new SelectionEventArgs(
                                               new Point((int)((e.ClientX - x) / zoom), (int)((e.ClientY - y) / zoom))));
                    }
                    else
                    {
                        // mouse is outside image region
                        MouseImagePosition(this, new SelectionEventArgs(new Point(-1, -1)));
                    }
                }
            }
        }