Exemplo n.º 1
0
        public EffectIntents Render()
        {
            if (IsDirty && !IsRendering)
            {
                IsRendering = true;
                try
                {
                    PreRender();
                }
                catch (Exception e)
                {
                    //Trap any errors to prevent the effect from staying in a state of rendering.
                    Logging.Error(e, $"Error rendering {EffectName} on element {TargetNodes?.FirstOrDefault()?.Name}");
                    Logging.Error($"Error rendering Effect Property settings: {PropertyInfo()}");
                }
                finally
                {
                    IsRendering = false;
                }
            }
            else
            {
                //To prevent the effect from being rendered multiple times if multiple threads
                //try to access it all at the same time. I.E the editor pre rendering process.
                while (IsRendering)
                {
                    Thread.Sleep(1);
                }
            }

            return(_Render());
        }
Exemplo n.º 2
0
        protected override void TargetNodesChanged()
        {
            CheckForInvalidColorData();
            var firstNode = TargetNodes.FirstOrDefault();

            if (firstNode != null && DepthOfEffect > firstNode.GetMaxChildDepth() - 1)
            {
                DepthOfEffect = 0;
            }
        }
Exemplo n.º 3
0
 protected override void TargetNodesChanged()
 {
     if (TargetNodes.Any())
     {
         CheckForInvalidColorData();
         if (DepthOfEffect > TargetNodes.FirstOrDefault().GetMaxChildDepth() - 1)
         {
             DepthOfEffect = 0;
         }
     }
 }
Exemplo n.º 4
0
        private IEnumerable <ElementNode> FindLeafParents()
        {
            var nodes           = new List <ElementNode>();
            var nonLeafElements = new List <ElementNode>();

            if (TargetNodes.FirstOrDefault() != null)
            {
                nonLeafElements = TargetNodes.SelectMany(x => x.GetNonLeafEnumerator()).ToList();
                foreach (var elementNode in TargetNodes)
                {
                    foreach (var leafNode in elementNode.GetLeafEnumerator())
                    {
                        nodes.AddRange(leafNode.Parents);
                    }
                }
            }
            //Some nodes can have multiple node parents with odd groupings so this fancy linq query makes sure that the parent
            //node is part of the Target nodes lineage.
            return(nodes.Distinct().Intersect(nonLeafElements));
        }
Exemplo n.º 5
0
 protected override void TargetNodesChanged()
 {
     if (TargetNodes.Any())
     {
         if (TargetNodes.Length > 1)
         {
             DepthOfEffect = 0;
         }
         else
         {
             CheckForInvalidColorData();
             var firstNode = TargetNodes.FirstOrDefault();
             if (firstNode != null && DepthOfEffect > firstNode.GetMaxChildDepth() - 1)
             {
                 DepthOfEffect = 0;
             }
         }
     }
     UpdateTargetingAttributes();
     TypeDescriptor.Refresh(this);
 }
Exemplo n.º 6
0
        protected Tuple <bool, StringOrientation> GetOrientation()
        {
            var value = new Tuple <bool, StringOrientation>(false, StringOrientation.Vertical);
            var node  = TargetNodes.FirstOrDefault();

            if (node != null && node.Properties.Contains(OrientationDescriptor._typeId))
            {
                var orientation = OrientationModule.GetOrientationForElement(node);
                switch (orientation)
                {
                case Orientation.Horizontal:
                    value = new Tuple <bool, StringOrientation>(true, StringOrientation.Horizontal);
                    break;

                default:
                    value = new Tuple <bool, StringOrientation>(true, StringOrientation.Vertical);
                    break;
                }
            }

            return(value);
        }
Exemplo n.º 7
0
        private int PixelsPerString()
        {
            int pps = PixelsPerString(TargetNodes.FirstOrDefault());

            return(pps);
        }