private void Execute_setMarker(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                double timeCursor;
                ObservableCollection <RenderSlice> selectedRsList;
                string markerSymbol = "M";
                if (e.Parameter != null && e.Parameter.Equals("ContextMenu"))
                {
                    // Informationen vom Contextmenu
                    timeCursor     = this.signalviewercontrol.stackercontrol.PluginContextMenuTimeCursor;
                    selectedRsList = this.signalviewercontrol.stackercontrol.PluginContextMenuSelectedRsList;
                }
                else
                {
                    // Informationen von der aktuellen Mausposition
                    HoverStackEventArgs currentHoverStackEventArgs = hoverStackEventArgs;
                    if (currentHoverStackEventArgs == null)
                    {
                        return;
                    }

                    Point point = Mouse.GetPosition(currentHoverStackEventArgs.ItemsControl);
                    timeCursor     = RendererManager.Time + (RendererManager.TimeStretch * point.X / currentHoverStackEventArgs.ItemsControl.ActualWidth);
                    markerSymbol   = (e.Parameter == null || e.Parameter.Equals(string.Empty)) ? "M" : e.Parameter.ToString();
                    selectedRsList = currentHoverStackEventArgs.Stack;
                }

                IEnumerable <XElement> retsigs = Marker.setMarker(RendererManager.GetSevEntries(selectedRsList), timeCursor, markerSymbol);

                // Neues signal hinzufuegen
                if (retsigs != null)
                {
                    foreach (XElement xe in retsigs)
                    {
                        if (StackerControl.IsSignalEventValueEntry(xe))
                        {
                            signalviewercontrol.stackercontrol.DropSignalEventValueEntry(xe, selectedRsList);
                        }
                    }
                }

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }
        private void Execute_truncateMarker(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                double timeCursor;
                ObservableCollection <RenderSlice> selectedRsList;
                if (e.Parameter != null && e.Parameter.Equals("ContextMenu"))
                {
                    // Informationen vom Contextmenu
                    timeCursor     = this.signalviewercontrol.stackercontrol.PluginContextMenuTimeCursor;
                    selectedRsList = this.signalviewercontrol.stackercontrol.PluginContextMenuSelectedRsList;
                }
                else
                {
                    // Informationen von der aktuellen Mausposition
                    HoverStackEventArgs currentHoverStackEventArgs = hoverStackEventArgs;
                    if (currentHoverStackEventArgs == null)
                    {
                        return;
                    }

                    Point point = Mouse.GetPosition(currentHoverStackEventArgs.ItemsControl);
                    timeCursor     = RendererManager.Time + (RendererManager.TimeStretch * point.X / currentHoverStackEventArgs.ItemsControl.ActualWidth);
                    selectedRsList = currentHoverStackEventArgs.Stack;
                }

                Marker.truncateMarker(RendererManager.GetSevEntries(selectedRsList), timeCursor);

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }
        private void Execute_deleteMarker(object sender, ExecutedRoutedEventArgs e)
        {
            using (new WaitCursor())
            {
                ObservableCollection <RenderSlice> selectedRsList;
                if (e.Parameter != null && e.Parameter.Equals("ContextMenu"))
                {
                    // Informationen vom Contextmenu
                    selectedRsList = this.signalviewercontrol.stackercontrol.PluginContextMenuSelectedRsList;
                }
                else
                {
                    // Informationen von der aktuellen Mausposition
                    HoverStackEventArgs currentHoverStackEventArgs = hoverStackEventArgs;
                    if (currentHoverStackEventArgs == null)
                    {
                        return;
                    }

                    selectedRsList = currentHoverStackEventArgs.Stack;
                }
                Marker.deleteMarker(RendererManager.GetSevEntries(selectedRsList), signalviewercontrol.SelectionStart, signalviewercontrol.SelectionEnd);

                // Deselect all and Render again
                signalviewercontrol.Deselect();

                if (RendererManager.TimeMax < RendererManager.Time)
                {
                    RendererManager.Scroll(0.0);
                }
                else
                {
                    RendererManager.Render();
                }

                // Save Unisens file after Plugin execution
                Executed_Save(null, null);
            }
        }
 private void WindowMain_HoverStack(object sender, HoverStackEventArgs e)
 {
     this.hoverStackEventArgs = e.ItemsControl != null ? e : null;
     e.Handled = true;
 }
        /// <summary>
        /// Run a plug-in after pressing a hotkey.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">pressed key event</param>
        private void WindowMain_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            HoverStackEventArgs currentHoverStackEventArgs = this.hoverStackEventArgs;

            if (currentHoverStackEventArgs != null)
            {
                PluginHotkeyBinding hb = (PluginHotkeyBinding)this.hotkeys.Bindings[new HotkeyHashkey(e.Key, Keyboard.Modifiers)];

                if (hb != null)
                {
                    Keyboard.Focus(signalviewercontrol);
                    e.Handled = true;

                    Point  point                   = Mouse.GetPosition(currentHoverStackEventArgs.ItemsControl);
                    double time_cursor             = RendererManager.Time + (RendererManager.TimeStretch * point.X / currentHoverStackEventArgs.ItemsControl.ActualWidth);
                    IEnumerable <XElement> retsigs = null;

                    switch (hb.Signals)
                    {
                    case PluginHotkeyBinding.SelectedSignals.AllOpenFiles:
                        retsigs = this.ExecutePlugin(hb.Plugin, RendererManager.GetSevEntriesAllRenderers(), time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.StackFiles:
                        retsigs = this.ExecutePlugin(hb.Plugin, currentHoverStackEventArgs.StackSevEntries, time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.StackChannels:
                        retsigs = this.ExecutePlugin(hb.Plugin, currentHoverStackEventArgs.StackChannelEntries, time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.StackSelectedFiles:
                        retsigs = this.ExecutePlugin(hb.Plugin, currentHoverStackEventArgs.StackSelectionSevEntries, time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.StackSelectedChannels:
                        retsigs = this.ExecutePlugin(hb.Plugin, currentHoverStackEventArgs.StackSelectionChannelEntries, time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.AllSignalEntries:
                        retsigs = this.ExecutePlugin(hb.Plugin, UnisensXmlFileManager.CurrentUnisensInstance.Xdocument.Root.Elements("{http://www.unisens.org/unisens2.0}signalEntry"), time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.AllEventEntries:
                        retsigs = this.ExecutePlugin(hb.Plugin, UnisensXmlFileManager.CurrentUnisensInstance.Xdocument.Root.Elements("{http://www.unisens.org/unisens2.0}eventEntry"), time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.AllValuesEntries:
                        retsigs = this.ExecutePlugin(hb.Plugin, UnisensXmlFileManager.CurrentUnisensInstance.Xdocument.Root.Elements("{http://www.unisens.org/unisens2.0}valuesEntry"), time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.Dialog:
                        retsigs = this.ExecutePluginWithDialog(hb.Plugin, time_cursor, hb.Parameter);
                        break;

                    case PluginHotkeyBinding.SelectedSignals.All:     // TODO: All Entries from Unisens.xml
                        List <XElement> entryElements = new List <XElement>();
                        entryElements.AddRange(UnisensXmlFileManager.CurrentUnisensInstance.Xdocument.Root.Elements("{http://www.unisens.org/unisens2.0}signalEntry"));
                        entryElements.AddRange(UnisensXmlFileManager.CurrentUnisensInstance.Xdocument.Root.Elements("{http://www.unisens.org/unisens2.0}eventEntry"));
                        entryElements.AddRange(UnisensXmlFileManager.CurrentUnisensInstance.Xdocument.Root.Elements("{http://www.unisens.org/unisens2.0}valuesEntry"));

                        retsigs = this.ExecutePlugin(hb.Plugin, entryElements, time_cursor, hb.Parameter);
                        break;
                    }

                    if (retsigs != null)
                    {
                        foreach (XElement xe in retsigs)
                        {
                            if (StackerControl.IsSignalEventValueEntry(xe))
                            {
                                this.signalviewercontrol.stackercontrol.DropSignalEventValueEntry(xe, currentHoverStackEventArgs.Stack);
                            }
                        }
                    }
                }
            }
        }