当前位置: 首页>>代码示例>>C#>>正文


C# ElementNode.GetLeafEnumerator方法代码示例

本文整理汇总了C#中ElementNode.GetLeafEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# ElementNode.GetLeafEnumerator方法的具体用法?C# ElementNode.GetLeafEnumerator怎么用?C# ElementNode.GetLeafEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElementNode的用法示例。


在下文中一共展示了ElementNode.GetLeafEnumerator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderNode

        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            if (!AudioUtilities.AudioLoaded)
                return;

            foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;
                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);

                for(int i = 0;i<(int)((TimeSpan.TotalMilliseconds/Spacing)-1);i++)
                {

                    double gradientPosition1 = (AudioUtilities.VolumeAtTime(i * Spacing) + Data.Range)/Data.Range ;
                    double gradientPosition2 = (AudioUtilities.VolumeAtTime((i+1) * Spacing) + Data.Range)/Data.Range;
                    if (gradientPosition1 <= 0)
                        gradientPosition1 = 0;
                    if (gradientPosition1 >= 1)
                        gradientPosition1 = 1;

                    //Some odd corner cases
                    if (gradientPosition2 <= 0)
                        gradientPosition2 = 0;
                    if (gradientPosition2 >= 1)
                        gradientPosition2 = 1;
                    TimeSpan startTime = TimeSpan.FromMilliseconds(i * Spacing);
                    ElementData.Add(GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition1, gradientPosition2, TimeSpan.FromMilliseconds(Spacing), startTime, discreteColors));

                }

            }
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:37,代码来源:VUMeter.cs

示例2: RenderNode

        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        public static EffectIntents RenderNode(ElementNode node, Curve levelCurve, ColorGradient colorGradient, TimeSpan duration, bool isDiscrete, bool allowZeroIntensity = false)
        {
            //Collect all the points first.
            double[] allPointsTimeOrdered = _GetAllSignificantDataPoints(levelCurve, colorGradient).ToArray();
            var elementData = new EffectIntents();
            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;

                //ElementColorType colorType = ColorModule.getColorTypeForElementNode(elementNode);

                if (isDiscrete && IsElementDiscrete(node))
                {
                    IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false)
                         .Intersect(colorGradient.GetColorsInGradient());
                    foreach (Color color in colors)
                    {
                        AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity, color);
                    }
                }
                else
                {
                    AddIntentsToElement(elementNode.Element, allPointsTimeOrdered, levelCurve, colorGradient, duration, elementData, allowZeroIntensity);
                }
            }

            return elementData;
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:34,代码来源:PulseRenderer.cs

