protected override void SetCurveValue(Curve c)
 {
     if (c != null)
     {
         Value = new GradientLevelPair(Value.ColorGradient, c);
     }
 }
Example #2
0
        public void OnDropCompleted(IDataObject obj, Point dropPoint)
        {
            var data = obj.GetData(ItemType);

            if (data != null && data.GetType() == ItemType)
            {
                Value = data;
            }
            //Our type does not match, so either we are applying Color to a Gradient or something to a GradientLevelPair
            else if (obj.GetDataPresent(typeof(Color)))
            {
                data = obj.GetData(typeof(Color));
                HandleColorDrop((Color)data);
            }
            else if (obj.GetDataPresent(typeof(ColorGradient)) && ItemType == typeof(GradientLevelPair))
            {
                var cg  = obj.GetData(typeof(ColorGradient)) as ColorGradient;
                var glp = (GradientLevelPair)Value;
                var newGradientLevelPair = new GradientLevelPair(cg, glp.Curve);
                Value = newGradientLevelPair;
            }
            else if (obj.GetDataPresent(typeof(Curve)) && ItemType == typeof(GradientLevelPair))
            {
                var c   = obj.GetData(typeof(Curve)) as Curve;
                var glp = (GradientLevelPair)Value;
                var newGradientLevelPair = new GradientLevelPair(glp.ColorGradient, c);
                Value = newGradientLevelPair;
            }
        }
 protected override void SetColorGradientValue(ColorGradient cg)
 {
     if (cg != null)
     {
         Value = new GradientLevelPair(cg, Value.Curve);
     }
 }
Example #4
0
        private void RenderElement(GradientLevelPair gradientLevelPair, TimeSpan startTime, TimeSpan interval,
                                   ElementNode element, EffectIntents effectIntents)
        {
            var result = PulseRenderer.RenderNode(element, gradientLevelPair.Curve, gradientLevelPair.ColorGradient, interval, HasDiscreteColors);

            result.OffsetAllCommandsByTime(startTime);
            effectIntents.Add(result);
        }
Example #5
0
        private void RenderElement(Pulse.Pulse pulse, GradientLevelPair gradientLevelPair, TimeSpan startTime,
                                   ElementNode element, EffectIntents effectIntents)
        {
            pulse.ColorGradient = gradientLevelPair.ColorGradient;
            pulse.LevelCurve    = gradientLevelPair.Curve;
            pulse.TargetNodes   = new[] { element };

            var result = pulse.Render();

            result.OffsetAllCommandsByTime(startTime);
            effectIntents.Add(result);
        }
Example #6
0
 private void HandleColorDrop(Color c)
 {
     if (ItemType == typeof(ColorGradient))
     {
         Value = new ColorGradient(c);
     }
     else if (ItemType == typeof(GradientLevelPair))
     {
         var glp = (GradientLevelPair)Value;
         var newGradientLevelPair = new GradientLevelPair(new ColorGradient(c), glp.Curve);
         Value = newGradientLevelPair;
     }
 }
Example #7
0
        private void OnShowGradientLevelCurveCommand(object sender, ExecutedRoutedEventArgs e)
        {
            var collectionItem = e.Parameter as CollectionItemValue;

            if (collectionItem != null)
            {
                var grid = sender as EffectPropertyEditorGrid;
                if (grid != null)
                {
                    Editors.Editor    editor = grid.GetEditors().GetEditor(typeof(Curve));
                    GradientLevelPair glp    = collectionItem.Value as GradientLevelPair;
                    if (glp != null)
                    {
                        var newValue = editor.ShowDialog(collectionItem.ParentProperty, glp.Curve, this);
                        if (newValue is Curve)
                        {
                            var newGradientLevelPair = new GradientLevelPair(glp.ColorGradient, (Curve)newValue);
                            collectionItem.Value = newGradientLevelPair;
                        }
                    }
                }
            }
        }
Example #8
0
        // 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(List <IElementNode> elements)
        {
            _strobeClass = new List <StrobeClass>();
            EffectIntents effectIntents = new EffectIntents();
            var           startTime     = TimeSpan.Zero;
            double        intervalPos   = GetEffectTimeIntervalPosition(startTime) * 100;
            double        interval;
            int           i = 0;

            if (StrobeSource != StrobeSource.TimeInterval)
            {
                SetupMarks();
                if (_marks == null || _strobeClass.Count == 0)
                {
                    return(effectIntents);
                }
                interval = _strobeClass[i].CycleTime;
            }
            else
            {
                interval = StrobeMode == StrobeMode.Simple ? CycleTime : CalculateInterval(intervalPos);
            }

            TimeSpan intervalTime = TimeSpan.FromMilliseconds(interval);
            TimeSpan onDuration   = TimeSpan.FromMilliseconds(interval * (StrobeMode == StrobeMode.Simple ? 0.5 : OnTimeCurve.GetValue(intervalPos) / 100));

            // Continue until the intent start time is >= effect duration.
            do
            {
                // Adjust the onDuration if intent end time is greater then the next marks start time.
                if (StrobeSource != StrobeSource.TimeInterval && (onDuration + startTime).TotalMilliseconds >
                    _strobeClass[i + 1].StartTime.TotalMilliseconds)
                {
                    onDuration = TimeSpan.FromMilliseconds((_strobeClass[i + 1].StartTime.TotalMilliseconds - 1 - startTime.TotalMilliseconds) / 2);
                }

                foreach (IElementNode element in elements)
                {
                    var glp = new GradientLevelPair(Colors, IntensityCurve);
                    RenderElement(glp, startTime, onDuration.Subtract(TimeSpan.FromMilliseconds(1)), element,
                                  effectIntents);
                }

                startTime   = startTime + intervalTime;
                intervalPos = GetEffectTimeIntervalPosition(startTime) * 100;

                // Get next Interval
                if (StrobeSource != StrobeSource.TimeInterval)
                {
                    if (_strobeClass[i + 1].StartTime.TotalMilliseconds < startTime.TotalMilliseconds)
                    {
                        i++;
                        startTime = _strobeClass[i].StartTime;
                        if (i > _strobeClass.Count - 1)
                        {
                            break;
                        }
                    }
                    interval = _strobeClass[i].CycleTime;
                }
                else
                {
                    interval = StrobeMode == StrobeMode.Simple ? CycleTime : CalculateInterval(intervalPos);
                }

                onDuration   = TimeSpan.FromMilliseconds(interval * (StrobeMode == StrobeMode.Simple ? 0.5 : OnTimeCurve.GetValue(intervalPos) / 100));
                intervalTime = TimeSpan.FromMilliseconds(interval);
            } while (startTime.TotalMilliseconds < TimeSpan.TotalMilliseconds);

            _strobeClass = null;
            return(effectIntents);
        }