Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / WinForms / Managed / System / WinForms / Design / PropertyTab.cs / 1 / PropertyTab.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms.Design {
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Win32;
///
///
/// Provides a base class for property tabs.
///
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")]
public abstract class PropertyTab : IExtenderProvider {
private Object[] components;
private Bitmap bitmap;
private bool checkedBmp;
///
~PropertyTab() {
Dispose(false);
}
// don't override this. Just put a 16x16 bitmap in a file with the same name as your class in your resources.
///
///
/// Gets or sets a bitmap to display in the property tab.
///
public virtual Bitmap Bitmap {
get {
if (!checkedBmp && bitmap == null) {
string bmpName = GetType().Name + ".bmp";
try
{
bitmap = new Bitmap(GetType(), bmpName);
}
catch (Exception ex)
{
Debug.Fail("Failed to find bitmap '" + bmpName + "' for class " + GetType().FullName, ex.ToString());
}
checkedBmp = true;
}
return bitmap;
}
}
// don't override this either.
///
///
/// Gets or sets the array of components the property tab is associated with.
///
public virtual Object[] Components {
get {
return components;
}
set {
this.components = value;
}
}
// okay. Override this to give a good TabName.
///
///
/// Gets or sets the name for the property tab.
///
public abstract string TabName {
get;
}
///
///
/// Gets or sets the help keyword that is to be associated with this tab. This defaults
/// to the tab name.
///
public virtual string HelpKeyword {
get {
return TabName;
}
}
// override this to reject components you don't want to support.
///
///
/// Gets a value indicating whether the specified object be can extended.
///
public virtual bool CanExtend(Object extendee) {
return true;
}
///
///
/// [To be supplied.]
///
public virtual void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
///
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (bitmap != null) {
bitmap.Dispose();
bitmap = null;
}
}
}
// return the default property item
///
///
/// Gets the default property of the specified component.
///
public virtual PropertyDescriptor GetDefaultProperty(Object component) {
return TypeDescriptor.GetDefaultProperty(component);
}
// okay, override this to return whatever you want to return... All properties must apply to component.
///
///
/// Gets the properties of the specified component.
///
public virtual PropertyDescriptorCollection GetProperties(Object component) {
return GetProperties(component, null);
}
///
///
/// Gets the properties of the specified component which match the specified
/// attributes.
///
public abstract PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes);
///
///
/// Gets the properties of the specified component...
///
public virtual PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes) {
return GetProperties(component, attributes);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms.Design {
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.Win32;
///
///
/// Provides a base class for property tabs.
///
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")]
public abstract class PropertyTab : IExtenderProvider {
private Object[] components;
private Bitmap bitmap;
private bool checkedBmp;
///
~PropertyTab() {
Dispose(false);
}
// don't override this. Just put a 16x16 bitmap in a file with the same name as your class in your resources.
///
///
/// Gets or sets a bitmap to display in the property tab.
///
public virtual Bitmap Bitmap {
get {
if (!checkedBmp && bitmap == null) {
string bmpName = GetType().Name + ".bmp";
try
{
bitmap = new Bitmap(GetType(), bmpName);
}
catch (Exception ex)
{
Debug.Fail("Failed to find bitmap '" + bmpName + "' for class " + GetType().FullName, ex.ToString());
}
checkedBmp = true;
}
return bitmap;
}
}
// don't override this either.
///
///
/// Gets or sets the array of components the property tab is associated with.
///
public virtual Object[] Components {
get {
return components;
}
set {
this.components = value;
}
}
// okay. Override this to give a good TabName.
///
///
/// Gets or sets the name for the property tab.
///
public abstract string TabName {
get;
}
///
///
/// Gets or sets the help keyword that is to be associated with this tab. This defaults
/// to the tab name.
///
public virtual string HelpKeyword {
get {
return TabName;
}
}
// override this to reject components you don't want to support.
///
///
/// Gets a value indicating whether the specified object be can extended.
///
public virtual bool CanExtend(Object extendee) {
return true;
}
///
///
/// [To be supplied.]
///
public virtual void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
///
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (bitmap != null) {
bitmap.Dispose();
bitmap = null;
}
}
}
// return the default property item
///
///
/// Gets the default property of the specified component.
///
public virtual PropertyDescriptor GetDefaultProperty(Object component) {
return TypeDescriptor.GetDefaultProperty(component);
}
// okay, override this to return whatever you want to return... All properties must apply to component.
///
///
/// Gets the properties of the specified component.
///
public virtual PropertyDescriptorCollection GetProperties(Object component) {
return GetProperties(component, null);
}
///
///
/// Gets the properties of the specified component which match the specified
/// attributes.
///
public abstract PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes);
///
///
/// Gets the properties of the specified component...
///
public virtual PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes) {
return GetProperties(component, attributes);
}
}
}
// 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
- WebPartUtil.cs
- ClientSettingsStore.cs
- BitmapEffectGroup.cs
- FileVersion.cs
- DataChangedEventManager.cs
- BinaryFormatterSinks.cs
- CounterSetInstance.cs
- XXXInfos.cs
- mediaeventargs.cs
- ProfileService.cs
- SqlCaseSimplifier.cs
- DocumentOrderQuery.cs
- TargetPerspective.cs
- HwndHost.cs
- ProfileGroupSettingsCollection.cs
- datacache.cs
- IdentityElement.cs
- LocatorPartList.cs
- InputBindingCollection.cs
- DataView.cs
- Blend.cs
- ExpressionParser.cs
- DispatcherTimer.cs
- ToolStripItemClickedEventArgs.cs
- GenerateHelper.cs
- TextWriter.cs
- WorkflowViewElement.cs
- ClassGenerator.cs
- AssemblyResourceLoader.cs
- CodeDomSerializerException.cs
- UniqueSet.cs
- SqlMethods.cs
- BaseResourcesBuildProvider.cs
- TextBox.cs
- LingerOption.cs
- CodeSnippetTypeMember.cs
- DesignerVerbToolStripMenuItem.cs
- TimeStampChecker.cs
- Help.cs
- X509CertificateInitiatorClientCredential.cs
- SmtpClient.cs
- PriorityBindingExpression.cs
- MsmqEncryptionAlgorithm.cs
- FormatException.cs
- AdapterUtil.cs
- recordstate.cs
- VisualStateChangedEventArgs.cs
- XamlSerializerUtil.cs
- ServiceChannel.cs
- WebBrowser.cs
- OutputCacheSection.cs
- TextTabProperties.cs
- XmlNotation.cs
- RC2.cs
- DbConnectionHelper.cs
- FileEnumerator.cs
- OleDbReferenceCollection.cs
- RoleManagerEventArgs.cs
- KeyGesture.cs
- SiteMapSection.cs
- ChannelSinkStacks.cs
- CodeExporter.cs
- TextBoxBaseDesigner.cs
- FileDialogCustomPlacesCollection.cs
- BooleanProjectedSlot.cs
- ObjectSet.cs
- BaseCollection.cs
- PhysicalFontFamily.cs
- ComponentCollection.cs
- TextureBrush.cs
- ParserStreamGeometryContext.cs
- BindingExpressionBase.cs
- JavaScriptSerializer.cs
- CodeIdentifier.cs
- MultiSelectRootGridEntry.cs
- CroppedBitmap.cs
- RangeValuePatternIdentifiers.cs
- ValueQuery.cs
- ToolConsole.cs
- EntityDataSourceDataSelection.cs
- AttachmentService.cs
- Listbox.cs
- TraceUtility.cs
- ScrollProperties.cs
- DBConnection.cs
- NativeMethodsCLR.cs
- ScriptIgnoreAttribute.cs
- FormsAuthenticationModule.cs
- HtmlForm.cs
- TextEditorLists.cs
- CreateParams.cs
- StaticTextPointer.cs
- GifBitmapEncoder.cs
- Exceptions.cs
- AnnotationHighlightLayer.cs
- InvalidPrinterException.cs
- CodeNamespaceImportCollection.cs
- GestureRecognitionResult.cs
- RegexBoyerMoore.cs
- DbProviderFactoriesConfigurationHandler.cs