public sealed override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner)
        {
            string cssClass          = String.Empty;
            bool   renderInlineStyle = true;

            if (_owner.IsSet(PROP_CSSCLASS))
            {
                cssClass = _owner.CssClass;
            }
            if (RegisteredCssClass.Length != 0)
            {
                renderInlineStyle = false;
                if (cssClass.Length != 0)
                {
                    cssClass = cssClass + " " + RegisteredCssClass;
                }
                else
                {
                    cssClass = RegisteredCssClass;
                }
            }

            if (cssClass.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
            }

            if (renderInlineStyle)
            {
                CssStyleCollection styleAttributes = GetStyleAttributes(owner);
                styleAttributes.Render(writer);
            }
        }
示例#2
0
 private void CopyStyle(Style toStyle, Style fromStyle)
 {
     if ((fromStyle != null) && fromStyle.IsSet(0x2000))
     {
         toStyle.Font.Underline = fromStyle.Font.Underline;
     }
     toStyle.CopyFrom(fromStyle);
 }
 private void CopyStyle(Style toStyle, Style fromStyle)
 {
     if ((fromStyle != null) && fromStyle.IsSet(0x2000))
     {
         toStyle.Font.Underline = fromStyle.Font.Underline;
     }
     toStyle.CopyFrom(fromStyle);
 }
