Beispiel #1
0
        private static float AdjustAmountAccordingToUnitType(string baseVariableName, float amount, object unitsVariableAsObject)
        {
            GeneralUnitType generalUnitType = UnitConverter.ConvertToGeneralUnit(unitsVariableAsObject);

            float xAmount;
            float yAmount;

            if (baseVariableName == "X" || baseVariableName == "Width")
            {
                xAmount = amount;
                yAmount = 0;
            }
            else
            {
                xAmount = 0;
                yAmount = amount;
            }

            if (generalUnitType == GeneralUnitType.PixelsFromMiddleInverted)
            {
                return(amount * -1);
            }
            else if (generalUnitType != GeneralUnitType.PixelsFromLarge && generalUnitType != GeneralUnitType.PixelsFromMiddle && generalUnitType != GeneralUnitType.PixelsFromSmall)
            {
                float parentWidth;
                float parentHeight;
                float fileWidth;
                float fileHeight;
                float outX;
                float outY;


                IRenderableIpso ipso = WireframeObjectManager.Self.GetSelectedRepresentation();
                ipso.GetFileWidthAndHeightOrDefault(out fileWidth, out fileHeight);
                ipso.GetParentWidthAndHeight(
                    ProjectManager.Self.GumProjectSave.DefaultCanvasWidth, ProjectManager.Self.GumProjectSave.DefaultCanvasHeight,
                    out parentWidth, out parentHeight);

                var unitsVariable = UnitConverter.ConvertToGeneralUnit(unitsVariableAsObject);

                UnitConverter.Self.ConvertToUnitTypeCoordinates(xAmount, yAmount, unitsVariable, unitsVariable, ipso.Width, ipso.Height, parentWidth, parentHeight, fileWidth, fileHeight,
                                                                out outX, out outY);

                if (baseVariableName == "X" || baseVariableName == "Width")
                {
                    return(outX);
                }
                else
                {
                    return(outY);
                }
            }
            else
            {
                return(amount);
            }
        }