Exemplo n.º 1
0
		private void EffectPropertyEditorValueChanged(object sender, PropertyValueChangedEventArgs e)
		{
			Dictionary<Element, Tuple<Object, PropertyDescriptor>> elementValues = new Dictionary<Element, Tuple<object, PropertyDescriptor>>();

			int i = 0;
			foreach (var element in _elements)
			{
				element.UpdateNotifyContentChanged();
				elementValues.Add(element, new Tuple<object, PropertyDescriptor>(e.OldValue[i], e.Property.UnderLyingPropertyDescriptor(i)));
				i++;
			}

			var undo = new EffectsPropertyModifiedUndoAction(elementValues);
			_sequenceEditorForm.AddEffectsModifiedToUndo(undo);
		}
Exemplo n.º 2
0
 private void CompleteDrop(Dictionary<Element, Tuple<object, PropertyDescriptor>> elementValues, Element element, string type)
 {
     if (elementValues.Any())
     {
         var undo = new EffectsPropertyModifiedUndoAction(elementValues);
         AddEffectsModifiedToUndo(undo);
         TimelineControl.grid.ClearSelectedElements();
         TimelineControl.SelectElement(element);
         UpdateToolStrip4(
             string.Format("{2} applied to {0} {1} effect(s).", elementValues.Count(), element.EffectNode.Effect.EffectName, type), 30);
     }
 }
Exemplo n.º 3
0
 public void AddEffectsModifiedToUndo(EffectsPropertyModifiedUndoAction modifiedElements)
 {
     _undoMgr.AddUndoAction(modifiedElements);
 }
Exemplo n.º 4
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();
        }