Ejemplo n.º 1
0
        public void Initialize(NetworkLogViewerBase viewer)
        {
            m_viewer = viewer;
            m_command = new PluginCommand(this, Strings.Gossip_OpenParser,
                new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Alt), Clicked);

            viewer.ProtocolChanged += new EventHandler(viewer_ProtocolChanged);
            viewer.NetworkLogChanged += new EventHandler(viewer_NetworkLogChanged);

            this.UpdateCommand();
            Console.WriteLine("Debug: Gossip Parser initialized.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unregisters a <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/>.
        /// </summary>
        /// <param name="command">
        /// The <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/> that should be unregistered.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// <c>command</c> is null.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The provided <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/> is not
        /// registered with the current <see cref="Kamilla.Network.Viewing.NetworkLogViewerBase"/>.
        /// </exception>
        public override void UnregisterPluginCommand(PluginCommand command)
        {
            if (!m_pluginCommands.Contains(command))
                throw new ArgumentException("Such command is not registered.", "command");

            m_pluginCommands.Remove(command);

            m_window.ThreadSafeBegin(_ =>
            {
                _.ui_miPlugins.Items.Remove(
                    _.ui_miPlugins.Items
                        .Cast<MenuItem>()
                        .Single(item => (PluginCommand)((MenuItem)item).Tag == command)
                );

                if (!_.ui_miPlugins.HasItems)
                    _.ui_miPlugins.IsEnabled = false;
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers a <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/>.
        /// </summary>
        /// <param name="command">
        /// The <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/> that should be registered.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// <c>command</c> is null.
        /// </exception>
        public override void RegisterPluginCommand(PluginCommand command)
        {
            if (m_pluginCommands.Contains(command))
                throw new ArgumentException("Such command is already registered.", "command");

            m_pluginCommands.Add(command);

            m_window.ThreadSafeBegin(_ =>
            {
                var item = new MenuItem();

                item.Header = command.Title;
                item.InputGestureText = command.Gesture.GetDisplayString();
                item.Tag = command;
                item.Click += (o, e) =>
                {
                    e.Handled = true;
                    command.Callback();
                };

                _.ui_miPlugins.Items.Add(item);
                _.ui_miPlugins.IsEnabled = true;
            });
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Unregisters a <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/>.
 /// </summary>
 /// <param name="command">
 /// The <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/> that should be unregistered.
 /// </param>
 /// <exception cref="System.ArgumentNullException">
 /// <c>command</c> is null.
 /// </exception>
 /// <exception cref="System.ArgumentException">
 /// The provided <see cref="Kamilla.Network.Viewing.Plugins.PluginCommand"/> is not
 /// registered with the current <see cref="Kamilla.Network.Viewing.NetworkLogViewerBase"/>.
 /// </exception>
 public abstract void UnregisterPluginCommand(PluginCommand command);