private void RefreshOperation() { this.OperationFlag &= ~OperationMask.MoveFlag; foreach (VisualObject selectedObject in this.selectedObjects) { if (selectedObject.OperationFlag == OperationMask.NoneFlag) { ComControlNode comControlNode = this; int operationFlag = (int)comControlNode.OperationFlag; int num = 0; comControlNode.OperationFlag = (OperationMask)num; break; } if (selectedObject.IsTransformEnabled) { this.OperationFlag |= OperationMask.MoveFlag; break; } } }
private void HandleRotation(PointF point) { PointF position = this.Position; PointF pointF; PointF pointF2; if (this.selectedParentObjects.Count <VisualObject>() == 1) { pointF = this.selectedParentObjects.FirstOrDefault <VisualObject>().TransformToParent(this.lastMousePoint); pointF2 = this.selectedParentObjects.FirstOrDefault <VisualObject>().TransformToParent(point); } else { pointF = this.canvasObject.TransformToSelf(this.lastMousePoint); pointF2 = this.canvasObject.TransformToSelf(point); } float num = ComControlNode.CC_DEGREES_TO_RADIANS(this.RotationSkew.ScaleX); float num2 = ComControlNode.CC_DEGREES_TO_RADIANS(this.RotationSkew.ScaleY); float num3 = (float)(-(float)Math.Atan2((double)(pointF.Y - position.Y), (double)(pointF.X - position.X))); float num4 = (float)(-(float)Math.Atan2((double)(pointF2.Y - position.Y), (double)(pointF2.X - position.X))); if (this.isShiftDown) { num4 = ((num4 * num3 < 0f) ? (-num4) : num4); float num5 = ComControlNode.CC_RADIANS_TO_DEGREES(num4 - num3); this.lastRotation += num5; if (Math.Abs(this.lastRotation) >= 15f) { float num6 = (float)((this.RotationSkew.ScaleX + this.lastRotation > 0f) ? 15 : -15); float num7 = (float)((this.RotationSkew.ScaleY + this.lastRotation > 0f) ? 15 : -15); this.RotationSkew = new ScaleValue(); this.lastRotation = 0f; } } else { num2 = ComControlNode.CC_RADIANS_TO_DEGREES(num2 + num4 - num3); num = ComControlNode.CC_RADIANS_TO_DEGREES(num + num4 - num3); this.RotationSkew = new ScaleValue(num, num2, 0.1, -99999999.0, 99999999.0); } }
private void HandleRotation(PointF point) { PointF position = this.Position; PointF pointF1; PointF pointF2; if (this.selectedParentObjects.Count <VisualObject>() == 1) { pointF1 = this.selectedParentObjects.FirstOrDefault <VisualObject>().TransformToParent(this.lastMousePoint); pointF2 = this.selectedParentObjects.FirstOrDefault <VisualObject>().TransformToParent(point); } else { pointF1 = this.canvasObject.TransformToSelf(this.lastMousePoint); pointF2 = this.canvasObject.TransformToSelf(point); } float radians1 = ComControlNode.CC_DEGREES_TO_RADIANS(this.RotationSkew.ScaleX); float radians2 = ComControlNode.CC_DEGREES_TO_RADIANS(this.RotationSkew.ScaleY); float num1 = (float)-Math.Atan2((double)pointF1.Y - (double)position.Y, (double)pointF1.X - (double)position.X); float num2 = (float)-Math.Atan2((double)pointF2.Y - (double)position.Y, (double)pointF2.X - (double)position.X); if (this.isShiftDown) { this.lastRotation += ComControlNode.CC_RADIANS_TO_DEGREES(((double)num2 * (double)num1 < 0.0 ? -num2 : num2) - num1); if ((double)Math.Abs(this.lastRotation) < 15.0) { return; } float num3 = (double)this.RotationSkew.ScaleX + (double)this.lastRotation > 0.0 ? 15f : -15f; float num4 = (double)this.RotationSkew.ScaleY + (double)this.lastRotation > 0.0 ? 15f : -15f; this.RotationSkew = new ScaleValue(); this.lastRotation = 0.0f; } else { float degrees = ComControlNode.CC_RADIANS_TO_DEGREES(radians2 + num2 - num1); this.RotationSkew = new ScaleValue(ComControlNode.CC_RADIANS_TO_DEGREES(radians1 + num2 - num1), degrees, 0.1, -99999999.0, 99999999.0); } }
private bool HandleScale(PointF point) { float scaleX = this.Scale.ScaleX; float scaleY = this.Scale.ScaleY; PointF anchorPointInPoints = this.CSCom.GetAnchorPointInPoints(); PointF p = this.TransformToSelf(ComControlNode.PointSub(point, anchorPointInPoints)); PointF p2 = this.TransformToSelf(ComControlNode.PointSub(this.lastMousePoint, anchorPointInPoints)); PointF pointF = ComControlNode.PointSub(p, p2); float num = pointF.X * scaleX; float num2 = pointF.Y * scaleY; float num3 = -num / anchorPointInPoints.X; float num4 = num / (this.Size.X - anchorPointInPoints.X); float num5 = -num2 / anchorPointInPoints.Y; float num6 = num2 / (this.Size.Y - anchorPointInPoints.Y); float num7 = 0f; float num8 = 0f; switch (this.controlPointType) { case ControlPointType.POINT_LEFT_TOP: if (this.AnchorPoint.ScaleX != 0f) { num7 = num3; } if (this.AnchorPoint.ScaleY != 1f) { num8 = num6; } break; case ControlPointType.POINT_LEFT_BOTTOM: if (this.AnchorPoint.ScaleX != 0f) { num7 = num3; } if (this.AnchorPoint.ScaleY != 0f) { num8 = num5; } break; case ControlPointType.POINT_RIGHT_BOTTOM: if (this.AnchorPoint.ScaleX != 1f) { num7 = num4; } if (this.AnchorPoint.ScaleY != 0f) { num8 = num5; } break; case ControlPointType.POINT_RIGHT_TOP: if (this.AnchorPoint.ScaleX != 1f) { num7 = num4; } if (this.AnchorPoint.ScaleY != 1f) { num8 = num6; } break; case ControlPointType.POINT_LEFT_MIDDLE: if (this.AnchorPoint.ScaleX != 0f) { num7 = num3; } break; case ControlPointType.POINT_MIDDLE_BOTTOM: if (this.AnchorPoint.ScaleY != 0f) { num8 = num5; } break; case ControlPointType.POINT_RIGHT_MIDDLE: if (this.AnchorPoint.ScaleX != 1f) { num7 = num4; } break; case ControlPointType.POINT_MIDDLE_TOP: if (this.AnchorPoint.ScaleY != 1f) { num8 = num6; } break; } bool result; if ((double)Math.Abs(this.Scale.ScaleX + num7) < 0.01) { result = false; } else if ((double)Math.Abs(this.Scale.ScaleY + num8) < 0.01) { result = false; } else { if (this.isShiftDown || this.isScaleLocked) { float num9 = this.Scale.ScaleY / this.Scale.ScaleX; float num10 = this.Scale.ScaleX + num7; this.Scale = new ScaleValue(num10, num10 * num9, 0.1, -99999999.0, 99999999.0); } else { this.Scale = new ScaleValue(this.Scale.ScaleX + num7, this.Scale.ScaleY + num8, 0.1, -99999999.0, 99999999.0); } result = true; } return(result); }
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; } } }
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; } } }