Example #1
0
        protected virtual FormButtons ConvertProcessing(OfficeRange aWordRange, FontConverter aThisFC, string strInput, ref int nCharIndex, ref string strReplace)
        {
            // here's the meat of the WordShowConversionDiffProcessor engine: only process
            //  the word if the input is different from the converted output
            string strOutput = aThisFC.DirectableEncConverter.Convert(strInput);

            FormButtons res = FormButtons.None;

            if (!Form.SkipIdenticalValues || (strInput != strOutput))
            {
                if (ReplaceAll)
                {
                    strReplace = strOutput;
                    res        = FormButtons.ReplaceAll;
                }
                else
                {
                    res = Form.Show(aThisFC, strInput, strOutput);

                    // just in case it's Replace or ReplaceAll, our replacement string is the 'Forward' conversion
                    strReplace = Form.ForwardString;
                }
            }

            return(res);
        }
        protected void ProcessButtonEx(FormButtons eFormButton)
        {
            if (String.IsNullOrEmpty(ecTextBoxFindWhat.Text))
            {
                throw new ApplicationException("Enter a regular expression in the 'Find what' box");
            }

            m_doc.Document.Application.System.Cursor = Microsoft.Office.Interop.Word.WdCursorType.wdCursorWait; // be sure to turn it off in backgroundWorker_RunWorkerCompleted

            // if there's no processor (e.g. initially, change of Find What or Replace With text)...
            if (m_aWordByWordProcessor == null)
            {
                AddToComboBox(ecTextBoxFindWhat, comboBoxFindWhat, Properties.Settings.Default.RecentFindWhat);

                // if the user clicked Find/Next, then don't give the Replace With text even if there is some
                m_aWordByWordProcessor = new FindWordProcessor(ecTextBoxFindWhat.Text, ecTextBoxReplaceWith.Text,
                                                               checkBoxMatchCase.Checked, ecTextBoxFindWhat.Font);
            }

            // update the button pressed information
            m_aWordByWordProcessor.FormButton = eFormButton;

            // if we're doing a replacement, then save the 'Replace with' string in our settings file
            if ((eFormButton == FormButtons.ReplaceOnce) || (eFormButton == FormButtons.ReplaceAll))
            {
                AddToComboBox(ecTextBoxReplaceWith, comboBoxReplaceWith, Properties.Settings.Default.RecentReplaceWith);

                // the user may have done 'Replace' when it was found, but then later clicked said ReplaceAll,
                //  so update the value
                if (eFormButton == FormButtons.ReplaceAll)
                {
                    m_aWordByWordProcessor.ReplaceAll        = true;
                    m_aWordByWordProcessor.NumOfReplacements = 0;
                }
            }

            // if the user manually repositioned the insertion point, then we have to start over.
            if (m_doc.HasPositionChanged)
            {
                // determine if this is a single selection or "the rest of the document" from the insertion point
                m_doc.DetermineRangeToSearch(out m_eSearchAreaType);
                System.Diagnostics.Debug.Assert(m_doc.theRangeToSearch != null);

                if (m_eSearchAreaType == SearchAreaType.eWholeDocument)
                {
                    progressBar.Maximum = m_doc.theRangeToSearch.End;
                }
            }
            else if (m_aWordByWordProcessor.IsFound && (eFormButton == FormButtons.Next))
            {
                m_doc.BumpPastLastFound();
            }

            m_doc.theSearchProcessor = m_aWordByWordProcessor;

            progressBar.Visible    = true; // be sure to turn it off during backgroundWorker_RunWorkerCompleted
            this.buttonCancel.Text = cstrStop;

            CallWorkerBee();
        }
