Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / UI / WebControls / HyperLinkStyle.cs / 1 / HyperLinkStyle.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
using System.Text;
using System.Web.UI;
using System.Web.Util;
// This class renders selectively attributes from the owner class, filtering out anything not font or forecolor
internal sealed class HyperLinkStyle : Style {
private bool _doNotRenderDefaults = false;
private Style _owner; // This is a style because of the newed IsSet (we need the Style.IsSet, not the new one)
public HyperLinkStyle(Style owner) {
_owner = owner;
}
public bool DoNotRenderDefaults {
get {
return _doNotRenderDefaults;
}
set {
_doNotRenderDefaults = value;
}
}
public sealed override bool IsEmpty {
get {
return (RegisteredCssClass.Length == 0) &&
!(_owner.IsSet(PROP_CSSCLASS) ||
_owner.IsSet(PROP_FORECOLOR) ||
_owner.IsSet(PROP_FONT_NAMES) ||
_owner.IsSet(PROP_FONT_SIZE) ||
_owner.IsSet(PROP_FONT_BOLD) ||
_owner.IsSet(PROP_FONT_ITALIC) ||
_owner.IsSet(PROP_FONT_UNDERLINE) ||
_owner.IsSet(PROP_FONT_OVERLINE) ||
_owner.IsSet(PROP_FONT_STRIKEOUT));
}
}
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);
}
}
protected override sealed void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver) {
Debug.Assert(_owner != null);
StateBag viewState = ViewState;
Color c;
// ForeColor
if (_owner.IsSet(PROP_FORECOLOR)) {
c = _owner.ForeColor;
if (!c.IsEmpty) {
attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(c));
}
}
// Not defaulting to black anymore for not entirely satisfying but reasonable reasons (VSWhidbey 356729)
// need to call the property get in case we have font properties from view state and have not
// created the font object
FontInfo font = _owner.Font;
// Font.Names
string[] names = font.Names;
if (names.Length > 0) {
attributes.Add(HtmlTextWriterStyle.FontFamily, String.Join(",", names));
}
// Font.Size
FontUnit fu = font.Size;
if (fu.IsEmpty == false) {
attributes.Add(HtmlTextWriterStyle.FontSize, fu.ToString(CultureInfo.InvariantCulture));
}
// Font.Bold
if (_owner.IsSet(PROP_FONT_BOLD)) {
if (font.Bold) {
attributes.Add(HtmlTextWriterStyle.FontWeight, "bold");
}
else {
attributes.Add(HtmlTextWriterStyle.FontWeight, "normal");
}
}
// Font.Italic
if (_owner.IsSet(PROP_FONT_ITALIC)) {
if (font.Italic == true) {
attributes.Add(HtmlTextWriterStyle.FontStyle, "italic");
}
else {
attributes.Add(HtmlTextWriterStyle.FontStyle, "normal");
}
}
string textDecoration = String.Empty;
if (font.Underline) {
textDecoration = "underline";
}
if (font.Overline) {
textDecoration += " overline";
}
if (font.Strikeout) {
textDecoration += " line-through";
}
if (textDecoration.Length > 0) {
attributes.Add(HtmlTextWriterStyle.TextDecoration, textDecoration);
}
else {
if (!DoNotRenderDefaults) {
attributes.Add(HtmlTextWriterStyle.TextDecoration, "none");
}
}
// Removing the border with an inline style if the class name was set
if (_owner.IsSet(PROP_CSSCLASS)) {
attributes.Add(HtmlTextWriterStyle.BorderStyle, "none");
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
using System.Text;
using System.Web.UI;
using System.Web.Util;
// This class renders selectively attributes from the owner class, filtering out anything not font or forecolor
internal sealed class HyperLinkStyle : Style {
private bool _doNotRenderDefaults = false;
private Style _owner; // This is a style because of the newed IsSet (we need the Style.IsSet, not the new one)
public HyperLinkStyle(Style owner) {
_owner = owner;
}
public bool DoNotRenderDefaults {
get {
return _doNotRenderDefaults;
}
set {
_doNotRenderDefaults = value;
}
}
public sealed override bool IsEmpty {
get {
return (RegisteredCssClass.Length == 0) &&
!(_owner.IsSet(PROP_CSSCLASS) ||
_owner.IsSet(PROP_FORECOLOR) ||
_owner.IsSet(PROP_FONT_NAMES) ||
_owner.IsSet(PROP_FONT_SIZE) ||
_owner.IsSet(PROP_FONT_BOLD) ||
_owner.IsSet(PROP_FONT_ITALIC) ||
_owner.IsSet(PROP_FONT_UNDERLINE) ||
_owner.IsSet(PROP_FONT_OVERLINE) ||
_owner.IsSet(PROP_FONT_STRIKEOUT));
}
}
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);
}
}
protected override sealed void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver) {
Debug.Assert(_owner != null);
StateBag viewState = ViewState;
Color c;
// ForeColor
if (_owner.IsSet(PROP_FORECOLOR)) {
c = _owner.ForeColor;
if (!c.IsEmpty) {
attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(c));
}
}
// Not defaulting to black anymore for not entirely satisfying but reasonable reasons (VSWhidbey 356729)
// need to call the property get in case we have font properties from view state and have not
// created the font object
FontInfo font = _owner.Font;
// Font.Names
string[] names = font.Names;
if (names.Length > 0) {
attributes.Add(HtmlTextWriterStyle.FontFamily, String.Join(",", names));
}
// Font.Size
FontUnit fu = font.Size;
if (fu.IsEmpty == false) {
attributes.Add(HtmlTextWriterStyle.FontSize, fu.ToString(CultureInfo.InvariantCulture));
}
// Font.Bold
if (_owner.IsSet(PROP_FONT_BOLD)) {
if (font.Bold) {
attributes.Add(HtmlTextWriterStyle.FontWeight, "bold");
}
else {
attributes.Add(HtmlTextWriterStyle.FontWeight, "normal");
}
}
// Font.Italic
if (_owner.IsSet(PROP_FONT_ITALIC)) {
if (font.Italic == true) {
attributes.Add(HtmlTextWriterStyle.FontStyle, "italic");
}
else {
attributes.Add(HtmlTextWriterStyle.FontStyle, "normal");
}
}
string textDecoration = String.Empty;
if (font.Underline) {
textDecoration = "underline";
}
if (font.Overline) {
textDecoration += " overline";
}
if (font.Strikeout) {
textDecoration += " line-through";
}
if (textDecoration.Length > 0) {
attributes.Add(HtmlTextWriterStyle.TextDecoration, textDecoration);
}
else {
if (!DoNotRenderDefaults) {
attributes.Add(HtmlTextWriterStyle.TextDecoration, "none");
}
}
// Removing the border with an inline style if the class name was set
if (_owner.IsSet(PROP_CSSCLASS)) {
attributes.Add(HtmlTextWriterStyle.BorderStyle, "none");
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ContainerParaClient.cs
- InternalConfigHost.cs
- RedirectionProxy.cs
- AnnotationHelper.cs
- SqlResolver.cs
- DataGridViewAutoSizeModeEventArgs.cs
- XmlSchemaDocumentation.cs
- MetabaseServerConfig.cs
- ListBoxItem.cs
- MiniLockedBorderGlyph.cs
- ListViewItemEventArgs.cs
- SpotLight.cs
- FrameSecurityDescriptor.cs
- ManifestSignedXml.cs
- TypeLoadException.cs
- TypeSystem.cs
- BidPrivateBase.cs
- AssociationSetMetadata.cs
- ListViewSortEventArgs.cs
- FaultDescription.cs
- ClientConfigurationHost.cs
- ObjectListItem.cs
- CredentialCache.cs
- CaseInsensitiveOrdinalStringComparer.cs
- TrackingProfileDeserializationException.cs
- Deflater.cs
- MarginsConverter.cs
- RecipientIdentity.cs
- WebContext.cs
- PathBox.cs
- FormViewCommandEventArgs.cs
- XmlProcessingInstruction.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- Matrix.cs
- X509CertificateCollection.cs
- AdRotator.cs
- Context.cs
- Size.cs
- FileFormatException.cs
- SqlReorderer.cs
- EntityDataSourceConfigureObjectContext.cs
- DesignerValidatorAdapter.cs
- DoubleLink.cs
- GatewayDefinition.cs
- XsdDataContractExporter.cs
- ImplicitInputBrush.cs
- OleDbPermission.cs
- SyntaxCheck.cs
- X509CertificateChain.cs
- MenuItemCollectionEditor.cs
- DateTimeFormatInfoScanner.cs
- SHA512.cs
- CrossSiteScriptingValidation.cs
- CheckBox.cs
- Camera.cs
- ArrayElementGridEntry.cs
- Style.cs
- WindowsSlider.cs
- WindowsAuthenticationModule.cs
- WindowsRichEdit.cs
- OrthographicCamera.cs
- StreamingContext.cs
- _NtlmClient.cs
- DbXmlEnabledProviderManifest.cs
- ComAwareEventInfo.cs
- NameValueConfigurationCollection.cs
- DrawingContextWalker.cs
- Expander.cs
- SoapServerMethod.cs
- SafeLocalMemHandle.cs
- XmlDataLoader.cs
- Point3DIndependentAnimationStorage.cs
- Trigger.cs
- AnnotationMap.cs
- XmlSchemas.cs
- DragAssistanceManager.cs
- ResponseBodyWriter.cs
- Input.cs
- ButtonField.cs
- SchemaContext.cs
- LocalizabilityAttribute.cs
- TextEditorParagraphs.cs
- SamlSubject.cs
- Models.cs
- UInt64Converter.cs
- OracleParameterBinding.cs
- PageAdapter.cs
- XmlWrappingWriter.cs
- TableRowsCollectionEditor.cs
- LocalizabilityAttribute.cs
- PolyBezierSegment.cs
- EntityContainer.cs
- SMSvcHost.cs
- GridEntryCollection.cs
- HtmlTableCell.cs
- CallbackException.cs
- SoapConverter.cs
- TemplateBindingExpression.cs
- PathFigureCollectionConverter.cs
- DataGridAddNewRow.cs