示例#4
0
        private void CopyStyle(Style toStyle, Style fromStyle)
        {
            Debug.Assert(toStyle != null);

            // Review: How to change the default value of Font.Underline?
            if (fromStyle != null && fromStyle.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
            {
                toStyle.Font.Underline = fromStyle.Font.Underline;
            }

            toStyle.CopyFrom(fromStyle);
        }
示例#5
0
        /// <include file='doc\Style.uex' path='docs/doc[@for="Style.MergeWith"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Copies non-blank elements from the specified style,
        ///       but will not overwrite any existing style elements.
        ///    </para>
        /// </devdoc>
        public virtual void MergeWith(Style s)
        {
            if (s == null || s.IsEmpty)
            {
                return;
            }

            if (IsEmpty)
            {
                // merge into an empty style is equivalent to a copy, which
                // is more efficient
                CopyFrom(s);
                return;
            }

            this.Font.MergeWith(s.Font);

            if (s.IsSet(PROP_CSSCLASS) && !this.IsSet(PROP_CSSCLASS))
            {
                this.CssClass = s.CssClass;
            }
            if (s.IsSet(PROP_BACKCOLOR) && (!this.IsSet(PROP_BACKCOLOR) || (BackColor == Color.Empty)))
            {
                this.BackColor = s.BackColor;
            }
            if (s.IsSet(PROP_FORECOLOR) && (!this.IsSet(PROP_FORECOLOR) || (ForeColor == Color.Empty)))
            {
                this.ForeColor = s.ForeColor;
            }
            if (s.IsSet(PROP_BORDERCOLOR) && (!this.IsSet(PROP_BORDERCOLOR) || (BorderColor == Color.Empty)))
            {
                this.BorderColor = s.BorderColor;
            }
            if (s.IsSet(PROP_BORDERWIDTH) && (!this.IsSet(PROP_BORDERWIDTH) || (BorderWidth == Unit.Empty)))
            {
                this.BorderWidth = s.BorderWidth;
            }
            if (s.IsSet(PROP_BORDERSTYLE) && !this.IsSet(PROP_BORDERSTYLE))
            {
                this.BorderStyle = s.BorderStyle;
            }
            if (s.IsSet(PROP_HEIGHT) && (!this.IsSet(PROP_HEIGHT) || (Height == Unit.Empty)))
            {
                this.Height = s.Height;
            }
            if (s.IsSet(PROP_WIDTH) && (!this.IsSet(PROP_WIDTH) || (Width == Unit.Empty)))
            {
                this.Width = s.Width;
            }
        }
示例#6
0
        /// <include file='doc\Style.uex' path='docs/doc[@for="Style.CopyFrom"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Copies non-blank elements from the specified style,
        ///       overwriting existing style elements if necessary.
        ///    </para>
        /// </devdoc>
        public virtual void CopyFrom(Style s)
        {
            if (s != null && !s.IsEmpty)
            {
                this.Font.CopyFrom(s.Font);

                if (s.IsSet(PROP_CSSCLASS))
                {
                    this.CssClass = s.CssClass;
                }
                if (s.IsSet(PROP_BACKCOLOR) && (s.BackColor != Color.Empty))
                {
                    this.BackColor = s.BackColor;
                }
                if (s.IsSet(PROP_FORECOLOR) && (s.ForeColor != Color.Empty))
                {
                    this.ForeColor = s.ForeColor;
                }
                if (s.IsSet(PROP_BORDERCOLOR) && (s.BorderColor != Color.Empty))
                {
                    this.BorderColor = s.BorderColor;
                }
                if (s.IsSet(PROP_BORDERWIDTH) && (s.BorderWidth != Unit.Empty))
                {
                    this.BorderWidth = s.BorderWidth;
                }
                if (s.IsSet(PROP_BORDERSTYLE))
                {
                    this.BorderStyle = s.BorderStyle;
                }
                if (s.IsSet(PROP_HEIGHT) && (s.Height != Unit.Empty))
                {
                    this.Height = s.Height;
                }
                if (s.IsSet(PROP_WIDTH) && (s.Width != Unit.Empty))
                {
                    this.Width = s.Width;
                }
            }
        }
示例#7
0
 /// <devdoc>
 /// <para>Combines the font properties of another <see cref='System.Web.UI.WebControls.FontInfo'/> with this
 ///    instance. </para>
 /// </devdoc>
 public void MergeWith(FontInfo f)
 {
     if (f != null)
     {
         Style fOwner = f.Owner;
         if (fOwner.RegisteredCssClass.Length == 0)
         {
             if (fOwner.IsSet(Style.PROP_FONT_NAMES) && !owner.IsSet(Style.PROP_FONT_NAMES))
             {
                 Names = f.Names;
             }
             if (fOwner.IsSet(Style.PROP_FONT_SIZE) && (!owner.IsSet(Style.PROP_FONT_SIZE) || (Size == FontUnit.Empty)))
             {
                 Size = f.Size;
             }
             if (fOwner.IsSet(Style.PROP_FONT_BOLD) && !owner.IsSet(Style.PROP_FONT_BOLD))
             {
                 Bold = f.Bold;
             }
             if (fOwner.IsSet(Style.PROP_FONT_ITALIC) && !owner.IsSet(Style.PROP_FONT_ITALIC))
             {
                 Italic = f.Italic;
             }
             if (fOwner.IsSet(Style.PROP_FONT_OVERLINE) && !owner.IsSet(Style.PROP_FONT_OVERLINE))
             {
                 Overline = f.Overline;
             }
             if (fOwner.IsSet(Style.PROP_FONT_STRIKEOUT) && !owner.IsSet(Style.PROP_FONT_STRIKEOUT))
             {
                 Strikeout = f.Strikeout;
             }
             if (fOwner.IsSet(Style.PROP_FONT_UNDERLINE) && !owner.IsSet(Style.PROP_FONT_UNDERLINE))
             {
                 Underline = f.Underline;
             }
         }
     }
 }
 public void MergeWith(FontInfo f)
 {
     if (f != null)
     {
         Style owner = f.Owner;
         if (owner.RegisteredCssClass.Length == 0)
         {
             if (owner.IsSet(0x200) && !this.owner.IsSet(0x200))
             {
                 this.Names = f.Names;
             }
             if (owner.IsSet(0x400) && (!this.owner.IsSet(0x400) || (this.Size == FontUnit.Empty)))
             {
                 this.Size = f.Size;
             }
             if (owner.IsSet(0x800) && !this.owner.IsSet(0x800))
             {
                 this.Bold = f.Bold;
             }
             if (owner.IsSet(0x1000) && !this.owner.IsSet(0x1000))
             {
                 this.Italic = f.Italic;
             }
             if (owner.IsSet(0x4000) && !this.owner.IsSet(0x4000))
             {
                 this.Overline = f.Overline;
             }
             if (owner.IsSet(0x8000) && !this.owner.IsSet(0x8000))
             {
                 this.Strikeout = f.Strikeout;
             }
             if (owner.IsSet(0x2000) && !this.owner.IsSet(0x2000))
             {
                 this.Underline = f.Underline;
             }
         }
     }
 }
示例#9
0
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            ITemplate           nodeTemplate = null;
            Style               s            = null;
            SiteMapNodeItemType itemType     = item.ItemType;
            SiteMapNode         siteMapNode  = item.SiteMapNode;

            switch (itemType)
            {
            case SiteMapNodeItemType.Root:
                nodeTemplate = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                s            = this._mergedRootNodeStyle;
                break;

            case SiteMapNodeItemType.Parent:
                nodeTemplate = this.NodeTemplate;
                s            = this._nodeStyle;
                break;

            case SiteMapNodeItemType.Current:
                nodeTemplate = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                s            = this._mergedCurrentNodeStyle;
                break;

            case SiteMapNodeItemType.PathSeparator:
                nodeTemplate = this.PathSeparatorTemplate;
                s            = this._pathSeparatorStyle;
                break;
            }
            if (nodeTemplate == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal child = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = this.PathSeparator
                    };
                    item.Controls.Add(child);
                    item.ApplyStyle(s);
                }
                else if ((itemType == SiteMapNodeItemType.Current) && !this.RenderCurrentNodeAsLink)
                {
                    Literal literal2 = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = siteMapNode.Title
                    };
                    item.Controls.Add(literal2);
                    item.ApplyStyle(s);
                }
                else
                {
                    HyperLink link = new HyperLink();
                    if ((s != null) && s.IsSet(0x2000))
                    {
                        link.Font.Underline = s.Font.Underline;
                    }
                    link.EnableTheming = false;
                    link.Enabled       = this.Enabled;
                    if (siteMapNode.Url.StartsWith(@"\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url));
                    }
                    else
                    {
                        link.NavigateUrl = (this.Context != null) ? this.Context.Response.ApplyAppPathModifier(base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url))) : siteMapNode.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(siteMapNode.Title);
                    if (this.ShowToolTips)
                    {
                        link.ToolTip = siteMapNode.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(s);
                }
            }
            else
            {
                nodeTemplate.InstantiateIn(item);
                item.ApplyStyle(s);
            }
        }
