/// <summary>
        /// Updates <see cref="newPluginInfo"/> with the contents of the
        /// form's controls. Also updates the preview box.
        /// </summary>
        private void UpdatePluginInfo()
        {
            // Create new pipeline and copy elements back from the binding list.
            Pipeline pipeline = new Pipeline();

            pipeline.Elements.AddRange(elements);

            // Create new plugin info and save encoded elements.
            PipelinePluginInfo pluginInfo = new PipelinePluginInfo {
                Id              = pluginId,
                Description     = NameTxt.Text,
                EncodedElements = pipeline.Encode(),
                RequiredVersion = pipeline.RequiredVersion,
                EditMode        = PipelinePluginEditMode.Expert,
            };

            Debug.Assert(!pluginInfo.Global);

            // Save plugin info and pipeline, then update preview and min version.
            newPluginInfo      = pluginInfo;
            newPipeline        = pipeline;
            PreviewCtrl.Plugin = newPluginInfo.ToPlugin();
            Version requiredVersion = newPipeline.RequiredVersion;
            int     numComponents;

            if (requiredVersion.Revision > 0)
            {
                numComponents = 4;
            }
            else if (requiredVersion.Build > 0)
            {
                numComponents = 3;
            }
            else
            {
                numComponents = 2;
            }
            MinVersionLbl.Text = string.Format(CultureInfo.CurrentCulture,
                                               MinVersionLbl.Tag as string, requiredVersion.ToString(numComponents));
        }
        /// <summary>
        /// Updates <see cref="newPluginInfo"/> with the contents of the
        /// form's controls. Also updates the preview box.
        /// </summary>
        private void UpdatePluginInfo()
        {
            // Create new pipeline and copy elements back from the binding list.
            Pipeline pipeline = new Pipeline();

            pipeline.Elements.AddRange(elements);

            // Create new plugin info and save encoded elements.
            PipelinePluginInfo pluginInfo = new PipelinePluginInfo();

            pluginInfo.Id              = pluginId;
            pluginInfo.Description     = NameTxt.Text;
            pluginInfo.EncodedElements = pipeline.Encode();
            pluginInfo.RequiredVersion = pipeline.RequiredVersion;
            pluginInfo.EditMode        = PipelinePluginEditMode.Expert;
            Debug.Assert(!pluginInfo.Global);

            // Save plugin info and pipeline, then update preview.
            newPluginInfo      = pluginInfo;
            newPipeline        = pipeline;
            PreviewCtrl.Plugin = newPluginInfo.ToPlugin();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates <see cref="newPluginInfo"/> with the contents of the
        /// form's controls. Also updates the preview box.
        /// </summary>
        private void UpdatePluginInfo()
        {
            // Create a pipeline based on form controls.
            Pipeline pipeline = new Pipeline();

            if (LaunchExecutableChk.Checked)
            {
                if (WithFilelistChk.Checked)
                {
                    pipeline.Elements.Add(new ExecutableWithFilelistPipelineElement(ExecutableTxt.Text));
                }
                else
                {
                    pipeline.Elements.Add(new ExecutablePipelineElement(ExecutableTxt.Text));
                }
            }
            if (CopyOnSameLineChk.Enabled)
            {
                if (CopyOnSameLineChk.Checked)
                {
                    pipeline.Elements.Add(new PathsSeparatorPipelineElement(PipelinePluginEditor.PATHS_SEPARATOR_ON_SAME_LINE));
                }
            }
            else
            {
                // Copy non-standard value we had earlier
                Debug.Assert(!String.IsNullOrEmpty(oldPathsSeparator));
                pipeline.Elements.Add(new PathsSeparatorPipelineElement(oldPathsSeparator));
            }
            if (BasePluginLst.SelectedIndex != -1)
            {
                pipeline.Elements.Add(new ApplyPluginPipelineElement(
                                          ((Plugin)BasePluginLst.SelectedItem).Id));
            }
            if (FindTxt.Text.Length > 0)
            {
                if (UseRegexChk.Checked)
                {
                    pipeline.Elements.Add(new RegexPipelineElement(FindTxt.Text, ReplaceTxt.Text, IgnoreCaseChk.Checked));
                }
                else
                {
                    pipeline.Elements.Add(new FindReplacePipelineElement(FindTxt.Text, ReplaceTxt.Text));
                }
            }
            if (BackToForwardSlashesRadio.Checked)
            {
                pipeline.Elements.Add(new BackToForwardSlashesPipelineElement());
            }
            else if (ForwardToBackslashesRadio.Checked)
            {
                pipeline.Elements.Add(new ForwardToBackslashesPipelineElement());
            }
            if (RemoveExtChk.Checked)
            {
                pipeline.Elements.Add(new RemoveExtPipelineElement());
            }
            if (OptionalQuotesChk.Checked)
            {
                pipeline.Elements.Add(new OptionalQuotesPipelineElement());
            }
            else if (QuotesChk.Checked)
            {
                pipeline.Elements.Add(new QuotesPipelineElement());
            }
            if (EmailLinksChk.Checked)
            {
                pipeline.Elements.Add(new EmailLinksPipelineElement());
            }
            if (EncodeURIWhitespaceChk.Checked)
            {
                if (EncodeURICharsChk.Enabled && EncodeURICharsChk.Checked)
                {
                    pipeline.Elements.Add(new EncodeURICharsPipelineElement());
                }
                else
                {
                    pipeline.Elements.Add(new EncodeURIWhitespacePipelineElement());
                }
            }

            // Create new plugin info and save encoded elements.
            PipelinePluginInfo pluginInfo = new PipelinePluginInfo();

            pluginInfo.Id              = pluginId;
            pluginInfo.Description     = NameTxt.Text;
            pluginInfo.EncodedElements = pipeline.Encode();
            pluginInfo.RequiredVersion = pipeline.RequiredVersion;
            pluginInfo.EditMode        = PipelinePluginEditMode.Simple;
            Debug.Assert(!pluginInfo.Global);

            // Save plugin info in newPluginInfo and update preview.
            newPluginInfo      = pluginInfo;
            PreviewCtrl.Plugin = newPluginInfo.ToPlugin();
        }