예제 #1
0
        private void timelineControl_ContextSelected(object sender, ContextSelectedEventArgs e)
        {
            _contextMenuStrip.Items.Clear();

            Element element          = e.ElementsUnderCursor.FirstOrDefault();
            TimedSequenceElement tse = element as TimedSequenceElement;

            #region Add Effect

            ToolStripMenuItem contextMenuItemAddEffect = new ToolStripMenuItem("Add Effect(s)")
            {
                Image = Resources.effects
            };
            IEnumerable <IEffectModuleDescriptor> effectDesriptors =
                ApplicationServices.GetModuleDescriptors <IEffectModuleInstance>()
                .Cast <IEffectModuleDescriptor>()
                .OrderBy(x => x.EffectGroup)
                .ThenBy(n => n.EffectName);
            EffectGroups group = effectDesriptors.First().EffectGroup;
            foreach (IEffectModuleDescriptor effectDesriptor in effectDesriptors)
            {
                if (effectDesriptor.EffectName == "Nutcracker")
                {
                    continue;                                                             //Remove this when the Nutcracker module is removed
                }
                if (effectDesriptor.EffectGroup != group)
                {
                    ToolStripSeparator seperator = new ToolStripSeparator();
                    contextMenuItemAddEffect.DropDownItems.Add(seperator);
                    group = effectDesriptor.EffectGroup;
                }
                // Add an entry to the menu
                ToolStripMenuItem contextMenuItemEffect = new ToolStripMenuItem(effectDesriptor.EffectName);
                contextMenuItemEffect.Image       = effectDesriptor.GetRepresentativeImage();
                contextMenuItemEffect.Tag         = effectDesriptor.TypeId;
                contextMenuItemEffect.ToolTipText = @"Use Shift key to add multiple effects of the same type.";
                contextMenuItemEffect.Click      += (mySender, myE) =>
                {
                    if (e.Row != null)
                    {
                        //add multiple
                        if (ModifierKeys == Keys.Shift || ModifierKeys == (Keys.Shift | Keys.Control))
                        {
                            AddMultipleEffects(e.GridTime, effectDesriptor.EffectName, (Guid)contextMenuItemEffect.Tag, e.Row);
                        }
                        else                         //add single
                        {
                            AddNewEffectById((Guid)contextMenuItemEffect.Tag, e.Row, e.GridTime, TimeSpan.FromSeconds(2), true);
                        }
                    }
                };

                contextMenuItemAddEffect.DropDownItems.Add(contextMenuItemEffect);
            }

            _contextMenuStrip.Items.Add(contextMenuItemAddEffect);

            #endregion

            #region Layer Section

            ConfigureLayerMenu(e);

            #endregion

            #region Effect Alignment Section

            ToolStripMenuItem contextMenuItemAlignment = new ToolStripMenuItem("Alignment")
            {
                Enabled = TimelineControl.grid.OkToUseAlignmentHelper(TimelineControl.SelectedElements),
                Image   = Resources.alignment
            };
            //Disables the Alignment menu if too many effects are selected in a row.
            if (!contextMenuItemAlignment.Enabled)
            {
                contextMenuItemAlignment.ToolTipText = @"Disabled, maximum selected effects per row is 32.";
            }

            ToolStripMenuItem contextMenuItemAlignStart = new ToolStripMenuItem("Align Start Times")
            {
                ToolTipText = @"Holding shift will align the start times, while holding duration.",
                Image       = Resources.alignStart
            };
            contextMenuItemAlignStart.Click +=
                (mySender, myE) =>
                TimelineControl.grid.AlignElementStartTimes(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);
            contextMenuItemAlignStart.ShortcutKeyDisplayString = @"(Shift)+S";

            ToolStripMenuItem contextMenuItemAlignEnd = new ToolStripMenuItem("Align End Times")
            {
                ToolTipText = @"Holding shift will align the end times, while holding duration.",
                Image       = Resources.alignEnd
            };
            contextMenuItemAlignEnd.Click +=
                (mySender, myE) =>
                TimelineControl.grid.AlignElementEndTimes(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);
            contextMenuItemAlignEnd.ShortcutKeyDisplayString = @"(Shift)+E";

            ToolStripMenuItem contextMenuItemAlignBoth = new ToolStripMenuItem("Align Both Times")
            {
                Image = Resources.alignBoth
            };
            contextMenuItemAlignBoth.Click +=
                (mySender, myE) => TimelineControl.grid.AlignElementStartEndTimes(TimelineControl.SelectedElements, element);
            contextMenuItemAlignBoth.ShortcutKeyDisplayString = @"B";

            ToolStripMenuItem contextMenuItemMatchDuration = new ToolStripMenuItem("Match Duration")
            {
                ToolTipText =
                    @"Holding shift will hold the effects end time and adjust the start time, by default the end time is adjusted.",
                Image = Resources.matchDuration
            };
            contextMenuItemMatchDuration.Click +=
                (mySender, myE) =>
                TimelineControl.grid.AlignElementDurations(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);
            contextMenuItemMatchDuration.ShortcutKeyDisplayString = @"(Shift)";

            ToolStripMenuItem contextMenuItemAlignStartToEnd = new ToolStripMenuItem("Align Start to End")
            {
                ToolTipText =
                    @"Holding shift will hold the effects end time and only adjust the start time, by default the entire effect is moved.",
                Image = Resources.alignStartEnd
            };
            contextMenuItemAlignStartToEnd.Click +=
                (mySender, myE) =>
                TimelineControl.grid.AlignElementStartToEndTimes(TimelineControl.SelectedElements, element,
                                                                 ModifierKeys == Keys.Shift);
            contextMenuItemAlignStartToEnd.ShortcutKeyDisplayString = @"(Shift)";

            ToolStripMenuItem contextMenuItemAlignEndToStart = new ToolStripMenuItem("Align End to Start")
            {
                ToolTipText =
                    @"Holding shift will hold the effects start time and only adjust the end time, by default the entire effect is moved.",
                Image = Resources.alignStartEnd
            };
            contextMenuItemAlignEndToStart.Click +=
                (mySender, myE) =>
                TimelineControl.grid.AlignElementEndToStartTime(TimelineControl.SelectedElements, element,
                                                                ModifierKeys == Keys.Shift);
            contextMenuItemAlignEndToStart.ShortcutKeyDisplayString = @"(Shift)";

            ToolStripMenuItem contextMenuItemDistDialog = new ToolStripMenuItem("Distribute Effects")
            {
                Image = Resources.distribute
            };
            contextMenuItemDistDialog.Click += (mySender, myE) => DistributeSelectedEffects();

            ToolStripMenuItem contextMenuItemAlignCenter = new ToolStripMenuItem("Align Centerpoints")
            {
                Image = Resources.alignCenter
            };
            contextMenuItemAlignCenter.Click +=
                (mySender, myE) => TimelineControl.grid.AlignElementCenters(TimelineControl.SelectedElements, element);

            ToolStripMenuItem contextMenuItemDistributeEqually = new ToolStripMenuItem("Distribute Equally")
            {
                ToolTipText =
                    @"This will stair step the selected elements, starting with the element that has the earlier start mouseLocation on the time line.",
                Image = Resources.distribute
            };
            contextMenuItemDistributeEqually.Click += (mySender, myE) => DistributeSelectedEffectsEqually();

            ToolStripMenuItem contextMenuItemAlignStartToMark = new ToolStripMenuItem("Align Start to nearest mark")
            {
                Image = Resources.alignStartMark
            };
            contextMenuItemAlignStartToMark.Click += (mySender, myE) => AlignEffectsToNearestMarks("Start");
            contextMenuItemAlignStartToMark.ShortcutKeyDisplayString = @"Ctrl+Shift+S";

            ToolStripMenuItem contextMenuItemAlignEndToMark = new ToolStripMenuItem("Align End to nearest mark")
            {
                Image = Resources.alignEndMark
            };
            contextMenuItemAlignEndToMark.Click += (mySender, myE) => AlignEffectsToNearestMarks("End");
            contextMenuItemAlignEndToMark.ShortcutKeyDisplayString = @"Ctrl+Shift+E";

            ToolStripMenuItem contextMenuItemAlignBothToMark = new ToolStripMenuItem("Align Both to nearest mark")
            {
                Image = Resources.alignBothMark
            };
            contextMenuItemAlignBothToMark.Click += (mySender, myE) => AlignEffectsToNearestMarks("Both");
            contextMenuItemAlignBothToMark.ShortcutKeyDisplayString = @"Ctrl+Shift+B";

            _contextMenuStrip.Items.Add(contextMenuItemAlignment);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignStart);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignEnd);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignBoth);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignCenter);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemMatchDuration);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignStartToEnd);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignEndToStart);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemDistributeEqually);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemDistDialog);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignStartToMark);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignEndToMark);
            contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignBothToMark);

            if (TimelineControl.SelectedElements.Count() > 1 || (TimelineControl.SelectedElements.Any() && !element.Selected))
            {
                contextMenuItemDistributeEqually.Enabled = true;
                contextMenuItemDistDialog.Enabled        = true;
                contextMenuItemAlignStart.Enabled        = true;
                contextMenuItemAlignEnd.Enabled          = true;
                contextMenuItemAlignBoth.Enabled         = true;
                contextMenuItemAlignCenter.Enabled       = true;
                contextMenuItemMatchDuration.Enabled     = true;
                contextMenuItemAlignEndToStart.Enabled   = true;
                contextMenuItemAlignStartToEnd.Enabled   = true;
                contextMenuItemAlignment.Enabled         = true;
                contextMenuItemAlignment.ToolTipText     = string.Empty;
            }
            else
            {
                contextMenuItemDistributeEqually.Enabled = false;
                contextMenuItemDistDialog.Enabled        = false;
                contextMenuItemAlignStart.Enabled        = false;
                contextMenuItemAlignEnd.Enabled          = false;
                contextMenuItemAlignBoth.Enabled         = false;
                contextMenuItemAlignCenter.Enabled       = false;
                contextMenuItemMatchDuration.Enabled     = false;
                contextMenuItemAlignEndToStart.Enabled   = false;
                contextMenuItemAlignStartToEnd.Enabled   = false;
                contextMenuItemAlignment.Enabled         = false;
                if (TimelineControl.SelectedElements.Count() == 1)
                {
                    contextMenuItemAlignment.ToolTipText =
                        @"Select more then one effect or ensure you have Marks added to enable the Alignment feature.";
                }
                else
                {
                    contextMenuItemAlignment.ToolTipText = @"Select more then one effect to enable the Alignment feature.";
                }
            }

            contextMenuItemAlignStartToMark.Enabled = false;
            contextMenuItemAlignEndToMark.Enabled   = false;
            contextMenuItemAlignBothToMark.Enabled  = false;

            foreach (MarkCollection mc in _sequence.LabeledMarkCollections)
            {
                if (mc.Marks.Any())
                {
                    contextMenuItemAlignStartToMark.Enabled = true;
                    contextMenuItemAlignEndToMark.Enabled   = true;
                    contextMenuItemAlignBothToMark.Enabled  = true;
                    contextMenuItemAlignment.Enabled        = true;
                    contextMenuItemAlignment.ToolTipText    = string.Empty;
                    break;
                }
            }
            #endregion

            #region Effect Manipulation Section
            if (tse != null)
            {
                ToolStripMenuItem contextMenuItemManipulation     = new ToolStripMenuItem("Manipulation");
                ToolStripMenuItem contextMenuItemManipulateDivide = new ToolStripMenuItem("Divide at cursor")
                {
                    Image = Resources.divide
                };
                contextMenuItemManipulateDivide.Click += (mySender, myE) =>
                {
                    if (TimelineControl.SelectedElements.Any())
                    {
                        TimelineControl.grid.SplitElementsAtTime(
                            TimelineControl.SelectedElements.Where(elem => elem.StartTime <e.GridTime && elem.EndTime> e.GridTime)
                            .ToList(), e.GridTime);
                    }
                    else
                    {
                        TimelineControl.grid.SplitElementsAtTime(new List <Element> {
                            element
                        }, e.GridTime);
                    }
                };

                ToolStripMenuItem contextMenuItemManipulationClone = new ToolStripMenuItem("Clone")
                {
                    Image = Resources.page_copy
                };
                contextMenuItemManipulationClone.Click += (mySender, myE) =>
                {
                    if (TimelineControl.SelectedElements.Any())
                    {
                        CloneElements(TimelineControl.SelectedElements ?? new List <Element> {
                            element
                        });
                    }
                    else
                    {
                        CloneElements(new List <Element> {
                            element
                        });
                    }
                };

                ToolStripMenuItem contextMenuItemManipulationCloneToOther = new ToolStripMenuItem("Clone to selected effects")
                {
                    Image = Resources.copySelect
                };
                contextMenuItemManipulationCloneToOther.Click += (mySender, myE) =>
                {
                    if (TimelineControl.SelectedElements.Any(elem => elem.EffectNode.Effect.TypeId != element.EffectNode.Effect.TypeId))
                    {
                        //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                        MessageBoxForm.msgIcon = SystemIcons.Warning;                         //this is used if you want to add a system icon to the message form.
                        var messageBox = new MessageBoxForm(string.Format(
                                                                "Some of the selected effects are not of the same type, only effects of {0} type will be modified.",
                                                                element.EffectNode.Effect.EffectName), @"Multiple type effect selected", false, true);
                        messageBox.ShowDialog();
                        if (messageBox.DialogResult == DialogResult.Cancel)
                        {
                            return;
                        }
                    }

                    foreach (
                        Element elem in
                        TimelineControl.SelectedElements.Where(elem => elem != element)
                        .Where(elem => elem.EffectNode.Effect.TypeId == element.EffectNode.Effect.TypeId))
                    {
                        elem.EffectNode.Effect.ParameterValues = element.EffectNode.Effect.ParameterValues;
                        elem.RenderElement();
                    }
                };
                contextMenuItemManipulationCloneToOther.Enabled = (TimelineControl.SelectedElements.Count() > 2);

                _contextMenuStrip.Items.Add(contextMenuItemManipulation);
                contextMenuItemManipulation.DropDown.Items.Add(contextMenuItemManipulateDivide);
                contextMenuItemManipulation.DropDown.Items.Add(contextMenuItemManipulationClone);
                contextMenuItemManipulation.DropDown.Items.Add(contextMenuItemManipulationCloneToOther);

                ToolStripMenuItem contextMenuItemEditTime = new ToolStripMenuItem("Edit Time")
                {
                    Image = Resources.clock_edit
                };
                contextMenuItemEditTime.Click += (mySender, myE) =>
                {
                    EffectTimeEditor editor = new EffectTimeEditor(tse.EffectNode.StartTime, tse.EffectNode.TimeSpan, SequenceLength);
                    if (editor.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }

                    if (TimelineControl.SelectedElements.Any())
                    {
                        var elementsToMove = TimelineControl.SelectedElements.ToDictionary(elem => elem,
                                                                                           elem => new Tuple <TimeSpan, TimeSpan>(editor.Start, editor.Start + editor.Duration));
                        TimelineControl.grid.MoveResizeElements(elementsToMove);
                    }
                    else
                    {
                        TimelineControl.grid.MoveResizeElement(element, editor.Start, editor.Duration);
                    }
                };
                //Why do we set .Tag ?
                contextMenuItemEditTime.Tag     = tse;
                contextMenuItemEditTime.Enabled = TimelineControl.grid.OkToUseAlignmentHelper(TimelineControl.SelectedElements);
                if (!contextMenuItemEditTime.Enabled)
                {
                    contextMenuItemEditTime.ToolTipText = @"Disabled, maximum selected effects per row is 32.";
                }
                _contextMenuStrip.Items.Add(contextMenuItemEditTime);
            }
            #endregion

            #region Cut Copy Paste Section

            _contextMenuStrip.Items.Add("-");

            ToolStripMenuItem contextMenuItemCopy = new ToolStripMenuItem("Copy", null, toolStripMenuItem_Copy_Click)
            {
                ShortcutKeyDisplayString = @"Ctrl+C",
                Image = Resources.page_copy
            };
            ToolStripMenuItem contextMenuItemCut = new ToolStripMenuItem("Cut", null, toolStripMenuItem_Cut_Click)
            {
                ShortcutKeyDisplayString = @"Ctrl+X",
                Image = Resources.cut
            };
            contextMenuItemCopy.Enabled = contextMenuItemCut.Enabled = TimelineControl.SelectedElements.Any();
            ToolStripMenuItem contextMenuItemPaste = new ToolStripMenuItem("Paste", null, toolStripMenuItem_Paste_Click)
            {
                ShortcutKeyDisplayString = @"Ctrl+V", Image = Resources.page_white_paste,
                Enabled = ClipboardHasData()
            };

            _contextMenuStrip.Items.AddRange(new ToolStripItem[] { contextMenuItemCut, contextMenuItemCopy, contextMenuItemPaste });

            if (TimelineControl.SelectedElements.Any())
            {
                //Add Delete/Collections
                ToolStripMenuItem contextMenuItemDelete = new ToolStripMenuItem("Delete Effect(s)", null,
                                                                                toolStripMenuItem_deleteElements_Click)
                {
                    ShortcutKeyDisplayString = @"Del", Image = Resources.delete
                };
                _contextMenuStrip.Items.Add(contextMenuItemDelete);
                AddContextCollectionsMenu();
            }

            #endregion

            #region Mark Section

            ToolStripMenuItem contextMenuItemAddMark = new ToolStripMenuItem("Add Marks to Effects")
            {
                Image = Resources.marks
            };
            contextMenuItemAddMark.Click += (mySender, myE) => AddMarksToSelectedEffects();
            _contextMenuStrip.Items.Add(contextMenuItemAddMark);

            #endregion

            e.AutomaticallyHandleSelection = false;
            _contextMenuStrip.Show(MousePosition);
        }