示例#10
0
        /// <devdoc>
        /// <para>Copies the font properties of another <see cref='System.Web.UI.WebControls.FontInfo'/> into this instance. </para>
        /// </devdoc>
        public void CopyFrom(FontInfo f)
        {
            if (f != null)
            {
                Style fOwner = f.Owner;
                if (fOwner.RegisteredCssClass.Length != 0)
                {
                    if (fOwner.IsSet(Style.PROP_FONT_NAMES))
                    {
                        ResetNames();
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_SIZE) && (f.Size != FontUnit.Empty))
                    {
                        ResetFontSize();
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_BOLD))
                    {
                        ResetBold();
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_ITALIC))
                    {
                        ResetItalic();
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_OVERLINE))
                    {
                        ResetOverline();
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_STRIKEOUT))
                    {
                        ResetStrikeout();
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_UNDERLINE))
                    {
                        ResetUnderline();
                    }
                }
                else
                {
                    if (fOwner.IsSet(Style.PROP_FONT_NAMES))
                    {
                        Names = f.Names;
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_SIZE) && (f.Size != FontUnit.Empty))
                    {
                        Size = f.Size;
                    }

                    // Only carry through true boolean values. Otherwise merging and copying
                    // can do 3 different things for each property, but they are only persisted
                    // as 2 state values.
                    if (fOwner.IsSet(Style.PROP_FONT_BOLD))
                    {
                        Bold = f.Bold;
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_ITALIC))
                    {
                        Italic = f.Italic;
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_OVERLINE))
                    {
                        Overline = f.Overline;
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_STRIKEOUT))
                    {
                        Strikeout = f.Strikeout;
                    }
                    if (fOwner.IsSet(Style.PROP_FONT_UNDERLINE))
                    {
                        Underline = f.Underline;
                    }
                }
            }
        }
