/// <summary>
        ///    <para>
        ///       Returns the design-time HTML of the <see cref='System.Web.UI.MobileControls.TextBox'/>
        ///       mobile control
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The HTML of the control.
        ///    </para>
        /// </returns>
        /// <seealso cref='System.Web.UI.MobileControls.TextBox'/>
        protected override String GetDesignTimeNormalHtml()
        {
            DesignerTextWriter tw = new DesignerTextWriter();

            _textBox.Adapter.Render(tw);
            return(tw.ToString());
        }
        /// <summary>
        ///    <para>
        ///       Gets the design time HTML of ValidatorBase controls.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The design time
        ///       HTML of the control.
        ///    </para>
        /// </returns>
        protected override String GetDesignTimeNormalHtml()
        {
            Debug.Assert(_baseValidator.Text != null);

            String           originalText     = _baseValidator.ErrorMessage;
            ValidatorDisplay validatorDisplay = _baseValidator.Display;
            bool             blankText        = (validatorDisplay == ValidatorDisplay.None ||
                                                 (originalText.Trim().Length == 0 && _baseValidator.Text.Trim().Length == 0));

            if (blankText)
            {
                _baseValidator.ErrorMessage = "[" + _baseValidator.ID + "]";
            }

            DesignerTextWriter tw = new DesignerTextWriter();

            _baseValidator.Adapter.Render(tw);

            if (blankText)
            {
                _baseValidator.ErrorMessage = originalText;
            }

            return(tw.ToString());
        }
Example #3
0
        protected override String GetDesignTimeNormalHtml()
        {
            DesignerTextWriter writer = new DesignerTextWriter();

            _adRotator.Adapter.Render(writer);

            return(writer.ToString());
        }
        /// <summary>
        ///    <para>
        ///       Gets the HTML to be used for the design time representation of the control runtime.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The design time HTML.
        ///    </para>
        /// </returns>
        protected override String GetDesignTimeNormalHtml()
        {
            DesignerTextWriter tw = new DesignerTextWriter();

            _validationSummary.Adapter.Render(tw);

            return(tw.ToString());
        }
        /// <summary>
        ///    <para>
        ///       Gets the HTML to be used for the design time representation
        ///       of the control.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The design time HTML.
        ///    </para>
        /// </returns>
        protected override String GetDesignTimeNormalHtml()
        {
            int    sampleRows = 5;
            bool   dummyDataSource = false;
            String oldLabelField, oldTableFields;

            oldLabelField  = _objectList.LabelField;
            oldTableFields = _objectList.TableFields;

            DesignerTextWriter htmlWriter = new DesignerTextWriter(true);

            if (_objectList.DeviceSpecific != null)
            {
                _objectList.DeviceSpecific.SetDesignerChoice(CurrentChoice);
            }

            IEnumerable designTimeDataSource = GetDesignTimeDataSource(sampleRows, out dummyDataSource);

            bool oldAutoGenerateFields = _objectList.AutoGenerateFields;

            if ((oldAutoGenerateFields == false) && (_objectList.Fields.Count == 0))
            {
                // ensure that AutoGenerateFields is true when we don't have
                // any fields defined, so we see atleast something at design time.
                _objectList.AutoGenerateFields = true;
            }

            // Replace original labelfield with empty string to ensure dummy datasource will be rendered
            if (dummyDataSource)
            {
                _objectList.LabelField  = String.Empty;
                _objectList.TableFields = String.Empty;
            }

            try
            {
                _objectList.DataSource = designTimeDataSource;
                _objectList.DataBind();
                _objectList.Adapter.Render(htmlWriter);
            }
            finally
            {
                _objectList.DataSource         = null;
                _objectList.AutoGenerateFields = oldAutoGenerateFields;

                if (dummyDataSource)
                {
                    _objectList.LabelField  = oldLabelField;
                    _objectList.TableFields = oldTableFields;
                }

                // Remove controls created by databinding the DataSource
                _objectList.Controls.Clear();
                _objectList.InvalidateDisplayFieldIndices();
            }

            return(htmlWriter.ToString());
        }
        /// <summary>
        ///    <para>
        ///       Gets the HTML to be used for the design time representation of the control runtime.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The design time HTML.
        ///    </para>
        /// </returns>
        protected override String GetDesignTimeNormalHtml()
        {
            String             tempUrl    = String.Empty;
            bool               replaceUrl = (_image.ImageUrl.Length > 0);
            DesignerTextWriter writer     = new DesignerTextWriter();

            tempUrl         = _image.ImageUrl;
            _image.ImageUrl = GetConvertedImageURI(_image.ImageUrl);
            _image.Adapter.Render(writer);
            _image.ImageUrl = tempUrl;

            return(writer.ToString());
        }
        /// <summary>
        ///    <para>
        ///       Returns the design-time HTML of the <see cref='System.Web.UI.MobileControls.PhoneCall'/>
        ///       mobile control
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The HTML of the control.
        ///    </para>
        /// </returns>
        /// <seealso cref='System.Web.UI.MobileControls.PhoneCall'/>
        protected override String GetDesignTimeNormalHtml()
        {
            Debug.Assert(_call.Text != null);

            DesignerTextWriter tw;

            Control[] children = null;

            String originalText = _call.Text;
            bool   blankText    = (originalText.Trim().Length == 0);
            bool   hasControls  = _call.HasControls();

            if (blankText)
            {
                if (hasControls)
                {
                    children = new Control[_call.Controls.Count];
                    _call.Controls.CopyTo(children, 0);
                }
                _call.Text = "[" + _call.ID + "]";
            }
            try
            {
                tw = new DesignerTextWriter();
                _call.Adapter.Render(tw);
            }
            finally
            {
                if (blankText)
                {
                    _call.Text = originalText;
                    if (hasControls)
                    {
                        foreach (Control c in children)
                        {
                            _call.Controls.Add(c);
                        }
                    }
                }
            }

            return(tw.ToString());
        }
