1 //------------------------------------------------------------------------------ 2 // <copyright file="DesignerAdRotatorAdapter.cs" company="Microsoft"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 //------------------------------------------------------------------------------ 6 7 using System.Diagnostics; 8 using System.Globalization; 9 using System.Web.Mobile; 10 using System.Web.UI.Design.MobileControls; 11 using System.Web.UI.MobileControls; 12 using System.Web.UI.MobileControls.Adapters; 13 14 namespace System.Web.UI.Design.MobileControls.Adapters 15 { 16 [ 17 System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, 18 Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode) 19 ] 20 [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.")] 21 internal class DesignerAdRotatorAdapter : System.Web.UI.MobileControls.Adapters.HtmlControlAdapter 22 { 23 public override MobileCapabilities Device 24 { 25 get 26 { 27 return DesignerCapabilities.Instance; 28 } 29 } 30 Render(HtmlMobileTextWriter writer)31 public override void Render(HtmlMobileTextWriter writer) 32 { 33 Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; 34 String width = DesignerAdapterUtil.GetWidth(Control); 35 36 byte templateStatus; 37 int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); 38 39 if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) 40 { 41 width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px"; 42 } 43 44 writer.WriteBeginTag("div"); 45 if (alignment == Alignment.Center) 46 { 47 writer.WriteAttribute("align", "center"); 48 } 49 writer.WriteAttribute("style", "padding=2px;overflow-x:hidden;width:" + width); 50 writer.Write(">"); 51 52 ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); 53 54 writer.WriteBeginTag("img"); 55 writer.WriteAttribute("alt", Control.ID); 56 ((DesignerTextWriter)writer).WriteStyleAttribute(Style); 57 58 // center alignment not part of HTML for images. 59 if (alignment == Alignment.Right || 60 alignment == Alignment.Left) 61 { 62 writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); 63 } 64 65 writer.WriteAttribute("height", "40"); 66 writer.WriteAttribute("width", "250"); 67 writer.WriteAttribute("border", "0"); 68 writer.Write(">"); 69 70 ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); 71 writer.WriteEndTag("div"); 72 } 73 } 74 } 75