Example #3
0
        protected override FormButtons ConvertProcessing(OfficeRange aWordRange, FontConverter aThisFC, string strInput, ref int nCharIndex, ref string strReplace)
        {
            // here's the meat of the RoundTripChecker engine: process the word both in the
            // forward and reverse directions and compare the 2nd output with the input
            string strOutput    = aThisFC.DirectableEncConverter.Convert(strInput);
            string strRoundtrip = aThisFC.DirectableEncConverter.ConvertDirectionOpposite(strOutput);

            // our 'form' is really a RoundTripProcessorForm (which has special methods/properties we need to call)
            RoundTripProcessorForm form = (RoundTripProcessorForm)Form;
            FormButtons            res  = FormButtons.None;

            if (!form.SkipIdenticalValues || (strInput != strRoundtrip))
            {
                if (ReplaceAll)
                {
                    strReplace = strRoundtrip;
                    res        = FormButtons.ReplaceAll;
                }
                else
                {
                    res = form.Show(aThisFC, strInput, strOutput, strRoundtrip);

                    // just in case it's Replace or ReplaceAll, our replacement string is the 'RoundTripString'
                    strReplace = form.RoundTripString;
                }
            }

            return(res);
        }
Example #4
0
        void OnMouseLeave(object sender, EventArgs e)
        {
            _hoveredButtons = Themes.FormButtons.None;
            _ttm.RemoveAll();

            Invalidate(_rcClose);
            Invalidate(_rcMinimize);
            Invalidate(_rcMaximize);
        }
Example #5
0
		protected void ProcessButtonEx(FormButtons eFormButton)
		{
			if (String.IsNullOrEmpty(ecTextBoxFindWhat.Text))
				throw new ApplicationException("Enter a regular expression in the 'Find what' box");

			m_doc.Document.Application.System.Cursor = Microsoft.Office.Interop.Word.WdCursorType.wdCursorWait; // be sure to turn it off in backgroundWorker_RunWorkerCompleted

			// if there's no processor (e.g. initially, change of Find What or Replace With text)...
			if (m_aWordByWordProcessor == null)
			{
				AddToComboBox(ecTextBoxFindWhat, comboBoxFindWhat, Properties.Settings.Default.RecentFindWhat);

				// if the user clicked Find/Next, then don't give the Replace With text even if there is some
				m_aWordByWordProcessor = new FindWordProcessor(ecTextBoxFindWhat.Text, ecTextBoxReplaceWith.Text,
					checkBoxMatchCase.Checked, ecTextBoxFindWhat.Font);
			}

			// update the button pressed information
			m_aWordByWordProcessor.FormButton = eFormButton;

			// if we're doing a replacement, then save the 'Replace with' string in our settings file
			if ((eFormButton == FormButtons.ReplaceOnce) || (eFormButton == FormButtons.ReplaceAll))
			{
				AddToComboBox(ecTextBoxReplaceWith, comboBoxReplaceWith, Properties.Settings.Default.RecentReplaceWith);

				// the user may have done 'Replace' when it was found, but then later clicked said ReplaceAll,
				//  so update the value
				if (eFormButton == FormButtons.ReplaceAll)
				{
					m_aWordByWordProcessor.ReplaceAll = true;
					m_aWordByWordProcessor.NumOfReplacements = 0;
				}
			}

			// if the user manually repositioned the insertion point, then we have to start over.
			if (m_doc.HasPositionChanged)
			{
				// determine if this is a single selection or "the rest of the document" from the insertion point
				m_doc.DetermineRangeToSearch(out m_eSearchAreaType);
				System.Diagnostics.Debug.Assert(m_doc.theRangeToSearch != null);

				if (m_eSearchAreaType == SearchAreaType.eWholeDocument)
					progressBar.Maximum = m_doc.theRangeToSearch.End;
			}
			else if (m_aWordByWordProcessor.IsFound && (eFormButton == FormButtons.Next))
			{
				m_doc.BumpPastLastFound();
			}

			m_doc.theSearchProcessor = m_aWordByWordProcessor;

			progressBar.Visible = true; // be sure to turn it off during backgroundWorker_RunWorkerCompleted
			this.buttonCancel.Text = cstrStop;

			CallWorkerBee();
		}
