Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Advanced / PrivateFontCollection.cs / 1305376 / PrivateFontCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Drawing.Text { using System.Diagnostics; using System; using System.Drawing; using System.Drawing.Internal; using System.Runtime.InteropServices; using System.ComponentModel; using Microsoft.Win32; using System.Security; using System.Security.Permissions; using System.Globalization; using System.Runtime.Versioning; ////// /// Encapsulates a collection of public sealed class PrivateFontCollection : FontCollection { ///objecs. /// /// /// [ResourceExposure(ResourceScope.Process)] [ResourceConsumption(ResourceScope.Process)] public PrivateFontCollection() { nativeFontCollection = IntPtr.Zero; int status = SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(out nativeFontCollection); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } ////// Initializes a new instance of the ///class. /// /// /// protected override void Dispose(bool disposing) { if (nativeFontCollection != IntPtr.Zero) { try{ #if DEBUG int status = #endif SafeNativeMethods.Gdip.GdipDeletePrivateFontCollection(out nativeFontCollection); #if DEBUG Debug.Assert(status == SafeNativeMethods.Gdip.Ok, "GDI+ returned an error status: " + status.ToString(CultureInfo.InvariantCulture)); #endif } catch( Exception ex ){ if( ClientUtils.IsSecurityOrCriticalException( ex ) ) { throw; } Debug.Fail( "Exception thrown during Dispose: " + ex.ToString() ); } finally{ nativeFontCollection = IntPtr.Zero; } } base.Dispose(disposing); } ////// Cleans up Windows resources for this /// ///. /// /// /// public void AddFontFile (string filename) { IntSecurity.DemandReadFileIO(filename); int status = SafeNativeMethods.Gdip.GdipPrivateAddFontFile(new HandleRef(this, nativeFontCollection), filename); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); // Register private font with GDI as well so pure GDI-based controls (TextBox, Button for instance) can access it. SafeNativeMethods.AddFontFile( filename ); } // public void AddMemoryFont (IntPtr memory, int length) { IntSecurity.ObjectFromWin32Handle.Demand(); int status = SafeNativeMethods.Gdip.GdipPrivateAddMemoryFont(new HandleRef(this, nativeFontCollection), new HandleRef(null, memory), length); if (status != SafeNativeMethods.Gdip.Ok) throw SafeNativeMethods.Gdip.StatusException(status); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Adds a font from the specified file to /// this ///. ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BooleanProjectedSlot.cs
- OleDbError.cs
- UriExt.cs
- processwaithandle.cs
- DynamicResourceExtension.cs
- CheckBoxField.cs
- ConvertersCollection.cs
- SiteMapNodeItem.cs
- XPathEmptyIterator.cs
- TakeQueryOptionExpression.cs
- ErrorsHelper.cs
- KnownBoxes.cs
- HttpClientChannel.cs
- ControlType.cs
- LookupBindingPropertiesAttribute.cs
- WebPartEditorOkVerb.cs
- embossbitmapeffect.cs
- EntityCodeGenerator.cs
- _FixedSizeReader.cs
- _ProxyRegBlob.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- CaseInsensitiveOrdinalStringComparer.cs
- HitTestDrawingContextWalker.cs
- ToolStripGrip.cs
- Geometry3D.cs
- XmlQualifiedNameTest.cs
- WebCategoryAttribute.cs
- RowUpdatedEventArgs.cs
- BitmapEffectInput.cs
- ScrollPattern.cs
- TakeOrSkipWhileQueryOperator.cs
- SamlAttribute.cs
- SecurityKeyUsage.cs
- SamlDelegatingWriter.cs
- AgileSafeNativeMemoryHandle.cs
- TextBoxView.cs
- UIElementAutomationPeer.cs
- ButtonBaseAdapter.cs
- ButtonColumn.cs
- QilXmlWriter.cs
- ConstructorBuilder.cs
- PinnedBufferMemoryStream.cs
- InternalMappingException.cs
- KnownTypesHelper.cs
- StrokeCollection.cs
- NavigationProperty.cs
- PiiTraceSource.cs
- XMLSyntaxException.cs
- CoreSwitches.cs
- SelectedGridItemChangedEvent.cs
- DuplexChannel.cs
- GlobalEventManager.cs
- ExtenderControl.cs
- ApplicationDirectory.cs
- ChtmlPageAdapter.cs
- HwndKeyboardInputProvider.cs
- GeneralTransformGroup.cs
- CLSCompliantAttribute.cs
- ModuleBuilder.cs
- AttributeCollection.cs
- ReadOnlyTernaryTree.cs
- XamlWriter.cs
- XamlBrushSerializer.cs
- querybuilder.cs
- UnsafeNativeMethodsCLR.cs
- DelegatingTypeDescriptionProvider.cs
- RightsManagementInformation.cs
- DerivedKeyCachingSecurityTokenSerializer.cs
- LinkLabelLinkClickedEvent.cs
- Int16Storage.cs
- XPathNavigatorReader.cs
- SqlServer2KCompatibilityAnnotation.cs
- OutputCacheSettingsSection.cs
- Parser.cs
- CatalogZone.cs
- PropertyItemInternal.cs
- WebPartsSection.cs
- followingsibling.cs
- StreamInfo.cs
- MediaSystem.cs
- RelationshipFixer.cs
- PassportAuthenticationEventArgs.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- ElementHostPropertyMap.cs
- IIS7UserPrincipal.cs
- SeekStoryboard.cs
- CharacterString.cs
- TextBoxBase.cs
- X509Utils.cs
- SQLBoolean.cs
- XmlSchemaImporter.cs
- PerformanceCountersElement.cs
- MarkerProperties.cs
- ObjectHelper.cs
- RequestCachingSection.cs
- dataobject.cs
- ScopedKnownTypes.cs
- TraceInternal.cs
- ProcessRequestArgs.cs
- HandlerElementCollection.cs