Exemple #1
0
        protected override HitTestResult HitTestCore(PointF point)
        {
            HitTestResult result;

            if (!this.Enabled)
            {
                result = null;
            }
            else
            {
                if (!this.isMouseDown)
                {
                    this.UpdateOperationType(point);
                    if (!this.OperationFlag.HasFlag(OperationMask.MoveFlag) || (this.operationType == OperationType.OPERATION_NONE && this.controlPointType == ControlPointType.POINT_NONE))
                    {
                        result = null;
                        return(result);
                    }
                    if (this.Size.X == 0f || this.Size.Y == 0f || this.Scale.ScaleX == 0f || this.Scale.ScaleY == 0f)
                    {
                        this.operationType = OperationType.OPERATION_POSITION;
                    }
                }
                CSMatrix anchorWorldMatrix = this.CSCom.GetAnchorWorldMatrix();
                PointF   pointF            = new PointF(anchorWorldMatrix.CX, anchorWorldMatrix.CY);
                float    rotate            = (float)(-(float)Math.Atan2((double)(point.Y - pointF.Y), (double)(point.X - pointF.X)));
                result = new HitTestResult(this, point, this.operationType, this.controlPointType, rotate);
            }
            return(result);
        }
Exemple #2
0
        protected override HitTestResult HitTestCore(PointF point)
        {
            if (!this.Enabled)
            {
                return((HitTestResult)null);
            }
            if (!this.isMouseDown)
            {
                int num = (int)this.UpdateOperationType(point);
                if (!this.OperationFlag.HasFlag((Enum)OperationMask.MoveFlag) || this.operationType == OperationType.OPERATION_NONE && this.controlPointType == ControlPointType.POINT_NONE)
                {
                    return((HitTestResult)null);
                }
                if ((double)this.Size.X == 0.0 || (double)this.Size.Y == 0.0 || (double)this.Scale.ScaleX == 0.0 || (double)this.Scale.ScaleY == 0.0)
                {
                    this.operationType = OperationType.OPERATION_POSITION;
                }
            }
            CSMatrix anchorWorldMatrix = this.CSCom.GetAnchorWorldMatrix();
            PointF   pointF            = new PointF(anchorWorldMatrix.CX, anchorWorldMatrix.CY);
            float    rotate            = (float)-Math.Atan2((double)point.Y - (double)pointF.Y, (double)point.X - (double)pointF.X);

            return(new HitTestResult((VisualObject)this, point, this.operationType, this.controlPointType, rotate));
        }
