Code:
/ DotNET / DotNET / 8.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 objecs.
///
public sealed class PrivateFontCollection : FontCollection {
///
///
///
/// Initializes a new instance of the class.
///
///
public PrivateFontCollection() {
nativeFontCollection = IntPtr.Zero;
int status = SafeNativeMethods.Gdip.GdipNewPrivateFontCollection(out nativeFontCollection);
if (status != SafeNativeMethods.Gdip.Ok)
throw SafeNativeMethods.Gdip.StatusException(status);
}
///
///
///
/// Cleans up Windows resources for this
/// .
///
///
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);
}
///
///
///
/// Adds a font from the specified file to
/// 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FilteredReadOnlyMetadataCollection.cs
- _NestedSingleAsyncResult.cs
- CodeTryCatchFinallyStatement.cs
- PartitionedStreamMerger.cs
- UrlMapping.cs
- SizeF.cs
- TextCompositionManager.cs
- COM2IDispatchConverter.cs
- D3DImage.cs
- CompatibleComparer.cs
- ProcessActivityTreeOptions.cs
- DnsPermission.cs
- DetailsViewInsertEventArgs.cs
- ExtendedProtectionPolicy.cs
- EntityFrameworkVersions.cs
- PropertyContainer.cs
- ConditionalAttribute.cs
- ChildTable.cs
- ResourceBinder.cs
- TextEditorCharacters.cs
- AmbientValueAttribute.cs
- QueryExpr.cs
- ListBoxItemAutomationPeer.cs
- RegexCode.cs
- RijndaelManaged.cs
- DataRowCollection.cs
- ContentPlaceHolder.cs
- BindingSource.cs
- Fonts.cs
- ConnectionsZoneAutoFormat.cs
- ConstrainedDataObject.cs
- sqlmetadatafactory.cs
- DoubleCollection.cs
- WebPartRestoreVerb.cs
- LockedHandleGlyph.cs
- ListCollectionView.cs
- FlowDocumentPage.cs
- ControlTemplate.cs
- PasswordDeriveBytes.cs
- FrugalList.cs
- CommentAction.cs
- ComplexObject.cs
- ReadOnlyDictionary.cs
- OdbcParameterCollection.cs
- InheritedPropertyChangedEventArgs.cs
- MessageDescription.cs
- FragmentQueryKB.cs
- StaticSiteMapProvider.cs
- XmlSchemaComplexContent.cs
- Light.cs
- SystemKeyConverter.cs
- Rotation3D.cs
- DataGrid.cs
- MultipartIdentifier.cs
- MobileCategoryAttribute.cs
- Scripts.cs
- CursorConverter.cs
- BaseCodeDomTreeGenerator.cs
- DelegateSerializationHolder.cs
- Model3DCollection.cs
- XPathSingletonIterator.cs
- OleDbParameter.cs
- PrefixQName.cs
- AuthenticationServiceManager.cs
- ProxyWebPartManager.cs
- ComNativeDescriptor.cs
- BindingFormattingDialog.cs
- loginstatus.cs
- TimeoutException.cs
- IdnElement.cs
- PopupControlService.cs
- TypeLoadException.cs
- CommandID.cs
- FilterException.cs
- WindowsFormsEditorServiceHelper.cs
- XmlSchemaSimpleContentRestriction.cs
- SetterTriggerConditionValueConverter.cs
- RunInstallerAttribute.cs
- ObjectSecurity.cs
- GridViewColumnHeader.cs
- ArcSegment.cs
- BinaryKeyIdentifierClause.cs
- ScriptingRoleServiceSection.cs
- Repeater.cs
- XPathChildIterator.cs
- TextDecorationUnitValidation.cs
- MobileRedirect.cs
- StreamGeometryContext.cs
- ScriptingScriptResourceHandlerSection.cs
- CompiledXpathExpr.cs
- LineMetrics.cs
- KeyedCollection.cs
- BitmapEffectDrawing.cs
- NameNode.cs
- WpfKnownMemberInvoker.cs
- XPathNodeList.cs
- CustomPopupPlacement.cs
- ObjectHelper.cs
- SystemResourceHost.cs
- LinqDataSource.cs