Пример #1
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>());
                    }

                }
            }
        }
Пример #2
0
        private void AddMultipleEffects(TimeSpan startTime, String effectName, Guid effectId, Row row)
        {
            var eDialog = new Form_AddMultipleEffects();
            if (ModifierKeys == (Keys.Shift | Keys.Control) && _amLastEffectCount > 0)
            {
                eDialog.EffectCount = _amLastEffectCount;
                eDialog.StartTime = _amLastStartTime;
                eDialog.Duration = _amLastDuration;
                eDialog.DurationBetween = _amLastDurationBetween;
            }
            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)
            {
                _amLastEffectCount = eDialog.EffectCount;
                _amLastStartTime = eDialog.StartTime;
                _amLastDuration = eDialog.Duration;
                _amLastDurationBetween = 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;
                        }

                        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: <AddMultipleEffects> - error adding effect of type " + newEffect.Descriptor.TypeId + " to row " +
                                         ((row == null) ? "<null>" : row.Name);
                                Logging.Error(msg, ex);
                        }
                    }
                    AddEffectNodes(newEffects);
                    SequenceModified();
                    var act = new EffectsAddedUndoAction(this, newEffects);
                    _undoMgr.AddUndoAction(act);
                }
                if (newEffects.Count > 0)
                {
                    if (eDialog.SelectEffects) SelectEffectNodes(newEffects);
                }
            }
        }