Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Adapters / ChtmlImageAdapter.cs / 1305376 / ChtmlImageAdapter.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System.Globalization;
using System.Web.UI.MobileControls.Adapters;
using System.Security.Permissions;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource
#else
namespace System.Web.UI.MobileControls.Adapters
#endif
{
/*
* ChtmlImageAdapter class.
*/
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[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.")]
public class ChtmlImageAdapter : HtmlImageAdapter
{
///
protected internal override void RenderImage(HtmlMobileTextWriter writer)
{
String source = Control.ImageUrl;
if (source.StartsWith(Constants.SymbolProtocol, StringComparison.Ordinal) &&
(Device.SupportsIModeSymbols || Device.SupportsJPhoneSymbols))
{
if (Device.SupportsIModeSymbols)
{
writer.Write("");
writer.Write(
source.Substring(Constants.SymbolProtocol.Length));
writer.Write(";");
}
else
{
// The ImageUrl should be in the format "symbol:xyyy",
// where x is group picture character (either G, E or F),
// and yyy (length can vary) is the picture's character
// code (in decimal).
String symbolChars = source.Substring(
Constants.SymbolProtocol.Length);
char code = DecimalStringToChar(symbolChars.Substring(1));
writer.Write("\u001B$");
writer.Write(Char.ToUpper(symbolChars[0], CultureInfo.InvariantCulture));
writer.Write(code);
writer.Write('\u000F');
}
}
else
{
base.RenderImage(writer);
}
}
// Convert decimal string "xxx" to '\u00xx'
private char DecimalStringToChar(String decimalString)
{
int codeValue = 0;
int adj = 1;
for (int i = decimalString.Length - 1; i >= 0; i--)
{
codeValue += DecimalCharToInt(decimalString[i]) * adj;
adj *= 10;
}
return (char) codeValue;
}
// Convert decimal char 'x' to decimal integer value x
private int DecimalCharToInt(char decimalChar)
{
int i;
if (decimalChar >= '0' && decimalChar <= '9')
{
i = decimalChar - '0';
}
else
{
throw new ArgumentException(
SR.GetString(SR.ChtmlImageAdapterDecimalCodeExpectedAfterGroupChar),
"ImageUrl");
}
return i;
}
///
protected override void AddAttributes(HtmlMobileTextWriter writer)
{
AddAccesskeyAttribute(writer);
AddJPhoneMultiMediaAttributes(writer);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System.Globalization;
using System.Web.UI.MobileControls.Adapters;
using System.Security.Permissions;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource
#else
namespace System.Web.UI.MobileControls.Adapters
#endif
{
/*
* ChtmlImageAdapter class.
*/
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[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.")]
public class ChtmlImageAdapter : HtmlImageAdapter
{
///
protected internal override void RenderImage(HtmlMobileTextWriter writer)
{
String source = Control.ImageUrl;
if (source.StartsWith(Constants.SymbolProtocol, StringComparison.Ordinal) &&
(Device.SupportsIModeSymbols || Device.SupportsJPhoneSymbols))
{
if (Device.SupportsIModeSymbols)
{
writer.Write("");
writer.Write(
source.Substring(Constants.SymbolProtocol.Length));
writer.Write(";");
}
else
{
// The ImageUrl should be in the format "symbol:xyyy",
// where x is group picture character (either G, E or F),
// and yyy (length can vary) is the picture's character
// code (in decimal).
String symbolChars = source.Substring(
Constants.SymbolProtocol.Length);
char code = DecimalStringToChar(symbolChars.Substring(1));
writer.Write("\u001B$");
writer.Write(Char.ToUpper(symbolChars[0], CultureInfo.InvariantCulture));
writer.Write(code);
writer.Write('\u000F');
}
}
else
{
base.RenderImage(writer);
}
}
// Convert decimal string "xxx" to '\u00xx'
private char DecimalStringToChar(String decimalString)
{
int codeValue = 0;
int adj = 1;
for (int i = decimalString.Length - 1; i >= 0; i--)
{
codeValue += DecimalCharToInt(decimalString[i]) * adj;
adj *= 10;
}
return (char) codeValue;
}
// Convert decimal char 'x' to decimal integer value x
private int DecimalCharToInt(char decimalChar)
{
int i;
if (decimalChar >= '0' && decimalChar <= '9')
{
i = decimalChar - '0';
}
else
{
throw new ArgumentException(
SR.GetString(SR.ChtmlImageAdapterDecimalCodeExpectedAfterGroupChar),
"ImageUrl");
}
return i;
}
///
protected override void AddAttributes(HtmlMobileTextWriter writer)
{
AddAccesskeyAttribute(writer);
AddJPhoneMultiMediaAttributes(writer);
}
}
}
// 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
- translator.cs
- AncestorChangedEventArgs.cs
- DataSysAttribute.cs
- BamlVersionHeader.cs
- ZoneMembershipCondition.cs
- SQLInt16Storage.cs
- LogEntryDeserializer.cs
- VariableBinder.cs
- SpAudioStreamWrapper.cs
- TransactionException.cs
- RightsManagementInformation.cs
- SapiAttributeParser.cs
- DataMemberFieldEditor.cs
- SynchronizationContext.cs
- CurrencyWrapper.cs
- CodeFieldReferenceExpression.cs
- RowToParametersTransformer.cs
- ThreadAbortException.cs
- RowBinding.cs
- tabpagecollectioneditor.cs
- PermissionSetEnumerator.cs
- WmlControlAdapter.cs
- itemelement.cs
- UnmanagedMemoryStreamWrapper.cs
- MailWriter.cs
- FigureHelper.cs
- SqlMethods.cs
- SingleSelectRootGridEntry.cs
- DebugView.cs
- NavigationCommands.cs
- UnsafeNativeMethodsMilCoreApi.cs
- DataPagerField.cs
- DataBinder.cs
- XdrBuilder.cs
- BinaryObjectReader.cs
- EntitySet.cs
- ContentOperations.cs
- DocobjHost.cs
- ListViewInsertEventArgs.cs
- InputDevice.cs
- BaseCAMarshaler.cs
- DefaultTraceListener.cs
- RawStylusSystemGestureInputReport.cs
- ScopedKnownTypes.cs
- StorageMappingItemLoader.cs
- FileRecordSequenceHelper.cs
- ISO2022Encoding.cs
- TextEditor.cs
- WsdlBuildProvider.cs
- RequestBringIntoViewEventArgs.cs
- NetSectionGroup.cs
- Parser.cs
- KeyedHashAlgorithm.cs
- ListViewEditEventArgs.cs
- relpropertyhelper.cs
- OutKeywords.cs
- DesignerAttribute.cs
- TokenBasedSet.cs
- TargetControlTypeAttribute.cs
- ClientCultureInfo.cs
- WindowsRegion.cs
- ScrollBarRenderer.cs
- MessageHeaderException.cs
- RootProjectionNode.cs
- MetadataCacheItem.cs
- NonVisualControlAttribute.cs
- XmlFormatReaderGenerator.cs
- HandlerFactoryWrapper.cs
- ChangeBlockUndoRecord.cs
- DataTableExtensions.cs
- TreeNodeCollection.cs
- LinqDataSourceUpdateEventArgs.cs
- BamlRecords.cs
- COM2TypeInfoProcessor.cs
- SoapProtocolReflector.cs
- TextSelectionProcessor.cs
- JoinGraph.cs
- WebPartCatalogAddVerb.cs
- MethodSignatureGenerator.cs
- Region.cs
- __TransparentProxy.cs
- RewritingSimplifier.cs
- TypeInitializationException.cs
- WebControlsSection.cs
- EventHandlers.cs
- DrawingState.cs
- sortedlist.cs
- Dump.cs
- DefaultPropertiesToSend.cs
- SqlXmlStorage.cs
- ObjectReaderCompiler.cs
- SerializationStore.cs
- DescendantOverDescendantQuery.cs
- EventLogInformation.cs
- SynchronizationHandlesCodeDomSerializer.cs
- ToolboxItemFilterAttribute.cs
- XamlDesignerSerializationManager.cs
- FlowDocumentPageViewerAutomationPeer.cs
- SourceSwitch.cs
- Msec.cs