Inheritance: EffectsAddedRemovedUndoAction
示例#1
0
 protected void DrawElement(object sender, DrawElementEventArgs e)
 {
     //Make sure we have enough of an effect to show up
         if (e.Duration > TimeSpan.FromSeconds(.010))
         {
             var newEffects = new List<EffectNode>();
             foreach (Row drawingRow in e.Rows)
             {
                 var newEffect = ApplicationServices.Get<IEffectModuleInstance>(e.Guid);
                 try
                 {
                     newEffects.Add(CreateEffectNode(newEffect, drawingRow, e.StartTime,e.Duration));
                 }
                 catch (Exception ex)
                 {
                     string msg = "TimedSequenceEditor DrawMultipleElements: error adding effect of type " + newEffect.Descriptor.TypeId + " to row " +
                                     ((drawingRow == null) ? "<null>" : drawingRow.Name);
                     Logging.ErrorException(msg, ex);
                 }
             }
             AddEffectNodes(newEffects);
             sequenceModified();
             var act = new EffectsAddedUndoAction(this, newEffects);
             _undoMgr.AddUndoAction(act);
             SelectEffectNodes(newEffects);
         }
 }
示例#2
0
        private List<Element> CloneElements(IEnumerable<Element> elements)
        {
            var newElements = new List<Element>();
            foreach (var element in elements)
            {
                var newEffect = ApplicationServices.Get<IEffectModuleInstance>(element.EffectNode.Effect.TypeId);
                newEffect.ModuleData = element.EffectNode.Effect.ModuleData.Clone();

                try
                {
                    // get the target element
                    var targetNode = (ElementNode)element.Row.Tag;

                    // populate the given effect instance with the appropriate target node and times, and wrap it in an effectNode
                    newEffect.TargetNodes = new[] { targetNode };
                    newEffect.TimeSpan = element.Duration;
                    var effectNode = new EffectNode(newEffect, element.StartTime);

                    // put it in the sequence and in the timeline display
                    newElements.Add(AddEffectNode(effectNode));

                } catch (Exception ex)
                {
                    string msg = "TimedSequenceEditor CloneElements: error adding effect of type " + newEffect.Descriptor.TypeId + " to row " +
                                 ((element.Row == null) ? "<null>" : element.Row.Name);
                    Logging.ErrorException(msg, ex);
                }
            }

            sequenceModified();

            //Add elements as a group to undo
            var act = new EffectsAddedUndoAction(this, newElements.Select(x => x.EffectNode).ToArray());
            _undoMgr.AddUndoAction(act);

            return newElements;
        }
示例#3
0
        private void AddMultipleEffects(TimeSpan StartTime, String EffectName, Guid EffectID, Row Row)
        {
            var eDialog = new Form_AddMultipleEffects();
            if (Control.ModifierKeys == (Keys.Shift | Keys.Control) && am_LastEffectCount > 0)
            {
                eDialog.EffectCount = am_LastEffectCount;
                eDialog.StartTime = am_LastStartTime;
                eDialog.Duration = am_LastDuration;
                eDialog.DurationBetween = am_LastDurationBetween;
            }
            else
            {
                eDialog.EffectCount = 2;
                eDialog.StartTime = StartTime;
                eDialog.Duration = TimeSpan.FromSeconds(2);
                eDialog.DurationBetween = TimeSpan.FromSeconds(2);
            }
            eDialog.EffectName = EffectName;
            eDialog.SequenceLength = eDialog.EndTime = SequenceLength;
            eDialog.MarkCollections = _sequence.MarkCollections;
            eDialog.ShowDialog();

            if (eDialog.DialogResult == DialogResult.OK)
            {
                am_LastEffectCount = eDialog.EffectCount;
                am_LastStartTime = eDialog.StartTime;
                am_LastDuration = eDialog.Duration;
                am_LastDurationBetween = eDialog.DurationBetween;

                var newEffects = new List<EffectNode>();

                if (eDialog.AlignToBeatMarks)
                {
                    newEffects = AddEffectsToBeatMarks(eDialog.CheckedMarks, eDialog.EffectCount, EffectID, eDialog.StartTime, eDialog.Duration, Row, eDialog.FillDuration, eDialog.SkipEOBeat);
                }
                else
                {
                    TimeSpan NextStartTime = eDialog.StartTime;
                    for (int i = 0; i < eDialog.EffectCount; i++)
                    {
                        if (NextStartTime + eDialog.Duration > SequenceLength)
                        {
                            //if something went wrong in the forms calculations
                            break;
                        }
                        else
                        {
                            var newEffect = ApplicationServices.Get<IEffectModuleInstance>(EffectID);
                            try
                            {
                                newEffects.Add(CreateEffectNode(newEffect, Row, NextStartTime, eDialog.Duration));
                                NextStartTime = NextStartTime + eDialog.Duration + eDialog.DurationBetween;
                            }
                            catch (Exception ex)
                            {
                                string msg = "TimedSequenceEditor AddMultipleElements: error adding effect of type " + newEffect.Descriptor.TypeId + " to row " +
                                             ((Row == null) ? "<null>" : Row.Name);
                                Logging.ErrorException(msg, ex);
                            }
                        }
                    }
                    AddEffectNodes(newEffects);
                    sequenceModified();
                    var act = new EffectsAddedUndoAction(this, newEffects);
                    _undoMgr.AddUndoAction(act);
                }
                if (newEffects.Count > 0)
                {
                    if (eDialog.SelectEffects || eDialog.EditEffects) SelectEffectNodes(newEffects);
                    if (eDialog.EditEffects && TimelineControl.SelectedElements.Any())
                    {
                        EditElements(TimelineControl.SelectedElements.Cast<TimedSequenceElement>());
                    }

                }
            }
        }
