Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Design / ImageDesigner.cs / 1305376 / ImageDesigner.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.MobileControls { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Drawing; using System.IO; using System.Text; using System.Web.UI; using System.Web.UI.Design; using System.Web.UI.MobileControls; using System.Web.UI.MobileControls.Adapters; using System.Web.UI.Design.MobileControls.Adapters; using System.Web.UI.Design.MobileControls.Converters; using System.Web.UI.Design.MobileControls.Util; using Image = System.Web.UI.MobileControls.Image; [ 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 ImageDesigner : MobileControlDesigner { private Image _image; private TemporaryBitmapFile _tempBmpFile; private Uri _cachedWbmpUri; private String _baseUrl = String.Empty; private String BaseUrl { get { if (_baseUrl != null && _baseUrl.Length == 0) { IWebFormsDocumentService wfServices = (IWebFormsDocumentService)GetService(typeof(IWebFormsDocumentService)); Debug.Assert(wfServices != null); _baseUrl = wfServices.DocumentUrl; } return _baseUrl; } } ////// /// /// The control element being designed. /// ////// Initializes the designer. /// ////// ////// This is called by the designer host to establish the component being /// designed. /// ///public override void Initialize(IComponent component) { Debug.Assert(component is System.Web.UI.MobileControls.Image, "ImageDesigner.Initialize - Invalid Image Control"); _image = (System.Web.UI.MobileControls.Image) component; base.Initialize(component); } /// /// ////// Disposes of the resources (other than memory) used by the /// ///. /// /// ////// Call ///when /// you are finished using the . The method leaves the in an unusable state. After /// calling , you must release all /// references to the so the memory it was occupying /// can be reclaimed by garbage collection. /// /// Always call ///before you release your last reference to /// the . Otherwise, the resources /// the is using will not be freed /// until garbage collection calls the object's /// destructor. /// protected override void Dispose(bool disposing) { if (disposing && _tempBmpFile != null) { _tempBmpFile.Dispose(); _cachedWbmpUri = null; _tempBmpFile = null; } base.Dispose(disposing); } private String GetConvertedImageURI(String imageUriString) { Uri baseUri = new Uri(BaseUrl); Uri imageUri = new Uri(baseUri, imageUriString); String extension = Path.GetExtension(imageUriString); if(extension.Equals(".wbmp")) { if(_tempBmpFile != null) { if(_cachedWbmpUri != null && _cachedWbmpUri.Equals(imageUri)) { return _tempBmpFile.Url; } else { _tempBmpFile.Dispose(); _tempBmpFile = null; _cachedWbmpUri = null; } } Byte[] buffer = FileReader.Read(imageUri); if(buffer == null) { // Could not read image from URI, return original URI to // Trident and let it render as a broken image. goto ConversionError; } Bitmap bitmap = WbmpConverter.Convert(buffer); if(bitmap == null) { // .wbmp appears to be corrupt, return original URI to // Trident and let it render as a broken image. goto ConversionError; } _tempBmpFile = new TemporaryBitmapFile(bitmap); imageUriString = _tempBmpFile.Url; _cachedWbmpUri = imageUri; } ConversionError: return imageUriString; } /// /// ////// Gets the HTML to be used for the design time representation of the control runtime. /// ////// protected override String GetDesignTimeNormalHtml() { String tempUrl = String.Empty; bool replaceUrl = (_image.ImageUrl.Length > 0); DesignerTextWriter writer = new DesignerTextWriter(); tempUrl = _image.ImageUrl; _image.ImageUrl = GetConvertedImageURI(_image.ImageUrl); _image.Adapter.Render(writer); _image.ImageUrl = tempUrl; return writer.ToString(); } public override void OnComponentChanged(Object sender, ComponentChangedEventArgs e) { if ((e.Member != null) && e.Member.Name.Equals("NavigateUrl")) { _image.NavigateUrl = NavigateUrlConverter.GetUrl( _image, e.NewValue.ToString(), e.OldValue.ToString() ); e = new ComponentChangedEventArgs(e.Component, e.Member, e.OldValue, _image.NavigateUrl); } base.OnComponentChanged(sender, e); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ ///// The design time HTML. /// ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.MobileControls { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Drawing; using System.IO; using System.Text; using System.Web.UI; using System.Web.UI.Design; using System.Web.UI.MobileControls; using System.Web.UI.MobileControls.Adapters; using System.Web.UI.Design.MobileControls.Adapters; using System.Web.UI.Design.MobileControls.Converters; using System.Web.UI.Design.MobileControls.Util; using Image = System.Web.UI.MobileControls.Image; [ 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 ImageDesigner : MobileControlDesigner { private Image _image; private TemporaryBitmapFile _tempBmpFile; private Uri _cachedWbmpUri; private String _baseUrl = String.Empty; private String BaseUrl { get { if (_baseUrl != null && _baseUrl.Length == 0) { IWebFormsDocumentService wfServices = (IWebFormsDocumentService)GetService(typeof(IWebFormsDocumentService)); Debug.Assert(wfServices != null); _baseUrl = wfServices.DocumentUrl; } return _baseUrl; } } ////// /// /// The control element being designed. /// ////// Initializes the designer. /// ////// ////// This is called by the designer host to establish the component being /// designed. /// ///public override void Initialize(IComponent component) { Debug.Assert(component is System.Web.UI.MobileControls.Image, "ImageDesigner.Initialize - Invalid Image Control"); _image = (System.Web.UI.MobileControls.Image) component; base.Initialize(component); } /// /// ////// Disposes of the resources (other than memory) used by the /// ///. /// /// ////// Call ///when /// you are finished using the . The method leaves the in an unusable state. After /// calling , you must release all /// references to the so the memory it was occupying /// can be reclaimed by garbage collection. /// /// Always call ///before you release your last reference to /// the . Otherwise, the resources /// the is using will not be freed /// until garbage collection calls the object's /// destructor. /// protected override void Dispose(bool disposing) { if (disposing && _tempBmpFile != null) { _tempBmpFile.Dispose(); _cachedWbmpUri = null; _tempBmpFile = null; } base.Dispose(disposing); } private String GetConvertedImageURI(String imageUriString) { Uri baseUri = new Uri(BaseUrl); Uri imageUri = new Uri(baseUri, imageUriString); String extension = Path.GetExtension(imageUriString); if(extension.Equals(".wbmp")) { if(_tempBmpFile != null) { if(_cachedWbmpUri != null && _cachedWbmpUri.Equals(imageUri)) { return _tempBmpFile.Url; } else { _tempBmpFile.Dispose(); _tempBmpFile = null; _cachedWbmpUri = null; } } Byte[] buffer = FileReader.Read(imageUri); if(buffer == null) { // Could not read image from URI, return original URI to // Trident and let it render as a broken image. goto ConversionError; } Bitmap bitmap = WbmpConverter.Convert(buffer); if(bitmap == null) { // .wbmp appears to be corrupt, return original URI to // Trident and let it render as a broken image. goto ConversionError; } _tempBmpFile = new TemporaryBitmapFile(bitmap); imageUriString = _tempBmpFile.Url; _cachedWbmpUri = imageUri; } ConversionError: return imageUriString; } /// /// ////// Gets the HTML to be used for the design time representation of the control runtime. /// ////// protected override String GetDesignTimeNormalHtml() { String tempUrl = String.Empty; bool replaceUrl = (_image.ImageUrl.Length > 0); DesignerTextWriter writer = new DesignerTextWriter(); tempUrl = _image.ImageUrl; _image.ImageUrl = GetConvertedImageURI(_image.ImageUrl); _image.Adapter.Render(writer); _image.ImageUrl = tempUrl; return writer.ToString(); } public override void OnComponentChanged(Object sender, ComponentChangedEventArgs e) { if ((e.Member != null) && e.Member.Name.Equals("NavigateUrl")) { _image.NavigateUrl = NavigateUrlConverter.GetUrl( _image, e.NewValue.ToString(), e.OldValue.ToString() ); e = new ComponentChangedEventArgs(e.Component, e.Member, e.OldValue, _image.NavigateUrl); } base.OnComponentChanged(sender, e); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// The design time HTML. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OutOfProcStateClientManager.cs
- LabelLiteral.cs
- ObjectSecurity.cs
- SqlNotificationEventArgs.cs
- DtrList.cs
- RoutedPropertyChangedEventArgs.cs
- SqlDataSourceConfigureSortForm.cs
- _TransmitFileOverlappedAsyncResult.cs
- MultiTargetingUtil.cs
- OpacityConverter.cs
- UrlAuthorizationModule.cs
- ScriptMethodAttribute.cs
- DataSourceCacheDurationConverter.cs
- WeakHashtable.cs
- MetadataItem_Static.cs
- CurrencyWrapper.cs
- ConfigurationManagerHelper.cs
- KerberosTokenFactoryCredential.cs
- Style.cs
- IndependentAnimationStorage.cs
- HotSpotCollection.cs
- TokenBasedSetEnumerator.cs
- PostBackOptions.cs
- ToolStripOverflow.cs
- RadioButtonRenderer.cs
- DescendentsWalker.cs
- Application.cs
- XmlDownloadManager.cs
- NaturalLanguageHyphenator.cs
- CodeDomConfigurationHandler.cs
- sqlnorm.cs
- PageSettings.cs
- DataGridViewDataErrorEventArgs.cs
- SspiHelper.cs
- UidManager.cs
- Int64Converter.cs
- versioninfo.cs
- _SSPIWrapper.cs
- AnimatedTypeHelpers.cs
- RangeBase.cs
- SqlDataReaderSmi.cs
- SelectorItemAutomationPeer.cs
- NativeMethods.cs
- Types.cs
- ReadOnlyAttribute.cs
- CheckBox.cs
- ToolTipService.cs
- ConfigXmlComment.cs
- TypedElement.cs
- EmissiveMaterial.cs
- SchemaEntity.cs
- EditBehavior.cs
- DocumentationServerProtocol.cs
- CodeAccessSecurityEngine.cs
- CodeTryCatchFinallyStatement.cs
- MaskDesignerDialog.cs
- ConfigurationManagerHelper.cs
- ipaddressinformationcollection.cs
- TextRunProperties.cs
- controlskin.cs
- ArrangedElementCollection.cs
- QilName.cs
- HostedElements.cs
- RootDesignerSerializerAttribute.cs
- ProxyAttribute.cs
- MissingSatelliteAssemblyException.cs
- Track.cs
- RegisteredArrayDeclaration.cs
- DecoderBestFitFallback.cs
- SqlSupersetValidator.cs
- Rules.cs
- UriTemplateLiteralQueryValue.cs
- RequestCacheEntry.cs
- UiaCoreTypesApi.cs
- DurableInstanceContextProvider.cs
- BreakRecordTable.cs
- ColumnReorderedEventArgs.cs
- ReadOnlyTernaryTree.cs
- MultiBinding.cs
- BooleanFunctions.cs
- IconBitmapDecoder.cs
- BmpBitmapEncoder.cs
- ActivityDesigner.cs
- ExtenderControl.cs
- TextWriter.cs
- TreeBuilderXamlTranslator.cs
- UncommonField.cs
- TypeSemantics.cs
- DayRenderEvent.cs
- StateInitialization.cs
- JsonWriter.cs
- CodeDelegateCreateExpression.cs
- MeshGeometry3D.cs
- EventLogHandle.cs
- RegexCharClass.cs
- BitmapEncoder.cs
- SkinBuilder.cs
- PublishLicense.cs
- UdpTransportBindingElement.cs
- PrePrepareMethodAttribute.cs