Exemplo n.º 1
0
        protected override IEnumerable <LiveObject> GetObjects()
        {
            var center = ReferenceSystem.ScreenOriginalPoint;
            var angles = CalAngles(Model.ObjectNumber);
            var radius = InnerMapper.GetScreenLocation(ReferenceSystem.Right, 0).X - center.X;

            foreach (float angle in angles)
            {
                var x = center.X + radius * (float)Math.Sin(Functions.DegreeToRadian(angle + RotateAngle));
                var y = center.Y - radius * (float)Math.Cos(Functions.DegreeToRadian(angle + RotateAngle));
                yield return(new LiveLine(center, new PointF(x, y))
                {
                    Value = angle
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Maps the <paramref name="source"/> <see cref="System.Collections.IEnumerable"/> to an <see cref="System.Collections.IEnumerable"/> of <typeparamref name="TDestination"/>.
        /// Caches the mapping func and type of elements and therefore should perform better than <see cref="Map{TSource, TDestination}"/> for IEnumerables.
        /// </summary>
        /// <typeparam name="TSource">Source type to map from.</typeparam>
        /// <typeparam name="TDestination">Target type to map to.</typeparam>
        /// <param name="source">Source enumerable to map from. The type of all elements of <paramref name="source"/> has to be the same type
        /// as the mapping function is only evaluated for the first element in the enumerable.</param>
        /// <returns>Enumerable of target type objects. The mappings are lazy evaluated, therefore if the result is not consumed no mapping will take place.</returns>
        public IEnumerable <TDestination> MapList <TSource, TDestination>(IEnumerable <TSource> source)
        {
            var func = InnerMapper <TSource, TDestination> .GetMap();

            return(source.Select(func));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Maps the <paramref name="source"/> object to <typeparamref name="TDestination"/> type.
 /// </summary>
 /// <typeparam name="TSource">Source type to map from.</typeparam>
 /// <typeparam name="TDestination">Target type to map to.</typeparam>
 /// <param name="source">Source object to map from. The source type is looked up at runtime. If this is a <see cref="System.Collections.IEnumerable"/> consider using <see cref="MapList{TSource, TDestination}"/> instead.</param>
 /// <returns>The mapped object.</returns>
 public TDestination Map <TSource, TDestination>(TSource source)
     where TSource : class
     where TDestination : class =>
 InnerMapper <TSource, TDestination> .GetMap()(source);
Exemplo n.º 4
0
 /// <summary>
 /// Registers a new mapping function.
 /// </summary>
 /// <typeparam name="TSource">Source type to be mapped from.</typeparam>
 /// <typeparam name="TDestination">Target type to map to.</typeparam>
 /// <param name="mappingFunc">Mapping function which will perform the mapping on call of <see cref="Map{TSource, TDestination}"/>.</param>
 public void RegisterMap <TSource, TDestination>(Func <TSource, TDestination> mappingFunc)
     where TSource : class
     where TDestination : class
 {
     InnerMapper <TSource, TDestination> .RegisterMap(mappingFunc);
 }