Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Design / Adapters / MSHTMLHostUtil.cs / 1305376 / MSHTMLHostUtil.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Drawing;
using System.Web.UI.Design.MobileControls.Util;
namespace System.Web.UI.Design.MobileControls.Adapters
{
[
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 static class MSHTMLHostUtil
{
private const int CONTROL_WIDTH = 64;
private const int CONTROL_HEIGHT = 4096;
private static MSHTMLHost _tridentControl;
private static NativeMethods.IHTMLElement _htmlBody;
private static NativeMethods.IHTMLElement _htmlDivOuter;
private static NativeMethods.IHTMLElement _htmlDivInner;
private static void CreateControl()
{
if (null != _tridentControl && null != _htmlBody)
{
return;
}
_tridentControl = new MSHTMLHost();
_tridentControl.Size = new Size(CONTROL_WIDTH, CONTROL_HEIGHT);
_tridentControl.CreateTrident();
_tridentControl.ActivateTrident();
NativeMethods.IHTMLDocument2 htmlDoc2 = _tridentControl.GetDocument();
_htmlBody = htmlDoc2.GetBody();
}
internal static void ApplyStyle(String enterStyle, String exitStyle, String cssStyle)
{
MSHTMLHostUtil.CreateControl();
String bodyInnerHTML = "" +
enterStyle +
"" +
exitStyle +
"";
// MessageBox.Show("Body HTML for empty content: " + bodyInnerHTML);
_htmlBody.SetInnerHTML(bodyInnerHTML);
NativeMethods.IHTMLDocument3 htmlDoc3 = (NativeMethods.IHTMLDocument3) _tridentControl.GetDocument();
Debug.Assert(null != htmlDoc3);
_htmlDivInner = htmlDoc3.GetElementById("__divInner");
_htmlDivOuter = htmlDoc3.GetElementById("__divOuter");
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
}
#if UNUSED_CODE
internal static int GetTextWidth(String text)
{
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
_htmlDivInner.SetInnerText(text);
NativeMethods.IHTMLElement2 htmlElement2 = (NativeMethods.IHTMLElement2) _htmlDivOuter;
Debug.Assert(null != htmlElement2);
return htmlElement2.GetClientWidth();
}
#endif
internal static int GetHtmlFragmentWidth(String htmlFragment)
{
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
_htmlDivInner.SetInnerHTML(htmlFragment);
NativeMethods.IHTMLElement2 htmlElement2 = (NativeMethods.IHTMLElement2) _htmlDivOuter;
Debug.Assert(null != htmlElement2);
return htmlElement2.GetClientWidth();
}
internal static int GetHtmlFragmentHeight(String htmlFragment)
{
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
_htmlDivInner.SetInnerHTML(htmlFragment);
NativeMethods.IHTMLElement2 htmlElement2 = (NativeMethods.IHTMLElement2) _htmlDivOuter;
Debug.Assert(null != htmlElement2);
return htmlElement2.GetClientHeight();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Drawing;
using System.Web.UI.Design.MobileControls.Util;
namespace System.Web.UI.Design.MobileControls.Adapters
{
[
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 static class MSHTMLHostUtil
{
private const int CONTROL_WIDTH = 64;
private const int CONTROL_HEIGHT = 4096;
private static MSHTMLHost _tridentControl;
private static NativeMethods.IHTMLElement _htmlBody;
private static NativeMethods.IHTMLElement _htmlDivOuter;
private static NativeMethods.IHTMLElement _htmlDivInner;
private static void CreateControl()
{
if (null != _tridentControl && null != _htmlBody)
{
return;
}
_tridentControl = new MSHTMLHost();
_tridentControl.Size = new Size(CONTROL_WIDTH, CONTROL_HEIGHT);
_tridentControl.CreateTrident();
_tridentControl.ActivateTrident();
NativeMethods.IHTMLDocument2 htmlDoc2 = _tridentControl.GetDocument();
_htmlBody = htmlDoc2.GetBody();
}
internal static void ApplyStyle(String enterStyle, String exitStyle, String cssStyle)
{
MSHTMLHostUtil.CreateControl();
String bodyInnerHTML = "" +
enterStyle +
"" +
exitStyle +
"";
// MessageBox.Show("Body HTML for empty content: " + bodyInnerHTML);
_htmlBody.SetInnerHTML(bodyInnerHTML);
NativeMethods.IHTMLDocument3 htmlDoc3 = (NativeMethods.IHTMLDocument3) _tridentControl.GetDocument();
Debug.Assert(null != htmlDoc3);
_htmlDivInner = htmlDoc3.GetElementById("__divInner");
_htmlDivOuter = htmlDoc3.GetElementById("__divOuter");
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
}
#if UNUSED_CODE
internal static int GetTextWidth(String text)
{
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
_htmlDivInner.SetInnerText(text);
NativeMethods.IHTMLElement2 htmlElement2 = (NativeMethods.IHTMLElement2) _htmlDivOuter;
Debug.Assert(null != htmlElement2);
return htmlElement2.GetClientWidth();
}
#endif
internal static int GetHtmlFragmentWidth(String htmlFragment)
{
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
_htmlDivInner.SetInnerHTML(htmlFragment);
NativeMethods.IHTMLElement2 htmlElement2 = (NativeMethods.IHTMLElement2) _htmlDivOuter;
Debug.Assert(null != htmlElement2);
return htmlElement2.GetClientWidth();
}
internal static int GetHtmlFragmentHeight(String htmlFragment)
{
Debug.Assert(null != _htmlDivOuter && null != _htmlDivInner);
_htmlDivInner.SetInnerHTML(htmlFragment);
NativeMethods.IHTMLElement2 htmlElement2 = (NativeMethods.IHTMLElement2) _htmlDivOuter;
Debug.Assert(null != htmlElement2);
return htmlElement2.GetClientHeight();
}
}
}
// 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
- GeneralTransform3D.cs
- ServiceSettingsResponseInfo.cs
- PageResolution.cs
- _ShellExpression.cs
- PostBackOptions.cs
- InheritanceContextChangedEventManager.cs
- SecurityTimestamp.cs
- ReadWriteObjectLock.cs
- ReferenceTypeElement.cs
- XamlGridLengthSerializer.cs
- DetailsViewPageEventArgs.cs
- FontInfo.cs
- HttpListenerRequestTraceRecord.cs
- StaticResourceExtension.cs
- ReadOnlyTernaryTree.cs
- SqlInternalConnectionTds.cs
- CloseCryptoHandleRequest.cs
- LinqDataSourceDisposeEventArgs.cs
- TraceRecord.cs
- DependencyStoreSurrogate.cs
- CqlIdentifiers.cs
- ChainOfDependencies.cs
- ClickablePoint.cs
- TraceSource.cs
- Visual3D.cs
- ArrangedElementCollection.cs
- TableProvider.cs
- InternalRelationshipCollection.cs
- CompositeTypefaceMetrics.cs
- EntityDataSourceReferenceGroup.cs
- XamlPathDataSerializer.cs
- TriggerCollection.cs
- AxParameterData.cs
- _SSPISessionCache.cs
- DecoderReplacementFallback.cs
- OutputWindow.cs
- AuthenticatedStream.cs
- MethodBuilderInstantiation.cs
- SessionStateSection.cs
- IDReferencePropertyAttribute.cs
- WorkflowInstanceAbortedRecord.cs
- SystemTcpConnection.cs
- HttpCookieCollection.cs
- RawKeyboardInputReport.cs
- OrderedEnumerableRowCollection.cs
- DbConvert.cs
- XmlTextReader.cs
- WSFederationHttpSecurityElement.cs
- NumericPagerField.cs
- EnumMember.cs
- FacetChecker.cs
- EventLogPermissionEntryCollection.cs
- FlowPanelDesigner.cs
- DefaultExpression.cs
- TypeConverterHelper.cs
- BreadCrumbTextConverter.cs
- UpdatePanelTrigger.cs
- ErrorWrapper.cs
- CodeNamespaceImport.cs
- RadioButtonRenderer.cs
- ClientData.cs
- PageAdapter.cs
- Positioning.cs
- AssemblyName.cs
- BidPrivateBase.cs
- HorizontalAlignConverter.cs
- RawContentTypeMapper.cs
- AmbiguousMatchException.cs
- HttpCookie.cs
- StaticDataManager.cs
- MD5CryptoServiceProvider.cs
- LockRecursionException.cs
- DataServiceExpressionVisitor.cs
- QueryGenerator.cs
- EndpointAddressProcessor.cs
- XmlSignatureProperties.cs
- ClientSponsor.cs
- Vector3DCollection.cs
- MinimizableAttributeTypeConverter.cs
- FullTextLine.cs
- LoginName.cs
- ConfigurationManagerHelper.cs
- DataColumnPropertyDescriptor.cs
- SystemColorTracker.cs
- Geometry3D.cs
- FrugalList.cs
- StorageBasedPackageProperties.cs
- WebPartDescriptionCollection.cs
- NativeMethods.cs
- SendSecurityHeader.cs
- PolyQuadraticBezierSegment.cs
- Geometry.cs
- CellParaClient.cs
- TailCallAnalyzer.cs
- FileSystemEventArgs.cs
- ZipIOExtraField.cs
- Tokenizer.cs
- XmlSortKey.cs
- ProgressBarHighlightConverter.cs
- LineGeometry.cs