Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / TemplateEditingService.cs / 1 / TemplateEditingService.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design { using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Design; using System.Diagnostics; using System.Web.UI; using System.Web.UI.WebControls; ////// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] [Obsolete("Use of this type is not recommended because template editing is handled in ControlDesigner. To support template editing expose template data in the TemplateGroups property and call SetViewFlags(ViewFlags.TemplateEditing, true). http://go.microsoft.com/fwlink/?linkid=14202")] public sealed class TemplateEditingService : ITemplateEditingService, IDisposable { private IDesignerHost designerHost; /// public TemplateEditingService(IDesignerHost designerHost) { if (designerHost == null) { throw new ArgumentNullException("designerHost"); } this.designerHost = designerHost; } /// public bool SupportsNestedTemplateEditing { get { return false; } } /// public ITemplateEditingFrame CreateFrame(TemplatedControlDesigner designer, string frameName, string[] templateNames) { return CreateFrame(designer, frameName, templateNames, null, null); } /// public ITemplateEditingFrame CreateFrame(TemplatedControlDesigner designer, string frameName, string[] templateNames, Style controlStyle, Style[] templateStyles) { if (designer == null) { throw new ArgumentNullException("designer"); } if ((frameName == null) || (frameName.Length == 0)) { throw new ArgumentNullException("frameName"); } if ((templateNames == null) || (templateNames.Length == 0)) { throw new ArgumentException("templateNames"); } if ((templateStyles != null) && (templateStyles.Length != templateNames.Length)) { throw new ArgumentException("templateStyles"); } frameName = CreateFrameName(frameName); return new TemplateEditingFrame(designer, frameName, templateNames, controlStyle, templateStyles); } private string CreateFrameName(string frameName) { Debug.Assert((frameName != null) && (frameName.Length != 0)); // Strips out the ampersand typically used for menu mnemonics int index = frameName.IndexOf('&'); if (index < 0) { return frameName; } else if (index == 0) { return frameName.Substring(index + 1); } else { return frameName.Substring(0, index) + frameName.Substring(index + 1); } } /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// ~TemplateEditingService() { Dispose(false); } private void Dispose(bool disposing) { if (disposing) { designerHost = null; } } /// public string GetContainingTemplateName(Control control) { string containingTemplateName = String.Empty; HtmlControlDesigner designer = (HtmlControlDesigner)designerHost.GetDesigner(control); if (designer != null) { IHtmlControlDesignerBehavior behavior = designer.BehaviorInternal; NativeMethods.IHTMLElement htmlElement = (NativeMethods.IHTMLElement)behavior.DesignTimeElement; if (htmlElement != null) { object[] varTemplateName = new Object[1]; NativeMethods.IHTMLElement htmlelemParentNext; NativeMethods.IHTMLElement htmlelemParentCur = htmlElement.GetParentElement(); while (htmlelemParentCur != null) { htmlelemParentCur.GetAttribute("templatename", /*lFlags*/ 0, varTemplateName); if (varTemplateName[0] != null && varTemplateName[0].GetType() == typeof(string)) { containingTemplateName = varTemplateName[0].ToString(); break; } htmlelemParentNext = htmlelemParentCur.GetParentElement(); htmlelemParentCur = htmlelemParentNext; } } } return containingTemplateName; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TrackPoint.cs
- SmtpCommands.cs
- ImageMetadata.cs
- DrawingImage.cs
- CaseInsensitiveComparer.cs
- PtsPage.cs
- WS2007FederationHttpBindingElement.cs
- TraceRecords.cs
- EventMap.cs
- ReadOnlyAttribute.cs
- MouseCaptureWithinProperty.cs
- ListItemParagraph.cs
- SqlNotificationRequest.cs
- SatelliteContractVersionAttribute.cs
- MailSettingsSection.cs
- QuaternionAnimationUsingKeyFrames.cs
- ExpressionWriter.cs
- FlowDocumentReader.cs
- CreateSequence.cs
- XPathAncestorIterator.cs
- ScrollItemPattern.cs
- MultiAsyncResult.cs
- DiscoveryDocumentSerializer.cs
- EnumerableRowCollectionExtensions.cs
- StylusShape.cs
- MachineKeyConverter.cs
- DataGridViewImageColumn.cs
- DeferredElementTreeState.cs
- SecurityHeaderElementInferenceEngine.cs
- InputElement.cs
- PerfCounterSection.cs
- MissingMemberException.cs
- DataGridColumn.cs
- StandardBindingReliableSessionElement.cs
- PolyBezierSegment.cs
- AutoSizeToolBoxItem.cs
- HwndKeyboardInputProvider.cs
- SignHashRequest.cs
- DynamicExpression.cs
- Baml2006Reader.cs
- PointAnimationUsingPath.cs
- HttpResponseHeader.cs
- SizeAnimationUsingKeyFrames.cs
- nulltextnavigator.cs
- WhitespaceSignificantCollectionAttribute.cs
- _DigestClient.cs
- HttpCachePolicy.cs
- Interlocked.cs
- NonBatchDirectoryCompiler.cs
- Style.cs
- Section.cs
- FormsAuthentication.cs
- SoapExtension.cs
- DataBindEngine.cs
- ConfigurationPropertyAttribute.cs
- coordinator.cs
- DrawListViewItemEventArgs.cs
- RuntimeConfigurationRecord.cs
- Nodes.cs
- ScrollChangedEventArgs.cs
- ResourceDisplayNameAttribute.cs
- Decorator.cs
- errorpatternmatcher.cs
- MultiView.cs
- ViewSimplifier.cs
- EffectiveValueEntry.cs
- ModelUIElement3D.cs
- AddInIpcChannel.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- VarRemapper.cs
- EntityTransaction.cs
- filewebresponse.cs
- ExplicitDiscriminatorMap.cs
- FacetDescription.cs
- CodeGroup.cs
- AssemblySettingAttributes.cs
- SqlDataSource.cs
- HttpServerUtilityWrapper.cs
- LinearQuaternionKeyFrame.cs
- ServiceNameElementCollection.cs
- ServiceOperationListItemList.cs
- BehaviorEditorPart.cs
- App.cs
- KeyEventArgs.cs
- DataTableReader.cs
- FieldNameLookup.cs
- RIPEMD160Managed.cs
- MiniParameterInfo.cs
- OdbcConnectionHandle.cs
- LateBoundBitmapDecoder.cs
- SecurityDescriptor.cs
- SelectedDatesCollection.cs
- ActiveDocumentEvent.cs
- RuntimeConfigLKG.cs
- EntityDataSourceChangingEventArgs.cs
- ConfigurationStrings.cs
- TransformedBitmap.cs
- XmlNamespaceMapping.cs
- documentsequencetextview.cs