Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CommonUI / System / Drawing / Advanced / PrivateFontCollection.cs / 1 / 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
- DataKeyPropertyAttribute.cs
- TextDecorationLocationValidation.cs
- DirectionalLight.cs
- Form.cs
- ZipIOCentralDirectoryFileHeader.cs
- TemplatePropertyEntry.cs
- WebEvents.cs
- ManualResetEvent.cs
- MailSettingsSection.cs
- IProducerConsumerCollection.cs
- UiaCoreProviderApi.cs
- XmlKeywords.cs
- ImageCollectionCodeDomSerializer.cs
- BindableAttribute.cs
- SecurityContext.cs
- LocalValueEnumerator.cs
- _LoggingObject.cs
- TableParagraph.cs
- AuthStoreRoleProvider.cs
- Perspective.cs
- HttpValueCollection.cs
- UnsafeNativeMethods.cs
- ResXDataNode.cs
- DiscardableAttribute.cs
- AutomationIdentifier.cs
- InputLanguageSource.cs
- BatchParser.cs
- ValidationSummary.cs
- DbDataRecord.cs
- XmlCharCheckingReader.cs
- EditorPart.cs
- SuppressIldasmAttribute.cs
- ExpressionVisitorHelpers.cs
- NamespaceList.cs
- ChildChangedEventArgs.cs
- DataGridViewUtilities.cs
- StateBag.cs
- ISFTagAndGuidCache.cs
- DocumentViewerBase.cs
- QueryCacheEntry.cs
- SystemIPInterfaceStatistics.cs
- Propagator.cs
- ToolStripDropDownClosingEventArgs.cs
- SynchronizationContextHelper.cs
- ClientApiGenerator.cs
- PageHandlerFactory.cs
- SuppressIldasmAttribute.cs
- PngBitmapEncoder.cs
- DataSourceListEditor.cs
- exports.cs
- TextCharacters.cs
- PerformanceCounterCategory.cs
- OrderedDictionary.cs
- Hashtable.cs
- ColorAnimation.cs
- ProtocolViolationException.cs
- AuthenticationModulesSection.cs
- UnsafeMethods.cs
- DataAdapter.cs
- SmtpNegotiateAuthenticationModule.cs
- _OSSOCK.cs
- DoubleAnimationUsingPath.cs
- UserMapPath.cs
- XmlArrayItemAttributes.cs
- FileSystemInfo.cs
- ComponentManagerBroker.cs
- ClientBuildManager.cs
- MethodBody.cs
- ComPlusAuthorization.cs
- _ProxyChain.cs
- UntypedNullExpression.cs
- LinqDataSourceDeleteEventArgs.cs
- BaseValidator.cs
- CellLabel.cs
- CodeAttributeDeclaration.cs
- WebPartConnectionsCancelVerb.cs
- Char.cs
- OverflowException.cs
- JavaScriptString.cs
- WebZone.cs
- TimeManager.cs
- PropertyReference.cs
- DesignerVerbToolStripMenuItem.cs
- ExtenderControl.cs
- SudsCommon.cs
- SynchronizationLockException.cs
- RegexParser.cs
- _LazyAsyncResult.cs
- TemplateKeyConverter.cs
- ResourceSet.cs
- EventManager.cs
- HttpRequestCacheValidator.cs
- HexParser.cs
- DataGridViewCellMouseEventArgs.cs
- Polyline.cs
- ValidationContext.cs
- RemotingConfigParser.cs
- RichTextBox.cs
- HtmlDocument.cs
- IPEndPointCollection.cs