示例3: RenderNode

        //(Numbers represent color/curve pairs, rows are elements columns are intervals)
        //12341234
        //23412341
        //34123412
        //41234123
        //An offset of 2
        //12341234
        //34123412
        //12341234
        //34123412
        //Offset 3
        //12341234
        //41234123
        //23412341
        //12341234
        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private EffectIntents RenderNode(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();
            int intervals = 1;
            var gradientLevelItem = 0;
            var startIndexOffset = 0;
            //make local hold variables to prevent changes in the middle of rendering.
            int group = GroupLevel;
            var skip = IntervalSkipCount;
            int colorCount = Colors.Count();
            //Use a single pulse to do our work, we don't need to keep creating it and then thowing it away making the GC work
            //hard for no reason.

            if (!EnableStatic)
            {
                intervals = Convert.ToInt32(Math.Ceiling(TimeSpan.TotalMilliseconds/Interval));
            }

            var startTime = TimeSpan.Zero;
            var nodes = node.GetLeafEnumerator();

            var intervalTime = intervals == 1
                    ? TimeSpan
                    : TimeSpan.FromMilliseconds(Interval);

            for (int i = 0; i < intervals; i++)
            {
                var elements = nodes.Select((x, index) => new { x, index })
                    .GroupBy(x => x.index / group, y => y.x);

                foreach (IGrouping<int, ElementNode> elementGroup in elements)
                {
                    var glp = Colors[gradientLevelItem];
                    foreach (var element in elementGroup)
                    {
                        RenderElement(glp, startTime, intervalTime, element, effectIntents);
                    }
                    gradientLevelItem = ++gradientLevelItem % colorCount;

                }

                startIndexOffset = (skip+startIndexOffset) % colorCount;
                gradientLevelItem = startIndexOffset;

                startTime += intervalTime;
            }

            return effectIntents;
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:66,代码来源:Alternating.cs

示例4: RenderNode

        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private void RenderNode(ElementNode node)
        {
            bool altColor = false;
            bool startingColor = false;
            double intervals = 1;

            if (Enable) {
                //intervals = Math.DivRem((long)TimeSpan.TotalMilliseconds, (long)Interval, out rem);
                intervals = Math.Ceiling(TimeSpan.TotalMilliseconds / (double)Interval);
            }

            TimeSpan startTime = TimeSpan.Zero;

            for (int i = 0; i < intervals; i++) {
                altColor = startingColor;
                var intervalTime = intervals == 1
                                    ? TimeSpan
                                    : TimeSpan.FromMilliseconds(Interval);

                LightingValue? lightingValue = null;

                int totalElements = node.Count();
                int currentNode = 0;

                var nodes = node.GetLeafEnumerator();

                while (currentNode < totalElements) {

                    var elements = nodes.Skip(currentNode).Take(GroupEffect);

                    currentNode += GroupEffect;

                    int cNode = 0;
                    elements.ToList().ForEach(element => {
                        RenderElement(altColor, ref startTime, ref intervalTime, ref lightingValue, element);
                        cNode++;
                    });
                    altColor = !altColor;
                }

                startTime += intervalTime;
                startingColor = !startingColor;
            }
        }
开发者ID:Jchuchla,项目名称:vixen,代码行数:46,代码来源:Alternating.cs

示例5: RenderNode

        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private EffectIntents RenderNode(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();
            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {

                if (HasDiscreteColors && IsElementDiscrete(elementNode))
                {
                    IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false);
                    if (!colors.Contains(Color))
                    {
                        continue;
                    }
                }

                var intent = CreateIntent(elementNode, Color, (float)HSV.FromRGB(Color).V * IntensityLevel, TimeSpan);
                effectIntents.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
            }

            return effectIntents;
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:23,代码来源:SetLevel.cs

示例6: RenderNode

        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            if (!AudioUtilities.AudioLoaded)
                return;

            int currentElement = 0;

            var nodeCount = 0;
            if (Inverted)
            {
                nodeCount = node.GetLeafEnumerator().Count();
            }

            foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;

                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);

                for (int i = 1;i<(int)(TimeSpan.TotalMilliseconds/Spacing);i++)
                {
                    int startAudioTime;
                    int endAudioTime;
                    if (Inverted)
                    {
                        startAudioTime = i * Spacing - (nodeCount-currentElement) * ((WaveformData)Data).ScrollSpeed + 1;
                        endAudioTime = (i + 1) * Spacing - (nodeCount-currentElement) * ((WaveformData)Data).ScrollSpeed;
                    }
                    else
                    {
                        startAudioTime = i * Spacing - currentElement * ((WaveformData)Data).ScrollSpeed + 1;
                        endAudioTime = (i + 1) * Spacing - currentElement * ((WaveformData)Data).ScrollSpeed;
                    }
                    TimeSpan startTime = TimeSpan.FromMilliseconds(i * Spacing);

                    if (startAudioTime > 0 && startAudioTime < TimeSpan.TotalMilliseconds && endAudioTime > 0 && endAudioTime < TimeSpan.TotalMilliseconds)
                    {

                        double gradientPosition1 = (AudioUtilities.VolumeAtTime(startAudioTime) + Data.Range) / Data.Range;
                        double gradientPosition2 = (AudioUtilities.VolumeAtTime(endAudioTime) + Data.Range) / Data.Range;

                        //Some odd corner cases
                        if (gradientPosition1 <= 0)
                            gradientPosition1 = 0;
                        if (gradientPosition1 >= 1)
                            gradientPosition1 = 1;

                        //Some odd corner cases
                        if (gradientPosition2 <= 0)
                            gradientPosition2 = 0;
                        if (gradientPosition2 >= 1)
                            gradientPosition2 = 1;

                        ElementData.Add(GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition1, gradientPosition2, TimeSpan.FromMilliseconds(Spacing), startTime, discreteColors));

                    }
                }
                currentElement++;
            }
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:65,代码来源:Waveform.cs

