public ConfigurableEntityDescriptor(IConfigurablePlugin plugin)
        {
            if (plugin == null)
                throw new ArgumentNullException("plugin");

            this.plugin = plugin;
        }
Beispiel #2
0
 private static void EnsureOutputsLoaded()
 {
     //DC this is a hack to make sure we can load the subMenus (which on 2nd load were causing an exception)
     try
     {
         foreach (IPersistableImageFormat format in imageOutputCollection)
         {
             var text = format.Menu.Text;
         }
     }
     catch
     {
         imageOutputCollection = null;
     }
     if (imageOutputCollection == null)
     {
         imageOutputCollection = Plugins.Load();
         foreach (IPersistableImageFormat format in imageOutputCollection)
         {
             IConfigurablePlugin plugin = format as IConfigurablePlugin;
             if (plugin != null && plugin.Settings != null)
             {
                 object settings = Configuration.Current.RetrieveSettingsForPlugin(plugin.Settings.GetType());
                 if (settings != null)
                 {
                     plugin.Settings = settings;
                 }
             }
         }
     }
 }
Beispiel #3
0
        private void HandlePluginSelectionChanged(object sender, EventArgs e)
        {
            if (configForm != null)
            {
                configForm.Hide();
                pluginConfigHostPanel.Controls.Remove(configForm);
                configForm = null;
            }

            IConfigurablePlugin plugin = pluginsComboBox.SelectedItem as IConfigurablePlugin;

            if (plugin?.ConfigurationForm != null)
            {
                configForm = plugin.ConfigurationForm;
                configForm.PerformAutoScale();

                if (plugin.HostInOptions)
                {
                    ShowHostedConfiguration();
                }
                else
                {
                    ShowDialogConfiguration();
                }
            }
        }
        private ConfigurationDialog(IConfigurablePlugin configurableEntity) : base(configurableEntity.Name)
        {            
            InitializeComponent();

            this.MainPanel.HideExpertOptions = HideExpertOptionsCHBOX.Checked;
            this.ConfigurableEntity = configurableEntity;
            this.Text = TextResources.UI_Caption_Configure_ + configurableEntity.Name;
            
            configurableEntity.PopulateConfigurationPanel(MainPanel);
        }
        private static Type[] GetAdditionalTypes()
        {
            List <Type> types = new List <Type>();

            foreach (IPersistableImageFormat format in ImageCapture.ImageOutputs)
            {
                IConfigurablePlugin plugin = format as IConfigurablePlugin;
                if (plugin?.Settings != null)
                {
                    types.Add(plugin.Settings.GetType());
                }
            }
            return(types.ToArray());
        }
        public static void Present(bool modal, IConfigurablePlugin plugin, string path)
        {
            ConfigurationDialog dialog = ConfigurationDialog.GetSingleton<ConfigurationDialog>(false);

            if (dialog == null)
            {
                dialog = new ConfigurationDialog();

                dialog.SetPath(path);
                dialog.Populate(plugin);
            }

            dialog.ShowSingleton(modal);
        }
