예제 #1
0
        public static IEnumerable <ICaptureMode> LoadPlugins(ToolStripMenuItem toolCaptures, EventHandler executeHandler)
        {
            toolCaptures.DropDownItems.Clear();
            var bootStrapper = new GenericBootStrapper <ICaptureMode>();

            bootStrapper.Compose();

            if (null != bootStrapper.Items)
            {
                List <ICaptureMode> captureModes = new List <ICaptureMode>(bootStrapper.Items);
                captureModes.Sort(delegate(ICaptureMode capturemode1, ICaptureMode capturemode2)
                {
                    return(capturemode1.Name.CompareTo(capturemode2.Name));
                });

                foreach (var menuItem in captureModes)
                {
                    if (menuItem.IsEnabled)
                    {
                        var capturemode = new ToolStripMenuItem(menuItem.Text);
                        capturemode.Click      += executeHandler;
                        capturemode.ToolTipText = menuItem.Description;
                        capturemode.Tag         = menuItem;
                        toolCaptures.DropDownItems.Add(capturemode);
                    }
                }
            }
            return(bootStrapper.Items);
        }
예제 #2
0
        public static IEnumerable <ISendTo> LoadPlugins(ComboBox ddlPlugins, ToolStripMenuItem toolStripSendTo, EventHandler sendToMenuItem_Click)
        {
            var bootStrapper = new GenericBootStrapper <ISendTo>();

            bootStrapper.Compose(Application.StartupPath);
            if (null != bootStrapper.Items)
            {
                ddlPlugins.Items.Clear();
                ddlPlugins.DisplayMember = "Name";
                ddlPlugins.ValueMember   = "Name";
                ddlPlugins.DataSource    = bootStrapper.Items;

                toolStripSendTo.DropDownItems.Clear();
                foreach (var menuItem in bootStrapper.Items)
                {
                    var sendToMenuItem = new ToolStripMenuItem(menuItem.Text);
                    sendToMenuItem.Click += sendToMenuItem_Click;
                    sendToMenuItem.Tag    = menuItem;
                    toolStripSendTo.DropDownItems.Add(sendToMenuItem);
                }

                string pluginName = Properties.Settings.Default.ExecuteAfterCapturePlugin;
                for (int i = 0; i < ddlPlugins.Items.Count; i++)
                {
                    if ((ddlPlugins.Items[i] as ISendTo).GetType().FullName.Equals(pluginName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        ddlPlugins.SelectedIndex = i;
                        break;
                    }
                }
            }
            return(bootStrapper.Items);
        }
예제 #3
0
        public static IEnumerable <T> LoadGenericPlugins <T>(ToolStripMenuItem toolCaptures, EventHandler executeHandler)
        {
            toolCaptures.DropDownItems.Clear();
            var bootStrapper = new GenericBootStrapper <T>();

            bootStrapper.Compose(Application.StartupPath);

            if (null != bootStrapper.Items)
            {
                List <T> captureModes = new List <T>(bootStrapper.Items);
                foreach (var menuItem in captureModes)
                {
                    var capturemode = new ToolStripMenuItem(GetValue(menuItem, "MenuCaption").ToString());
                    capturemode.Visible     = (bool)GetValue(menuItem, "IsVisible");
                    capturemode.Click      += executeHandler;
                    capturemode.ToolTipText = GetValue(menuItem, "Description").ToString();
                    capturemode.Tag         = menuItem;
                    toolCaptures.DropDownItems.Add(capturemode);
                }
            }
            return(bootStrapper.Items);
        }