Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / CommonUI / System / Drawing / Advanced / PrivateFontCollection.cs / 1 / PrivateFontCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /*************************************************************************\ * * Copyright (c) 1998-1999, Microsoft Corp. All Rights Reserved. * * Module Name: * * font.cs * * Abstract: * * COM+ wrapper for GDI+ font objects * * Revision History: * * 3/16/2000 [...] * Created it. * \**************************************************************************/ 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; ////// /// Encapsulates a collection of public sealed class PrivateFontCollection : FontCollection { ///objecs. /// /// /// 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. // Copyright (c) Microsoft Corporation. All rights reserved./// 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
- UITypeEditor.cs
- DataGridViewColumnStateChangedEventArgs.cs
- UrlMappingsSection.cs
- EventBuilder.cs
- DesignerActionUIStateChangeEventArgs.cs
- TargetControlTypeAttribute.cs
- XmlSchemaValidationException.cs
- XmlArrayItemAttribute.cs
- DoWorkEventArgs.cs
- BaseResourcesBuildProvider.cs
- MatrixAnimationUsingKeyFrames.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- Rect.cs
- RequestQueryProcessor.cs
- EntityDataSourceConfigureObjectContextPanel.cs
- XmlReaderSettings.cs
- RedBlackList.cs
- UITypeEditors.cs
- DefaultIfEmptyQueryOperator.cs
- WebEventCodes.cs
- TabControlCancelEvent.cs
- Padding.cs
- ToolZone.cs
- ZipIORawDataFileBlock.cs
- ShapeTypeface.cs
- TransformGroup.cs
- DiscoveryClientDuplexChannel.cs
- RegexGroup.cs
- SqlMultiplexer.cs
- ObjectQueryExecutionPlan.cs
- WebEventTraceProvider.cs
- DesignerUtility.cs
- WebPartCancelEventArgs.cs
- ExportOptions.cs
- Model3D.cs
- DocumentScope.cs
- MobileControlsSectionHandler.cs
- UserControl.cs
- TypeElement.cs
- LineBreak.cs
- CommandID.cs
- FileRegion.cs
- IgnoreSection.cs
- TdsParserHelperClasses.cs
- VerbConverter.cs
- MethodExpr.cs
- AnimatedTypeHelpers.cs
- EmptyStringExpandableObjectConverter.cs
- ThemeInfoAttribute.cs
- AutoFocusStyle.xaml.cs
- ReadOnlyMetadataCollection.cs
- safemediahandle.cs
- ObjectMaterializedEventArgs.cs
- diagnosticsswitches.cs
- DataGridViewHitTestInfo.cs
- DBConnection.cs
- ResourceType.cs
- CodeIdentifiers.cs
- XhtmlBasicCalendarAdapter.cs
- UnmanagedMemoryStream.cs
- WinFormsComponentEditor.cs
- DataGridViewComboBoxColumn.cs
- _ListenerAsyncResult.cs
- TagNameToTypeMapper.cs
- GenericUI.cs
- Nodes.cs
- KeyInstance.cs
- EntityDataSourceMemberPath.cs
- DataColumnPropertyDescriptor.cs
- TemplateComponentConnector.cs
- ProfilePropertyNameValidator.cs
- FontResourceCache.cs
- DictionaryCustomTypeDescriptor.cs
- OracleColumn.cs
- ToolTip.cs
- CounterCreationDataCollection.cs
- PathNode.cs
- DSASignatureDeformatter.cs
- StorageEntityTypeMapping.cs
- ExceptionHandler.cs
- MulticastDelegate.cs
- TypeDelegator.cs
- DynamicEndpointElement.cs
- ListParaClient.cs
- EntityClientCacheKey.cs
- LocalizeDesigner.cs
- nulltextcontainer.cs
- HttpServerUtilityBase.cs
- DefaultClaimSet.cs
- SynchronousSendBindingElement.cs
- ExpressionEditorAttribute.cs
- SerialPort.cs
- StateDesigner.CommentLayoutGlyph.cs
- RadioButton.cs
- GridSplitter.cs
- XmlMemberMapping.cs
- TextViewElement.cs
- QualifiedId.cs
- ScrollChangedEventArgs.cs
- ButtonAutomationPeer.cs