예제 #1
0
        //! \copydoc Interpolator::interpolateAbsolute
        public string InterpolateAbsolute(string value1, string value2, float position)
        {
            var val1 = MathematicsEx.QuaternionParse(value1);
            var val2 = MathematicsEx.QuaternionParse(value2);

            return(PropertyHelper.ToString(Lunatics.Mathematics.Quaternion.Slerp(val1, val2, position)));
        }
예제 #2
0
        static PropertyHelper()
        {
            RegisterFunction <Boolean>(
                x => Boolean.Parse(x),
                x => ((Boolean)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <Byte>(
                x => Byte.Parse(x, CultureInfo.InvariantCulture),
                x => ((Byte)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <Int16>(
                x => Int16.Parse(x, CultureInfo.InvariantCulture),
                x => ((Int16)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <Int32>(
                x => Int32.Parse(x, CultureInfo.InvariantCulture),
                x => ((Int32)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <Int64>(
                x => Int64.Parse(x, CultureInfo.InvariantCulture),
                x => ((Int64)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <UInt16>(
                x => UInt16.Parse(x, CultureInfo.InvariantCulture),
                x => ((UInt16)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <UInt32>(
                x => UInt32.Parse(x, CultureInfo.InvariantCulture),
                x => ((UInt32)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <UInt64>(
                x => UInt64.Parse(x, CultureInfo.InvariantCulture),
                x => ((UInt64)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <Char>(
                x => Char.Parse(x),
                x => ((Char)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <Single>(
                x => String.IsNullOrEmpty(x) ? 0f : Single.Parse(x, CultureInfo.InvariantCulture),
                x => ((Single)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <Double>(
                x => Double.Parse(x, CultureInfo.InvariantCulture),
                x => ((Double)x).ToString(CultureInfo.InvariantCulture));

            RegisterFunction <String>(
                x => x,
                x => (string)x);

            RegisterFunction <Colour>(
                x => Colour.Parse(x),
                x => ((Colour)x).ToString());

            RegisterFunction <ColourRect>(
                x => ColourRect.Parse(x, CultureInfo.InvariantCulture),
                x => x.ToString());

            RegisterFunction <Sizef>(
                x => Sizef.Parse(x, CultureInfo.InvariantCulture),
                x => ((Sizef)x).ToString());

            RegisterFunction <Lunatics.Mathematics.Vector3>(
                x => MathematicsEx.Vector3Parse(x, CultureInfo.InvariantCulture),
                x => MathematicsEx.ToString((Lunatics.Mathematics.Vector3)x));

            RegisterFunction <Rectf>(
                x => Rectf.Parse(x, CultureInfo.InvariantCulture),
                x => ((Rectf)x).ToString());

            RegisterFunction <Lunatics.Mathematics.Quaternion>(
                x => MathematicsEx.QuaternionParse(x, CultureInfo.InvariantCulture),
                x => MathematicsEx.ToString((Lunatics.Mathematics.Quaternion)x));

            RegisterFunction <UDim>(
                x => UDim.Parse(x, CultureInfo.InvariantCulture),
                x => ((UDim)x).ToString());

            RegisterFunction <UVector2>(
                x => UVector2.Parse(x, CultureInfo.InvariantCulture),
                x => ((UVector2)x).ToString());

            RegisterFunction <USize>(
                x => USize.Parse(x, CultureInfo.InvariantCulture),
                x => ((USize)x).ToString());

            RegisterFunction <URect>(
                x => URect.Parse(x, CultureInfo.InvariantCulture),
                x => ((URect)x).ToString());

            RegisterFunction <UBox>(
                x => UBox.Parse(x, CultureInfo.InvariantCulture),
                x => ((UBox)x).ToString());

            RegisterFunction <Image>(
                x => String.IsNullOrEmpty(x) ? null : ImageManager.GetSingleton().Get(x),
                x => x != null ? ((Image)x).GetName() : String.Empty);

            RegisterFunction <Font>(
                x => String.IsNullOrEmpty(x) ? null : FontManager.GetSingleton().Get(x),
                x => x != null ? ((Font)x).GetName() : String.Empty);

            RegisterFunction <FontMetricType>(
                x => (FontMetricType)Enum.Parse(typeof(FontMetricType), x, true),
                x => ((FontMetricType)x).ToString());

            RegisterFunction <AspectMode>(
                x => (AspectMode)Enum.Parse(typeof(AspectMode), x, true),
                x => ((AspectMode)x).ToString());

            RegisterFunction <HorizontalAlignment>(
                x =>
            {
                HorizontalAlignment value;
                if (!Enum.TryParse(x, true, out value))
                {
                    switch (x.ToLowerInvariant())
                    {
                    case "leftaligned":
                        return(HorizontalAlignment.Left);

                    case "centrealigned":
                        return(HorizontalAlignment.Centre);

                    case "rightaligned":
                        return(HorizontalAlignment.Right);
                    }
                }

                return(value);
            },
                x => ((HorizontalAlignment)x).ToString());

            RegisterFunction <VerticalAlignment>(
                x =>
            {
                VerticalAlignment value;
                if (!Enum.TryParse(x, true, out value))
                {
                    switch (x.ToLowerInvariant())
                    {
                    case "topaligned":
                        return(VerticalAlignment.Top);

                    case "centrealigned":
                        return(VerticalAlignment.Centre);

                    case "bottomaligned":
                        return(VerticalAlignment.Bottom);
                    }
                }

                return(value);
            },
                x => ((VerticalAlignment)x).ToString());

            RegisterFunction <VerticalTextFormatting>(
                x => (VerticalTextFormatting)Enum.Parse(typeof(VerticalTextFormatting), x, true),
                x => ((VerticalTextFormatting)x).ToString());

            RegisterFunction <HorizontalTextFormatting>(
                x => (HorizontalTextFormatting)Enum.Parse(typeof(HorizontalTextFormatting), x, true),
                x => ((HorizontalTextFormatting)x).ToString());

            RegisterFunction <AutoScaledMode>(
                x =>
            {
                AutoScaledMode value;
                if (!Enum.TryParse(x, true, out value))
                {
                    if (x.ToLowerInvariant() == "false")
                    {
                        return(AutoScaledMode.Disabled);
                    }
                }
                return(value);
            },
                x => ((AutoScaledMode)x).ToString());

            RegisterFunction <VerticalFormatting>(
                x => (VerticalFormatting)Enum.Parse(typeof(VerticalFormatting), x, true),
                x => ((VerticalFormatting)x).ToString());

            RegisterFunction <HorizontalFormatting>(
                x => (HorizontalFormatting)Enum.Parse(typeof(HorizontalFormatting), x, true),
                x => ((HorizontalFormatting)x).ToString());

            RegisterFunction <FrameImageComponent>(
                x => (FrameImageComponent)Enum.Parse(typeof(FrameImageComponent), x, true),
                x => ((FrameImageComponent)x).ToString());

            RegisterFunction <DimensionType>(
                x => (DimensionType)Enum.Parse(typeof(DimensionType), x, true),
                x => ((DimensionType)x).ToString());

            RegisterFunction <DimensionOperator>(
                x => (DimensionOperator)Enum.Parse(typeof(DimensionOperator), x, true),
                x => ((DimensionOperator)x).ToString());

            RegisterFunction <WindowUpdateMode>(
                x => (WindowUpdateMode)Enum.Parse(typeof(WindowUpdateMode), x, true),
                x => ((WindowUpdateMode)x).ToString());

            RegisterFunction <ScrollbarDisplayMode>(
                x => (ScrollbarDisplayMode)Enum.Parse(typeof(ScrollbarDisplayMode), x, true),
                x => ((ScrollbarDisplayMode)x).ToString());

            RegisterFunction <ViewSortMode>(
                x => (ViewSortMode)Enum.Parse(typeof(ViewSortMode), x, true),
                x => ((ViewSortMode)x).ToString());

            RegisterFunction <Tuple <float, float> >(
                x => { throw new NotImplementedException(); },
                x => String.Format("min:{0} max:{1}", ((Tuple <float, float>)x).Item1, ((Tuple <float, float>)x).Item1));

            #region Types from Widgets

            RegisterFunction <ListHeaderSegment.SortDirection>(
                x => (ListHeaderSegment.SortDirection)Enum.Parse(typeof(ListHeaderSegment.SortDirection), x, true),
                x => ((ListHeaderSegment.SortDirection)x).ToString());

            RegisterFunction <MultiColumnList.SelectionMode>(
                x => (MultiColumnList.SelectionMode)Enum.Parse(typeof(MultiColumnList.SelectionMode), x, true),
                x => ((MultiColumnList.SelectionMode)x).ToString());

            RegisterFunction <ItemListBase.SortMode>(
                x => (ItemListBase.SortMode)Enum.Parse(typeof(ItemListBase.SortMode), x, true),
                x => ((ItemListBase.SortMode)x).ToString());

            RegisterFunction <Spinner.TextInputMode>(
                x => (Spinner.TextInputMode)Enum.Parse(typeof(Spinner.TextInputMode), x, true),
                x => ((Spinner.TextInputMode)x).ToString());

            RegisterFunction <GridLayoutContainer.AutoPositioning>(
                x => (GridLayoutContainer.AutoPositioning)Enum.Parse(typeof(GridLayoutContainer.AutoPositioning), x, true),
                x => ((GridLayoutContainer.AutoPositioning)x).ToString());

            #endregion
        }