Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / InheritanceUI.cs / 1 / InheritanceUI.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Windows.Forms.Design {
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Design;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
///
/// This class handles the user interface for inherited components.
///
internal class InheritanceUI {
private static Bitmap inheritanceGlyph;
private static Rectangle inheritanceGlyphRect;
private ToolTip tooltip;
///
/// The bitmap we use to show inheritance.
///
public Bitmap InheritanceGlyph {
get {
if (inheritanceGlyph == null) {
inheritanceGlyph = new Bitmap(typeof(InheritanceUI), "InheritedGlyph.bmp");
inheritanceGlyph.MakeTransparent();
}
return inheritanceGlyph;
}
}
///
/// The rectangle surrounding the glyph.
///
public Rectangle InheritanceGlyphRectangle {
get {
if (inheritanceGlyphRect == Rectangle.Empty) {
Size size = InheritanceGlyph.Size;
inheritanceGlyphRect = new Rectangle(0, 0, size.Width, size.Height);
}
return inheritanceGlyphRect;
}
}
///
/// Adds an inherited control to our list. This creates a tool tip for that
/// control.
///
public void AddInheritedControl(Control c, InheritanceLevel level) {
if (tooltip == null) {
tooltip = new ToolTip();
tooltip.ShowAlways = true;
}
Debug.Assert(level != InheritanceLevel.NotInherited, "This should only be called for inherited components.");
string text;
if (level == InheritanceLevel.InheritedReadOnly) {
text = SR.GetString(SR.DesignerInheritedReadOnly);
}
else {
text = SR.GetString(SR.DesignerInherited);
}
tooltip.SetToolTip(c, text);
// Also, set all of its non-sited children
foreach(Control child in c.Controls) {
if (child.Site == null) {
tooltip.SetToolTip(child, text);
}
}
}
public void Dispose() {
if (tooltip != null) {
tooltip.Dispose();
}
}
///
/// Removes a previously added inherited control.
///
public void RemoveInheritedControl(Control c) {
if (tooltip != null && tooltip.GetToolTip(c).Length > 0) {
tooltip.SetToolTip(c, null);
// Also, set all of its non-sited children
foreach(Control child in c.Controls) {
if (child.Site == null) {
tooltip.SetToolTip(child, null);
}
}
}
}
}
}
// 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
- CodeExporter.cs
- ClientRuntimeConfig.cs
- PartialClassGenerationTask.cs
- ToolBarButton.cs
- DataBindingValueUIHandler.cs
- querybuilder.cs
- ListViewEditEventArgs.cs
- TaskHelper.cs
- NativeMethods.cs
- ElementsClipboardData.cs
- StringFormat.cs
- Image.cs
- WinEventQueueItem.cs
- UnsafeNativeMethods.cs
- PackageFilter.cs
- NullableConverter.cs
- WebServiceHostFactory.cs
- WebPartDisplayMode.cs
- DiagnosticsElement.cs
- WindowClosedEventArgs.cs
- cryptoapiTransform.cs
- TransformPatternIdentifiers.cs
- CellNormalizer.cs
- HttpDictionary.cs
- SparseMemoryStream.cs
- DeviceFilterDictionary.cs
- PackagePart.cs
- BoundColumn.cs
- PersonalizationStateInfo.cs
- Encoding.cs
- State.cs
- ReadOnlyPermissionSet.cs
- ConfigurationPropertyAttribute.cs
- CollectionViewGroup.cs
- PageAsyncTask.cs
- BooleanFunctions.cs
- DataBoundControl.cs
- TCPClient.cs
- ProtocolsConfiguration.cs
- SlipBehavior.cs
- PropertyOverridesDialog.cs
- ActivityBuilderHelper.cs
- AssertFilter.cs
- ListViewUpdateEventArgs.cs
- TextTreeInsertElementUndoUnit.cs
- PreloadHost.cs
- DefaultProxySection.cs
- DataSourceControl.cs
- ValidationEventArgs.cs
- ChannelManager.cs
- HierarchicalDataSourceControl.cs
- mediaeventargs.cs
- GetPageCompletedEventArgs.cs
- InheritablePropertyChangeInfo.cs
- MobileUserControl.cs
- UserControl.cs
- PointAnimationUsingPath.cs
- SafeLibraryHandle.cs
- StickyNoteContentControl.cs
- TextContainer.cs
- FormViewInsertedEventArgs.cs
- ReversePositionQuery.cs
- IProvider.cs
- EntityDataSourceWrapperCollection.cs
- DataColumnMappingCollection.cs
- ListControl.cs
- _ChunkParse.cs
- HttpCapabilitiesBase.cs
- SerializationSectionGroup.cs
- IOException.cs
- HttpProfileBase.cs
- ContentTextAutomationPeer.cs
- MaterialCollection.cs
- ErrorProvider.cs
- CharConverter.cs
- UIElementHelper.cs
- PassportIdentity.cs
- Single.cs
- AssemblyCache.cs
- XmlText.cs
- MenuEventArgs.cs
- ColorTransformHelper.cs
- StrictModeSecurityHeaderElementInferenceEngine.cs
- TimeoutValidationAttribute.cs
- StringValidator.cs
- IsolationInterop.cs
- RegexCapture.cs
- UnitySerializationHolder.cs
- KeyGesture.cs
- SequenceDesignerAccessibleObject.cs
- BuilderElements.cs
- StringBuilder.cs
- TypeBrowserDialog.cs
- CodeChecksumPragma.cs
- HierarchicalDataBoundControl.cs
- MimeFormReflector.cs
- UInt16Converter.cs
- XmlSchemaFacet.cs
- FontDialog.cs
- XNameTypeConverter.cs