Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / Behavior / GrabHandleGlyph.cs / 1 / GrabHandleGlyph.cs
namespace System.Windows.Forms.Design.Behavior { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Design; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms.Design; using System.Runtime.InteropServices; ////// /// The GrabHandleGlyph represents the 8 handles of our new seleciton /// model. Note that the pen and brush are created once per instance of this class /// and re-used in our painting logic for perf. reasonse. /// internal class GrabHandleGlyph : SelectionGlyphBase { private bool isPrimary = false; ////// /// GrabHandleGlyph's constructor takes additional parameters: 'type' and 'primary selection'. /// Also, we create/cache our pen & brush here to avoid this action with every paint message. /// internal GrabHandleGlyph(Rectangle controlBounds, GrabHandleGlyphType type, Behavior behavior, bool primarySelection) : base(behavior) { isPrimary = primarySelection; hitTestCursor = Cursors.Default; rules = SelectionRules.None; // We +/- DesignerUtils.HANDLEOVERLAP because we want each GrabHandle to overlap the control by DesignerUtils.HANDLEOVERLAP pixels switch (type) { case GrabHandleGlyphType.UpperLeft: bounds = new Rectangle((controlBounds.X+DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, (controlBounds.Y+DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNWSE; rules = SelectionRules.TopSizeable | SelectionRules.LeftSizeable; break; case GrabHandleGlyphType.UpperRight: bounds = new Rectangle(controlBounds.Right - DesignerUtils.HANDLEOVERLAP, (controlBounds.Y+DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNESW; rules = SelectionRules.TopSizeable | SelectionRules.RightSizeable; break; case GrabHandleGlyphType.LowerRight: bounds = new Rectangle(controlBounds.Right - DesignerUtils.HANDLEOVERLAP, controlBounds.Bottom-DesignerUtils.HANDLEOVERLAP, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNWSE; rules = SelectionRules.BottomSizeable | SelectionRules.RightSizeable; break; case GrabHandleGlyphType.LowerLeft: bounds = new Rectangle((controlBounds.X+DesignerUtils.HANDLEOVERLAP) -DesignerUtils.HANDLESIZE, controlBounds.Bottom-DesignerUtils.HANDLEOVERLAP, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNESW; rules = SelectionRules.BottomSizeable | SelectionRules.LeftSizeable; break; case GrabHandleGlyphType.MiddleTop: // Only add this one if there's room enough. Room is enough is as follows: // 2*HANDLEOVERLAP for UpperLeft and UpperRight handles, 1 HANDLESIZE for the MiddleTop handle, 1 HANDLESIZE // for padding if (controlBounds.Width >= (2 * DesignerUtils.HANDLEOVERLAP) + (2 * DesignerUtils.HANDLESIZE)) { bounds = new Rectangle(controlBounds.X + (controlBounds.Width/2) - (DesignerUtils.HANDLESIZE/2), (controlBounds.Y+DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNS; rules = SelectionRules.TopSizeable; } break; case GrabHandleGlyphType.MiddleBottom: // Only add this one if there's room enough. Room is enough is as follows: // 2*HANDLEOVERLAP for LowerLeft and LowerRight handles, 1 HANDLESIZE for the MiddleBottom handle, 1 HANDLESIZE // for padding if (controlBounds.Width >= (2 * DesignerUtils.HANDLEOVERLAP) + (2 * DesignerUtils.HANDLESIZE)) { bounds = new Rectangle(controlBounds.X + (controlBounds.Width/2) - (DesignerUtils.HANDLESIZE/2), controlBounds.Bottom-DesignerUtils.HANDLEOVERLAP, DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeNS; rules = SelectionRules.BottomSizeable; } break; case GrabHandleGlyphType.MiddleLeft: // Only add this one if there's room enough. Room is enough is as follows: // 2*HANDLEOVERLAP for UpperLeft and LowerLeft handles, 1 HANDLESIZE for the MiddleLeft handle, 1 HANDLESIZE // for padding if (controlBounds.Height >= (2 * DesignerUtils.HANDLEOVERLAP) + (2 * DesignerUtils.HANDLESIZE)) { bounds = new Rectangle((controlBounds.X+DesignerUtils.HANDLEOVERLAP) - DesignerUtils.HANDLESIZE, controlBounds.Y + (controlBounds.Height/2) - (DesignerUtils.HANDLESIZE/2), DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeWE; rules = SelectionRules.LeftSizeable; } break; case GrabHandleGlyphType.MiddleRight: // Only add this one if there's room enough. Room is enough is as follows: // 2*HANDLEOVERLAP for UpperRight and LowerRight handles, 1 HANDLESIZE for the MiddleRight handle, 1 HANDLESIZE // for padding if (controlBounds.Height >= (2 * DesignerUtils.HANDLEOVERLAP) + (2 * DesignerUtils.HANDLESIZE)) { bounds = new Rectangle(controlBounds.Right - DesignerUtils.HANDLEOVERLAP, controlBounds.Y + (controlBounds.Height/2) - (DesignerUtils.HANDLESIZE/2), DesignerUtils.HANDLESIZE, DesignerUtils.HANDLESIZE); hitTestCursor = Cursors.SizeWE; rules = SelectionRules.RightSizeable; } break; default: Debug.Assert(false, "GrabHandleGlyph was called with a bad GrapHandleGlyphType."); break; } hitBounds = bounds; } ////// /// Very simple paint logic. /// public override void Paint(PaintEventArgs pe) { DesignerUtils.DrawGrabHandle(pe.Graphics, bounds, isPrimary, this); } } } // 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
- LabelInfo.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- DocumentViewerConstants.cs
- FastPropertyAccessor.cs
- StringCollectionEditor.cs
- TreeNodeMouseHoverEvent.cs
- OdbcDataAdapter.cs
- BamlTreeUpdater.cs
- FeatureSupport.cs
- securitycriticaldata.cs
- FieldValue.cs
- XsdDuration.cs
- SessionKeyExpiredException.cs
- ChangeInterceptorAttribute.cs
- StopStoryboard.cs
- GraphicsPathIterator.cs
- IteratorDescriptor.cs
- ZoneButton.cs
- VirtualDirectoryMapping.cs
- XmlIncludeAttribute.cs
- UnmanagedMemoryStream.cs
- HtmlTableCellCollection.cs
- ScriptResourceInfo.cs
- FormsIdentity.cs
- StreamWriter.cs
- SqlUtils.cs
- CustomPopupPlacement.cs
- AttributeSetAction.cs
- FunctionNode.cs
- TextEditorTyping.cs
- UnmanagedMemoryStream.cs
- TabControlToolboxItem.cs
- HttpDebugHandler.cs
- RulePatternOps.cs
- XmlSchemaChoice.cs
- MatrixIndependentAnimationStorage.cs
- TextParaLineResult.cs
- Quad.cs
- ExpressionVisitor.cs
- BulletedListEventArgs.cs
- ColorMatrix.cs
- TextPointerBase.cs
- ActivityCodeDomReferenceService.cs
- KoreanCalendar.cs
- EntityCommandExecutionException.cs
- InnerItemCollectionView.cs
- embossbitmapeffect.cs
- EventProviderWriter.cs
- XhtmlBasicLabelAdapter.cs
- HttpApplicationFactory.cs
- MultiPropertyDescriptorGridEntry.cs
- querybuilder.cs
- ParallelRangeManager.cs
- UnsafeNativeMethods.cs
- XmlSigningNodeWriter.cs
- AnnouncementEndpoint.cs
- FormViewModeEventArgs.cs
- KeyedHashAlgorithm.cs
- RoutedEvent.cs
- TabItemAutomationPeer.cs
- MutexSecurity.cs
- KeyTimeConverter.cs
- DbConnectionFactory.cs
- SingleAnimationUsingKeyFrames.cs
- Matrix3DStack.cs
- DesignerGenericWebPart.cs
- GlyphInfoList.cs
- CurrencyWrapper.cs
- TCPClient.cs
- AuthorizationSection.cs
- DesignColumnCollection.cs
- SHA256CryptoServiceProvider.cs
- TextServicesDisplayAttributePropertyRanges.cs
- FontInfo.cs
- SortKey.cs
- ChainedAsyncResult.cs
- WebEventTraceProvider.cs
- SortableBindingList.cs
- CachedTypeface.cs
- GlyphsSerializer.cs
- StatusBarPanelClickEvent.cs
- ItemChangedEventArgs.cs
- RoleService.cs
- GuidConverter.cs
- RepeaterItemEventArgs.cs
- KeyValueConfigurationElement.cs
- Effect.cs
- WebPartDisplayModeCollection.cs
- UniqueConstraint.cs
- CheckBoxPopupAdapter.cs
- KeyGestureConverter.cs
- ApplicationGesture.cs
- DesignerCapabilities.cs
- BindableAttribute.cs
- Buffer.cs
- CLRBindingWorker.cs
- ProcessModule.cs
- Simplifier.cs
- HandleValueEditor.cs
- DataGridViewMethods.cs