// Overriden to always write the "align" or "wrap" attributes when
        // they are changing, even if they are set to defaults.

        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.OpenParagraph"]/*' />
        protected override void OpenParagraph(WmlLayout layout, bool writeAlignment, bool writeWrapping)
        {
            base.OpenParagraph(layout,
                               writeAlignment || layout.Align != _lastAlignment,
                               writeWrapping || layout.Wrap != _lastWrapping);
            _lastAlignment = layout.Align;
            _lastWrapping  = layout.Wrap;
        }
        /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.BeginForm"]/*' />
        public virtual void BeginForm(Form form)
        {
            _cachedFormQueryString = null;
            _currentForm = form;

            _writtenFormVariables = false;

            // To keep track of postbacks which submit form variables,
            // and postbacks that don't. Used for postback cards
            // (see UsePostBackCards)

            _usingPostBackType[0] = _usingPostBackType[1] = false;

            if (AnalyzeMode)
            {
                _numberOfPostBacks = 0;
                _postBackCardsEfficient = false;
                _controlShortNames = null;
            }
            else
            {
                PendingBreak = false;
                _currentWrittenLayout = null;
                _currentWrittenFormat = null;

                RenderBeginForm(form);
            }
        }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlLayout.Compare"]/*' />
 public virtual bool Compare(WmlLayout layout)
 {
     return Wrap == layout.Wrap && Align == layout.Align;
 }
 /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlLayout.WmlLayout"]/*' />
 public WmlLayout(Style style, WmlLayout currentLayout)
 {
     Alignment align = (Alignment)style[Style.AlignmentKey, true];
     Align = (align != Alignment.NotSet) ? align : currentLayout.Align;
     Wrapping wrap = (Wrapping)style[Style.WrappingKey , true];
     Wrap = (wrap != Wrapping.NotSet) ? wrap : currentLayout.Wrap;
 }
        /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.EnterLayout"]/*' />
        public override void EnterLayout(Style style)
        {
            if (AnalyzeMode)
            {
                return;
            }

            WmlLayout newLayout = new WmlLayout(style, CurrentLayout);
            _layoutStack.Push(newLayout);
        }
        // Close any open paragraph.

        /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.CloseParagraph"]/*' />
        protected virtual void CloseParagraph()
        {
            if (_currentWrittenLayout != null)
            {
                CloseCharacterFormat();
                WriteEndTag("p");
                _currentWrittenLayout = null;
            }
        }
        // Opens a paragraph with the given layout. Only the specified 
        // attributes are used.

        /// <include file='doc\WmlMobileTextWriter.uex' path='docs/doc[@for="WmlMobileTextWriter.OpenParagraph"]/*' />
        protected virtual void OpenParagraph(WmlLayout layout, bool writeAlignment, bool writeWrapping)
        {
            if (_currentWrittenLayout == null)
            {
                WriteBeginTag("p");
                if (writeAlignment)
                {
                    String alignment;
                    switch (layout.Align)
                    {
                        case Alignment.Right:
                            alignment = "right";
                            break;

                        case Alignment.Center:
                            alignment = "center";
                            break;

                        default:
                            alignment = "left";
                            break;
                    }

                    WriteAttribute("align", alignment);
                }
                if (writeWrapping)
                {
                    WriteAttribute("mode",
                                   layout.Wrap == Wrapping.NoWrap ? "nowrap" : "wrap");
                }
                Write(">");
                _currentWrittenLayout = layout;
            }
        }
        // Overriden to always write the "align" or "wrap" attributes when
        // they are changing, even if they are set to defaults.

        /// <include file='doc\UpWmlMobileTextWriter.uex' path='docs/doc[@for="UpWmlMobileTextWriter.OpenParagraph"]/*' />
        protected override void OpenParagraph(WmlLayout layout, bool writeAlignment, bool writeWrapping)
        {
            base.OpenParagraph(layout,
                               writeAlignment || layout.Align != _lastAlignment,
                               writeWrapping  || layout.Wrap != _lastWrapping);
            _lastAlignment = layout.Align;
            _lastWrapping = layout.Wrap;
        }