예제 #2
0
        private void timelineControl_ContextSelected(object sender, ContextSelectedEventArgs e)
        {
            _contextMenuStrip.Items.Clear();

            ToolStripMenuItem contextMenuItemAddEffect = new ToolStripMenuItem("Add Effect(s)"){Image = Resources.effects};
            IEnumerable<IEffectModuleDescriptor> effectDesriptors =
                ApplicationServices.GetModuleDescriptors<IEffectModuleInstance>()
                    .Cast<IEffectModuleDescriptor>()
                    .OrderBy(x => x.EffectGroup)
                    .ThenBy(n => n.EffectName);
            EffectGroups group = effectDesriptors.First().EffectGroup;
            foreach (IEffectModuleDescriptor effectDesriptor in effectDesriptors)
            {
                if (effectDesriptor.EffectName == "Nutcracker") continue;  //Remove this when the Nutcracker module is removed
                if (effectDesriptor.EffectGroup != group)
                {
                    ToolStripSeparator seperator = new ToolStripSeparator();
                    contextMenuItemAddEffect.DropDownItems.Add(seperator);
                    group = effectDesriptor.EffectGroup;
                }
                // Add an entry to the menu
                ToolStripMenuItem contextMenuItemEffect = new ToolStripMenuItem(effectDesriptor.EffectName);
                contextMenuItemEffect.Image = effectDesriptor.GetRepresentativeImage(48, 48);
                contextMenuItemEffect.Tag = effectDesriptor.TypeId;
                contextMenuItemEffect.ToolTipText = @"Use Shift key to add multiple effects of the same type.";
                contextMenuItemEffect.Click += (mySender, myE) =>
                {
                    if (e.Row != null)
                    {
                        //Modified 7-9-2014 J. Bolding - Changed so that the multiple element addition is wrapped into one action by the undo/redo engine.
                        if (ModifierKeys == Keys.Shift || ModifierKeys == (Keys.Shift | Keys.Control))
                        {
                            //add multiple here
                            AddMultipleEffects(e.GridTime, effectDesriptor.EffectName, (Guid) contextMenuItemEffect.Tag, e.Row);
                        }
                        else
                            AddNewEffectById((Guid) contextMenuItemEffect.Tag, e.Row, e.GridTime, TimeSpan.FromSeconds(2), true);
                    }
                };

                contextMenuItemAddEffect.DropDownItems.Add(contextMenuItemEffect);
            }

            _contextMenuStrip.Items.Add(contextMenuItemAddEffect);

            ConfigureLayerMenu(e);

            if (e.ElementsUnderCursor != null && e.ElementsUnderCursor.Count() == 1)
            {

                Element element = e.ElementsUnderCursor.FirstOrDefault();

                TimedSequenceElement tse = element as TimedSequenceElement;

                //Effect Alignment Menu
                ToolStripMenuItem contextMenuItemAlignment = new ToolStripMenuItem("Alignment")
                {
                    Enabled = TimelineControl.grid.OkToUseAlignmentHelper(TimelineControl.SelectedElements),
                    Image = Resources.alignment
                };
                //Disables the Alignment menu if too many effects are selected in a row.
                if (!contextMenuItemAlignment.Enabled)
                {
                    contextMenuItemAlignment.ToolTipText = @"Disabled, maximum selected effects per row is 32.";
                }

                ToolStripMenuItem contextMenuItemAlignStart = new ToolStripMenuItem("Align Start Times (shift)")
                {
                    ToolTipText = @"Holding shift will align the start times, while holding duration.",
                    Image = Resources.alignStart
                };
                contextMenuItemAlignStart.Click +=
                    (mySender, myE) =>
                        TimelineControl.grid.AlignElementStartTimes(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);

                ToolStripMenuItem contextMenuItemAlignEnd = new ToolStripMenuItem("Align End Times (shift)")
                {
                    ToolTipText = @"Holding shift will align the end times, while holding duration.",
                    Image = Resources.alignEnd
                };
                contextMenuItemAlignEnd.Click +=
                    (mySender, myE) =>
                        TimelineControl.grid.AlignElementEndTimes(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);

                ToolStripMenuItem contextMenuItemAlignBoth = new ToolStripMenuItem("Align Both Times") { Image = Resources.alignBoth };
                contextMenuItemAlignBoth.Click +=
                    (mySender, myE) => TimelineControl.grid.AlignElementStartEndTimes(TimelineControl.SelectedElements, element);

                ToolStripMenuItem contextMenuItemMatchDuration = new ToolStripMenuItem("Match Duration (shift)")
                {
                    ToolTipText =
                        @"Holding shift will hold the effects end time and adjust the start time, by default the end time is adjusted."
                };
                contextMenuItemMatchDuration.Click +=
                    (mySender, myE) =>
                        TimelineControl.grid.AlignElementDurations(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);

                ToolStripMenuItem contextMenuItemAlignStartToEnd = new ToolStripMenuItem("Align Start to End (shift)")
                {
                    ToolTipText =
                        @"Holding shift will hold the effects end time and only adjust the start time, by default the entire effect is moved."
                };
                contextMenuItemAlignStartToEnd.Click +=
                    (mySender, myE) =>
                        TimelineControl.grid.AlignElementStartToEndTimes(TimelineControl.SelectedElements, element,
                            ModifierKeys == Keys.Shift);

                ToolStripMenuItem contextMenuItemAlignEndToStart = new ToolStripMenuItem("Align End to Start (shift)")
                {
                    ToolTipText =
                        @"Holding shift will hold the effects start time and only adjust the end time, by default the entire effect is moved."
                };
                contextMenuItemAlignEndToStart.Click +=
                    (mySender, myE) =>
                        TimelineControl.grid.AlignElementEndToStartTime(TimelineControl.SelectedElements, element,
                            ModifierKeys == Keys.Shift);

                ToolStripMenuItem contextMenuItemDistDialog = new ToolStripMenuItem("Distribute Effects");
                contextMenuItemDistDialog.Click += (mySender, myE) => DistributeSelectedEffects();

                ToolStripMenuItem contextMenuItemAlignCenter = new ToolStripMenuItem("Align Centerpoints") { Image = Resources.alignCenter };
                contextMenuItemAlignCenter.Click +=
                    (mySender, myE) => TimelineControl.grid.AlignElementCenters(TimelineControl.SelectedElements, element);

                ToolStripMenuItem contextMenuItemDistributeEqually = new ToolStripMenuItem("Distribute Equally")
                {
                    ToolTipText =
                        @"This will stair step the selected elements, starting with the element that has the earlier start mouseLocation on the time line."
                };
                contextMenuItemDistributeEqually.Click += (mySender, myE) => DistributeSelectedEffectsEqually();

                ToolStripMenuItem contextMenuItemAlignStartToMark = new ToolStripMenuItem("Align Start to nearest mark");
                contextMenuItemAlignStartToMark.Click += (mySender, myE) => AlignEffectsToNearestMarks("Start");

                ToolStripMenuItem contextMenuItemAlignEndToMark = new ToolStripMenuItem("Align End to nearest mark");
                contextMenuItemAlignEndToMark.Click += (mySender, myE) => AlignEffectsToNearestMarks("End");

                ToolStripMenuItem contextMenuItemAlignBothToMark = new ToolStripMenuItem("Align Both to nearest mark");
                contextMenuItemAlignBothToMark.Click += (mySender, myE) => AlignEffectsToNearestMarks("Both");

                _contextMenuStrip.Items.Add(contextMenuItemAlignment);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignStart);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignEnd);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignBoth);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignCenter);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemMatchDuration);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignStartToEnd);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignEndToStart);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemDistributeEqually);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemDistDialog);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignStartToMark);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignEndToMark);
                contextMenuItemAlignment.DropDown.Items.Add(contextMenuItemAlignBothToMark);

                if (tse != null)
                {
                    //Effect Manipulation Menu
                    ToolStripMenuItem contextMenuItemManipulation = new ToolStripMenuItem("Manipulation");
                    ToolStripMenuItem contextMenuItemManipulateDivide = new ToolStripMenuItem("Divide at cursor") { Image = Resources.divide };
                    contextMenuItemManipulateDivide.Click += (mySender, myE) =>
                    {
                        if (TimelineControl.SelectedElements.Any())
                        {
                            TimelineControl.grid.SplitElementsAtTime(
                                TimelineControl.SelectedElements.Where(elem => elem.StartTime < e.GridTime && elem.EndTime > e.GridTime)
                                    .ToList(), e.GridTime);
                        }
                        else
                        {
                            TimelineControl.grid.SplitElementsAtTime(new List<Element> {element}, e.GridTime);
                        }

                    };

                    ToolStripMenuItem contextMenuItemManipulationClone = new ToolStripMenuItem("Clone") { Image = Resources.page_copy };
                    contextMenuItemManipulationClone.Click += (mySender, myE) =>
                    {
                        if (TimelineControl.SelectedElements.Any())
                        {
                            CloneElements(TimelineControl.SelectedElements ?? new List<Element> {element});
                        }
                        else
                        {
                            CloneElements(new List<Element> {element});
                        }
                    };

                    ToolStripMenuItem contextMenuItemManipulationCloneToOther = new ToolStripMenuItem("Clone to selected effects") { Image = Resources.copySelect };
                    contextMenuItemManipulationCloneToOther.Click += (mySender, myE) =>
                    {
                        if (TimelineControl.SelectedElements.Any(elem => elem.EffectNode.Effect.TypeId != element.EffectNode.Effect.TypeId))
                        {
                            //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                            MessageBoxForm.msgIcon = SystemIcons.Warning; //this is used if you want to add a system icon to the message form.
                            var messageBox = new MessageBoxForm(string.Format(
                                    "Some of the selected effects are not of the same type, only effects of {0} type will be modified.",
                                    element.EffectNode.Effect.EffectName), @"Multiple type effect selected", false, true);
                            messageBox.ShowDialog();
                            if (messageBox.DialogResult == DialogResult.Cancel) return;
                        }

                        foreach (
                            Element elem in
                                TimelineControl.SelectedElements.Where(elem => elem != element)
                                    .Where(elem => elem.EffectNode.Effect.TypeId == element.EffectNode.Effect.TypeId))
                        {
                            elem.EffectNode.Effect.ParameterValues = element.EffectNode.Effect.ParameterValues;
                            elem.RenderElement();
                        }
                    };
                    contextMenuItemManipulationCloneToOther.Enabled = (TimelineControl.SelectedElements.Count() > 2);

                    _contextMenuStrip.Items.Add(contextMenuItemManipulation);
                    contextMenuItemManipulation.DropDown.Items.Add(contextMenuItemManipulateDivide);
                    contextMenuItemManipulation.DropDown.Items.Add(contextMenuItemManipulationClone);
                    contextMenuItemManipulation.DropDown.Items.Add(contextMenuItemManipulationCloneToOther);

                    ToolStripMenuItem contextMenuItemEditTime = new ToolStripMenuItem("Edit Time") { Image = Resources.clock_edit };
                    contextMenuItemEditTime.Click += (mySender, myE) =>
                    {
                        EffectTimeEditor editor = new EffectTimeEditor(tse.EffectNode.StartTime, tse.EffectNode.TimeSpan);
                        if (editor.ShowDialog(this) != DialogResult.OK) return;

                        if (TimelineControl.SelectedElements.Any())
                        {
                            var elementsToMove = TimelineControl.SelectedElements.ToDictionary(elem => elem,
                                elem => new Tuple<TimeSpan, TimeSpan>(editor.Start, editor.Start + editor.Duration));
                            TimelineControl.grid.MoveResizeElements(elementsToMove);
                        }
                        else
                        {
                            TimelineControl.grid.MoveResizeElement(element, editor.Start, editor.Duration);
                        }
                    };
                    //Why do we set .Tag ?
                    contextMenuItemEditTime.Tag = tse;
                    contextMenuItemEditTime.Enabled = TimelineControl.grid.OkToUseAlignmentHelper(TimelineControl.SelectedElements);
                    if (!contextMenuItemEditTime.Enabled)
                        contextMenuItemEditTime.ToolTipText = @"Disabled, maximum selected effects per row is 32.";
                    _contextMenuStrip.Items.Add(contextMenuItemEditTime);

                }
            }

            //Add Copy/Cut/paste section
            //Previously this section used the toolstripmenuitems from the main menu bar, however this caused those items
            //to be deleted from the edit menu. This is the work-around for that issue - JMB 12-14-2014
            _contextMenuStrip.Items.Add("-");

            ToolStripMenuItem contextMenuItemCopy = new ToolStripMenuItem("Copy", null, toolStripMenuItem_Copy_Click)
            {
                ShortcutKeyDisplayString = @"Ctrl+C",
                Image = Resources.page_copy
            };
            ToolStripMenuItem contextMenuItemCut = new ToolStripMenuItem("Cut", null, toolStripMenuItem_Cut_Click)
            {
                ShortcutKeyDisplayString = @"Ctrl+X",
                Image = Resources.cut
            };
            contextMenuItemCopy.Enabled = contextMenuItemCut.Enabled = TimelineControl.SelectedElements.Any();
            ToolStripMenuItem contextMenuItemPaste = new ToolStripMenuItem("Paste", null, toolStripMenuItem_Paste_Click)
            {
                ShortcutKeyDisplayString = @"Ctrl+V", Image = Resources.page_white_paste,
                Enabled = ClipboardHasData()
            };

            _contextMenuStrip.Items.AddRange(new ToolStripItem[] {contextMenuItemCut, contextMenuItemCopy,  contextMenuItemPaste});

            if (TimelineControl.SelectedElements.Any())
            {
                //Add Delete/Collections
                ToolStripMenuItem contextMenuItemDelete = new ToolStripMenuItem("Delete Effect(s)", null,
                    toolStripMenuItem_deleteElements_Click) { ShortcutKeyDisplayString = @"Del", Image = Resources.delete };
                _contextMenuStrip.Items.Add(contextMenuItemDelete);
                AddContextCollectionsMenu();

            }

            ToolStripMenuItem contextMenuItemResetTimeLineSettings = new ToolStripMenuItem("Reset Timeline Settings"){ Image = Resources.Reset};
            contextMenuItemResetTimeLineSettings.ToolTipText = "Resets TimeLine Start to Zero and Timeline Zoom to 14sec";
            contextMenuItemResetTimeLineSettings.Click += (mySender, myE) => ResetTimeLineSettings();
            _contextMenuStrip.Items.Add(contextMenuItemResetTimeLineSettings);

            e.AutomaticallyHandleSelection = false;

            _contextMenuStrip.Show(MousePosition);
        }