示例#11
0
 public virtual void CopyFrom(Style s)
 {
     if (this.RegisteredCssClass.Length != 0)
     {
         throw new InvalidOperationException(System.Web.SR.GetString("Style_RegisteredStylesAreReadOnly"));
     }
     if ((s != null) && !s.IsEmpty)
     {
         this.Font.CopyFrom(s.Font);
         if (s.IsSet(2))
         {
             this.CssClass = s.CssClass;
         }
         if (s.RegisteredCssClass.Length != 0)
         {
             if (this.IsSet(2))
             {
                 this.CssClass = this.CssClass + " " + s.RegisteredCssClass;
             }
             else
             {
                 this.CssClass = s.RegisteredCssClass;
             }
             if (s.IsSet(8) && (s.BackColor != Color.Empty))
             {
                 this.ViewState.Remove("BackColor");
                 this.ClearBit(8);
             }
             if (s.IsSet(4) && (s.ForeColor != Color.Empty))
             {
                 this.ViewState.Remove("ForeColor");
                 this.ClearBit(4);
             }
             if (s.IsSet(0x10) && (s.BorderColor != Color.Empty))
             {
                 this.ViewState.Remove("BorderColor");
                 this.ClearBit(0x10);
             }
             if (s.IsSet(0x20) && (s.BorderWidth != Unit.Empty))
             {
                 this.ViewState.Remove("BorderWidth");
                 this.ClearBit(0x20);
             }
             if (s.IsSet(0x40))
             {
                 this.ViewState.Remove("BorderStyle");
                 this.ClearBit(0x40);
             }
             if (s.IsSet(0x80) && (s.Height != Unit.Empty))
             {
                 this.ViewState.Remove("Height");
                 this.ClearBit(0x80);
             }
             if (s.IsSet(0x100) && (s.Width != Unit.Empty))
             {
                 this.ViewState.Remove("Width");
                 this.ClearBit(0x100);
             }
         }
         else
         {
             if (s.IsSet(8) && (s.BackColor != Color.Empty))
             {
                 this.BackColor = s.BackColor;
             }
             if (s.IsSet(4) && (s.ForeColor != Color.Empty))
             {
                 this.ForeColor = s.ForeColor;
             }
             if (s.IsSet(0x10) && (s.BorderColor != Color.Empty))
             {
                 this.BorderColor = s.BorderColor;
             }
             if (s.IsSet(0x20) && (s.BorderWidth != Unit.Empty))
             {
                 this.BorderWidth = s.BorderWidth;
             }
             if (s.IsSet(0x40))
             {
                 this.BorderStyle = s.BorderStyle;
             }
             if (s.IsSet(0x80) && (s.Height != Unit.Empty))
             {
                 this.Height = s.Height;
             }
             if (s.IsSet(0x100) && (s.Width != Unit.Empty))
             {
                 this.Width = s.Width;
             }
         }
     }
 }
示例#12
0
        /// <devdoc>
        /// Copies non-blank elements from the specified style,
        /// but will not overwrite any existing style elements.
        /// </devdoc>
        public virtual void MergeWith(Style s)
        {
            if (RegisteredCssClass.Length != 0)
            {
                throw new InvalidOperationException(SR.GetString(SR.Style_RegisteredStylesAreReadOnly));
            }

            if (s == null || s.IsEmpty)
            {
                return;
            }

            if (IsEmpty)
            {
                // merge into an empty style is equivalent to a copy, which
                // is more efficient
                CopyFrom(s);
                return;
            }

            this.Font.MergeWith(s.Font);

            if (s.IsSet(PROP_CSSCLASS) && !this.IsSet(PROP_CSSCLASS))
            {
                this.CssClass = s.CssClass;
            }

            // If the source Style is registered and this one isn't, copy
            // the CSS class and any style props not included in the CSS class
            // if they aren't set on this Style
            if (s.RegisteredCssClass.Length == 0)
            {
                if (s.IsSet(PROP_BACKCOLOR) && (!this.IsSet(PROP_BACKCOLOR) || (BackColor == Color.Empty)))
                {
                    this.BackColor = s.BackColor;
                }
                if (s.IsSet(PROP_FORECOLOR) && (!this.IsSet(PROP_FORECOLOR) || (ForeColor == Color.Empty)))
                {
                    this.ForeColor = s.ForeColor;
                }
                if (s.IsSet(PROP_BORDERCOLOR) && (!this.IsSet(PROP_BORDERCOLOR) || (BorderColor == Color.Empty)))
                {
                    this.BorderColor = s.BorderColor;
                }
                if (s.IsSet(PROP_BORDERWIDTH) && (!this.IsSet(PROP_BORDERWIDTH) || (BorderWidth == Unit.Empty)))
                {
                    this.BorderWidth = s.BorderWidth;
                }
                if (s.IsSet(PROP_BORDERSTYLE) && !this.IsSet(PROP_BORDERSTYLE))
                {
                    this.BorderStyle = s.BorderStyle;
                }
                if (s.IsSet(PROP_HEIGHT) && (!this.IsSet(PROP_HEIGHT) || (Height == Unit.Empty)))
                {
                    this.Height = s.Height;
                }
                if (s.IsSet(PROP_WIDTH) && (!this.IsSet(PROP_WIDTH) || (Width == Unit.Empty)))
                {
                    this.Width = s.Width;
                }
            }
            else
            {
                if (IsSet(PROP_CSSCLASS))
                {
                    CssClass += " " + s.RegisteredCssClass;
                }
                else
                {
                    CssClass = s.RegisteredCssClass;
                }
            }
        }
