Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / OwnerDrawPropertyBag.cs / 1305376 / OwnerDrawPropertyBag.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System.Diagnostics; using System; using System.Drawing; using System.Diagnostics.CodeAnalysis; using System.Windows.Forms.Internal; using System.Windows.Forms; using Microsoft.Win32; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Security.Permissions; ////// /// /// Class used to pass new font/color information around for "partial" ownerdraw list/treeview items. /// ///// [SuppressMessage("Microsoft.Usage", "CA2240:ImplementISerializableCorrectly")] [Serializable] public class OwnerDrawPropertyBag : MarshalByRefObject, ISerializable { Font font = null; Color foreColor = Color.Empty; Color backColor = Color.Empty; Control.FontHandleWrapper fontWrapper = null; private static object internalSyncObject = new object(); /** * Constructor used in deserialization * Has to be protected because OwnerDrawPropertyBag is not sealed. FxCop Rule CA2229. */ protected OwnerDrawPropertyBag(SerializationInfo info, StreamingContext context) { foreach (SerializationEntry entry in info) { if (entry.Name == "Font") { // SEC font = (Font) entry.Value; } else if (entry.Name =="ForeColor") { // SEC foreColor =(Color)entry.Value; } else if (entry.Name =="BackColor") { // SEC backColor = (Color)entry.Value; } } } internal OwnerDrawPropertyBag(){ } /// /// /// public Font Font { get { return font; } set { font = value; } } ///[To be supplied.] ////// /// public Color ForeColor { get { return foreColor; } set { foreColor = value; } } ///[To be supplied.] ////// /// public Color BackColor { get { return backColor; } set { backColor = value; } } internal IntPtr FontHandle { get { if (fontWrapper == null) { fontWrapper = new Control.FontHandleWrapper(Font); } return fontWrapper.Handle; } } ///[To be supplied.] ////// /// Returns whether or not this property bag contains all default values (is empty) /// public virtual bool IsEmpty() { return (Font == null && foreColor.IsEmpty && backColor.IsEmpty); } ////// /// Copies the bag. Always returns a valid ODPB object /// public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value) { lock(internalSyncObject) { OwnerDrawPropertyBag ret = new OwnerDrawPropertyBag(); if (value == null) return ret; ret.backColor = value.backColor; ret.foreColor = value.foreColor; ret.Font = value.font; return ret; } } ////// /// ISerializable private implementation /// ///[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)] void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context) { si.AddValue("BackColor", BackColor); si.AddValue("ForeColor", ForeColor); si.AddValue("Font", Font); } } } // 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
- SmtpReplyReader.cs
- XappLauncher.cs
- HttpServerUtilityWrapper.cs
- Rect3D.cs
- ImageCollectionEditor.cs
- TagPrefixInfo.cs
- BasicExpandProvider.cs
- JsonFormatReaderGenerator.cs
- OrthographicCamera.cs
- PublisherIdentityPermission.cs
- HandlerBase.cs
- TextBox.cs
- SimpleType.cs
- SqlResolver.cs
- ColorAnimationUsingKeyFrames.cs
- SQLDateTimeStorage.cs
- ToolboxBitmapAttribute.cs
- ActivityTrace.cs
- ClassDataContract.cs
- CompareInfo.cs
- SettingsSection.cs
- TextRangeEdit.cs
- XamlValidatingReader.cs
- WeakEventTable.cs
- SingleKeyFrameCollection.cs
- ObjectDisposedException.cs
- BinaryFormatterWriter.cs
- TextEditorThreadLocalStore.cs
- EnumerableRowCollection.cs
- SecurityCriticalDataForSet.cs
- PropertyGroupDescription.cs
- SimpleFieldTemplateFactory.cs
- Mappings.cs
- DispatcherSynchronizationContext.cs
- PageThemeBuildProvider.cs
- Constants.cs
- XmlSchemaType.cs
- CryptoKeySecurity.cs
- RubberbandSelector.cs
- XPathDocumentBuilder.cs
- XmlSerializationWriter.cs
- UrlPropertyAttribute.cs
- MeasureItemEvent.cs
- Expression.cs
- BoundField.cs
- HMACSHA256.cs
- AssemblyContextControlItem.cs
- ListControlBuilder.cs
- ResourceReader.cs
- ThicknessKeyFrameCollection.cs
- NativeCompoundFileAPIs.cs
- TextServicesLoader.cs
- DataGridViewSelectedRowCollection.cs
- IMembershipProvider.cs
- SafeLibraryHandle.cs
- UnionCodeGroup.cs
- XmlExpressionDumper.cs
- SendMailErrorEventArgs.cs
- DesignerTransactionCloseEvent.cs
- BindStream.cs
- XPathAncestorQuery.cs
- HttpListenerPrefixCollection.cs
- SecureUICommand.cs
- ImportCatalogPart.cs
- WebServiceMethodData.cs
- PasswordRecovery.cs
- CombinedGeometry.cs
- WebConfigurationHostFileChange.cs
- InvalidDataException.cs
- ScriptControl.cs
- Screen.cs
- RecipientIdentity.cs
- TemplateBindingExpression.cs
- Tile.cs
- ResourceAssociationType.cs
- OleDbReferenceCollection.cs
- VariantWrapper.cs
- Path.cs
- InkPresenterAutomationPeer.cs
- _BufferOffsetSize.cs
- RegexRunner.cs
- MSAANativeProvider.cs
- WindowClosedEventArgs.cs
- Compilation.cs
- XmlElementAttributes.cs
- ServicePointManagerElement.cs
- ConstraintEnumerator.cs
- TextContainerHelper.cs
- WaitForChangedResult.cs
- MailBnfHelper.cs
- FieldNameLookup.cs
- SqlTrackingWorkflowInstance.cs
- SafeRegistryHandle.cs
- SelfIssuedAuthRSAPKCS1SignatureFormatter.cs
- HttpProfileGroupBase.cs
- QuaternionIndependentAnimationStorage.cs
- NumericUpDownAccelerationCollection.cs
- StorageEntitySetMapping.cs
- CompilerTypeWithParams.cs
- CodeAttributeDeclarationCollection.cs