Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / WinForms / Managed / System / WinForms / Design / ComponentEditorPage.cs / 1 / ComponentEditorPage.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Windows.Forms.Design {
using System.Runtime.Remoting;
using System.ComponentModel;
using System.Diagnostics;
using System;
using System.Security.Permissions;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.ComponentModel;
using System.ComponentModel.Design;
using Microsoft.Win32;
using System.Runtime.InteropServices;
///
///
/// Provides a base implementation for a .
///
[ComVisible(true),
ClassInterface(ClassInterfaceType.AutoDispatch),
System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1012:AbstractTypesShouldNotHaveConstructors") // Shipped in Everett
]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")]
public abstract class ComponentEditorPage : Panel {
IComponentEditorPageSite pageSite;
IComponent component;
bool firstActivate;
bool loadRequired;
int loading;
Icon icon;
bool commitOnDeactivate;
///
///
///
/// Initializes a new instance of the class.
///
///
public ComponentEditorPage() : base() {
commitOnDeactivate = false;
firstActivate = true;
loadRequired = false;
loading = 0;
Visible = false;
}
///
///
///
/// Hide the property
///
///
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override bool AutoSize
{
get
{
return base.AutoSize;
}
set
{
base.AutoSize = value;
}
}
///
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
new public event EventHandler AutoSizeChanged
{
add
{
base.AutoSizeChanged += value;
}
remove
{
base.AutoSizeChanged -= value;
}
}
///
///
/// Gets or sets the page site.
///
protected IComponentEditorPageSite PageSite {
get { return pageSite; }
set { pageSite = value; }
}
///
///
/// Gets or sets the component to edit.
///
protected IComponent Component {
get { return component; }
set { component = value; }
}
///
///
/// Indicates whether the page is being activated for the first time.
///
protected bool FirstActivate {
get { return firstActivate; }
set { firstActivate = value; }
}
///
///
/// Indicates whether a load is required previous to editing.
///
protected bool LoadRequired {
get { return loadRequired; }
set { loadRequired = value; }
}
///
///
/// Indicates if loading is taking place.
///
protected int Loading {
get { return loading; }
set { loading = value; }
}
///
///
/// Indicates whether an editor should apply its
/// changes before it is deactivated.
///
public bool CommitOnDeactivate {
get {
return commitOnDeactivate;
}
set {
commitOnDeactivate = value;
}
}
///
///
/// Gets or sets the creation parameters for this control.
///
protected override CreateParams CreateParams {
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
get {
CreateParams cp = base.CreateParams;
cp.Style &= ~(NativeMethods.WS_BORDER | NativeMethods.WS_OVERLAPPED | NativeMethods.WS_DLGFRAME);
return cp;
}
}
///
///
/// Gets or sets the icon for this page.
///
public Icon Icon {
get {
if (icon == null) {
icon = new Icon(typeof(ComponentEditorPage), "ComponentEditorPage.ico");
}
return icon;
}
set {
icon = value;
}
}
///
///
///
/// Gets or sets the title of the page.
///
public virtual string Title {
get {
return base.Text;
}
}
///
///
/// Activates and displays the page.
///
public virtual void Activate() {
if (loadRequired) {
EnterLoadingMode();
LoadComponent();
ExitLoadingMode();
loadRequired = false;
}
Visible = true;
firstActivate = false;
}
///
///
/// Applies changes to all the components being edited.
///
public virtual void ApplyChanges() {
SaveComponent();
}
///
///
/// Deactivates and hides the page.
///
public virtual void Deactivate() {
Visible = false;
}
///
///
/// Increments the loading counter, which determines whether a page
/// is in loading mode.
///
protected void EnterLoadingMode() {
loading++;
}
///
///
/// Decrements the loading counter, which determines whether a page
/// is in loading mode.
///
protected void ExitLoadingMode() {
Debug.Assert(loading > 0, "Unbalanced Enter/ExitLoadingMode calls");
loading--;
}
///
///
/// Gets the control that represents the window for this page.
///
public virtual Control GetControl() {
return this;
}
///
///
/// Gets the component that is to be edited.
///
protected IComponent GetSelectedComponent() {
return component;
}
///
///
/// Processes messages that could be handled by the page.
///
public virtual bool IsPageMessage(ref Message msg) {
return PreProcessMessage(ref msg);
}
///
///
/// Gets a value indicating whether the page is being activated for the first time.
///
protected bool IsFirstActivate() {
return firstActivate;
}
///
///
/// Gets a value indicating whether the page is being loaded.
///
protected bool IsLoading() {
return loading != 0;
}
///
///
/// Loads the component into the page UI.
///
protected abstract void LoadComponent();
///
///
///
/// Called when the page along with its sibling
/// pages have applied their changes.
///
public virtual void OnApplyComplete() {
ReloadComponent();
}
///
///
/// Called when the current component may have changed elsewhere
/// and needs to be reloded into the UI.
///
protected virtual void ReloadComponent() {
if (Visible == false) {
loadRequired = true;
}
}
///
///
/// Saves the component from the page UI.
///
protected abstract void SaveComponent();
///
///
/// Sets the page to be in dirty state.
///
protected virtual void SetDirty() {
if (IsLoading() == false) {
pageSite.SetDirty();
}
}
///
///
/// Sets the component to be edited.
///
public virtual void SetComponent(IComponent component) {
this.component = component;
loadRequired = true;
}
///
///
/// Sets the site for this page.
///
public virtual void SetSite(IComponentEditorPageSite site) {
this.pageSite = site;
pageSite.GetControl().Controls.Add(this);
}
///
///
///
/// Provides help information to the help system.
///
public virtual void ShowHelp() {
}
///
///
/// Gets a value indicating whether the editor supports Help.
///
public virtual bool SupportsHelp() {
return false;
}
}
}
// 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.Remoting;
using System.ComponentModel;
using System.Diagnostics;
using System;
using System.Security.Permissions;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.ComponentModel;
using System.ComponentModel.Design;
using Microsoft.Win32;
using System.Runtime.InteropServices;
///
///
/// Provides a base implementation for a .
///
[ComVisible(true),
ClassInterface(ClassInterfaceType.AutoDispatch),
System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1012:AbstractTypesShouldNotHaveConstructors") // Shipped in Everett
]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")]
public abstract class ComponentEditorPage : Panel {
IComponentEditorPageSite pageSite;
IComponent component;
bool firstActivate;
bool loadRequired;
int loading;
Icon icon;
bool commitOnDeactivate;
///
///
///
/// Initializes a new instance of the class.
///
///
public ComponentEditorPage() : base() {
commitOnDeactivate = false;
firstActivate = true;
loadRequired = false;
loading = 0;
Visible = false;
}
///
///
///
/// Hide the property
///
///
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override bool AutoSize
{
get
{
return base.AutoSize;
}
set
{
base.AutoSize = value;
}
}
///
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
new public event EventHandler AutoSizeChanged
{
add
{
base.AutoSizeChanged += value;
}
remove
{
base.AutoSizeChanged -= value;
}
}
///
///
/// Gets or sets the page site.
///
protected IComponentEditorPageSite PageSite {
get { return pageSite; }
set { pageSite = value; }
}
///
///
/// Gets or sets the component to edit.
///
protected IComponent Component {
get { return component; }
set { component = value; }
}
///
///
/// Indicates whether the page is being activated for the first time.
///
protected bool FirstActivate {
get { return firstActivate; }
set { firstActivate = value; }
}
///
///
/// Indicates whether a load is required previous to editing.
///
protected bool LoadRequired {
get { return loadRequired; }
set { loadRequired = value; }
}
///
///
/// Indicates if loading is taking place.
///
protected int Loading {
get { return loading; }
set { loading = value; }
}
///
///
/// Indicates whether an editor should apply its
/// changes before it is deactivated.
///
public bool CommitOnDeactivate {
get {
return commitOnDeactivate;
}
set {
commitOnDeactivate = value;
}
}
///
///
/// Gets or sets the creation parameters for this control.
///
protected override CreateParams CreateParams {
[SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
get {
CreateParams cp = base.CreateParams;
cp.Style &= ~(NativeMethods.WS_BORDER | NativeMethods.WS_OVERLAPPED | NativeMethods.WS_DLGFRAME);
return cp;
}
}
///
///
/// Gets or sets the icon for this page.
///
public Icon Icon {
get {
if (icon == null) {
icon = new Icon(typeof(ComponentEditorPage), "ComponentEditorPage.ico");
}
return icon;
}
set {
icon = value;
}
}
///
///
///
/// Gets or sets the title of the page.
///
public virtual string Title {
get {
return base.Text;
}
}
///
///
/// Activates and displays the page.
///
public virtual void Activate() {
if (loadRequired) {
EnterLoadingMode();
LoadComponent();
ExitLoadingMode();
loadRequired = false;
}
Visible = true;
firstActivate = false;
}
///
///
/// Applies changes to all the components being edited.
///
public virtual void ApplyChanges() {
SaveComponent();
}
///
///
/// Deactivates and hides the page.
///
public virtual void Deactivate() {
Visible = false;
}
///
///
/// Increments the loading counter, which determines whether a page
/// is in loading mode.
///
protected void EnterLoadingMode() {
loading++;
}
///
///
/// Decrements the loading counter, which determines whether a page
/// is in loading mode.
///
protected void ExitLoadingMode() {
Debug.Assert(loading > 0, "Unbalanced Enter/ExitLoadingMode calls");
loading--;
}
///
///
/// Gets the control that represents the window for this page.
///
public virtual Control GetControl() {
return this;
}
///
///
/// Gets the component that is to be edited.
///
protected IComponent GetSelectedComponent() {
return component;
}
///
///
/// Processes messages that could be handled by the page.
///
public virtual bool IsPageMessage(ref Message msg) {
return PreProcessMessage(ref msg);
}
///
///
/// Gets a value indicating whether the page is being activated for the first time.
///
protected bool IsFirstActivate() {
return firstActivate;
}
///
///
/// Gets a value indicating whether the page is being loaded.
///
protected bool IsLoading() {
return loading != 0;
}
///
///
/// Loads the component into the page UI.
///
protected abstract void LoadComponent();
///
///
///
/// Called when the page along with its sibling
/// pages have applied their changes.
///
public virtual void OnApplyComplete() {
ReloadComponent();
}
///
///
/// Called when the current component may have changed elsewhere
/// and needs to be reloded into the UI.
///
protected virtual void ReloadComponent() {
if (Visible == false) {
loadRequired = true;
}
}
///
///
/// Saves the component from the page UI.
///
protected abstract void SaveComponent();
///
///
/// Sets the page to be in dirty state.
///
protected virtual void SetDirty() {
if (IsLoading() == false) {
pageSite.SetDirty();
}
}
///
///
/// Sets the component to be edited.
///
public virtual void SetComponent(IComponent component) {
this.component = component;
loadRequired = true;
}
///
///
/// Sets the site for this page.
///
public virtual void SetSite(IComponentEditorPageSite site) {
this.pageSite = site;
pageSite.GetControl().Controls.Add(this);
}
///
///
///
/// Provides help information to the help system.
///
public virtual void ShowHelp() {
}
///
///
/// Gets a value indicating whether the editor supports Help.
///
public virtual bool SupportsHelp() {
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
- Pkcs7Recipient.cs
- BitmapVisualManager.cs
- LongMinMaxAggregationOperator.cs
- HtmlInputSubmit.cs
- SqlErrorCollection.cs
- InvariantComparer.cs
- QuestionEventArgs.cs
- BamlLocalizer.cs
- UncommonField.cs
- Base64Decoder.cs
- MemoryStream.cs
- WorkflowView.cs
- ParamArrayAttribute.cs
- InputProviderSite.cs
- AlternateViewCollection.cs
- Authorization.cs
- FormParameter.cs
- IdentityManager.cs
- StoreContentChangedEventArgs.cs
- RoleManagerModule.cs
- EmptyQuery.cs
- ProgressBarHighlightConverter.cs
- StorageScalarPropertyMapping.cs
- SupportingTokenAuthenticatorSpecification.cs
- PenLineCapValidation.cs
- LabelInfo.cs
- IdnMapping.cs
- RMEnrollmentPage1.cs
- DependencyPropertyKey.cs
- FastEncoder.cs
- XmlChildEnumerator.cs
- RawTextInputReport.cs
- CollectionMarkupSerializer.cs
- DataSysAttribute.cs
- Interlocked.cs
- Int16AnimationUsingKeyFrames.cs
- HttpHandlerAction.cs
- _ShellExpression.cs
- TextEditorCharacters.cs
- PageRouteHandler.cs
- Highlights.cs
- TokenBasedSetEnumerator.cs
- HwndSource.cs
- PassportAuthentication.cs
- XsdCachingReader.cs
- XmlSchemaElement.cs
- NodeCounter.cs
- MetadataUtilsSmi.cs
- SimpleBitVector32.cs
- ChangePasswordDesigner.cs
- CompModSwitches.cs
- CorrelationTokenInvalidatedHandler.cs
- StylusPointPropertyId.cs
- Point3DConverter.cs
- FigureParaClient.cs
- SqlRewriteScalarSubqueries.cs
- ServiceModelSecurityTokenTypes.cs
- Tracking.cs
- ProfileInfo.cs
- DataContractSet.cs
- AsyncCallback.cs
- LogReservationCollection.cs
- Message.cs
- ProgressBarBrushConverter.cs
- ConstraintConverter.cs
- FormViewRow.cs
- Page.cs
- PointAnimationUsingKeyFrames.cs
- TraceSwitch.cs
- MetafileHeader.cs
- ToolBarButtonClickEvent.cs
- SmiMetaData.cs
- _NegotiateClient.cs
- ToolboxCategoryItems.cs
- FocusTracker.cs
- TextEditorMouse.cs
- NestedContainer.cs
- CombinedTcpChannel.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DelegatingTypeDescriptionProvider.cs
- DomainUpDown.cs
- NumberAction.cs
- BitmapDecoder.cs
- PointLight.cs
- ServiceDescriptionImporter.cs
- ButtonChrome.cs
- tooltip.cs
- TrackingDataItem.cs
- ExpressionHelper.cs
- Base64Stream.cs
- SrgsSemanticInterpretationTag.cs
- XmlParser.cs
- MimeFormImporter.cs
- DataStreams.cs
- TimersDescriptionAttribute.cs
- ISessionStateStore.cs
- GuidTagList.cs
- TimeoutValidationAttribute.cs
- ActivityDesigner.cs
- PropertyEmitterBase.cs