示例#13
0
		internal virtual void CopyTextStylesFrom (Style source)
		{
			if (source.IsSet (FORECOLOR)&& (source.ForeColor != Color.Empty))
				ForeColor = source.ForeColor;
		}
示例#14
0
		public virtual void CopyFrom (Style source)
		{
			if (source == null || source.IsEmpty)
				return;

			Font.CopyFrom (source.Font);
			if (source.IsSet (HEIGHT)&& (source.Height != Unit.Empty))
				Height = source.Height;

			if (source.IsSet (WIDTH)&& (source.Width != Unit.Empty))
				Width = source.Width;

			if (source.IsSet (BORDERCOLOR)&& (source.BorderColor != Color.Empty))
				BorderColor = source.BorderColor;

			if (source.IsSet (BORDERWIDTH)&& (source.BorderWidth != Unit.Empty))
				BorderWidth = source.BorderWidth;

			if (source.IsSet (BORDERSTYLE))
				BorderStyle = source.BorderStyle;

			if (source.IsSet (BACKCOLOR)&& (source.BackColor != Color.Empty))
				BackColor = source.BackColor;

			if (source.IsSet (CSSCLASS))
				CssClass = source.CssClass;

			if (source.IsSet (FORECOLOR)&& (source.ForeColor != Color.Empty))
				ForeColor = source.ForeColor;

		}
示例#15
0
        /// <devdoc>
        ///    <para>
        ///       Copies non-blank elements from the specified style,
        ///       overwriting existing style elements if necessary.
        ///    </para>
        /// </devdoc>
        public virtual void CopyFrom(Style s) {
            if (RegisteredCssClass.Length != 0) {
                throw new InvalidOperationException(SR.GetString(SR.Style_RegisteredStylesAreReadOnly));
            }

            if (s != null && !s.IsEmpty) {
                this.Font.CopyFrom(s.Font);

                if (s.IsSet(PROP_CSSCLASS))
                    this.CssClass = s.CssClass;


                // if the source Style is registered and this one isn't,
                // reset all the styles set by the source Style so it's
                // css class can be used to set those values
                if (s.RegisteredCssClass.Length != 0) {
                    if (IsSet(PROP_CSSCLASS)) {
                        CssClass += " " + s.RegisteredCssClass;
                    }
                    else {
                        CssClass = s.RegisteredCssClass;
                    }

                    if (s.IsSet(PROP_BACKCOLOR) && (s.BackColor != Color.Empty)) {
                        ViewState.Remove("BackColor");
                        ClearBit(PROP_BACKCOLOR);
                    }
                    if (s.IsSet(PROP_FORECOLOR) && (s.ForeColor != Color.Empty)) {
                        ViewState.Remove("ForeColor");
                        ClearBit(PROP_FORECOLOR);
                    }
                    if (s.IsSet(PROP_BORDERCOLOR) && (s.BorderColor != Color.Empty)) {
                        ViewState.Remove("BorderColor");
                        ClearBit(PROP_BORDERCOLOR);
                    }
                    if (s.IsSet(PROP_BORDERWIDTH) && (s.BorderWidth != Unit.Empty)) {
                        ViewState.Remove("BorderWidth");
                        ClearBit(PROP_BORDERWIDTH);
                    }
                    if (s.IsSet(PROP_BORDERSTYLE)) {
                        ViewState.Remove("BorderStyle");
                        ClearBit(PROP_BORDERSTYLE);
                    }
                    if (s.IsSet(PROP_HEIGHT) && (s.Height != Unit.Empty)) {
                        ViewState.Remove("Height");
                        ClearBit(PROP_HEIGHT);
                    }
                    if (s.IsSet(PROP_WIDTH) && (s.Width != Unit.Empty)) {
                        ViewState.Remove("Width");
                        ClearBit(PROP_WIDTH);
                    }
                }
                else {
                    if (s.IsSet(PROP_BACKCOLOR) && (s.BackColor != Color.Empty))
                        this.BackColor = s.BackColor;
                    if (s.IsSet(PROP_FORECOLOR) && (s.ForeColor != Color.Empty))
                        this.ForeColor = s.ForeColor;
                    if (s.IsSet(PROP_BORDERCOLOR) && (s.BorderColor != Color.Empty))
                        this.BorderColor = s.BorderColor;
                    if (s.IsSet(PROP_BORDERWIDTH) && (s.BorderWidth != Unit.Empty))
                        this.BorderWidth = s.BorderWidth;
                    if (s.IsSet(PROP_BORDERSTYLE))
                        this.BorderStyle = s.BorderStyle;
                    if (s.IsSet(PROP_HEIGHT) && (s.Height != Unit.Empty))
                        this.Height = s.Height;
                    if (s.IsSet(PROP_WIDTH) && (s.Width != Unit.Empty))
                        this.Width = s.Width;
                }
            }
        }