Exemple #3
0
        private void HandleMouseMove(PointF point)
        {
            this.isMouseMoved = true;
            List <CSMatrix> list = new List <CSMatrix>();
            CSMatrix        anchorWorldMatrix = this.CSCom.GetAnchorWorldMatrix();

            this.Print(anchorWorldMatrix);
            CSMatrix cSMatrix = this.CSCom.Mat4Inverse(anchorWorldMatrix);

            this.Print(cSMatrix);
            for (int i = 0; i < this.selectedParentObjects.Count <VisualObject>(); i++)
            {
                VisualObject visualObject       = this.selectedParentObjects.ElementAt(i);
                CSMatrix     anchorWorldMatrix2 = visualObject.GetCSVisual().GetAnchorWorldMatrix();
                this.Print(anchorWorldMatrix2);
                CSMatrix cSMatrix2 = this.CSCom.Mat4Multiply(cSMatrix, anchorWorldMatrix2);
                this.Print(cSMatrix2);
                list.Add(cSMatrix2);
            }
            if (this.operationType == OperationType.OPERATION_ANCHOR_POINT)
            {
                this.HandleAnchorPoint(point);
                if (this.SelectedObjects.Count <VisualObject>() > 1)
                {
                    return;
                }
            }
            else if (this.operationType == OperationType.OPERATION_POSITION)
            {
                this.HandlePosition(point);
            }
            else if (this.operationType == OperationType.OPERATION_ROTATION)
            {
                this.HandleRotation(point);
            }
            else if (this.operationType == OperationType.OPERATION_SCALE)
            {
                if (!this.HandleScale(point))
                {
                    this.updateLastMousePoint = false;
                    return;
                }
            }
            else if (this.operationType == OperationType.OPERATION_SKEW)
            {
                this.HandleSkew(point);
            }
            CSMatrix anchorWorldMatrix3 = this.CSCom.GetAnchorWorldMatrix();

            this.Print(anchorWorldMatrix3);
            for (int i = 0; i < this.selectedParentObjects.Count <VisualObject>(); i++)
            {
                VisualObject visualObject = this.selectedParentObjects.ElementAt(i);
                VisualObject parent       = (visualObject as NodeObject).Parent;
                if (parent == null)
                {
                    parent = this.canvasObject;
                }
                CSMatrix cSMatrix3 = visualObject.GetCSVisual().GetParentWorldMatrix();
                this.Print(cSMatrix3);
                cSMatrix3 = this.CSCom.Mat4Inverse(cSMatrix3);
                this.Print(cSMatrix3);
                CSMatrix cSMatrix4 = this.CSCom.Mat4Multiply(anchorWorldMatrix3, list[i]);
                this.Print(cSMatrix4);
                CSMatrix cSMatrix2 = this.CSCom.Mat4Multiply(cSMatrix3, cSMatrix4);
                this.Print(cSMatrix2);
                MatrixNode matrixNode = this.CSCom.Mat4ToMatrixNode(cSMatrix2);
                if (!this.TestFloatEqual(visualObject.Position.X, matrixNode.CX, 0.001f) || !this.TestFloatEqual(visualObject.Position.Y, matrixNode.CY, 0.001f))
                {
                    if (!this.positionChanged)
                    {
                        this.positionChanged = this.NeedAutoCreateFirstFrame(visualObject, typeof(PositionFrame).Name);
                    }
                    visualObject.Position = new PointF(matrixNode.CX, matrixNode.CY);
                }
                if (!this.TestFloatEqual(visualObject.Scale.ScaleX, matrixNode.CScaleX, 0.001f) || !this.TestFloatEqual(visualObject.Scale.ScaleY, matrixNode.CScaleY, 0.001f))
                {
                    if (!this.scaleChanged)
                    {
                        this.scaleChanged = this.NeedAutoCreateFirstFrame(visualObject, typeof(ScaleFrame).Name);
                    }
                    visualObject.Scale = new ScaleValue(matrixNode.CScaleX, matrixNode.CScaleY, 0.1, -99999999.0, 99999999.0);
                }
                float      num          = this.SimplifyRotation(ComControlNode.CC_RADIANS_TO_DEGREES(-matrixNode.CSkewX));
                float      num2         = this.SimplifyRotation(ComControlNode.CC_RADIANS_TO_DEGREES(-matrixNode.CSkewY));
                ScaleValue rotationSkew = visualObject.RotationSkew;
                float      num3         = this.SimplifyRotation(rotationSkew.ScaleX);
                float      num4         = this.SimplifyRotation(rotationSkew.ScaleY);
                if (!this.TestFloatEqual(rotationSkew.ScaleX, num, 0.001f) || !this.TestFloatEqual(rotationSkew.ScaleY, num2, 0.001f))
                {
                    if (!this.rotationChanged)
                    {
                        this.rotationChanged = this.NeedAutoCreateFirstFrame(visualObject, typeof(RotationSkewFrame).Name);
                    }
                    float num5 = this.SimplifyRotationDif(num - num3);
                    float num6 = this.SimplifyRotationDif(num2 - num4);
                    rotationSkew.ScaleX      += num5;
                    rotationSkew.ScaleY      += num6;
                    visualObject.RotationSkew = rotationSkew;
                }
            }
        }
Exemple #4
0
 private void Print(CSMatrix m)
 {
 }
