public ArtboardSnapEngineContext(ArtboardSnapEngine engine, ArtboardSnapEngineContextParameters parameters)
 {
     Engine               = engine;
     Parameters           = parameters;
     SourceSnapPrimitives = new ReadOnlyCollection <ArtboardSnapSourcePrimitive>(Engine.GetSourcesInternal(Parameters.Element).SelectMany(snapSource => snapSource.GetSnapPrimitives(Parameters)).ToList());
     TargetSnapPrimitives = new ReadOnlyCollection <ArtboardSnapTargetPrimitive>(Engine.GetTargetsInternal(Parameters.Element).SelectMany(snapTarget => snapTarget.GetSnapPrimitives(Parameters)).ToList());
     DynamicTargets       = new ReadOnlyCollection <ArtboardSnapTargetPrimitive>(TargetSnapPrimitives.Where(p => p.IsFixed == false).ToList());
 }
Beispiel #2
0
        public override IEnumerable <ArtboardSnapSourcePrimitive> GetSnapPrimitives(ArtboardSnapEngineContextParameters parameters)
        {
            var side = parameters.Side;

            var hasLeft   = ArtboardSnapEngineUtils.HasLeft(side);
            var hasTop    = ArtboardSnapEngineUtils.HasTop(side);
            var hasRight  = ArtboardSnapEngineUtils.HasRight(side);
            var hasBottom = ArtboardSnapEngineUtils.HasBottom(side);

            if (hasTop && hasLeft)
            {
                yield return(_topLeft);
            }

            if (hasTop && hasRight)
            {
                yield return(_topRight);
            }

            if (hasBottom && hasRight)
            {
                yield return(_bottomRight);
            }

            if (hasBottom && hasLeft)
            {
                yield return(_bottomLeft);
            }

            if (hasLeft)
            {
                yield return(_left);
            }

            if (hasTop)
            {
                yield return(_top);
            }

            if (hasRight)
            {
                yield return(_right);
            }

            if (hasBottom)
            {
                yield return(_bottom);
            }
        }
Beispiel #3
0
 public override IEnumerable <ArtboardSnapTargetPrimitive> GetSnapPrimitives(ArtboardSnapEngineContextParameters parameters)
 {
     return(_snapPrimitives);
 }
Beispiel #4
0
 public abstract IEnumerable <ArtboardSnapSourcePrimitive> GetSnapPrimitives(ArtboardSnapEngineContextParameters parameters);