Example #6
0
		protected void ProcessButton(FormButtons eFormButton)
		{
			try
			{
				if (backgroundWorker.IsBusy)
					throw new ApplicationException("Click the 'Stop' button to cancel the current search");
				ProcessButtonEx(eFormButton);
			}
			catch (Exception ex)
			{
				OfficeApp.DisplayException(ex);
			}
		}
 protected void ProcessButton(FormButtons eFormButton)
 {
     try
     {
         if (backgroundWorker.IsBusy)
         {
             throw new ApplicationException("Click the 'Stop' button to cancel the current search");
         }
         ProcessButtonEx(eFormButton);
     }
     catch (Exception ex)
     {
         OfficeApp.DisplayException(ex);
     }
 }
Example #8
0
        void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_titleDragOperation)
                {
                    int dx = e.X - this._mouseDownLocation.X;
                    int dy = e.Y - this._mouseDownLocation.Y;

                    this.Left += dx;
                    this.Top  += dy;
                }
            }

            _hoveredButtons = FormButtons.None;
            if (_rcClose != Rectangle.Empty && _rcClose.Contains(e.Location))
            {
                _hoveredButtons = FormButtons.Close;
            }
            else if (_rcMinimize != Rectangle.Empty && _rcMinimize.Contains(e.Location))
            {
                _hoveredButtons = FormButtons.Minimize;
            }
            else if (_rcMaximize != Rectangle.Empty && _rcMaximize.Contains(e.Location))
            {
                _hoveredButtons = FormButtons.Maximize;
            }
            else if (_rcTitle != Rectangle.Empty && _rcTitle.Contains(e.Location))
            {
            }
            else
            {
                //_tip.Hide(this);
            }

            Invalidate(_rcClose);
            Invalidate(_rcMinimize);
            Invalidate(_rcMaximize);
        }
Example #9
0
        public bool CompareInputOutputProcess(OfficeRange aWordRange, ref int nCharIndex)
        {
            FormButtons res = FormButtons.None;

            do
            {
                string strInput = aWordRange.Text;
                if (String.IsNullOrEmpty(strInput))
                {
                    return(true);
                }

                // not technically required, but this'll help users (but only for the font we're looking for.
                if (!SuspendUI)
                {
                    aWordRange.Select();
                }

                // did the caller give us a set of Fonts to scan?
                string        strFontName = aWordRange.FontName;
                FontConverter aThisFC     = null;
                if (m_aFC != null)
                {
                    aThisFC = m_aFC;
                }
                else if (m_aFCs != null)
                {
                    if (m_aFCs.ContainsKey(strFontName))
                    {
                        aThisFC = m_aFCs[strFontName];
                    }
                }
                else // otherwise, query the user directly
                {
                    aThisFC = QueryUserForFontScan(strFontName);
                }

                res = FormButtons.None;
                if (aThisFC == null)
                {
                    // not a font that we're processing
                    continue;
                }

                // see if we've already checked this word
                string strReplace = null;
                if (!m_mapCheckedInputStrings.TryGetValue(strInput, out strReplace))
                {
                    res = ConvertProcessing(aWordRange, aThisFC, strInput, ref nCharIndex, ref strReplace);

                    if (res == FormButtons.Cancel)
                    {
                        return(false);
                    }
                    else if ((res == FormButtons.ReplaceAll) || (res == FormButtons.ReplaceOnce) || (res == FormButtons.ReplaceEvery))
                    {
                        ReplaceAll |= (res == FormButtons.ReplaceAll);

                        // this means replace the word in situ, with what was converted
                        ReplaceText(aWordRange, aThisFC.DirectableEncConverter.TargetFont, ref nCharIndex, strReplace);

                        // keep track of this word so that if it comes up again, we'll replace it as is.
                        if (AutoReplaceOnNextFind || (res == FormButtons.ReplaceEvery))
                        {
                            m_mapCheckedInputStrings.Add(strInput, strReplace);
                        }
                    }
                    else if ((aThisFC.RhsFont != null) && (res != FormButtons.Next))
                    {
                        // even if the string doesn't change, if we have an output font, we have to set it.
                        SetRangeFont(aWordRange, aThisFC.RhsFont.Name);
                    }
                }
                else
                {
                    // this particular input string has already been approved for replacement
                    ReplaceText(aWordRange, aThisFC.DirectableEncConverter.TargetFont, ref nCharIndex, strReplace);
                }
            } while (res == FormButtons.Redo);

            return(true);
        }