示例#16
0
        /// <devdoc>
        /// Copies non-blank elements from the specified style,
        /// but will not overwrite any existing style elements.
        /// </devdoc>
        public virtual void MergeWith(Style s) {
            if (RegisteredCssClass.Length != 0) {
                throw new InvalidOperationException(SR.GetString(SR.Style_RegisteredStylesAreReadOnly));
            }

            if (s == null || s.IsEmpty)
                return;

            if (IsEmpty) {
                // merge into an empty style is equivalent to a copy, which
                // is more efficient
                CopyFrom(s);
                return;
            }

            this.Font.MergeWith(s.Font);

            if (s.IsSet(PROP_CSSCLASS) && !this.IsSet(PROP_CSSCLASS))
                this.CssClass = s.CssClass;

            // If the source Style is registered and this one isn't, copy
            // the CSS class and any style props not included in the CSS class
            // if they aren't set on this Style
            if (s.RegisteredCssClass.Length == 0) {
                if (s.IsSet(PROP_BACKCOLOR) && (!this.IsSet(PROP_BACKCOLOR) || (BackColor == Color.Empty)))
                    this.BackColor = s.BackColor;
                if (s.IsSet(PROP_FORECOLOR) && (!this.IsSet(PROP_FORECOLOR) || (ForeColor == Color.Empty)))
                    this.ForeColor = s.ForeColor;
                if (s.IsSet(PROP_BORDERCOLOR) && (!this.IsSet(PROP_BORDERCOLOR) || (BorderColor == Color.Empty)))
                    this.BorderColor = s.BorderColor;
                if (s.IsSet(PROP_BORDERWIDTH) && (!this.IsSet(PROP_BORDERWIDTH) || (BorderWidth == Unit.Empty)))
                    this.BorderWidth = s.BorderWidth;
                if (s.IsSet(PROP_BORDERSTYLE) && !this.IsSet(PROP_BORDERSTYLE))
                    this.BorderStyle = s.BorderStyle;
                if (s.IsSet(PROP_HEIGHT) && (!this.IsSet(PROP_HEIGHT) || (Height == Unit.Empty)))
                    this.Height = s.Height;
                if (s.IsSet(PROP_WIDTH) && (!this.IsSet(PROP_WIDTH) || (Width == Unit.Empty)))
                    this.Width = s.Width;
            }
            else {
                if (IsSet(PROP_CSSCLASS)) {
                    CssClass += " " + s.RegisteredCssClass;
                }
                else {
                    CssClass = s.RegisteredCssClass;
                }
            }
        }
示例#17
0
        /// <devdoc>
        /// <para>A protected method. Populates iteratively the specified <see cref='System.Web.UI.WebControls.SiteMapNodeItem'/> with a
        ///    sub-hierarchy of child controls.</para>
        /// </devdoc>
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            Debug.Assert(_mergedCurrentNodeStyle != null && _mergedRootNodeStyle != null);

            ITemplate           template = null;
            Style               style    = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode         node     = item.SiteMapNode;

            switch (itemType)
            {
            case SiteMapNodeItemType.Root:
                template = RootNodeTemplate != null ? RootNodeTemplate : NodeTemplate;
                style    = _mergedRootNodeStyle;
                break;

            case SiteMapNodeItemType.Parent:
                template = NodeTemplate;
                style    = _nodeStyle;
                break;

            case SiteMapNodeItemType.Current:
                template = CurrentNodeTemplate != null ? CurrentNodeTemplate : NodeTemplate;
                style    = _mergedCurrentNodeStyle;
                break;

            case SiteMapNodeItemType.PathSeparator:
                template = PathSeparatorTemplate;
                style    = _pathSeparatorStyle;
                break;
            }

            if (template == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal separatorLiteral = new Literal();
                    separatorLiteral.Mode = LiteralMode.Encode;
                    separatorLiteral.Text = PathSeparator;
                    item.Controls.Add(separatorLiteral);
                    item.ApplyStyle(style);
                }
                else if (itemType == SiteMapNodeItemType.Current && !RenderCurrentNodeAsLink)
                {
                    Literal currentNodeLiteral = new Literal();
                    currentNodeLiteral.Mode = LiteralMode.Encode;
                    currentNodeLiteral.Text = node.Title;
                    item.Controls.Add(currentNodeLiteral);
                    item.ApplyStyle(style);
                }
                else
                {
                    HyperLink link = new HyperLink();

                    if (style != null && style.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
                    {
                        link.Font.Underline = style.Font.Underline;
                    }

                    link.EnableTheming = false;
                    link.Enabled       = this.Enabled;
                    // VSWhidbey 281869 Don't modify input when url pointing to unc share
                    if (node.Url.StartsWith("\\\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url));
                    }
                    else
                    {
                        link.NavigateUrl = Context != null?
                                           Context.Response.ApplyAppPathModifier(ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url))) : node.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(node.Title);
                    if (ShowToolTips)
                    {
                        link.ToolTip = node.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(style);
                }
            }
            else
            {
                template.InstantiateIn(item);
                item.ApplyStyle(style);
            }
        }