Exemple #5
0
        private void HandleMouseMove(PointF point)
        {
            this.isMouseMoved = true;
            List <CSMatrix> csMatrixList       = new List <CSMatrix>();
            CSMatrix        anchorWorldMatrix1 = this.CSCom.GetAnchorWorldMatrix();

            this.Print(anchorWorldMatrix1);
            CSMatrix csMatrix1 = this.CSCom.Mat4Inverse(anchorWorldMatrix1);

            this.Print(csMatrix1);
            for (int index = 0; index < this.selectedParentObjects.Count <VisualObject>(); ++index)
            {
                CSMatrix anchorWorldMatrix2 = this.selectedParentObjects.ElementAt <VisualObject>(index).GetCSVisual().GetAnchorWorldMatrix();
                this.Print(anchorWorldMatrix2);
                CSMatrix m = this.CSCom.Mat4Multiply(csMatrix1, anchorWorldMatrix2);
                this.Print(m);
                csMatrixList.Add(m);
            }
            if (this.operationType == OperationType.OPERATION_ANCHOR_POINT)
            {
                this.HandleAnchorPoint(point);
                if (this.SelectedObjects.Count <VisualObject>() > 1)
                {
                    return;
                }
            }
            else if (this.operationType == OperationType.OPERATION_POSITION)
            {
                this.HandlePosition(point);
            }
            else if (this.operationType == OperationType.OPERATION_ROTATION)
            {
                this.HandleRotation(point);
            }
            else if (this.operationType == OperationType.OPERATION_SCALE)
            {
                if (!this.HandleScale(point))
                {
                    this.updateLastMousePoint = false;
                    return;
                }
            }
            else if (this.operationType == OperationType.OPERATION_SKEW)
            {
                this.HandleSkew(point);
            }
            CSMatrix anchorWorldMatrix3 = this.CSCom.GetAnchorWorldMatrix();

            this.Print(anchorWorldMatrix3);
            for (int index = 0; index < this.selectedParentObjects.Count <VisualObject>(); ++index)
            {
                VisualObject node = this.selectedParentObjects.ElementAt <VisualObject>(index);
                if ((VisualObject)(node as NodeObject).Parent == null)
                {
                    VisualObject canvasObject = this.canvasObject;
                }
                CSMatrix parentWorldMatrix = node.GetCSVisual().GetParentWorldMatrix();
                this.Print(parentWorldMatrix);
                CSMatrix csMatrix2 = this.CSCom.Mat4Inverse(parentWorldMatrix);
                this.Print(csMatrix2);
                CSMatrix csMatrix3 = this.CSCom.Mat4Multiply(anchorWorldMatrix3, csMatrixList[index]);
                this.Print(csMatrix3);
                CSMatrix csMatrix4 = this.CSCom.Mat4Multiply(csMatrix2, csMatrix3);
                this.Print(csMatrix4);
                MatrixNode matrixNode = this.CSCom.Mat4ToMatrixNode(csMatrix4);
                if (!this.TestFloatEqual(node.Position.X, matrixNode.CX, 1f / 1000f) || !this.TestFloatEqual(node.Position.Y, matrixNode.CY, 1f / 1000f))
                {
                    if (!this.positionChanged)
                    {
                        this.positionChanged = this.NeedAutoCreateFirstFrame(node, typeof(PositionFrame).Name);
                    }
                    node.Position = new PointF(matrixNode.CX, matrixNode.CY);
                }
                if (!this.TestFloatEqual(node.Scale.ScaleX, matrixNode.CScaleX, 1f / 1000f) || !this.TestFloatEqual(node.Scale.ScaleY, matrixNode.CScaleY, 1f / 1000f))
                {
                    if (!this.scaleChanged)
                    {
                        this.scaleChanged = this.NeedAutoCreateFirstFrame(node, typeof(ScaleFrame).Name);
                    }
                    node.Scale = new ScaleValue(matrixNode.CScaleX, matrixNode.CScaleY, 0.1, -99999999.0, 99999999.0);
                }
                float      v2_1         = this.SimplifyRotation(ComControlNode.CC_RADIANS_TO_DEGREES(-matrixNode.CSkewX));
                float      v2_2         = this.SimplifyRotation(ComControlNode.CC_RADIANS_TO_DEGREES(-matrixNode.CSkewY));
                ScaleValue rotationSkew = node.RotationSkew;
                float      num1         = this.SimplifyRotation(rotationSkew.ScaleX);
                float      num2         = this.SimplifyRotation(rotationSkew.ScaleY);
                if (!this.TestFloatEqual(rotationSkew.ScaleX, v2_1, 1f / 1000f) || !this.TestFloatEqual(rotationSkew.ScaleY, v2_2, 1f / 1000f))
                {
                    if (!this.rotationChanged)
                    {
                        this.rotationChanged = this.NeedAutoCreateFirstFrame(node, typeof(RotationSkewFrame).Name);
                    }
                    float num3 = this.SimplifyRotationDif(v2_1 - num1);
                    float num4 = this.SimplifyRotationDif(v2_2 - num2);
                    rotationSkew.ScaleX += num3;
                    rotationSkew.ScaleY += num4;
                    node.RotationSkew    = rotationSkew;
                }
            }
        }