Example #1
0
        private void InitBoundingBox()
        {
            float num  = 0f;
            float num2 = 0f;
            float num3 = 0f;
            float num4 = 0f;
            bool  flag = true;

            foreach (VisualObject current in this.selectedObjects)
            {
                VisualObject visualObject = current;
                PointF       boundingSize = visualObject.GetBoundingSize();
                Rectangle    rect         = new Rectangle(0, 0, (int)boundingSize.X, (int)boundingSize.Y);
                CSRect       cSRect       = this.CSCom.RectApplyTransform(rect, visualObject.GetCSVisual().ConvertToNodeMatrix(this.canvasObject.GetCSVisual()));
                if (flag)
                {
                    num  = cSRect.MinX();
                    num2 = cSRect.MinY();
                    num3 = cSRect.MaxX();
                    num4 = cSRect.MaxY();
                    flag = false;
                }
                else
                {
                    num  = Math.Min(num, cSRect.MinX());
                    num2 = Math.Min(num2, cSRect.MinY());
                    num3 = Math.Max(num3, cSRect.MaxX());
                    num4 = Math.Max(num4, cSRect.MaxY());
                }
            }
            this.InitMatrix(num, num2, num3, num4);
        }
Example #2
0
 public ComControlNode(CanvasObject canvasObject)
 {
     this.canvasObject = canvasObject;
     this.CSCom.SetCanvasObject(canvasObject.GetCSVisual());
     this.Visible = (this.VisibleForFrame = true);
     TimelineActionManager.Instance.CurrentFrameIndexChangedEvent += new CurrentFrameIndexChangedHandler(this.OnFrameIndexChanged);
     Services.Workbench.ActiveDocumentChanged += new EventHandler(this.DocumentChanged);
     Services.EventsService.GetEvent <AlignedObjectsEvent>().Subscribe(new Action <AlignedObjectsArgs>(this.OnAlignedObjects));
     Services.EventsService.GetEvent <ScaleLockedChangeEvent>().Subscribe(new Action <bool>(this.OnScaleLockedChange));
     Services.EventsService.GetEvent <CanvasSizeChangeEvent>().Subscribe(new Action <CanvasSizeChangeEventArgs>(this.OnCanvasSizeChange));
 }
Example #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;
                }
            }
        }
Example #4
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;
                }
            }
        }