Example #10
0
        void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_titleDragOperation)
                {
                    int dx = e.X - this._mouseDownLocation.X;
                    int dy = e.Y - this._mouseDownLocation.Y;

                    this.Left += dx;
                    this.Top += dy;
                }
            }

            _hoveredButtons = FormButtons.None;
            if (_rcClose != Rectangle.Empty && _rcClose.Contains(e.Location))
            {
                _hoveredButtons = FormButtons.Close;
            }
            else if (_rcMinimize != Rectangle.Empty && _rcMinimize.Contains(e.Location))
            {
                _hoveredButtons = FormButtons.Minimize;
            }
            else if (_rcMaximize != Rectangle.Empty && _rcMaximize.Contains(e.Location))
            {
                _hoveredButtons = FormButtons.Maximize;
            }
            else if (_rcTitle != Rectangle.Empty && _rcTitle.Contains(e.Location))
            {
            }
            else
            {
                //_tip.Hide(this);
            }

            Invalidate(_rcClose);
            Invalidate(_rcMinimize);
            Invalidate(_rcMaximize);

        }
Example #11
0
        void OnMouseLeave(object sender, EventArgs e)
        {
            _hoveredButtons = Themes.FormButtons.None;
            _ttm.RemoveAll();

            Invalidate(_rcClose);
            Invalidate(_rcMinimize);
            Invalidate(_rcMaximize);
        }
        /// <summary>
        /// Build the email address entry form
        /// </summary>
        protected override void CreateChildControls()
        {
            if (this.Service == null || this.Service.Id <= 0 || String.IsNullOrEmpty(this.Service.Name))
            {
                // Add header template
                if (NotFoundHeaderTemplate != null)
                {
                    XhtmlContainer header = new XhtmlContainer();
                    NotFoundHeaderTemplate.InstantiateIn(header);
                    this.Controls.Add(header);
                }

                // Add no service template
                if (NotFoundTemplate == null)
                {
                    NotFoundTemplate = new DefaultTemplate(this.Service, Resources.EmailSubscribeNoService);
                }

                XhtmlContainer template = new XhtmlContainer();
                NotFoundTemplate.InstantiateIn(template);
                this.Controls.Add(template);

                // Add footer template
                if (NotFoundFooterTemplate != null)
                {
                    XhtmlContainer footer = new XhtmlContainer();
                    NotFoundFooterTemplate.InstantiateIn(footer);
                    this.Controls.Add(footer);
                }
            }
            else
            {
                bool IsNewSubscription = true;

                // Get activation code from querystring
                string subscriptionCode = this.Context.Request.QueryString[this.CodeParameter];
                // Did we find a valid subscription code?
                if (!string.IsNullOrEmpty(subscriptionCode))
                {
                    // This is a change of an existing subscription.
                    IsNewSubscription = false;
                }

                // Add header template
                if (SubscribeHeaderTemplate != null)
                {
                    XhtmlContainer header = new XhtmlContainer();
                    SubscribeHeaderTemplate.InstantiateIn(header);
                    this.Controls.Add(header);
                }

                // Add intro template
                if (IntroTemplate == null)
                {
                    if (IsNewSubscription)
                    {
                        IntroTemplate = new DefaultTemplate(this.Service, Resources.EmailSubscribeIntro);
                    }
                    else
                    {
                        IntroTemplate = new DefaultTemplate(this.Service, Resources.SubscriptionOptionsUpdateIntro);
                    }
                }

                XhtmlContainer intro = new XhtmlContainer();
                IntroTemplate.InstantiateIn(intro);
                this.Controls.Add(intro);

                // If the intro contains a Literal with the id "serviceName", replace it with the current service name
                Literal serviceName = intro.FindControl("IntroServiceName") as Literal;
                if (serviceName != null)
                {
                    serviceName.Text = Service.Name;
                }

                // validation messages - added in at this point to work around a .NET bug
                this.Controls.Add(new EsccValidationSummary());

                // Add form header template
                if (FormHeaderTemplate != null)
                {
                    XhtmlContainer header = new XhtmlContainer();
                    FormHeaderTemplate.InstantiateIn(header);
                    this.Controls.Add(header);
                }

                if (IsNewSubscription)
                {
                    // Display controls suitable for a new subscription.

                    // email box
                    this.email           = new TextBox();
                    this.email.MaxLength = 255;    // e-GIF
                    this.email.ID        = "sub1"; // don't call the box "email", spammers look for that
                    this.email.CssClass  = "email";

                    FormPart emailPart = new FormPart(Resources.EmailEntryPrompt, this.email);
                    emailPart.Required = true;
                    this.Controls.Add(emailPart);

                    // Confirm email box
                    this.confirmEmail           = new TextBox();
                    this.confirmEmail.MaxLength = 255; // e-GIF
                    this.confirmEmail.ID        = "sub2";
                    this.confirmEmail.CssClass  = "email";

                    FormPart confirmPart = new FormPart(Resources.EmailConfirmEntryPrompt, this.confirmEmail);
                    confirmPart.Required = true;
                    this.Controls.Add(confirmPart);

                    // validate email
                    EsccRequiredFieldValidator vrEmail = new EsccRequiredFieldValidator(this.email.ID, Resources.EmailRequiredError);
                    this.Controls.Add(vrEmail);

                    EmailValidator vrxEmail = new EmailValidator(this.email.ID, Resources.EmailInvalidError);
                    this.Controls.Add(vrxEmail);

                    // validate confirmation of email - no need for an EmailValidator because it must match the one above
                    EsccRequiredFieldValidator vrConfirm = new EsccRequiredFieldValidator(this.confirmEmail.ID, Resources.EmailConfirmRequiredError);
                    this.Controls.Add(vrConfirm);

                    EsccCustomValidator vMatchConfirm = new EsccCustomValidator(this.confirmEmail.ID, Resources.EmailConfirmMismatchError);
                    vMatchConfirm.ServerValidate += new ServerValidateEventHandler(vMatchConfirm_ServerValidate);
                    this.Controls.Add(vMatchConfirm);

                    // validate that email is not already subscribed to this service
                    EsccCustomValidator vSubscriptionExists = new EsccCustomValidator(this.confirmEmail.ID, Resources.EmailAlreadySubscribed);
                    vSubscriptionExists.ServerValidate += new ServerValidateEventHandler(vSubscriptionExists_ServerValidate);
                    this.Controls.Add(vSubscriptionExists);
                }
                else
                {
                    // Display controls suitable for a subscription update.

                    // Add the subscription email address as information feedback.
                    this.emailReadOnly      = new Label();
                    this.emailReadOnly.ID   = "sub3"; // don't call the box "email", spammers look for that
                    this.emailReadOnly.Text = this.GetEmailAddressForExistingSubscription(new Guid(subscriptionCode));

                    FormPart emailPart = new FormPart(Properties.Resources.EmailEntryPrompt, this.emailReadOnly);
                    this.Controls.Add(emailPart);
                }

                // Add extra options template
                if (FormExtraOptionsTemplate != null)
                {
                    XhtmlContainer extraOptions = new XhtmlContainer();
                    FormExtraOptionsTemplate.InstantiateIn(extraOptions);
                    this.Controls.Add(extraOptions);
                }

                // Add form footer template
                if (FormFooterTemplate != null)
                {
                    XhtmlContainer footer = new XhtmlContainer();
                    FormFooterTemplate.InstantiateIn(footer);
                    this.Controls.Add(footer);
                }

                // Submit button
                EsccButton submitButton = new EsccButton();
                submitButton.Text     = Resources.SubscribeButtonText;
                submitButton.CssClass = "button";
                submitButton.Click   += new EventHandler(submitButton_Click);

                // Update button
                EsccButton updateButton = new EsccButton();
                updateButton.Text     = Resources.SubscriptionOptionsUpdateButtonText;
                updateButton.CssClass = "button buttonBigger";
                updateButton.Click   += new EventHandler(updateButton_Click);

                FormButtons buttons = new FormButtons();
                if (IsNewSubscription)
                {
                    buttons.Controls.Add(submitButton);
                }
                else
                {
                    buttons.Controls.Add(updateButton);
                }
                this.Controls.Add(buttons);

                // Add footer template
                if (SubscribeFooterTemplate != null)
                {
                    XhtmlContainer footer = new XhtmlContainer();
                    SubscribeFooterTemplate.InstantiateIn(footer);
                    this.Controls.Add(footer);
                }
            }
        }
        /// <summary>
        /// Build the email address entry form
        /// </summary>
        protected override void CreateChildControls()
        {
            if (this.Service == null || this.Service.Id <= 0 || String.IsNullOrEmpty(this.Service.Name))
            {
                // Add header template
                if (NotFoundHeaderTemplate != null)
                {
                    XhtmlContainer header = new XhtmlContainer();
                    NotFoundHeaderTemplate.InstantiateIn(header);
                    this.Controls.Add(header);
                }

                // Add no service template
                if (NotFoundTemplate == null) NotFoundTemplate = new DefaultTemplate(this.Service, Resources.EmailSubscribeNoService);

                XhtmlContainer template = new XhtmlContainer();
                NotFoundTemplate.InstantiateIn(template);
                this.Controls.Add(template);

                // Add footer template
                if (NotFoundFooterTemplate != null)
                {
                    XhtmlContainer footer = new XhtmlContainer();
                    NotFoundFooterTemplate.InstantiateIn(footer);
                    this.Controls.Add(footer);
                }
            }
            else
            {
                bool IsNewSubscription = true;

                // Get activation code from querystring
                string subscriptionCode = this.Context.Request.QueryString[this.CodeParameter];
                // Did we find a valid subscription code?
                if (!string.IsNullOrEmpty(subscriptionCode))
                {
                    // This is a change of an existing subscription.
                    IsNewSubscription = false;
                }

                // Add header template
                if (SubscribeHeaderTemplate != null)
                {
                    XhtmlContainer header = new XhtmlContainer();
                    SubscribeHeaderTemplate.InstantiateIn(header);
                    this.Controls.Add(header);
                }

                // Add intro template
                if (IntroTemplate == null)
                {
                    if (IsNewSubscription)
                    {
                        IntroTemplate = new DefaultTemplate(this.Service, Resources.EmailSubscribeIntro);
                    }
                    else
                    {
                        IntroTemplate = new DefaultTemplate(this.Service, Resources.SubscriptionOptionsUpdateIntro);
                    }
                }

                XhtmlContainer intro = new XhtmlContainer();
                IntroTemplate.InstantiateIn(intro);
                this.Controls.Add(intro);

                // If the intro contains a Literal with the id "serviceName", replace it with the current service name
                Literal serviceName = intro.FindControl("IntroServiceName") as Literal;
                if (serviceName != null) serviceName.Text = Service.Name;

                // validation messages - added in at this point to work around a .NET bug
                this.Controls.Add(new EsccValidationSummary());

                // Add form header template
                if (FormHeaderTemplate != null)
                {
                    XhtmlContainer header = new XhtmlContainer();
                    FormHeaderTemplate.InstantiateIn(header);
                    this.Controls.Add(header);
                }

                if (IsNewSubscription)
                {
                    // Display controls suitable for a new subscription.

                    // email box
                    this.email = new TextBox();
                    this.email.MaxLength = 255; // e-GIF
                    this.email.ID = "sub1"; // don't call the box "email", spammers look for that
                    this.email.CssClass = "email";

                    FormPart emailPart = new FormPart(Resources.EmailEntryPrompt, this.email);
                    emailPart.Required = true;
                    this.Controls.Add(emailPart);

                    // Confirm email box
                    this.confirmEmail = new TextBox();
                    this.confirmEmail.MaxLength = 255; // e-GIF
                    this.confirmEmail.ID = "sub2";
                    this.confirmEmail.CssClass = "email";

                    FormPart confirmPart = new FormPart(Resources.EmailConfirmEntryPrompt, this.confirmEmail);
                    confirmPart.Required = true;
                    this.Controls.Add(confirmPart);

                    // validate email
                    EsccRequiredFieldValidator vrEmail = new EsccRequiredFieldValidator(this.email.ID, Resources.EmailRequiredError);
                    this.Controls.Add(vrEmail);

                    EmailValidator vrxEmail = new EmailValidator(this.email.ID, Resources.EmailInvalidError);
                    this.Controls.Add(vrxEmail);

                    // validate confirmation of email - no need for an EmailValidator because it must match the one above
                    EsccRequiredFieldValidator vrConfirm = new EsccRequiredFieldValidator(this.confirmEmail.ID, Resources.EmailConfirmRequiredError);
                    this.Controls.Add(vrConfirm);

                    EsccCustomValidator vMatchConfirm = new EsccCustomValidator(this.confirmEmail.ID, Resources.EmailConfirmMismatchError);
                    vMatchConfirm.ServerValidate += new ServerValidateEventHandler(vMatchConfirm_ServerValidate);
                    this.Controls.Add(vMatchConfirm);

                    // validate that email is not already subscribed to this service
                    EsccCustomValidator vSubscriptionExists = new EsccCustomValidator(this.confirmEmail.ID, Resources.EmailAlreadySubscribed);
                    vSubscriptionExists.ServerValidate += new ServerValidateEventHandler(vSubscriptionExists_ServerValidate);
                    this.Controls.Add(vSubscriptionExists);
                }
                else
                {
                    // Display controls suitable for a subscription update.

                    // Add the subscription email address as information feedback.
                    this.emailReadOnly = new Label();
                    this.emailReadOnly.ID = "sub3"; // don't call the box "email", spammers look for that
                    this.emailReadOnly.Text = this.GetEmailAddressForExistingSubscription(new Guid(subscriptionCode));

                    FormPart emailPart = new FormPart(Properties.Resources.EmailEntryPrompt, this.emailReadOnly);
                    this.Controls.Add(emailPart);
                }

                // Add extra options template
                if (FormExtraOptionsTemplate != null)
                {
                    XhtmlContainer extraOptions = new XhtmlContainer();
                    FormExtraOptionsTemplate.InstantiateIn(extraOptions);
                    this.Controls.Add(extraOptions);
                }

                // Add form footer template
                if (FormFooterTemplate != null)
                {
                    XhtmlContainer footer = new XhtmlContainer();
                    FormFooterTemplate.InstantiateIn(footer);
                    this.Controls.Add(footer);
                }

                // Submit button
                EsccButton submitButton = new EsccButton();
                submitButton.Text = Resources.SubscribeButtonText;
                submitButton.CssClass = "button";
                submitButton.Click += new EventHandler(submitButton_Click);

                // Update button
                EsccButton updateButton = new EsccButton();
                updateButton.Text = Resources.SubscriptionOptionsUpdateButtonText;
                updateButton.CssClass = "button buttonBigger";
                updateButton.Click += new EventHandler(updateButton_Click);

                FormButtons buttons = new FormButtons();
                if (IsNewSubscription) buttons.Controls.Add(submitButton); else buttons.Controls.Add(updateButton);
                this.Controls.Add(buttons);

                // Add footer template
                if (SubscribeFooterTemplate != null)
                {
                    XhtmlContainer footer = new XhtmlContainer();
                    SubscribeFooterTemplate.InstantiateIn(footer);
                    this.Controls.Add(footer);
                }
            }
        }