예제 #3
0
        private void timelineControl_ContextSelected(object sender, ContextSelectedEventArgs e)
        {
            contextMenuStrip.Items.Clear();

            ToolStripMenuItem addEffectItem = new ToolStripMenuItem("Add Effect");

            foreach (
                IEffectModuleDescriptor effectDesriptor in
                    ApplicationServices.GetModuleDescriptors<IEffectModuleInstance>().Cast<IEffectModuleDescriptor>())
            {
                // Add an entry to the menu
                ToolStripMenuItem menuItem = new ToolStripMenuItem(effectDesriptor.EffectName);
                menuItem.Tag = effectDesriptor.TypeId;
                menuItem.ToolTipText = "Use Shift key to add multiple effects of the same type.";
                menuItem.Click += (mySender, myE) =>
                {
                    if (e.Row != null)
                    {
                        //Modified 7-9-2014 J. Bolding - Changed so that the multiple element addition is wrapped into one action by the undo/redo engine.
                        if (Control.ModifierKeys == Keys.Shift || Control.ModifierKeys == (Keys.Shift | Keys.Control))
                        {
                            //add multiple here
                            AddMultipleEffects(e.GridTime,effectDesriptor.EffectName,(Guid)menuItem.Tag,e.Row);
                        }
                        else
                            addNewEffectById((Guid)menuItem.Tag, e.Row, e.GridTime, TimeSpan.FromSeconds(2));
                    }
                };

                addEffectItem.DropDownItems.Add(menuItem);
            }

            contextMenuStrip.Items.Add(addEffectItem);

            if (e.ElementsUnderCursor != null && e.ElementsUnderCursor.Count() == 1)
            {

                Element element = e.ElementsUnderCursor.FirstOrDefault();

                TimedSequenceElement tse = element as TimedSequenceElement;

                if (TimelineControl.SelectedElements.Count() > 1)
                {
                    ToolStripMenuItem itemAlignment = new ToolStripMenuItem("Alignment");
                    //Disables the Alignment menu if too many effects are selected in a row.
                    itemAlignment.Enabled = TimelineControl.grid.OkToUseAlignmentHelper(TimelineControl.SelectedElements);
                    if (!itemAlignment.Enabled)
                    {
                        itemAlignment.ToolTipText = "Disabled, maximum selected effects per row is 4.";
                    }

                    ToolStripMenuItem itemAlignStart = new ToolStripMenuItem("Align Start Times (shift)");
                    itemAlignStart.ToolTipText = "Holding shift will align the start times, while holding duration.";
                    itemAlignStart.Click += (mySender, myE) => TimelineControl.grid.AlignElementStartTimes(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);

                    ToolStripMenuItem itemAlignEnd = new ToolStripMenuItem("Align End Times (shift)");
                    itemAlignEnd.ToolTipText = "Holding shift will align the end times, while holding duration.";
                    itemAlignEnd.Click += (mySender, myE) => TimelineControl.grid.AlignElementEndTimes(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);

                    ToolStripMenuItem itemAlignBoth = new ToolStripMenuItem("Align Both Times");
                    itemAlignBoth.Click += (mySender, myE) => TimelineControl.grid.AlignElementStartEndTimes(TimelineControl.SelectedElements, element);

                    ToolStripMenuItem itemMatchDuration = new ToolStripMenuItem("Match Duration (shift)");
                    itemMatchDuration.ToolTipText = "Holding shift will hold the effects end time and adjust the start time, by default the end time is adjusted.";
                    itemMatchDuration.Click += (mySender, myE) => TimelineControl.grid.AlignElementDurations(TimelineControl.SelectedElements, element, ModifierKeys == Keys.Shift);

                    ToolStripMenuItem itemAlignStartToEnd = new ToolStripMenuItem("Align Start to End");
                    itemAlignStartToEnd.Click += (mySender, myE) => TimelineControl.grid.AlignElementStartToEndTimes(TimelineControl.SelectedElements, element);

                    ToolStripMenuItem itemAlignEndToStart = new ToolStripMenuItem("Align End to Start");
                    itemAlignEndToStart.Click += (mySender, myE) => TimelineControl.grid.AlignElementEndToStartTime(TimelineControl.SelectedElements, element);

                    ToolStripMenuItem itemDistDialog = new ToolStripMenuItem("Distribute Effects");
                    itemDistDialog.Click += (mySender, myE) => DistributeSelectedEffects();

                    ToolStripMenuItem itemAlignCenter = new ToolStripMenuItem("Align Centerpoints");
                    itemAlignCenter.Click += (mySender, myE) => TimelineControl.grid.AlignElementCenters(TimelineControl.SelectedElements, element);

                    ToolStripMenuItem itemDistributeEqually = new ToolStripMenuItem("Distribute Equally");
                    itemDistributeEqually.ToolTipText = "This will stair step the selected elements, starting with the element that has the earlier start point on the time line.";
                    itemDistributeEqually.Click += (mySender, myE) => DistributeSelectedEffectsEqually();

                    contextMenuStrip.Items.Add(itemAlignment);
                    itemAlignment.DropDown.Items.Add(itemAlignStart);
                    itemAlignment.DropDown.Items.Add(itemAlignEnd);
                    itemAlignment.DropDown.Items.Add(itemAlignBoth);
                    itemAlignment.DropDown.Items.Add(itemAlignCenter);
                    itemAlignment.DropDown.Items.Add(itemMatchDuration);
                    itemAlignment.DropDown.Items.Add(itemAlignStartToEnd);
                    itemAlignment.DropDown.Items.Add(itemAlignEndToStart);
                    itemAlignment.DropDown.Items.Add(itemDistributeEqually);
                    itemAlignment.DropDown.Items.Add(itemDistDialog);
                }

                if (tse != null)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem("Edit Time");
                    item.Click += (mySender, myE) =>
                    {
                        EffectTimeEditor editor = new EffectTimeEditor(tse.EffectNode.StartTime, tse.EffectNode.TimeSpan);
                        if (editor.ShowDialog(this) == DialogResult.OK)
                        {
                            TimelineControl.grid.MoveResizeElement(element, editor.Start, editor.Duration);
                        }
                    };
                    item.Tag = tse;
                    contextMenuStrip.Items.Add(item);

                }

            }

            //Add Copy/Cut/paste section
            contextMenuStrip.Items.Add("-");
            contextMenuStrip.Items.Add(toolStripMenuItem_Copy);
            contextMenuStrip.Items.Add(toolStripMenuItem_Cut);
            contextMenuStrip.Items.Add(toolStripMenuItem_Paste);
            if (TimelineControl.SelectedElements.Any())
            {
                //Add Edit/Delete/Collections
                contextMenuStrip.Items.Add("-");
                contextMenuStrip.Items.Add(toolStripMenuItem_EditEffect);
                contextMenuStrip.Items.Add(toolStripMenuItem_deleteElements);
                contextMenuStrip.Items.Add("-");

                AddContextCollectionsMenu();

            }

            e.AutomaticallyHandleSelection = false;

            contextMenuStrip.Show(MousePosition);
        }
