Example #1
0
        /// <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);
                            }
                        }
                    }
                }
            }
        }