Esempio n. 1
0
        public void Setup(Plugin plugin)
        {
            ToolBarButton       toolButton = null;
            ToolBarButtonPlugin toolPlugin = plugin.PluginBase as ToolBarButtonPlugin;

            if (toolPlugin.AssemblyName != string.Empty &&
                toolPlugin.AssemblyName != null &&
                toolPlugin.ClassName != string.Empty &&
                toolPlugin.ClassName != null)
            {
                string  assemblyPath = AssemblyToolkit.GetDll(toolPlugin.AssemblyName);
                Command cmd          = AssemblyToolkit.ActivateObject <Command>(assemblyPath, toolPlugin.ClassName);
                toolButton = new ToolBarButton(cmd);
            }
            else
            {
                toolButton = new ToolBarButton();
            }
            if (toolPlugin.Image != string.Empty && toolPlugin.Image != null)
            {
                string imagePath = CommonToolkit.GetResourceDirectory(toolPlugin.Image);
                toolButton.Image = CommonToolkit.GetResourceImage(imagePath);
            }
            toolButton.DisplayStyle = ToolBarToolkit.GetDisplayStyle(toolPlugin.DisplayStyle);
            toolButton.Text         = (toolPlugin.Label.Equals(string.Empty) || toolPlugin.Label.Equals(null)) ? "无" : toolPlugin.Label;

            ToolBarSingleton.MainToolbar.Add(toolButton);
        }
Esempio n. 2
0
        private static void SetupLinkGroup(LinkGroupCollection menuLinkGroups, LinkCollection titleLinks, LinkGroupData linkGroupData, ref Uri contentSource)
        {
            Uri firstUri  = null;
            var linkGroup = new LinkGroup {
                DisplayName = linkGroupData.DisplayName, GroupKey = linkGroupData.GroupKey
            };

            foreach (var link in linkGroupData.Links)
            {
                var assemblyPath = AssemblyToolkit.GetDll(linkGroupData.Assembly);
                var settingsLink = new Link {
                    DisplayName = link.DisplayName, Source = new Uri(assemblyPath + "+" + link.Source, UriKind.RelativeOrAbsolute)
                };
                linkGroup.Links.Add(settingsLink);
                firstUri = new Uri(assemblyPath + "+" + link.Source, UriKind.RelativeOrAbsolute);
                if (flag++ == 0)
                {
                    contentSource = new Uri(assemblyPath + "+" + link.Source, UriKind.RelativeOrAbsolute);
                }
            }
            if (linkGroupData.IsTitleLink)
            {
                titleLinks.Add(new Link {
                    DisplayName = linkGroupData.DisplayName, Source = firstUri
                });
            }
            menuLinkGroups.Add(linkGroup);
        }
Esempio n. 3
0
        public void SetupDockBar(Plugin plugin)
        {
            DockBarPlugin dockPlugin = plugin.PluginBase as DockBarPlugin;

            if (dockPlugin == null)
            {
                throw new NullReferenceException();
            }
            if (dockPlugin.AssemblyName != string.Empty && dockPlugin.AssemblyName != null &&
                dockPlugin.DockWindowClass != string.Empty && dockPlugin.DockWindowClass != null)
            {
                DockState  state        = GetDockState(dockPlugin.DockType);
                string     assemblyPath = AssemblyToolkit.GetDll(plugin.PluginBase.AssemblyName);
                ToolWindow window       = AssemblyToolkit.ActivateObject <ToolWindow>(assemblyPath, dockPlugin.DockWindowClass);
                window.Text = dockPlugin.Label;
                window.Show(DockPanelSingleton.MainDockPanel, state);
            }
        }
Esempio n. 4
0
        public MenuItem GetMenuItem(MenuPlugin menuPlugin)
        {
            MenuItem item = null;

            if (menuPlugin.AssemblyName != string.Empty && menuPlugin.AssemblyName != null &&
                menuPlugin.ClassName != string.Empty && menuPlugin.ClassName != null)
            {
                string  assemblyPath = AssemblyToolkit.GetDll(menuPlugin.AssemblyName);
                Command cmd          = AssemblyToolkit.ActivateObject <Command>(assemblyPath, menuPlugin.ClassName);
                item = new MenuItem(cmd);
            }
            else
            {
                item = new MenuItem();
            }
            if (menuPlugin.Image != string.Empty && menuPlugin.Image != null)
            {
                string imagePath = CommonToolkit.GetResourceDirectory(menuPlugin.Image);
                item.Image = CommonToolkit.GetResourceImage(imagePath);
            }
            item.Text = (menuPlugin.Label.Equals(string.Empty) || menuPlugin.Label.Equals(null)) ? CommonToolkit.GetLastString(menuPlugin.Path) : menuPlugin.Label;
            return(item);
        }