예제 #4
0
        private void timelineControl_ContextSelected(object sender, ContextSelectedEventArgs e)
        {
            contextMenuStrip.Items.Clear();

            ToolStripMenuItem addEffectItem = new ToolStripMenuItem();

            //addEffectItem.Size = new System.Drawing.Size(215, 22);
            addEffectItem.Text = "Add Effect";

            foreach (
                IEffectModuleDescriptor effectDesriptor in
                    ApplicationServices.GetModuleDescriptors<IEffectModuleInstance>().Cast<IEffectModuleDescriptor>())
            {
                // Add an entry to the menu
                ToolStripMenuItem menuItem = new ToolStripMenuItem(effectDesriptor.EffectName);
                menuItem.Tag = effectDesriptor.TypeId;
                menuItem.Click += (mySender, myE) =>
                {
                    if (e.Row != null)
                    {
                        addNewEffectById((Guid)menuItem.Tag, e.Row, e.GridTime,
                                         TimeSpan.FromSeconds(2));
                    }
                };

                addEffectItem.DropDownItems.Add(menuItem);
            }

            contextMenuStrip.Items.Add(addEffectItem);

            if (e.ElementsUnderCursor != null && e.ElementsUnderCursor.Count() == 1)
            {

                Element element = e.ElementsUnderCursor.FirstOrDefault();

                TimedSequenceElement tse = element as TimedSequenceElement;
                if (tse != null)
                {
                    ToolStripMenuItem item = new ToolStripMenuItem("Edit Time");
                    item.Click += (mySender, myE) =>
                    {
                        EffectTimeEditor editor = new EffectTimeEditor(tse._effectNode.StartTime, tse._effectNode.TimeSpan);
                        if (editor.ShowDialog(this) == DialogResult.OK)
                        {
                            TimelineControl.grid.MoveResizeElement(element, editor.Start, editor.Duration);
                        }
                    };
                    item.Tag = tse;
                    contextMenuStrip.Items.Add(item);

                }

                if (TimelineControl.SelectedElements.Count() > 1)
                {

                    ToolStripMenuItem itemAlignStart = new ToolStripMenuItem("Align Start Times");
                    itemAlignStart.Click += (mySender, myE) =>
                    {

                        foreach (Element selectedElement in TimelineControl.SelectedElements)
                        {
                            if (selectedElement.StartTime == element.StartTime) continue;
                            TimelineControl.grid.MoveResizeElementByStartEnd(selectedElement, element.StartTime, selectedElement.EndTime);
                        }
                    };

                    ToolStripMenuItem itemAlignEnd = new ToolStripMenuItem("Align End Times");
                    itemAlignEnd.Click += (mySender, myE) =>
                    {

                        foreach (Element selectedElement in TimelineControl.SelectedElements)
                        {
                            if (selectedElement.EndTime == element.EndTime) continue;
                            TimelineControl.grid.MoveResizeElementByStartEnd(selectedElement, selectedElement.StartTime, element.EndTime);
                        }
                    };

                    contextMenuStrip.Items.Add(itemAlignStart);
                    contextMenuStrip.Items.Add(itemAlignEnd);

                }
            }

            //Add Copy/Cut/paste section
            contextMenuStrip.Items.Add("-");
            contextMenuStrip.Items.Add(toolStripMenuItem_Copy);
            contextMenuStrip.Items.Add(toolStripMenuItem_Cut);
            contextMenuStrip.Items.Add(toolStripMenuItem_Paste);
            if (TimelineControl.SelectedElements.Any())
            {
                //Add Edit delete
                contextMenuStrip.Items.Add("-");
                contextMenuStrip.Items.Add(toolStripMenuItem_EditEffect);
                contextMenuStrip.Items.Add(toolStripMenuItem_deleteElements);
            }

            e.AutomaticallyHandleSelection = false;

            contextMenuStrip.Show(MousePosition);
        }