Example #8
0
        /// <summary>
        ///    Update scheme preview
        /// </summary>
        /// <internalonly/>
        private void UpdateSamplePreview()
        {
            if (_firstActivate)
            {
                return;
            }

            NativeMethods.IHTMLDocument2   tridentDocument = _samplePreview.GetDocument();
            NativeMethods.IHTMLElement     documentElement = tridentDocument.GetBody();
            NativeMethods.IHTMLBodyElement bodyElement;

            bodyElement = (NativeMethods.IHTMLBodyElement)documentElement;
            bodyElement.SetScroll("no");

            if (SelectedStyle == null)
            {
                documentElement.SetInnerHTML(String.Empty);
                tridentDocument.SetBgColor("buttonface");
                return;
            }
            else
            {
                tridentDocument.SetBgColor(String.Empty);
            }

            bool cycle = ReferencesContainCycle(SelectedStyle);

            if (cycle)
            {
                documentElement.SetInnerHTML(String.Empty);
                return;
            }

            // apply the current Style to label
            ApplyStyle();

            DesignerTextWriter tw = new DesignerTextWriter();

            //ToolTip
            tw.AddAttribute("title", ((StyleNode)SelectedStyle).RuntimeStyle.Name);

            // ForeColor
            Color c = _previewStyle.ForeColor;

            if (!c.Equals(Color.Empty))
            {
                tw.AddStyleAttribute("color", ColorTranslator.ToHtml(c));
            }

            // BackColor
            c = _previewStyle.BackColor;
            if (!c.Equals(Color.Empty))
            {
                tw.AddStyleAttribute("background-color", ColorTranslator.ToHtml(c));
            }

            // Font Name
            String name = _previewStyle.Font.Name;

            if (!name.Equals(String.Empty))
            {
                tw.AddStyleAttribute("font-family", name);
            }

            // Font Size
            switch (_previewStyle.Font.Size)
            {
            case FontSize.Large:
                tw.AddStyleAttribute("font-size", "Medium");
                break;

            case FontSize.Small:
                tw.AddStyleAttribute("font-size", "X-Small");
                break;

            default:
                tw.AddStyleAttribute("font-size", "Small");
                break;
            }

            // Font Style
            if (_previewStyle.Font.Bold == BooleanOption.True)
            {
                tw.AddStyleAttribute("font-weight", "bold");
            }
            if (_previewStyle.Font.Italic == BooleanOption.True)
            {
                tw.AddStyleAttribute("font-style", "italic");
            }

            tw.RenderBeginTag("span");
            tw.Write(SR.GetString(SR.StylesEditorDialog_PreviewText));
            tw.RenderEndTag();

            // and show it!
            String finalHTML = "<div align='center'><table width='100%' height='100%'><tr><td><p align='center'>" +
                               tw.ToString() + "</p></td></tr></table></div>";

            documentElement.SetInnerHTML(finalHTML);
        }
        /// <summary>
        ///    <para>
        ///       Gets the HTML to be used for the design-time representation
        ///       of the control.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The design-time HTML.
        ///    </para>
        /// </returns>
        protected override String GetDesignTimeNormalHtml()
        {
            const int   numberOfStaticItems = 5;
            IEnumerable selectedDataSource = null;
            String      oldDataTextField = null, oldDataValueField = null;
            bool        dummyDataSource = false;

            DesignerTextWriter htmlWriter = new DesignerTextWriter(true);

            MobileListItemCollection items = _selectionList.Items;

            Debug.Assert(items != null, "Items is null in LisControl");

            if (items.Count > 0)
            {
                _selectionList.Adapter.Render(htmlWriter);
            }
            else
            {
                MobileListItem[] oldItems = items.GetAll();
                int sampleRows            = numberOfStaticItems;

                // try designtime databinding.
                selectedDataSource = GetResolvedSelectedDataSource();

                IEnumerable designTimeDataSource =
                    GetDesignTimeDataSource(
                        selectedDataSource,
                        sampleRows,
                        out dummyDataSource);

                // If dummy datasource is applied, change the data fields so that
                // dummy source will be rendered.
                if (dummyDataSource)
                {
                    oldDataTextField              = _selectionList.DataTextField;
                    oldDataValueField             = _selectionList.DataValueField;
                    _selectionList.DataTextField  = "Column0";
                    _selectionList.DataValueField = "Column1";
                }

                try
                {
                    _selectionList.DataSource = designTimeDataSource;
                    _selectionList.DataBind();
                    _selectionList.Adapter.Render(htmlWriter);
                }
                finally
                {
                    _selectionList.DataSource = null;
                    _selectionList.Items.SetAll(oldItems);

                    if (dummyDataSource)
                    {
                        _selectionList.DataTextField  = oldDataTextField;
                        _selectionList.DataValueField = oldDataValueField;
                    }
                }
            }

            return(htmlWriter.ToString());
        }