示例#18
0
        /// <devdoc>
        ///    <para>
        ///       Copies non-blank elements from the specified style,
        ///       overwriting existing style elements if necessary.
        ///    </para>
        /// </devdoc>
        public virtual void CopyFrom(Style s)
        {
            if (RegisteredCssClass.Length != 0)
            {
                throw new InvalidOperationException(SR.GetString(SR.Style_RegisteredStylesAreReadOnly));
            }

            if (s != null && !s.IsEmpty)
            {
                this.Font.CopyFrom(s.Font);

                if (s.IsSet(PROP_CSSCLASS))
                {
                    this.CssClass = s.CssClass;
                }


                // if the source Style is registered and this one isn't,
                // reset all the styles set by the source Style so it's
                // css class can be used to set those values
                if (s.RegisteredCssClass.Length != 0)
                {
                    if (IsSet(PROP_CSSCLASS))
                    {
                        CssClass += " " + s.RegisteredCssClass;
                    }
                    else
                    {
                        CssClass = s.RegisteredCssClass;
                    }

                    if (s.IsSet(PROP_BACKCOLOR) && (s.BackColor != Color.Empty))
                    {
                        ViewState.Remove("BackColor");
                        ClearBit(PROP_BACKCOLOR);
                    }
                    if (s.IsSet(PROP_FORECOLOR) && (s.ForeColor != Color.Empty))
                    {
                        ViewState.Remove("ForeColor");
                        ClearBit(PROP_FORECOLOR);
                    }
                    if (s.IsSet(PROP_BORDERCOLOR) && (s.BorderColor != Color.Empty))
                    {
                        ViewState.Remove("BorderColor");
                        ClearBit(PROP_BORDERCOLOR);
                    }
                    if (s.IsSet(PROP_BORDERWIDTH) && (s.BorderWidth != Unit.Empty))
                    {
                        ViewState.Remove("BorderWidth");
                        ClearBit(PROP_BORDERWIDTH);
                    }
                    if (s.IsSet(PROP_BORDERSTYLE))
                    {
                        ViewState.Remove("BorderStyle");
                        ClearBit(PROP_BORDERSTYLE);
                    }
                    if (s.IsSet(PROP_HEIGHT) && (s.Height != Unit.Empty))
                    {
                        ViewState.Remove("Height");
                        ClearBit(PROP_HEIGHT);
                    }
                    if (s.IsSet(PROP_WIDTH) && (s.Width != Unit.Empty))
                    {
                        ViewState.Remove("Width");
                        ClearBit(PROP_WIDTH);
                    }
                }
                else
                {
                    if (s.IsSet(PROP_BACKCOLOR) && (s.BackColor != Color.Empty))
                    {
                        this.BackColor = s.BackColor;
                    }
                    if (s.IsSet(PROP_FORECOLOR) && (s.ForeColor != Color.Empty))
                    {
                        this.ForeColor = s.ForeColor;
                    }
                    if (s.IsSet(PROP_BORDERCOLOR) && (s.BorderColor != Color.Empty))
                    {
                        this.BorderColor = s.BorderColor;
                    }
                    if (s.IsSet(PROP_BORDERWIDTH) && (s.BorderWidth != Unit.Empty))
                    {
                        this.BorderWidth = s.BorderWidth;
                    }
                    if (s.IsSet(PROP_BORDERSTYLE))
                    {
                        this.BorderStyle = s.BorderStyle;
                    }
                    if (s.IsSet(PROP_HEIGHT) && (s.Height != Unit.Empty))
                    {
                        this.Height = s.Height;
                    }
                    if (s.IsSet(PROP_WIDTH) && (s.Width != Unit.Empty))
                    {
                        this.Width = s.Width;
                    }
                }
            }
        }
 public void CopyFrom(FontInfo f)
 {
     if (f != null)
     {
         Style owner = f.Owner;
         if (owner.RegisteredCssClass.Length != 0)
         {
             if (owner.IsSet(0x200))
             {
                 this.ResetNames();
             }
             if (owner.IsSet(0x400) && (f.Size != FontUnit.Empty))
             {
                 this.ResetFontSize();
             }
             if (owner.IsSet(0x800))
             {
                 this.ResetBold();
             }
             if (owner.IsSet(0x1000))
             {
                 this.ResetItalic();
             }
             if (owner.IsSet(0x4000))
             {
                 this.ResetOverline();
             }
             if (owner.IsSet(0x8000))
             {
                 this.ResetStrikeout();
             }
             if (owner.IsSet(0x2000))
             {
                 this.ResetUnderline();
             }
         }
         else
         {
             if (owner.IsSet(0x200))
             {
                 this.Names = f.Names;
             }
             if (owner.IsSet(0x400) && (f.Size != FontUnit.Empty))
             {
                 this.Size = f.Size;
             }
             if (owner.IsSet(0x800))
             {
                 this.Bold = f.Bold;
             }
             if (owner.IsSet(0x1000))
             {
                 this.Italic = f.Italic;
             }
             if (owner.IsSet(0x4000))
             {
                 this.Overline = f.Overline;
             }
             if (owner.IsSet(0x8000))
             {
                 this.Strikeout = f.Strikeout;
             }
             if (owner.IsSet(0x2000))
             {
                 this.Underline = f.Underline;
             }
         }
     }
 }
