Beispiel #1
0
        private void LoadWindowPlugin(string filename, Type t)
        {
            try
            {
                IWindowPlugin plugin = (IWindowPlugin)Activator.CreateInstance(t);
                plugin.SetServiceProvider(_windowManager);

                string id = plugin.GetID();

                // Ignore classes with blank ID, for example a base class.
                if (!string.IsNullOrEmpty(id))
                {
                    _windowPlugins.Add(id, plugin);
                    _windowManager.AddPlugin(id, plugin as DockContent, true);

                    // If kind is MainWindow, then we have a main menu option, otherwise
                    // the project browser will build a context sensitive right click menu.
                    // Whatever, the menu option for the plugin will hold the reference to
                    // that plugin, and duplicates should not matter.
                    if (plugin.GetKind() == WindowPluginKind.MainWindow)
                    {
                        _windowManager.MenuManager.AddMenuOption(
                            plugin,
                            "Window",
                            plugin.GetID());
                    }
                    else
                    {
                        _windowManager.MenuManager.AddContextMenuOption(
                            plugin,
                            plugin.GetHandledTypes(),
                            plugin.GetID());
                    }

                    _windowManager.Logger.LogStr(string.Format(
                                                     "Loaded UI Plugin '{0}'", t.Name));
                }
            }
            catch (Exception exc)
            {
                if (_windowManager.Logger.LogCatchAll(exc, string.Format(
                                                          "Unexpected error in plugin '{0}'", t.ToString())))
                {
                    throw;
                }
            }
        }
Beispiel #2
0
        private void SetItemInternal(DockContent window, BaseItem item)
        {
            try
            {
                IActiveItemViewer viewer = window as IActiveItemViewer;
                IWindowPlugin     plugin = window as IWindowPlugin;

                // Always set a main window plugin, but only set others if they've changed.
                if (plugin.GetKind() == WindowPluginKind.MainWindow ||
                    viewer.GetActiveItem() != item)
                {
                    viewer.SetActiveItem(item);
                }
            }
            catch (Exception exc)
            {
                if (_logView.LogCatchAll(exc, "Unexpected plugin error"))
                {
                    throw;
                }
            }
        }