Example #10
0
        /// <summary>
        ///    <para>
        ///       Gets the HTML to be used for the design-time representation
        ///       of the control.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The design-time HTML.
        ///    </para>
        /// </returns>
        /// <remarks>
        ///    <para>
        ///       The rule for handing DesignTimeHTML is similar to System.Web.UI.DataList control,
        ///       if list has a HTML templateset, then generate sample data from static data or
        ///       dynamic data (if static data does not exist). Show the sample data with templates
        ///       applied.
        ///    </para>
        /// </remarks>
        protected override String GetDesignTimeNormalHtml()
        {
            IEnumerable selectedDataSource = null;
            String      oldDataTextField = null, oldDataValueField = null;
            bool        dummyDataSource = false;

            DesignerTextWriter writer = new DesignerTextWriter(true);

            // Apply the current device specific
            if (_list.DeviceSpecific != null)
            {
                _list.DeviceSpecific.SetDesignerChoice(CurrentChoice);
            }

            MobileListItemCollection items = _list.Items;

            Debug.Assert(items != null, "Items is null in LisControl");
            MobileListItem[] oldItems = items.GetAll();

            // Hack: If List is templated, use DataBind() to create child controls.
            //       If it is empty, use dummy data source to create fake child controls.
            if (_list.IsTemplated || items.Count == 0)
            {
                int sampleRows = items.Count;

                // If List does not contain any items, use five dummy items.
                if (sampleRows == 0)
                {
                    sampleRows = 5;
                }

                // try designtime databinding.
                selectedDataSource = GetResolvedSelectedDataSource();

                // Recreate the dummy data table, if number of items changed. BUG from webforms
                if (sampleRows != _numberItems)
                {
                    OnDummyDataTableChanged();

                    // keep the new item count
                    _numberItems = sampleRows;
                }

                IEnumerable designTimeDataSource =
                    GetDesignTimeDataSource(selectedDataSource, sampleRows, out dummyDataSource);

                // If dummy datasource is applied, change the data fields so that
                // dummy source will be rendered.
                if (dummyDataSource)
                {
                    oldDataTextField     = _list.DataTextField;
                    oldDataValueField    = _list.DataValueField;
                    _list.DataTextField  = "Column0";
                    _list.DataValueField = "Column1";
                }

                try
                {
                    _list.DataSource = designTimeDataSource;
                    _list.DataBind();
                    _list.Adapter.Render(writer);
                }
                finally
                {
                    _list.DataSource = null;

                    // restore the old items since databinding creates items from templates.
                    _list.Items.SetAll(oldItems);

                    // clear all child controls created by databinding.
                    _list.Controls.Clear();

                    if (dummyDataSource)
                    {
                        _list.DataTextField  = oldDataTextField;
                        _list.DataValueField = oldDataValueField;
                    }
                }
            }
            // Otherwise, list only contains static items, just render it directly.
            else
            {
                _list.Adapter.Render(writer);
            }

            return(writer.ToString());
        }