Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CommonUI / System / Drawing / Advanced / PrivateFontCollection.cs / 2 / 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; ////// /// 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. //------------------------------------------------------------------------------ ///// Adds a font from the specified file to /// this ///. /// // 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; ////// /// 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./// 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
- WorkflowTimerService.cs
- SrgsSemanticInterpretationTag.cs
- DataServiceStreamProviderWrapper.cs
- DateTimeSerializationSection.cs
- CompositeFontInfo.cs
- HandleCollector.cs
- FontFamily.cs
- SqlCommandBuilder.cs
- CqlLexerHelpers.cs
- Grant.cs
- OnOperation.cs
- ToolStripDropDownButton.cs
- DigitShape.cs
- TextTreeTextBlock.cs
- AuthenticationManager.cs
- HitTestParameters3D.cs
- QueryPageSettingsEventArgs.cs
- MapPathBasedVirtualPathProvider.cs
- PageAsyncTaskManager.cs
- TaskFormBase.cs
- ProviderCommandInfoUtils.cs
- _AuthenticationState.cs
- ObjectDataSourceFilteringEventArgs.cs
- HtmlAnchor.cs
- ZipIOExtraFieldZip64Element.cs
- ComboBox.cs
- IsolatedStorageFilePermission.cs
- WeakKeyDictionary.cs
- BitmapFrameEncode.cs
- OpenFileDialog.cs
- ExportOptions.cs
- RoleManagerSection.cs
- ToolstripProfessionalRenderer.cs
- TextDecorationCollection.cs
- QuotedPrintableStream.cs
- RowBinding.cs
- TextWriter.cs
- DataChangedEventManager.cs
- CellQuery.cs
- LogicalExpr.cs
- BooleanToVisibilityConverter.cs
- ReferenceEqualityComparer.cs
- InsufficientMemoryException.cs
- EventItfInfo.cs
- Decorator.cs
- ConditionChanges.cs
- SystemFonts.cs
- EventTrigger.cs
- RuntimeConfigLKG.cs
- PermissionSetEnumerator.cs
- JsonClassDataContract.cs
- TransportSecurityHelpers.cs
- TableLayoutPanelCellPosition.cs
- AttachedAnnotation.cs
- XmlQualifiedName.cs
- InterleavedZipPartStream.cs
- AssociationType.cs
- HttpListenerResponse.cs
- TemplateControlCodeDomTreeGenerator.cs
- ItemAutomationPeer.cs
- FontEmbeddingManager.cs
- ContextConfiguration.cs
- StreamGeometry.cs
- UnsafeNetInfoNativeMethods.cs
- DataService.cs
- Mutex.cs
- AutoGeneratedField.cs
- DataGridCaption.cs
- ConfigurationPropertyAttribute.cs
- ReflectionTypeLoadException.cs
- DataGridViewCellStyle.cs
- ChannelServices.cs
- ConfigurationLockCollection.cs
- _Connection.cs
- DataGridView.cs
- ToolStripDropDownButton.cs
- CharKeyFrameCollection.cs
- FamilyTypeface.cs
- CopyNamespacesAction.cs
- CompiledRegexRunner.cs
- SelectionRangeConverter.cs
- SecureConversationServiceElement.cs
- BigInt.cs
- DesignRelationCollection.cs
- TextDecorationCollectionConverter.cs
- AssociatedControlConverter.cs
- EFDataModelProvider.cs
- _NetRes.cs
- PropertyMapper.cs
- Base64Stream.cs
- CachedTypeface.cs
- DataControlFieldCollection.cs
- MenuItemStyle.cs
- RuleProcessor.cs
- ExpressionPrefixAttribute.cs
- AdCreatedEventArgs.cs
- MonitorWrapper.cs
- LinkClickEvent.cs
- ProjectedSlot.cs
- GeneralTransformCollection.cs