Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Design / Util / TemporaryBitmapFile.cs / 1305376 / TemporaryBitmapFile.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.MobileControls.Util { using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; ////// This class encapsulates a bitmap and a file that represents /// the bitmap on disk. It would have been cleaner to subclass /// bitmap, but the bitmap class is sealed. /// [ System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode) ] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] internal class TemporaryBitmapFile : IDisposable { private String _path; private Bitmap _bitmap; internal TemporaryBitmapFile(Bitmap bitmap) { Debug.Assert(bitmap != null, "You must provide a valid bitmap object." ); _bitmap = bitmap; _path = Path.GetTempPath() + Guid.NewGuid().ToString() + ".bmp"; [....](); } public void Dispose() { if(_bitmap != null) { _bitmap.Dispose(); _bitmap = null; } if(_path != null) { FileAttributes fa = File.GetAttributes(_path); File.SetAttributes(_path, fa & ~FileAttributes.ReadOnly); File.Delete(_path); _path = null; } } private void [....]() { FileAttributes fa; if(File.Exists(_path)) { fa = File.GetAttributes(_path); File.SetAttributes(_path, fa & ~FileAttributes.ReadOnly); } _bitmap.Save(_path, ImageFormat.Bmp); // If the file did not exist previously, fa will not be valid. fa = File.GetAttributes(_path); File.SetAttributes(_path, fa | FileAttributes.ReadOnly); } internal String Url { get { return "file:///" + _path; } } internal Bitmap UnderlyingBitmap { get { return _bitmap; } set { Debug.Assert(value != null, "Do not set UnderlyingBitmap to null. Instead, "+ "dispose of this object and create a new one later if " + "neccessary. (A zero sized bmp can not be written to disk)" ); if(_bitmap != null) { _bitmap.Dispose(); } _bitmap = value; [....](); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IgnoreFileBuildProvider.cs
- Track.cs
- SHA256.cs
- WebServiceHost.cs
- XmlWrappingReader.cs
- SurrogateSelector.cs
- RelationshipSet.cs
- HashHelper.cs
- DataGridColumnCollection.cs
- Socket.cs
- WindowsFormsHostPropertyMap.cs
- Task.cs
- WorkflowMarkupSerializationException.cs
- Logging.cs
- Cloud.cs
- ExpandCollapsePattern.cs
- SqlBuilder.cs
- Console.cs
- loginstatus.cs
- ArgumentNullException.cs
- XmlParser.cs
- EmptyElement.cs
- AlternateView.cs
- Transactions.cs
- ListViewDeletedEventArgs.cs
- MouseGestureConverter.cs
- RewritingValidator.cs
- Token.cs
- PropertyEmitterBase.cs
- ProtocolsConfigurationHandler.cs
- ReflectionUtil.cs
- ObjectCloneHelper.cs
- OrderedDictionary.cs
- ContentValidator.cs
- GestureRecognizer.cs
- ExpressionBuilderContext.cs
- IEnumerable.cs
- DesignTimeVisibleAttribute.cs
- SignedInfo.cs
- TreeViewDataItemAutomationPeer.cs
- CodeObjectCreateExpression.cs
- VerticalConnector.xaml.cs
- elementinformation.cs
- IUnknownConstantAttribute.cs
- TextPatternIdentifiers.cs
- InputReportEventArgs.cs
- ECDsa.cs
- ListMarkerLine.cs
- EmptyTextWriter.cs
- Viewport3DAutomationPeer.cs
- SecurityPermission.cs
- Delay.cs
- ActivationServices.cs
- AlgoModule.cs
- StrokeSerializer.cs
- HelloOperationAsyncResult.cs
- PTProvider.cs
- CoreSwitches.cs
- StorageAssociationSetMapping.cs
- SystemThemeKey.cs
- ErrorFormatter.cs
- DrawListViewItemEventArgs.cs
- CultureTable.cs
- FontFamily.cs
- Helper.cs
- Model3D.cs
- ColumnResizeUndoUnit.cs
- FormsAuthenticationTicket.cs
- IsolatedStorageFile.cs
- XslCompiledTransform.cs
- IgnoreDeviceFilterElement.cs
- SymDocumentType.cs
- HasCopySemanticsAttribute.cs
- MergePropertyDescriptor.cs
- PackWebRequest.cs
- ContainerUIElement3D.cs
- tooltip.cs
- DocumentViewerHelper.cs
- XDRSchema.cs
- EventLogPermissionEntry.cs
- OleDbInfoMessageEvent.cs
- MenuAdapter.cs
- RepeaterItemEventArgs.cs
- EventData.cs
- ICspAsymmetricAlgorithm.cs
- Int32RectConverter.cs
- ObjectPersistData.cs
- WebPartConnectVerb.cs
- XPathQilFactory.cs
- XmlArrayItemAttributes.cs
- ReverseInheritProperty.cs
- WebConfigurationFileMap.cs
- XmlDataSourceView.cs
- XmlAttributeCache.cs
- DocumentReference.cs
- ToolStripItemClickedEventArgs.cs
- Cursor.cs
- PreProcessInputEventArgs.cs
- HttpStaticObjectsCollectionWrapper.cs
- CriticalHandle.cs