Beispiel #7
0
        private void HandleOkClick(object sender, EventArgs e)
        {
            if (addingSize)
            {
                addingSize = false;
                return;
            }

            Configuration.Current.OutputPath = Environment.ExpandEnvironmentVariables(folderChooser.Text);
            if (ValidateFileName(fullImageTemplate.Text))
            {
                Configuration.Current.FullImageTemplate = fullImageTemplate.Text;
            }
            if (ValidateFileName(thumbImageTemplate.Text))
            {
                Configuration.Current.ThumbImageTemplate = thumbImageTemplate.Text;
            }

            Configuration.Current.ColorNonFormArea            = colorNonFormAreaCheck.Checked;
            Configuration.Current.NonFormAreaColorArgb        = backgroundColor.BackColor.ToArgb();
            Configuration.Current.UserOpacity                 = (double)(opacitySlider.Value * 10) / 100;
            Configuration.Current.ShowOpacityMenu             = showOpacityMenu.Checked;
            Configuration.Current.TrapPrintScreen             = trapPrintScreen.Checked;
            Configuration.Current.HideFormAfterCapture        = hideAfterCapture.Checked;
            Configuration.Current.LeavePrintScreenOnClipboard = keepPrntScrnOnClipboard.Checked;
            Configuration.Current.AllowMultipleInstances      = allowMultipleCropperInstances.Checked;
            Configuration.Current.IncludeMouseCursorInCapture = includeMouseCursorInCapture.Checked;
            Configuration.Current.PredefinedSizes             = predefinedSizeList.Items.Cast <CropSize>().ToArray();
            Configuration.Current.PredefinedThumbSizes        = predefinedThumbSizeList.Items.Cast <double>().ToArray();
            Configuration.Current.HotKeySettings              = HotKeys.GetRegisteredHotKeys(true).Select(hk => new HotKeySetting {
                Id = hk.Id, KeyCode = (int)hk.KeyData
            }).ToArray();

            List <object> pluginSettings = new List <object>();

            foreach (IPersistableImageFormat output in ImageCapture.ImageOutputs)
            {
                IConfigurablePlugin plugin = output as IConfigurablePlugin;
                plugin?.ConfigurationForm?.Save();
                if (plugin?.Settings != null)
                {
                    pluginSettings.Add(plugin.Settings);
                }
            }
            Configuration.Current.PluginSettings = pluginSettings.ToArray();

            DialogResult = DialogResult.OK;
            Close();
        }
        public static void Present(IConfigurablePlugin configurableEntity, string path, bool modal)
        {
            if (configurableEntity == null) 
                throw new ArgumentNullException("configurableEntity");

            ConfigurationDialog singleton = ConfigurationDialog.GetSingleton<ConfigurationDialog>(false, configurableEntity.Name) ?? 
                new ConfigurationDialog(configurableEntity);

            if (singleton.MainPanel.Categories.Count == 0)
                MessageBox.Show(TextResources.MsgBox_Text_NoOptionsAvailable, TextResources.MsgBox_Caption_NoOptionsAvailable, MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
            {
                singleton.MainPanel.SetPath(path);
                singleton.ShowSingleton(modal);
            }
        }
Beispiel #9
0
 private static void EnsureOutputsLoaded()
 {
     if (imageOutputCollection == null)
     {
         imageOutputCollection = Plugins.Load();
         foreach (IPersistableImageFormat format in imageOutputCollection)
         {
             IConfigurablePlugin plugin = format as IConfigurablePlugin;
             if (plugin != null && plugin.Settings != null)
             {
                 object settings = Configuration.Current.RetrieveSettingsForPlugin(plugin.Settings.GetType());
                 if (settings != null)
                 {
                     plugin.Settings = settings;
                 }
             }
         }
     }
 }
Beispiel #10
0
 public static string CreatePath(IConfigurablePlugin plugin, string category, string item)
 {
     return CreatePath(plugin, category, item, null);
 }
Beispiel #11
0
 public static void Present(IConfigurablePlugin configurableEntity, bool modal)
 {
     Present(configurableEntity, null, modal);
 }
Beispiel #12
0
        public static string CreatePath(IConfigurablePlugin plugin, string category, string item, string parameter)
        {
            if (plugin == null)
                throw new ArgumentNullException("plugin");

            if (String.IsNullOrEmpty(category))
                throw new ArgumentNullException("category");

            if (String.IsNullOrEmpty(item))
                throw new ArgumentNullException("item");

            return String.Format("{1}{0}{2}{0}{3}{0}{4}", PathSeparator.ToString(), plugin.Name, category, item, (parameter ?? String.Empty));
        }
Beispiel #13
0
 public static void Present(bool modal, IConfigurablePlugin plugin)
 {
     Present(modal, plugin, null);
 }
Beispiel #14
0
        private TabStripPage CreateAndRegisterEntityPage(CategoryCollection categories, IConfigurablePlugin entity, int index)
        {
            TabStripPage entityPage = new TabStripPage();
            entityPage.BaseColor = System.Drawing.Color.FromArgb(215, 227, 242);
            entityPage.BaseColorOn = System.Drawing.Color.FromArgb(215, 227, 242);
            entityPage.Dock = System.Windows.Forms.DockStyle.Fill;
            entityPage.Opacity = 255;
            entityPage.Padding = new System.Windows.Forms.Padding(0, 3, 0, 0);
            entityPage.Size = new System.Drawing.Size(784, 99);
            entityPage.Speed = 1;
            entityPage.TabIndex = index;

            RibbonPageSwitcher.Controls.Add(entityPage);

            Tab entityTab = new Tab(entity.Name);
            entityTab.AutoSize = false;
            entityTab.Checked = true;
            entityTab.CheckState = CheckState.Checked;
            entityTab.ForeColor = System.Drawing.Color.FromArgb(44, 90, 154);
            entityTab.Margin = new Padding(6, 1, 0, 2);
            entityTab.Size = new Size(73, 23);
            entityTab.Text = entity.Name;
            entityTab.TabStripPage = entityPage;

            if (entity is IInternalConfigurator)
                entityTab.Image = VisualResources.Icon_16x16_Hyphen.ToBitmap();

            RibbonStrip.Items.Add(entityTab);

            return entityPage;
        }
Beispiel #15
0
        private void PopulateCategoryPanel(TabStripPage entityPage, Category category, IConfigurablePlugin plugin, int index)
        {
            TabPanel categoryPanel = CreateCategoryPanel(category, index);
            entityPage.Controls.Add(categoryPanel);

            if (CanNavigateTo(plugin, category))
                RibbonPageSwitcher.SelectedTabStripPage = entityPage;

            Point nextLocation = new Point();

            foreach (CategoryItem item in category.Items)
            {
                RibbonButton btn = CreateButton(item, ref nextLocation);
                categoryPanel.Controls.Add(btn);

                if (CanNavigateTo(item))
                    RibbonButton_Click(btn, EventArgs.Empty);
            }
        }
Beispiel #16
0
        private void Populate(IConfigurablePlugin pluginToPopulate)
        {
            ConfigurableEntities.Clear();

            RibbonPageSwitcher.SelectedTabStripPage = null;
            RibbonStrip.Items.Clear();

            if (pluginToPopulate == null)
            {
                PopulateHyphenConfiguration();

                if (AppDomain.CurrentDomain.IsDefaultAppDomain())
                    PopulateStandalonePlugins();
                else
                    PopulateIsolatedPlugins();
            }
            else
            {
                ConfigurableEntities.Add(new ConfigurableEntityDescriptor(pluginToPopulate));
                Text += String.Format(" : {0}", pluginToPopulate.Name);
            }

            PopulateItems();
        }
Beispiel #17
0
        private bool CanNavigateTo(IConfigurablePlugin plugin, Category category)
        {
            if (plugin == null)
                throw new ArgumentNullException("plugin");

            if (category == null)
                throw new ArgumentNullException("category");

            if (CurrentPath == null)
                return false;

            return (CurrentPath[0] == plugin.Name && CurrentPath[1] == category.Name);
        }