示例#20
0
        private void CopyStyle(Style toStyle, Style fromStyle) {
            Debug.Assert(toStyle != null);

            // Review: How to change the default value of Font.Underline?
            if (fromStyle != null && fromStyle.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
                toStyle.Font.Underline = fromStyle.Font.Underline;

            toStyle.CopyFrom(fromStyle);
        }
示例#21
0
 public virtual void MergeWith(Style s)
 {
     if (this.RegisteredCssClass.Length != 0)
     {
         throw new InvalidOperationException(System.Web.SR.GetString("Style_RegisteredStylesAreReadOnly"));
     }
     if ((s != null) && !s.IsEmpty)
     {
         if (this.IsEmpty)
         {
             this.CopyFrom(s);
         }
         else
         {
             this.Font.MergeWith(s.Font);
             if (s.IsSet(2) && !this.IsSet(2))
             {
                 this.CssClass = s.CssClass;
             }
             if (s.RegisteredCssClass.Length == 0)
             {
                 if (s.IsSet(8) && (!this.IsSet(8) || (this.BackColor == Color.Empty)))
                 {
                     this.BackColor = s.BackColor;
                 }
                 if (s.IsSet(4) && (!this.IsSet(4) || (this.ForeColor == Color.Empty)))
                 {
                     this.ForeColor = s.ForeColor;
                 }
                 if (s.IsSet(0x10) && (!this.IsSet(0x10) || (this.BorderColor == Color.Empty)))
                 {
                     this.BorderColor = s.BorderColor;
                 }
                 if (s.IsSet(0x20) && (!this.IsSet(0x20) || (this.BorderWidth == Unit.Empty)))
                 {
                     this.BorderWidth = s.BorderWidth;
                 }
                 if (s.IsSet(0x40) && !this.IsSet(0x40))
                 {
                     this.BorderStyle = s.BorderStyle;
                 }
                 if (s.IsSet(0x80) && (!this.IsSet(0x80) || (this.Height == Unit.Empty)))
                 {
                     this.Height = s.Height;
                 }
                 if (s.IsSet(0x100) && (!this.IsSet(0x100) || (this.Width == Unit.Empty)))
                 {
                     this.Width = s.Width;
                 }
             }
             else if (this.IsSet(2))
             {
                 this.CssClass = this.CssClass + " " + s.RegisteredCssClass;
             }
             else
             {
                 this.CssClass = s.RegisteredCssClass;
             }
         }
     }
 }