Beispiel #1
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);
        }
        private void ConfigureLayerMenu(ContextSelectedEventArgs e)
        {
            if ((e.ElementsUnderCursor != null && e.ElementsUnderCursor.Any()) || TimelineControl.SelectedElements.Any())
            {
                var layers = Sequence.GetAllLayers();
                if (layers.Count() > 1)
                {
                    ToolStripMenuItem contextMenuToLayer = new ToolStripMenuItem("Layer")
                    {
                        Enabled = true,
                        Image = Resources.layers,
                        ToolTipText = @"Assign effects to a layer"
                    };

                    HashSet<Guid> layersUsed = new HashSet<Guid>();
                    var sequenceLayers = Sequence.GetSequenceLayerManager();
                    if (TimelineControl.SelectedElements.Any())
                    {
                        foreach (var selectedElement in TimelineControl.SelectedElements)
                        {
                            var curentLayer = sequenceLayers.GetLayer(selectedElement.EffectNode);
                            if (layersUsed.Contains(curentLayer.Id) == false)
                            {
                                layersUsed.Add(curentLayer.Id);
                                if (layersUsed.Count == sequenceLayers.Count)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (var elementUnderCursor in e.ElementsUnderCursor)
                        {
                            var curentLayer = sequenceLayers.GetLayer(elementUnderCursor.EffectNode);
                            if (layersUsed.Contains(curentLayer.Id) == false)
                            {
                                layersUsed.Add(curentLayer.Id);
                                if (layersUsed.Count == sequenceLayers.Count)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    Bitmap checkMarkColor;
                    int iconSize = (int)(24 * ScalingTools.GetScaleFactor());
                    if (layersUsed.Count == 1)
                    {
                        checkMarkColor = Tools.GetIcon(Resources.check_mark, iconSize);
                    }
                    else
                    {
                        checkMarkColor = Tools.GetIcon(Resources.check_markMedium, iconSize);
                    }

                    foreach (var layer in layers.Reverse())
                    {
                        var item = new ToolStripMenuItem(layer.LayerName);
                        item.Tag = layer;
                        item.ToolTipText = layer.FilterName;

                        if (layersUsed.Contains(layer.Id))
                        {
                            item.Image = checkMarkColor;
                        }

                        contextMenuToLayer.DropDownItems.Add(item);
                        item.Click += (sender, args) =>
                        {
                            var el = e.ElementsUnderCursor;
                            Dictionary<IEffectNode, ILayer> modifiedNodes = new Dictionary<IEffectNode, ILayer>();
                            var newLayer = (ILayer) item.Tag;
                            //First try to apply to selected elements
                            if (TimelineControl.SelectedElements.Any())
                            {
                                foreach (var selectedElement in TimelineControl.SelectedElements)
                                {
                                    var curentLayer = sequenceLayers.GetLayer(selectedElement.EffectNode);
                                    if (newLayer != curentLayer)
                                    {
                                        modifiedNodes.Add(selectedElement.EffectNode, curentLayer);
                                        sequenceLayers.AssignEffectNodeToLayer(selectedElement.EffectNode, newLayer);
                                    }
                                }
                            }
                            else if (el != null && el.Any())
                            {
                                //if there are no selected elements, then try to apply to the element under the cursor
                                foreach (var selectedElement in el)
                                {
                                    var curentLayer = sequenceLayers.GetLayer(selectedElement.EffectNode);
                                    if (newLayer != curentLayer)
                                    {
                                        modifiedNodes.Add(selectedElement.EffectNode, curentLayer);
                                        sequenceLayers.AssignEffectNodeToLayer(selectedElement.EffectNode, newLayer);
                                    }
                                }
                            }

                            if (modifiedNodes.Any())
                            {
                                var undo = new EffectsLayerChangedUndoAction(this, modifiedNodes);
                                _undoMgr.AddUndoAction(undo);
                                SequenceModified();
                            }
                        };
                    }
                    _contextMenuStrip.Items.Add(contextMenuToLayer);
                }
            }
        }
        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);
        }
        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);
        }