Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / GroupBoxDesigner.cs / 1 / GroupBoxDesigner.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
//#define TESTVALUEUI
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope="member", Target="System.Windows.Forms.Design.GroupBoxDesigner..ctor()")]
namespace System.Windows.Forms.Design {
using System.Diagnostics;
using System;
using System.Design;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.Win32;
using System.ComponentModel;
using System.Drawing.Design;
using System.ComponentModel.Design;
using System.Collections;
///
///
/// This class handles all design time behavior for the group box class. Group
/// boxes may contain sub-components and therefore use the frame designer.
///
internal class GroupBoxDesigner : ParentControlDesigner {
private InheritanceUI inheritanceUI;
///
///
/// Determines the default location for a control added to this designer.
/// it is usualy (0,0), but may be modified if the container has special borders, etc.
///
protected override Point DefaultControlLocation {
get {
GroupBox gb = (GroupBox)this.Control;
return new Point(gb.DisplayRectangle.X,gb.DisplayRectangle.Y);
}
}
#if TESTVALUEUI
///
///
/// Initializes the designer with the given component. The designer can
/// get the component's site and request services from it in this call.
///
public override void Initialize(IComponent component) {
base.Initialize(component);
AutoResizeHandles = true;
IPropertyValueUIService pvUISvc = (IPropertyValueUIService)component.Site.GetService(typeof(IPropertyValueUIService));
if (pvUISvc != null) {
pvUISvc.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnGetUIValueItem));
}
}
private void OnGetUIValueItem(object component, PropertyDescriptor propDesc, ArrayList valueUIItemList){
if (propDesc.PropertyType == typeof(string)) {
Bitmap bmp = new Bitmap(typeof(GroupBoxDesigner), "BoundProperty.bmp");
bmp.MakeTransparent();
valueUIItemList.Add(new LocalUIItem(bmp, new PropertyValueUIItemInvokeHandler(this.OnPropertyValueUIItemInvoke), "Data Can"));
//bmp = new Bitmap("BoundProperty.bmp");
valueUIItemList.Add(new LocalUIItem(bmp, new PropertyValueUIItemInvokeHandler(this.OnPropertyValueUIItemInvoke), "Little Button"));
}
}
private void OnPropertyValueUIItemInvoke(ITypeDescriptorContext context, PropertyDescriptor descriptor, PropertyValueUIItem invokedItem) {
Debug.Fail("propertyuivalue '" + invokedItem.ToolTip + "' invoked");
}
#endif
///
///
/// We override this because even though we still want to
/// offset our grid for our display rectangle, we still want
/// to align to our parent's grid - so we don't look funny
///
protected override void OnPaintAdornments(PaintEventArgs pe) {
if (DrawGrid) {
Control control = (Control)Control;
Rectangle rectangle = Control.DisplayRectangle;
rectangle.Width++; // gpr: FillRectangle with a TextureBrush comes up one pixel short
rectangle.Height++;
ControlPaint.DrawGrid(pe.Graphics, rectangle, GridSize, control.BackColor);
}
// If this control is being inherited, paint it
//
if (Inherited) {
if (inheritanceUI == null) {
inheritanceUI = (InheritanceUI)GetService(typeof(InheritanceUI));
}
if (inheritanceUI != null) {
pe.Graphics.DrawImage(inheritanceUI.InheritanceGlyph, 0, 0);
}
}
}
///
///
/// We override our base class's WndProc here because
/// the group box always returns HTTRANSPARENT. This
/// causes the mouse to go "through" the group box, but
/// that's not what we want at design time.
///
protected override void WndProc(ref Message m) {
switch (m.Msg) {
case NativeMethods.WM_NCHITTEST:
// The group box always fires HTTRANSPARENT, which
// causes the message to go to our parent. We want
// the group box's designer to get these messages, however,
// so change this.
//
base.WndProc(ref m);
if ((int)m.Result == NativeMethods.HTTRANSPARENT) {
m.Result = (IntPtr)NativeMethods.HTCLIENT;
}
break;
default:
base.WndProc(ref m);
break;
}
}
#if TESTVALUEUI
internal class LocalUIItem : PropertyValueUIItem {
private string itemName;
public LocalUIItem(Image img, PropertyValueUIItemInvokeHandler handler, string itemName) : base(img, handler, itemName) {
this.itemName = itemName;
}
}
#endif
}
}
// 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
- DelegateOutArgument.cs
- DataBindingsDialog.cs
- SectionRecord.cs
- DataGridViewCellEventArgs.cs
- RuleElement.cs
- RecordsAffectedEventArgs.cs
- CombinedTcpChannel.cs
- WebPartVerbCollection.cs
- XmlNodeWriter.cs
- HttpListenerPrefixCollection.cs
- ModuleBuilder.cs
- HttpResponseHeader.cs
- TransformBlockRequest.cs
- ColumnClickEvent.cs
- AppDomainAttributes.cs
- Solver.cs
- XsdBuildProvider.cs
- SqlClientMetaDataCollectionNames.cs
- InsufficientMemoryException.cs
- DependencyPropertyAttribute.cs
- TableDetailsRow.cs
- SystemColors.cs
- LogEntryHeaderDeserializer.cs
- SoapInteropTypes.cs
- ShaderRenderModeValidation.cs
- RowCache.cs
- DurableOperationContext.cs
- DecimalAverageAggregationOperator.cs
- KernelTypeValidation.cs
- SqlRecordBuffer.cs
- NameValueCollection.cs
- AttributeSetAction.cs
- EllipseGeometry.cs
- DesignerVerb.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- Point3D.cs
- FloatUtil.cs
- Stacktrace.cs
- HandlerWithFactory.cs
- MethodAccessException.cs
- LinqDataSourceUpdateEventArgs.cs
- XmlSortKey.cs
- DropSource.cs
- SmiRecordBuffer.cs
- DataGridTextBoxColumn.cs
- GraphicsPathIterator.cs
- WorkflowRuntimeSection.cs
- Scalars.cs
- ListSourceHelper.cs
- SecurityDocument.cs
- InkCanvasInnerCanvas.cs
- OleAutBinder.cs
- SafeNativeMethods.cs
- WinFormsUtils.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- ScalarConstant.cs
- RotationValidation.cs
- EmitterCache.cs
- PKCS1MaskGenerationMethod.cs
- ForceCopyBuildProvider.cs
- Symbol.cs
- CapabilitiesSection.cs
- HitTestWithPointDrawingContextWalker.cs
- DataSourceExpression.cs
- UseLicense.cs
- Operators.cs
- ChangeTracker.cs
- DataGridViewRowsAddedEventArgs.cs
- SoapTypeAttribute.cs
- ContractDescription.cs
- XpsException.cs
- MenuTracker.cs
- ObfuscationAttribute.cs
- SoapExtensionTypeElementCollection.cs
- SqlLiftWhereClauses.cs
- DataGridPageChangedEventArgs.cs
- CodeObjectCreateExpression.cs
- HashSetEqualityComparer.cs
- RtType.cs
- TreeNodeStyleCollection.cs
- XmlNodeList.cs
- Vector3DKeyFrameCollection.cs
- SchemaComplexType.cs
- SafeNativeMethodsCLR.cs
- ScrollData.cs
- PageAdapter.cs
- ChannelSinkStacks.cs
- AuthorizationRule.cs
- RecordBuilder.cs
- BaseCollection.cs
- MatrixAnimationUsingPath.cs
- ContentFilePart.cs
- BufferModesCollection.cs
- RegexRunner.cs
- CommandExpr.cs
- EmbossBitmapEffect.cs
- BitmapEncoder.cs
- SiblingIterators.cs
- ToolboxBitmapAttribute.cs
- ConstrainedDataObject.cs