Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / UserControlDocumentDesigner.cs / 1 / UserControlDocumentDesigner.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Windows.Forms.Design {
using System.Collections;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Diagnostics;
using System;
using System.Design;
using System.ComponentModel.Design;
using Microsoft.Win32;
using System.Drawing;
using System.Drawing.Design;
using System.IO;
using System.Windows.Forms;
///
///
/// Provides a base implementation of a designer for user controls.
///
[
ToolboxItemFilter("System.Windows.Forms.UserControl", ToolboxItemFilterType.Custom),
ToolboxItemFilter("System.Windows.Forms.MainMenu", ToolboxItemFilterType.Prevent)
]
internal class UserControlDocumentDesigner : DocumentDesigner {
public UserControlDocumentDesigner() {
AutoResizeHandles = true;
}
///
/// On user controls, size == client size. We do this so we can mess around
/// with the non-client area of the user control when editing menus and not
/// mess up the size property.
///
private Size Size {
get {
return Control.ClientSize;
}
set {
Control.ClientSize = value;
}
}
internal override bool CanDropComponents(DragEventArgs de) {
bool canDrop = base.CanDropComponents(de);
if (canDrop) {
// Figure out if any of the components in a main menu item.
// We don't like main menus on UserControlDocumentDesigner.
//
OleDragDropHandler ddh = GetOleDragHandler();
object[] dragComps = ddh.GetDraggingObjects(de);
if (dragComps != null) {
IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
for (int i = 0; i < dragComps.Length; i++) {
if (host == null || dragComps[i] == null || !(dragComps[i] is IComponent)) {
continue;
}
if (dragComps[i] is MainMenu)
return false;
}
}
}
return canDrop;
}
///
///
/// Allows a designer to filter the set of properties
/// the component it is designing will expose through the
/// TypeDescriptor object. This method is called
/// immediately before its corresponding "Post" method.
/// If you are overriding this method you should call
/// the base implementation before you perform your own
/// filtering.
///
protected override void PreFilterProperties(IDictionary properties) {
PropertyDescriptor prop;
base.PreFilterProperties(properties);
// Handle shadowed properties
//
string[] shadowProps = new string[] {
"Size"
};
Attribute[] empty = new Attribute[0];
for (int i = 0; i < shadowProps.Length; i++) {
prop = (PropertyDescriptor)properties[shadowProps[i]];
if (prop != null) {
properties[shadowProps[i]] = TypeDescriptor.CreateProperty(typeof(UserControlDocumentDesigner), prop, empty);
}
}
}
}
}
// 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
- WebPartConnectionsCancelEventArgs.cs
- HtmlContainerControl.cs
- Rect3D.cs
- CodeParameterDeclarationExpression.cs
- XmlTextReaderImpl.cs
- InstanceKeyCompleteException.cs
- SafeArchiveContext.cs
- WebPartTransformerAttribute.cs
- ListItemParagraph.cs
- Bezier.cs
- AutomationPropertyInfo.cs
- IisTraceListener.cs
- Listbox.cs
- EndOfStreamException.cs
- FontInfo.cs
- WaveHeader.cs
- SQLBytes.cs
- TransformerConfigurationWizardBase.cs
- PenLineCapValidation.cs
- OutOfProcStateClientManager.cs
- RoutedPropertyChangedEventArgs.cs
- HttpsHostedTransportConfiguration.cs
- ListViewTableRow.cs
- RootAction.cs
- FrameworkElement.cs
- SoapReflectionImporter.cs
- OperationResponse.cs
- FixedSOMTableRow.cs
- Version.cs
- NullReferenceException.cs
- OutOfMemoryException.cs
- _CookieModule.cs
- NavigateEvent.cs
- LinkLabel.cs
- IndentTextWriter.cs
- ProcessModule.cs
- TreeNodeStyleCollection.cs
- PropertyDescriptorComparer.cs
- Binding.cs
- PipelineModuleStepContainer.cs
- CodePageUtils.cs
- BitmapPalettes.cs
- XmlText.cs
- WeakReadOnlyCollection.cs
- InstanceNotReadyException.cs
- MdiWindowListStrip.cs
- DockPanel.cs
- RawStylusInput.cs
- ResourceSet.cs
- BoundingRectTracker.cs
- Validator.cs
- CodeLinePragma.cs
- DataObjectFieldAttribute.cs
- TraceHandler.cs
- ValueTypePropertyReference.cs
- CustomErrorsSection.cs
- GridProviderWrapper.cs
- DrawingBrush.cs
- ChannelHandler.cs
- SerialPinChanges.cs
- ButtonColumn.cs
- DynamicPropertyReader.cs
- FloatUtil.cs
- TextTreeFixupNode.cs
- ConfigXmlAttribute.cs
- SelectingProviderEventArgs.cs
- SoapAttributes.cs
- ProcessModelInfo.cs
- BuildResultCache.cs
- querybuilder.cs
- CodeGen.cs
- _FtpDataStream.cs
- ProtocolsConfigurationHandler.cs
- HScrollProperties.cs
- DataBindingCollection.cs
- ExpressionVisitor.cs
- AddInBase.cs
- WebPartVerbsEventArgs.cs
- XNodeValidator.cs
- _SafeNetHandles.cs
- ZipIOCentralDirectoryBlock.cs
- MatcherBuilder.cs
- ToolStripPanelRow.cs
- UnescapedXmlDiagnosticData.cs
- OleStrCAMarshaler.cs
- DbgCompiler.cs
- MissingManifestResourceException.cs
- BuildResultCache.cs
- TargetInvocationException.cs
- TripleDES.cs
- ListQueryResults.cs
- TimeoutException.cs
- ForEachAction.cs
- Wildcard.cs
- PagerSettings.cs
- TCPListener.cs
- EventLogEntry.cs
- ValueCollectionParameterReader.cs
- MinimizableAttributeTypeConverter.cs
- MimeMapping.cs