Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / Layout / LayoutEngine.cs / 1305376 / LayoutEngine.cs
//#define LAYOUT_PERFWATCH //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Layout { using System; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Security.Permissions; ///public abstract class LayoutEngine { internal IArrangedElement CastToArrangedElement(object obj) { IArrangedElement element = obj as IArrangedElement; if(obj == null) { throw new NotSupportedException(SR.GetString(SR.LayoutEngineUnsupportedType, obj.GetType())); } return element; } internal virtual Size GetPreferredSize(IArrangedElement container, Size proposedConstraints) { return Size.Empty; } /// [System.Runtime.TargetedPatchingOptOutAttribute("Performance critical to inline across NGen image boundaries")] public virtual void InitLayout(object child, BoundsSpecified specified) { InitLayoutCore(CastToArrangedElement(child), specified); } internal virtual void InitLayoutCore(IArrangedElement element, BoundsSpecified bounds) {} internal virtual void ProcessSuspendedLayoutEventArgs(IArrangedElement container, LayoutEventArgs args) {} #if LAYOUT_PERFWATCH private static int LayoutWatch = 100; #endif /// [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] public virtual bool Layout(object container, LayoutEventArgs layoutEventArgs) { #if LAYOUT_PERFWATCH Debug.WriteLine(container.GetType().Name + "::Layout(" + (layoutEventArgs.AffectedControl != null ? layoutEventArgs.AffectedControl.Name : "null") + ", " + layoutEventArgs.AffectedProperty + ")"); Debug.Indent(); Stopwatch sw = new Stopwatch(); sw.Start(); #endif bool parentNeedsLayout = LayoutCore(CastToArrangedElement(container), layoutEventArgs); #if LAYOUT_PERFWATCH sw.Stop(); if (sw.ElapsedMilliseconds > LayoutWatch && Debugger.IsAttached) { Debugger.Break(); } Debug.Unindent(); Debug.WriteLine(container.GetType().Name + "::Layout elapsed " + sw.ElapsedMilliseconds.ToString() + " returned: " + parentNeedsLayout); #endif return parentNeedsLayout; } internal virtual bool LayoutCore(IArrangedElement container, LayoutEventArgs layoutEventArgs) { return false; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //#define LAYOUT_PERFWATCH //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.Layout { using System; using System.Collections; using System.Collections.Specialized; using System.ComponentModel; using System.Drawing; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Security.Permissions; ///public abstract class LayoutEngine { internal IArrangedElement CastToArrangedElement(object obj) { IArrangedElement element = obj as IArrangedElement; if(obj == null) { throw new NotSupportedException(SR.GetString(SR.LayoutEngineUnsupportedType, obj.GetType())); } return element; } internal virtual Size GetPreferredSize(IArrangedElement container, Size proposedConstraints) { return Size.Empty; } /// [System.Runtime.TargetedPatchingOptOutAttribute("Performance critical to inline across NGen image boundaries")] public virtual void InitLayout(object child, BoundsSpecified specified) { InitLayoutCore(CastToArrangedElement(child), specified); } internal virtual void InitLayoutCore(IArrangedElement element, BoundsSpecified bounds) {} internal virtual void ProcessSuspendedLayoutEventArgs(IArrangedElement container, LayoutEventArgs args) {} #if LAYOUT_PERFWATCH private static int LayoutWatch = 100; #endif /// [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] public virtual bool Layout(object container, LayoutEventArgs layoutEventArgs) { #if LAYOUT_PERFWATCH Debug.WriteLine(container.GetType().Name + "::Layout(" + (layoutEventArgs.AffectedControl != null ? layoutEventArgs.AffectedControl.Name : "null") + ", " + layoutEventArgs.AffectedProperty + ")"); Debug.Indent(); Stopwatch sw = new Stopwatch(); sw.Start(); #endif bool parentNeedsLayout = LayoutCore(CastToArrangedElement(container), layoutEventArgs); #if LAYOUT_PERFWATCH sw.Stop(); if (sw.ElapsedMilliseconds > LayoutWatch && Debugger.IsAttached) { Debugger.Break(); } Debug.Unindent(); Debug.WriteLine(container.GetType().Name + "::Layout elapsed " + sw.ElapsedMilliseconds.ToString() + " returned: " + parentNeedsLayout); #endif return parentNeedsLayout; } internal virtual bool LayoutCore(IArrangedElement container, LayoutEventArgs layoutEventArgs) { return false; } } } // 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
- HttpApplicationFactory.cs
- FixedSOMPage.cs
- InitializationEventAttribute.cs
- WebProxyScriptElement.cs
- DeflateEmulationStream.cs
- EditingMode.cs
- ConfigUtil.cs
- MenuItemBinding.cs
- Switch.cs
- StandardToolWindows.cs
- MutexSecurity.cs
- TextEffect.cs
- NavigationWindow.cs
- Registry.cs
- ToolBar.cs
- DbConnectionHelper.cs
- XmlQueryCardinality.cs
- MessageEventSubscriptionService.cs
- EncoderReplacementFallback.cs
- MenuItemAutomationPeer.cs
- SelectorItemAutomationPeer.cs
- ProcessModelInfo.cs
- Message.cs
- OleDbParameterCollection.cs
- TextWriterTraceListener.cs
- RegisteredArrayDeclaration.cs
- HttpClientCertificate.cs
- Guid.cs
- ActivityStatusChangeEventArgs.cs
- safesecurityhelperavalon.cs
- HttpChannelBindingToken.cs
- EventSourceCreationData.cs
- WpfPayload.cs
- CmsInterop.cs
- PolicyStatement.cs
- TypeBuilder.cs
- ScriptingWebServicesSectionGroup.cs
- LineUtil.cs
- ReferenceEqualityComparer.cs
- XmlName.cs
- HttpFileCollectionWrapper.cs
- XamlPointCollectionSerializer.cs
- ToolStripDropDown.cs
- webeventbuffer.cs
- ContextMenu.cs
- OleDbDataAdapter.cs
- HtmlGenericControl.cs
- WebAdminConfigurationHelper.cs
- DataTableTypeConverter.cs
- PrintPageEvent.cs
- SoapSchemaExporter.cs
- EnumerableCollectionView.cs
- TdsParserSafeHandles.cs
- ParameterCollectionEditorForm.cs
- EventProviderWriter.cs
- TextShapeableCharacters.cs
- ProtectedConfiguration.cs
- XmlDocumentType.cs
- CharacterMetrics.cs
- ItemContainerPattern.cs
- GlyphManager.cs
- XPathParser.cs
- AdRotatorDesigner.cs
- EntityCommandCompilationException.cs
- MatrixStack.cs
- SplitterCancelEvent.cs
- TableCellsCollectionEditor.cs
- ListViewItem.cs
- ControlCollection.cs
- ResourcesBuildProvider.cs
- ChangeDirector.cs
- HTMLTagNameToTypeMapper.cs
- ContentElementAutomationPeer.cs
- QilXmlWriter.cs
- TrackingMemoryStreamFactory.cs
- XsltException.cs
- LinearQuaternionKeyFrame.cs
- ProcessThread.cs
- GenericRootAutomationPeer.cs
- TextStore.cs
- PropertyDescriptorGridEntry.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- MoveSizeWinEventHandler.cs
- ResourceAssociationSet.cs
- WebPartVerbCollection.cs
- messageonlyhwndwrapper.cs
- FunctionParameter.cs
- ContextInformation.cs
- InputElement.cs
- ThrowHelper.cs
- BuildProvider.cs
- DbProviderFactoriesConfigurationHandler.cs
- RowType.cs
- ContainerAction.cs
- CodeTypeReference.cs
- CurrentChangingEventArgs.cs
- Utils.cs
- AssociationTypeEmitter.cs
- ContainerActivationHelper.cs
- InstalledFontCollection.cs