Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / WebControls / LoginStatusDesigner.cs / 1 / LoginStatusDesigner.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.WebControls { using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design; using System.Design; using System.Diagnostics; using System.Globalization; using System.Web.UI.WebControls; ////// /// Designer for the LoginStatus control. Includes verb to switch whether the control renders as "login" or "logout". /// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] public class LoginStatusDesigner : CompositeControlDesigner { private bool _loggedIn; private LoginStatus _loginStatus; ///public override DesignerActionListCollection ActionLists { get { DesignerActionListCollection actionLists = new DesignerActionListCollection(); actionLists.AddRange(base.ActionLists); actionLists.Add(new LoginStatusDesignerActionList(this)); return actionLists; } } protected override bool UsePreviewControl { get { return true; } } public override string GetDesignTimeHtml() { IDictionary parameters = new HybridDictionary(2); parameters["LoggedIn"] = _loggedIn; LoginStatus loginStatus = (LoginStatus)ViewControl; ((IControlDesignerAccessor)loginStatus).SetDesignModeState(parameters); bool blank; string originalText; if (_loggedIn) { originalText = loginStatus.LogoutText; // Need to check if original text is empty OR a single space " ", since it is // persisted as a single space in the designer due to a Trident bug blank = (originalText == null || originalText.Length == 0 || originalText == " "); if (blank) { loginStatus.LogoutText = "[" + loginStatus.ID + "]"; } } else { originalText = loginStatus.LoginText; blank = (originalText == null || originalText.Length == 0 || originalText == " "); if (blank) { loginStatus.LoginText = "[" + loginStatus.ID + "]"; } } return base.GetDesignTimeHtml(); } /// public override void Initialize(IComponent component) { VerifyInitializeArgument(component, typeof(LoginStatus)); _loginStatus = (LoginStatus) component; base.Initialize(component); } private class LoginStatusDesignerActionList : DesignerActionList { private LoginStatusDesigner _designer; public LoginStatusDesignerActionList(LoginStatusDesigner designer) :base(designer.Component) { _designer = designer; } public override bool AutoShow { get { return true; } set { } } [TypeConverter(typeof(LoginStatusViewTypeConverter))] public string View { get { if (_designer._loggedIn) { return SR.GetString(SR.LoginStatus_LoggedInView); } else { return SR.GetString(SR.LoginStatus_LoggedOutView); } } set { if (String.Compare(value, SR.GetString(SR.LoginStatus_LoggedInView), StringComparison.Ordinal) == 0) { _designer._loggedIn = true; } else if (String.Compare(value, SR.GetString(SR.LoginStatus_LoggedOutView), StringComparison.Ordinal) == 0) { _designer._loggedIn = false; } else { Debug.Fail("Unexpected view value"); } _designer.UpdateDesignTimeHtml(); } } public override DesignerActionItemCollection GetSortedActionItems() { DesignerActionItemCollection items = new DesignerActionItemCollection(); items.Add(new DesignerActionPropertyItem("View", SR.GetString(SR.WebControls_Views), String.Empty, SR.GetString(SR.WebControls_ViewsDescription))); return items; } private class LoginStatusViewTypeConverter : TypeConverter { public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { string[] names = new string[2]; names[0] = SR.GetString(SR.LoginStatus_LoggedOutView); names[1] = SR.GetString(SR.LoginStatus_LoggedInView); return new StandardValuesCollection(names); } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UDPClient.cs
- BaseTemplateParser.cs
- CodeComment.cs
- MaskedTextBox.cs
- Accessible.cs
- LogReservationCollection.cs
- EncoderFallback.cs
- ReadOnlyAttribute.cs
- InputGestureCollection.cs
- FixedPageStructure.cs
- CookielessHelper.cs
- PrtCap_Reader.cs
- QualificationDataAttribute.cs
- SmtpMail.cs
- SQLDateTime.cs
- SystemSounds.cs
- ComponentChangedEvent.cs
- ItemsChangedEventArgs.cs
- GetPageCompletedEventArgs.cs
- Compensation.cs
- PeerName.cs
- Selection.cs
- GenericEnumConverter.cs
- XsdBuildProvider.cs
- XmlHelper.cs
- HTMLTagNameToTypeMapper.cs
- SerialStream.cs
- DigestTraceRecordHelper.cs
- BinaryParser.cs
- DropShadowEffect.cs
- ContextMenu.cs
- FrugalList.cs
- DbConnectionStringBuilder.cs
- DragStartedEventArgs.cs
- SocketPermission.cs
- PropertyBuilder.cs
- AttachedAnnotationChangedEventArgs.cs
- ServiceNameElement.cs
- CurrencyWrapper.cs
- MessageProperties.cs
- Int32CollectionValueSerializer.cs
- CaseCqlBlock.cs
- X509Certificate.cs
- mactripleDES.cs
- AutoGeneratedFieldProperties.cs
- TagNameToTypeMapper.cs
- Propagator.ExtentPlaceholderCreator.cs
- TransportSecurityBindingElement.cs
- TrackingProfileCache.cs
- Int64Storage.cs
- WebPartRestoreVerb.cs
- JournalEntryListConverter.cs
- SqlCaseSimplifier.cs
- TypeReference.cs
- TargetConverter.cs
- _CacheStreams.cs
- WaitingCursor.cs
- AutoSizeComboBox.cs
- BaseCAMarshaler.cs
- Walker.cs
- GlobalDataBindingHandler.cs
- Rfc2898DeriveBytes.cs
- JavaScriptObjectDeserializer.cs
- Attributes.cs
- EntityDataSource.cs
- SelectionEditor.cs
- DisplayInformation.cs
- OverrideMode.cs
- AxisAngleRotation3D.cs
- FilteredAttributeCollection.cs
- RangeValidator.cs
- TempEnvironment.cs
- GatewayDefinition.cs
- ValidatedControlConverter.cs
- ColorTranslator.cs
- IPGlobalProperties.cs
- CodeSnippetExpression.cs
- ConnectionOrientedTransportBindingElement.cs
- PageThemeParser.cs
- AddressingVersion.cs
- ProxyWebPartManager.cs
- DiagnosticsConfiguration.cs
- DesignOnlyAttribute.cs
- DecimalAnimationBase.cs
- WebBodyFormatMessageProperty.cs
- DebugView.cs
- RIPEMD160.cs
- QilStrConcat.cs
- HttpMethodConstraint.cs
- HatchBrush.cs
- DynamicDocumentPaginator.cs
- SqlWriter.cs
- IdentitySection.cs
- WbemProvider.cs
- NumericUpDownAcceleration.cs
- UnsettableComboBox.cs
- WebMessageEncodingElement.cs
- Container.cs
- DecoderFallbackWithFailureFlag.cs
- PhonemeEventArgs.cs