private void DxHostOnMouseMove(object sender, MouseEventArgs e)
        {
            var newPosition = new Point((int)e.GetPosition(dxHost).X, (int)e.GetPosition(dxHost).Y);

            // don't interrupt when processing
            if (models.Progress.IsProcessing)
            {
                return;
            }

            if (mouseDown || mouse2Down)
            {
                // drag event
                var diff = new Point(newPosition.X - mousePosition.X, newPosition.Y - mousePosition.Y);
                if (Math.Abs(diff.X) > 0.01 || Math.Abs(diff.Y) > 0.01)
                {
                    if (mouseDown)
                    {
                        currentView.OnDrag(new Vector2(diff.X, diff.Y));
                    }
                    if (mouse2Down)
                    {
                        currentView.OnDrag2(new Vector2(diff.X, diff.Y));
                    }
                }
            }

            // set handle to true to keep getting mouse move events
            e.Handled     = true;
            mousePosition = newPosition;

            DispatchRecomputeTexelColor();
        }
Ejemplo n.º 2
0
        private void GlControlOnMouseMove(object sender, MouseEventArgs args)
        {
            var newPosition = new Point(args.X, args.Y);

            // dont interrupt when processing
            if (models.Progress.IsProcessing)
            {
                return;
            }

            if (mouseDown)
            {
                // drag event
                var diff = new Point(newPosition.X - mousePosition.X, newPosition.Y - mousePosition.Y);
                if (Math.Abs(diff.X) > 0.01 || Math.Abs(diff.Y) > 0.01)
                {
                    currentView.OnDrag(new Vector2(diff.X, diff.Y));
                }
            }

            mousePosition = newPosition;

            models.Display.TexelPosition = currentView.GetTexelPosition(
                ConvertToCanonical(new Vector2((float)args.X, (float)args.Y)));

            // TODO only redraw on certain conditions
            models.GlContext.RedrawFrame();
        }