示例#1
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);
 }
示例#2
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);
        }
示例#3
0
        private void ApplyColorCollection(ColorCollection collection, bool randomOrder)
        {
            if (!collection.Color.Any())
                return;

            bool skipElements = false;
            int index = 0;

            foreach (Element elem in TimelineControl.SelectedElements)
            {
                if (!SupportsColor(elem))
                {
                    skipElements = true;
                    continue;
                }
                var colors = GetSupportedColorsFromCollection(elem, collection.Color);

                var properties = MetadataRepository.GetProperties(elem.EffectNode.Effect).Where(x => (x.PropertyType == typeof(Color) ||
                    x.PropertyType == typeof(ColorGradient) || x.PropertyType == typeof(List<ColorGradient>) || x.PropertyType == typeof(List<GradientLevelPair>)) && x.IsBrowsable);

                Dictionary<Element, Tuple<Object, PropertyDescriptor>> elementValues = new Dictionary<Element, Tuple<object, PropertyDescriptor>>();

                foreach (var propertyData in properties)
                {

                    if (propertyData.PropertyType == typeof (Color))
                    {
                        var color = randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count];
                        elementValues.Add(elem,
                            new Tuple<object, PropertyDescriptor>(propertyData.Descriptor.GetValue(elem.EffectNode.Effect),
                                propertyData.Descriptor));
                        UpdateEffectProperty(propertyData.Descriptor, elem, color);
                    }
                    else
                    {
                        //The rest take a gradient.
                        if (propertyData.PropertyType == typeof(ColorGradient))
                        {
                            var color = randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count];
                            elementValues.Add(elem,
                                new Tuple<object, PropertyDescriptor>(propertyData.Descriptor.GetValue(elem.EffectNode.Effect),
                                    propertyData.Descriptor));
                            UpdateEffectProperty(propertyData.Descriptor, elem, new ColorGradient(color));
                        }
                        else if (propertyData.PropertyType == typeof(List<ColorGradient>))
                        {
                            var gradients = propertyData.Descriptor.GetValue(elem.EffectNode.Effect) as List<ColorGradient>;
                            if (gradients != null)
                            {
                                var newGradients = gradients.ToList();
                                for (int i = 0; i < newGradients.Count; i++)
                                {
                                    newGradients[i] =
                                        new ColorGradient(randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count]);
                                }
                                elementValues.Add(elem,
                                    new Tuple<object, PropertyDescriptor>(gradients,
                                        propertyData.Descriptor));
                                UpdateEffectProperty(propertyData.Descriptor, elem, newGradients);
                            }

                        }
                        else if (propertyData.PropertyType == typeof(List<GradientLevelPair>))
                        {
                            var gradients = propertyData.Descriptor.GetValue(elem.EffectNode.Effect) as List<GradientLevelPair>;
                            if (gradients != null)
                            {
                                var newGradients = gradients.ToList();
                                for (int i = 0; i < newGradients.Count; i++)
                                {
                                    newGradients[i] = new GradientLevelPair(new ColorGradient(randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count]), new Curve(gradients[i].Curve));
                                }
                                elementValues.Add(elem,
                                    new Tuple<object, PropertyDescriptor>(gradients,
                                        propertyData.Descriptor));
                                UpdateEffectProperty(propertyData.Descriptor, elem, newGradients);
                            }

                        }

                    }
                }

                if (elementValues.Any())
                {
                    var undo = new EffectsPropertyModifiedUndoAction(elementValues);
                    AddEffectsModifiedToUndo(undo);
                }
            }

            if (skipElements)
            {
                MessageBoxForm.msgIcon = SystemIcons.Information; //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("One or more effects were selected that do not support colors.\nAll effects that do were updated.",
                                    @"Information", true, false);
                messageBox.ShowDialog();
            }
            SequenceModified();
        }
示例#4
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;
			}
		}
示例#5
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;
			}
		}
示例#6
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;
						}
					}
					
				}

			}
		}