示例7: RenderNode

		// renders the given node to the internal ElementData dictionary. If the given node is
		// not a element, will recursively descend until we render its elements.
		private void RenderNode(ElementNode node)
		{
			//Collect all the points first.
			double[] allPointsTimeOrdered = _GetAllSignificantDataPoints().ToArray();
			foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
				// this is probably always going to be a single element for the given node, as
				// we have iterated down to leaf nodes in RenderNode() above. May as well do
				// it this way, though, in case something changes in future.
				if (elementNode == null || elementNode.Element == null)
					continue;

				ElementColorType colorType = ColorModule.getColorTypeForElementNode(elementNode);

				if (colorType == ElementColorType.FullColor) {
					addIntentsToElement(elementNode.Element, allPointsTimeOrdered);
				}
				else {
					IEnumerable<Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false)
						 .Intersect(ColorGradient.GetColorsInGradient());
					foreach (Color color in colors) {
						addIntentsToElement(elementNode.Element, allPointsTimeOrdered, color);	
					}
				}
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:27,代码来源:Pulse.cs

示例8: RenderNode

        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        protected override void RenderNode(ElementNode node)
        {
            int currentElement = 0;

            int elementCount = node.GetLeafEnumerator().Count();

               foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
                // this is probably always going to be a single element for the given node, as
                // we have iterated down to leaf nodes in RenderNode() above. May as well do
                // it this way, though, in case something changes in future.
                if (elementNode == null || elementNode.Element == null)
                    continue;

                if (!AudioUtilities.AudioLoaded)
                    return;
                bool discreteColors = ColorModule.isElementNodeDiscreteColored(elementNode);
                var lastTime = TimeSpan.FromMilliseconds(0);

                double gradientPosition = (double)(currentElement) / elementCount;

                //Audio max is at 0db. The threshold gets shifted from 0 to 1 to -1 to 0 and then scaled.
                double threshold;
                if (!((VerticalMeterData)Data).Inverted)
                {
                    threshold = (((double)(elementCount - currentElement)) / elementCount - 1) * Data.Range;
                    gradientPosition = 1 - gradientPosition;
                }
                else
                {
                    threshold = (((double)currentElement) / elementCount - 1) * Data.Range;

                }

               var lastValue = AudioUtilities.VolumeAtTime(0) >= threshold;

                TimeSpan start;
                for(int i = 1;i<(int)(TimeSpan.TotalMilliseconds/Spacing);i++)
                {
                    //Current time in ms = i*spacing
                    var currentValue = AudioUtilities.VolumeAtTime(i * Spacing) >= threshold;

                    if( currentValue != lastValue) {
                        start = lastTime;

                        if(lastValue)
                        {
                            var effectIntents = GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition,
                                gradientPosition, TimeSpan.FromMilliseconds(i*Spacing) - lastTime, start, discreteColors);
                            ElementData.Add(effectIntents);
                        }

                        lastTime = TimeSpan.FromMilliseconds(i * Spacing);
                        lastValue = currentValue;
                    }
                }

                if (lastValue)
                {
                    start = lastTime;
                    var effectIntents = GenerateEffectIntents(elementNode, WorkingGradient, MeterIntensityCurve, gradientPosition,
                                gradientPosition, TimeSpan - lastTime, start, discreteColors);
                    ElementData.Add(effectIntents);
                }

                currentElement++;
            }
        }
开发者ID:jaredb7,项目名称:vixen,代码行数:69,代码来源:VerticalMeter.cs

示例9: RenderNode

        // renders the given node to the internal ElementData dictionary. If the given node is
        // not a element, will recursively descend until we render its elements.
        private EffectIntents RenderNode(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();
            foreach (ElementNode elementNode in node.GetLeafEnumerator())
            {
                var intent = CreateIntent(elementNode, Color, (float) HSV.FromRGB(Color).V * IntensityLevel, TimeSpan);
                effectIntents.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
            }

            return effectIntents;
        }
开发者ID:eberletj,项目名称:vixen,代码行数:13,代码来源:SetLevel.cs

示例10: RenderNode

		// renders the given node to the internal ElementData dictionary. If the given node is
		// not a element, will recursively descend until we render its elements.
		private void RenderNode(ElementNode node)
		{
			foreach (ElementNode elementNode in node.GetLeafEnumerator()) {
				LightingValue lightingValue = new LightingValue(Color, (float) IntensityLevel);
				IIntent intent = new LightingIntent(lightingValue, lightingValue, TimeSpan);
				_elementData.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:10,代码来源:SetLevel.cs


注:本文中的ElementNode.GetLeafEnumerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。