Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 /// <returns></returns>
 internal Engine.MousePoint MousePointRelativeToImagePositionAndZoom(Engine.MousePoint e)
 {
     // values of mouse points are those relative to PaintualCanvas. If canvas moves, values of mouse points
     // are ok.
     Engine.MousePoint p = new MousePoint((int)(e.X / t_zoomFactor), (int)(e.Y / t_zoomFactor));
     return(p);
 }
Example #2
0
        public List <MousePoint> LinearInterpolate()
        {
            List <MousePoint> points = new List <MousePoint>();

            if (Engine.Application.UISelectedValues.InterpolateMouseMoves == false)
            {
                OnlyKeepLastMousePoint();
                points.Add(t_mousePoints[0]);
                return(points);
            }

            if (this.t_mousePoints.Count > 1)
            {
                int X1 = this.t_mousePoints[0].X;
                int Y1 = this.t_mousePoints[0].Y;
                int X2 = this.t_mousePoints[this.t_mousePoints.Count - 1].X;
                int Y2 = this.t_mousePoints[this.t_mousePoints.Count - 1].Y;

                int deltaX = Math.Abs(X2 - X1);
                int deltaY = Math.Abs(Y2 - Y1);

                int maxSteps = Math.Max(deltaX, deltaY);

                if (maxSteps <= 1)
                {
                    OnlyKeepLastMousePoint();
                    points.Add(t_mousePoints[0]);
                    return(points);
                }

                deltaX = X2 - X1;
                deltaY = Y2 - Y1;

                float increaseX = (float)deltaX / (float)maxSteps;
                float increaseY = (float)deltaY / (float)maxSteps;

                points.Add(new Engine.MousePoint(X1, Y1, Engine.MouseActionType.MouseMove, true));

                for (int i = 0; i < maxSteps; i++)
                {
                    int stepX = (int)((i * increaseX) + (float)X1);
                    int stepY = (int)((i * increaseY) + (float)Y1);

                    // have these coordinates modified to take into account zoom and pan
                    MousePoint p2 = new Engine.MousePoint(stepX, stepY, Engine.MouseActionType.MouseMove, false);
                    points.Add(p2);
                }

                points.Add(new Engine.MousePoint(X2, Y2, Engine.MouseActionType.MouseMove, true));
            }
            else
            {
                points.Add(new Engine.MousePoint(t_mousePoints[0].X, t_mousePoints[0].Y));
            }

            OnlyKeepLastMousePoint();
            return(points);
        }
Example #3
0
        internal void FeedMouseAction(Engine.MousePoint e)
        {
            if (t_workflow.DrawingBoardMode == DrawingBoardModes.Disabled)
            {
                return;
            }

            // correct coords relative to image position and zoom
            Engine.MousePoint correctedPoint = t_workflow.CoordinatesManager.MousePointRelativeToImagePositionAndZoom(e);

            switch (e.MouseAction)
            {
            case Engine.MouseActionType.MouseDown:
                switch (t_workflow.DrawingBoardMode)
                {
                case DrawingBoardModes.None:
                case DrawingBoardModes.SuspendDraw:
                    t_workflow.DrawingBoardMode = DrawingBoardModes.Draw;
                    ActivityPreProcess(correctedPoint);
                    // no threaded because drawing action would start before canvas is allowed to refresh its content.
                    t_workflow.AllowInvalidate = true;
                    ActivityProcess(correctedPoint);
                    break;
                }
                break;

            case Engine.MouseActionType.MouseMove:
                switch (t_workflow.DrawingBoardMode)
                {
                case DrawingBoardModes.Draw:
                    ActivityProcess(correctedPoint);
                    break;
                }
                break;


            case Engine.MouseActionType.MouseUp:
                t_workflow.DrawingBoardMode = DrawingBoardModes.SuspendDraw;

                // should find a way to force display of final brush stroke although it will be shown
                // by PaintualCanvas at next tick of timer unless t_allowInvalidate is set to false before

                //t_motionAttribute.ThisIsLastMousePoint();

                // waiting for the action to complete before calling DisallowInvalidate, this may prevent end of brush stroke to no
                // be displayed as this was the case before (when using RunAndForget)
                ActivityPostProcess(correctedPoint);
                t_workflow.ThreadingQueue.RunAndAwait(new Action(t_workflow.MotionAttribute.Clear));
                t_workflow.ThreadingQueue.RunAndForget(new Action(t_workflow.DisallowInvalidate));
                break;

            default:

                break;
            }
        }