示例#4
0
        private List<EffectNode> AddEffectsToBeatMarks(ListView.CheckedListViewItemCollection CheckedMarks, int EffectCount, Guid EffectGuid, TimeSpan StartTime, TimeSpan Duration, Row Row, Boolean FillDuration, Boolean SkipEOBeat)
        {
            List<TimeSpan> Times = new List<TimeSpan>();
            bool SkipThisBeat = false;

            foreach (ListViewItem ListItem in CheckedMarks)
            {
                foreach (MarkCollection MCItem in _sequence.MarkCollections)
                {
                    if (MCItem.Name == ListItem.Text)
                    {
                        foreach (TimeSpan Mark in MCItem.Marks)
                        {
                            if (Mark >= StartTime) Times.Add(Mark);
                        }
                    }
                }
            }

            Times.Sort();

            var newEffects = new List<EffectNode>();

            if (Times.Count > 0)
            {
                foreach (TimeSpan Mark in Times)
                {
                    if (newEffects.Count < EffectCount)
                    {
                        if (!SkipEOBeat || (SkipEOBeat && !SkipThisBeat))
                        {
                            var newEffect = ApplicationServices.Get<IEffectModuleInstance>(EffectGuid);
                            try
                            {
                                if (FillDuration)
                                {
                                    if (Times.IndexOf(Mark) == Times.Count - 1) //The dialog hanles this, but just to make sure
                                        break; //We're done -- There are no more marks to fill, don't create it
                                    Duration = Times[Times.IndexOf(Mark) + 1] - Mark;
                                    if (Duration < TimeSpan.FromSeconds(.01)) Duration = TimeSpan.FromSeconds(.01);
                                }
                                newEffects.Add(CreateEffectNode(newEffect, Row, Mark, Duration));
                            }
                            catch (Exception ex)
                            {
                                string msg = "TimedSequenceEditor AddMultipleElements: error adding effect of type " + newEffect.Descriptor.TypeId + " to row " +
                                             ((Row == null) ? "<null>" : Row.Name);
                                Logging.ErrorException(msg, ex);
                            }
                        }
                        SkipThisBeat = (SkipThisBeat ? false : true);
                    }
                    else
                        break; //We're done creating, we've matched counts
                }

                AddEffectNodes(newEffects);
                sequenceModified();
                var act = new EffectsAddedUndoAction(this, newEffects);
                _undoMgr.AddUndoAction(act);
            }

            return newEffects;
        }
示例#5
0
        /// <summary>
        /// Wraps an effect instance in an EffectNode, adds it to the sequence, and an associated element to the timeline control.
        /// Adds a Undo record for the add as well.
        /// </summary>
        /// <param name="effectInstance">Effect instance</param>
        /// <param name="row">Common.Controls.Timeline.Row to add the effect instance to</param>
        /// <param name="startTime">The start time of the effect</param>
        /// <param name="timeSpan">The duration of the effect</param>
        private void addEffectInstance(IEffectModuleInstance effectInstance, Row row, TimeSpan startTime, TimeSpan timeSpan)
        {
            try
            {
                //Debug.WriteLine("{0}   addEffectInstance(InstanceId={1})", (int)DateTime.Now.TimeOfDay.TotalMilliseconds, effectInstance.InstanceId);

                if ((startTime + timeSpan) > SequenceLength)
                {
                    timeSpan = SequenceLength - startTime;
                }

                var effectNode = CreateEffectNode(effectInstance, row, startTime, timeSpan);

                // put it in the sequence and in the timeline display
                AddEffectNode(effectNode);
                sequenceModified();

                var act = new EffectsAddedUndoAction(this, new[] { effectNode });
                _undoMgr.AddUndoAction(act);
            }
            catch (Exception ex)
            {
                string msg = "TimedSequenceEditor: error adding effect of type " + effectInstance.Descriptor.TypeId + " to row " +
                             ((row == null) ? "<null>" : row.Name);
                Logging.ErrorException(msg, ex);
            }
        }
        /// <summary>
        /// Wraps an effect instance in an EffectNode, adds it to the sequence, and an associated element to the timeline control.
        /// </summary>
        /// <param name="effectInstance">Effect instance</param>
        /// <param name="row">Common.Controls.Timeline.Row to add the effect instance to</param>
        /// <param name="startTime">The start time of the effect</param>
        /// <param name="timeSpan">The duration of the effect</param>
        private void addEffectInstance(IEffectModuleInstance effectInstance, Row row, TimeSpan startTime, TimeSpan timeSpan)
        {
            try {
                //Debug.WriteLine("{0}   addEffectInstance(InstanceId={1})", (int)DateTime.Now.TimeOfDay.TotalMilliseconds, effectInstance.InstanceId);

                // get the target channel
                ChannelNode targetNode = (ChannelNode)row.Tag;

                // populate the given effect instance with the appropriate target node and times, and wrap it in an effectNode
                effectInstance.TargetNodes = new ChannelNode[] {targetNode};
                effectInstance.TimeSpan = timeSpan;
                EffectNode effectNode = new EffectNode(effectInstance, startTime);

                // put it in the sequence and in the timeline display
                TimedSequenceElement newElement = AddEffectNode(effectNode);
                sequenceModified();

                var act = new EffectsAddedUndoAction(this, new EffectNode[] {effectNode});
                _undoMgr.AddUndoAction(act);

            } catch(Exception ex) {
                string msg = "TimedSequenceEditor: error adding effect of type " + effectInstance.Descriptor.TypeId + " to row " + ((row == null) ? "<null>" : row.Name);
                VixenSystem.Logging.Error(msg, ex);
            }
        }