コード例 #1
0
        /// <summary>
        /// Called when the form is about to close. If user pressed OK, we save
        /// the content of plugin here.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void AdvancedPipelinePluginForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // If user chose to press OK or switch to Simple Mode, save plugin info.
            if (DialogResult == DialogResult.OK || DialogResult == DialogResult.Retry)
            {
                // Make sure user has entered a name (unless we're switching to Simple Mode).
                if (!string.IsNullOrEmpty(NameTxt.Text) || DialogResult == DialogResult.Retry)
                {
                    // Update plugin info so that we have a pipeline.
                    UpdatePluginInfo();

                    // If pipeline is too complex, user might lose customization by switching
                    // to simple mode. Warn in this case.
                    Debug.Assert(newPipeline != null);
                    if (DialogResult == DialogResult.Retry && !PipelinePluginEditor.IsPipelineSimple(newPipeline))
                    {
                        DialogResult subDialogRes = MessageBox.Show(Resources.PipelinePluginForm_PipelineTooComplexForSimpleMode,
                                                                    Resources.PipelinePluginForm_MsgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (subDialogRes == DialogResult.No)
                        {
                            e.Cancel = true;
                        }
                    }
                }
                else
                {
                    // Warn user that we need a non-empty name.
                    MessageBox.Show(Resources.PipelinePluginForm_EmptyName, Resources.PipelinePluginForm_MsgTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NameTxt.Focus();
                    e.Cancel = true;
                }
            }
        }
コード例 #2
0
 private void NameTxt_Validating(object sender, CancelEventArgs e)
 {
     if (NameTxt.Text.Length > 50)
     {
         MessageBox.Show("Text should be less than 50 char");
     }
     NameTxt.Focus();
 }
コード例 #3
0
 private void AddBtn_Click(object sender, EventArgs e)
 {
     EmployeeList.SelectedItem = null;
     NameTxt.BackColor         = Color.White;
     UniqueIdTxt.BackColor     = Color.White;
     _adding           = true;
     EditGroup.Visible = true;
     NameTxt.Text      = "";
     PasswordTxt.Text  = "";
     EmailTxt.Text     = "";
     UniqueIdTxt.Text  = "";
     Save.Visible      = true;
     Delete.Visible    = false;
     NameTxt.Focus();
 }
コード例 #4
0
 /// <summary>
 /// Called when the form is about to close. If user pressed OK, we save
 /// the content of the plugin here.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event arguments.</param>
 private void PipelinePluginForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     // If user chose to press OK or switch to Expert Mode, save plugin info.
     if (this.DialogResult == DialogResult.OK || this.DialogResult == DialogResult.Retry)
     {
         // Make sure user has entered a name (unless we're switching to Expert Mode).
         if (!String.IsNullOrEmpty(NameTxt.Text) || this.DialogResult == DialogResult.Retry)
         {
             // Update plugin info in case it's out-of-date, so that EditPlugin can return it.
             UpdatePluginInfo();
         }
         else
         {
             // Warn user that we need a non-empty name.
             MessageBox.Show(Resources.PipelinePluginForm_EmptyName, Resources.PipelinePluginForm_MsgTitle,
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
             NameTxt.Focus();
             e.Cancel = true;
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Called when the form is about to close. If user pressed OK, we save
        /// the content of the plugin here.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void PipelinePluginForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // If user chose to press OK, save plugin info.
            if (this.DialogResult == DialogResult.OK)
            {
                // Make sure user has entered a name.
                if (!String.IsNullOrEmpty(NameTxt.Text))
                {
                    // Create a pipeline based on form controls.
                    if (pipeline == null)
                    {
                        pipeline = new Pipeline();
                    }
                    else
                    {
                        pipeline.Clear();
                    }
                    if (CopyOnSameLineChk.Enabled)
                    {
                        if (CopyOnSameLineChk.Checked)
                        {
                            pipeline.Elements.Add(new PathsSeparatorPipelineElement(PATHS_SEPARATOR_ON_SAME_LINE));
                        }
                    }
                    else
                    {
                        // Copy non-standard value we had earlier
                        Debug.Assert(!String.IsNullOrEmpty(pathsSeparator));
                        pipeline.Elements.Add(new PathsSeparatorPipelineElement(pathsSeparator));
                    }
                    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 (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 plugin info if we don't already have one.
                    if (pluginInfo == null)
                    {
                        pluginInfo    = new PipelinePluginInfo();
                        pluginInfo.Id = Guid.NewGuid();
                    }

                    // Save info in plugin info wrapper.
                    pluginInfo.Description     = NameTxt.Text;
                    pluginInfo.EncodedElements = pipeline.Encode();
                    pluginInfo.RequiredVersion = pipeline.RequiredVersion;
                    Debug.Assert(!pluginInfo.Global);
                }
                else
                {
                    // Warn user that we need a non-empty name.
                    MessageBox.Show(Resources.PipelinePluginForm_EmptyName, Resources.PipelinePluginForm_MsgTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    NameTxt.Focus();
                    e.Cancel = true;
                }
            }
        }