Example #4
0
        // see Tools.MotionAttribute where original method exists
        private List <MousePoint> LinearInterpolate(Point a, Point b)
        {
            List <MousePoint> points = new List <MousePoint>();

            int X1 = a.X;
            int Y1 = a.Y;
            int X2 = b.X;
            int Y2 = b.Y;

            int deltaX = Math.Abs(X2 - X1);
            int deltaY = Math.Abs(Y2 - Y1);

            int maxSteps = Math.Max(deltaX, deltaY);

            if (maxSteps <= 1)
            {
                points.Add(new MousePoint(a.X, a.Y));
                return(points);
            }

            deltaX = X2 - X1;
            deltaY = Y2 - Y1;

            float increaseX = (float)deltaX / (float)maxSteps;
            float increaseY = (float)deltaY / (float)maxSteps;

            points.Add(new Engine.MousePoint(X1, Y1, Engine.MouseActionType.MouseMove, true));

            // don't add last point, it creates a duplicate when tracing next particle position
            for (int i = 1; i < maxSteps; i++)
            {
                int stepX = (int)((i * increaseX) + (float)X1);
                int stepY = (int)((i * increaseY) + (float)Y1);

                // have these coordinates modified to take into account zoom and pan
                MousePoint p2 = new Engine.MousePoint(stepX, stepY, Engine.MouseActionType.MouseMove, false);
                points.Add(p2);
            }

            points.Add(new Engine.MousePoint(X2, Y2, Engine.MouseActionType.MouseMove, true));


            return(points);
        }
Example #5
0
        public static List <MousePoint> LinearInterpolate(MousePoint start, MousePoint end)
        {
            List <MousePoint> points = new List <MousePoint>();

            int X1 = start.X;
            int Y1 = start.Y;
            int X2 = end.X;
            int Y2 = end.Y;

            int deltaX = System.Math.Abs(X2 - X1);
            int deltaY = System.Math.Abs(Y2 - Y1);

            int maxSteps = System.Math.Max(deltaX, deltaY);

            if (maxSteps <= 1)
            {
                points.Add(start);
                return(points);
            }

            deltaX = X2 - X1;
            deltaY = Y2 - Y1;

            float increaseX = (float)deltaX / (float)maxSteps;
            float increaseY = (float)deltaY / (float)maxSteps;

            points.Add(new Engine.MousePoint(X1, Y1, Engine.MouseActionType.MouseMove, true));

            for (int i = 0; i < maxSteps; i++)
            {
                int stepX = (int)((i * increaseX) + (float)X1);
                int stepY = (int)((i * increaseY) + (float)Y1);

                MousePoint p2 = new Engine.MousePoint(stepX, stepY, Engine.MouseActionType.MouseMove, false);
                points.Add(p2);
            }

            points.Add(new Engine.MousePoint(X2, Y2, Engine.MouseActionType.MouseMove, true));

            return(points);
        }
Example #6
0
 private void E_Grid_MouseUp(object sender, MouseButtonEventArgs e)
 {
     Engine.MousePoint mp = new Engine.MousePoint(e.GetPosition(this).X, e.GetPosition(this).Y, Engine.MouseActionType.MouseUp);
     t_workflow.FeedMouseAction(mp);
 }
Example #7
0
 private void E_Grid_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     Engine.MousePoint mp = new Engine.MousePoint(e.GetPosition(this).X, e.GetPosition(this).Y, Engine.MouseActionType.MouseMove);
     t_workflow.FeedMouseAction(mp);
 }
Example #8
0
 private void ActivityPostProcess(Engine.MousePoint correctedPoint)
 {
     t_workflow.ThreadingQueue.RunAndReturn <MousePoint, int>(t_workflow.MotionAttribute.AddMousePoint, correctedPoint);
     t_workflow.ThreadingQueue.RunAndForget(t_workflow.GraphicActivity.PostProcess);
 }