Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / Behavior / SelectionBorderGlyph.cs / 1 / SelectionBorderGlyph.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.Windows.Forms.Design;
///
///
/// The SelectionBorderGlyph draws one side (depending on type) of a SelectionBorder.
///
internal class SelectionBorderGlyph : SelectionGlyphBase {
///
///
/// This constructor extends from the standard SelectionGlyphBase constructor.
///
internal SelectionBorderGlyph(Rectangle controlBounds, SelectionRules rules, SelectionBorderGlyphType type, Behavior behavior) : base(behavior) {
InitializeGlyph(controlBounds, rules, type);
}
///
/// Helper function that initializes the Glyph based on bounds, type, and bordersize.
///
private void InitializeGlyph(Rectangle controlBounds, SelectionRules selRules, SelectionBorderGlyphType type) {
rules = SelectionRules.None;
hitTestCursor = Cursors.Default;
//this will return the rect representing the bounds of the glyph
bounds = DesignerUtils.GetBoundsForSelectionType(controlBounds, type);
hitBounds = bounds;
// The hitbounds for the border is actually a bit bigger than the glyph bounds
switch (type) {
case SelectionBorderGlyphType.Top:
if ((selRules & SelectionRules.TopSizeable) != 0) {
hitTestCursor = Cursors.SizeNS;
rules = SelectionRules.TopSizeable;
}
// We want to apply the SELECTIONBORDERHITAREA to the top and the bottom of the selection border glyph
hitBounds.Y -= (DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE) / 2;
hitBounds.Height += DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE;
break;
case SelectionBorderGlyphType.Bottom:
if ((selRules & SelectionRules.BottomSizeable) != 0) {
hitTestCursor = Cursors.SizeNS;
rules = SelectionRules.BottomSizeable;
}
// We want to apply the SELECTIONBORDERHITAREA to the top and the bottom of the selection border glyph
hitBounds.Y -= (DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE) / 2;
hitBounds.Height += DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE;
break;
case SelectionBorderGlyphType.Left:
if ((selRules & SelectionRules.LeftSizeable) != 0) {
hitTestCursor = Cursors.SizeWE;
rules = SelectionRules.LeftSizeable;
}
// We want to apply the SELECTIONBORDERHITAREA to the left and the right of the selection border glyph
hitBounds.X -= (DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE) / 2;
hitBounds.Width += DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE;
break;
case SelectionBorderGlyphType.Right:
if ((selRules & SelectionRules.RightSizeable) != 0) {
hitTestCursor = Cursors.SizeWE;
rules = SelectionRules.RightSizeable;
}
// We want to apply the SELECTIONBORDERHITAREA to the left and the right of the selection border glyph
hitBounds.X -= (DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE) / 2;
hitBounds.Width += DesignerUtils.SELECTIONBORDERHITAREA - DesignerUtils.SELECTIONBORDERSIZE;
break;
}
}
///
///
/// Simple painting logic for selection Glyphs.
///
public override void Paint(PaintEventArgs pe) {
DesignerUtils.DrawSelectionBorder(pe.Graphics, bounds);
}
}
}
// 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
- OrderedDictionaryStateHelper.cs
- Convert.cs
- Model3DGroup.cs
- Preprocessor.cs
- EventLogEntryCollection.cs
- CacheHelper.cs
- FieldDescriptor.cs
- XmlException.cs
- Parameter.cs
- HttpValueCollection.cs
- PackageRelationship.cs
- BitmapEffectDrawingContextWalker.cs
- SecurityUtils.cs
- DbConnectionPoolCounters.cs
- DesignerForm.cs
- FontFamilyValueSerializer.cs
- DataGridViewCellParsingEventArgs.cs
- CaseInsensitiveComparer.cs
- documentsequencetextcontainer.cs
- TextTreeExtractElementUndoUnit.cs
- ManagementQuery.cs
- AddInProcess.cs
- AutoSizeToolBoxItem.cs
- SafeCryptContextHandle.cs
- QilTypeChecker.cs
- ArgumentNullException.cs
- _AcceptOverlappedAsyncResult.cs
- XsdBuilder.cs
- TraceListeners.cs
- VariableQuery.cs
- ComponentConverter.cs
- HorizontalAlignConverter.cs
- XamlTreeBuilder.cs
- DiagnosticsConfigurationHandler.cs
- SqlEnums.cs
- WindowsFormsSectionHandler.cs
- HiddenField.cs
- Overlapped.cs
- CapiNative.cs
- ServiceModelStringsVersion1.cs
- _ShellExpression.cs
- XmlExtensionFunction.cs
- RegisteredScript.cs
- SimpleHandlerBuildProvider.cs
- DBConnection.cs
- AdornerLayer.cs
- XmlTextAttribute.cs
- Int64.cs
- MasterPage.cs
- ToggleButtonAutomationPeer.cs
- UrlAuthFailureHandler.cs
- GridViewCommandEventArgs.cs
- AttributeCollection.cs
- SchemaComplexType.cs
- ForceCopyBuildProvider.cs
- SqlConnectionFactory.cs
- SqlCrossApplyToCrossJoin.cs
- SqlStream.cs
- Substitution.cs
- TransactionManager.cs
- EntitySqlQueryBuilder.cs
- ScrollContentPresenter.cs
- BoolLiteral.cs
- WebEventCodes.cs
- ExtendedPropertiesHandler.cs
- OleDbDataReader.cs
- XmlAttributeOverrides.cs
- MultitargetUtil.cs
- WebPartZoneBase.cs
- Vector3DConverter.cs
- PageFunction.cs
- RuntimeResourceSet.cs
- SchemaNamespaceManager.cs
- NativeRightsManagementAPIsStructures.cs
- DataSetMappper.cs
- BoundColumn.cs
- XhtmlBasicValidationSummaryAdapter.cs
- SchemaLookupTable.cs
- AssemblyEvidenceFactory.cs
- CompoundFileIOPermission.cs
- PropertySourceInfo.cs
- DescendantOverDescendantQuery.cs
- NamespaceInfo.cs
- RepeatInfo.cs
- cookie.cs
- UIntPtr.cs
- FormViewInsertedEventArgs.cs
- FlowNode.cs
- EntityTypeEmitter.cs
- WebPartCancelEventArgs.cs
- WindowsTab.cs
- HierarchicalDataBoundControlAdapter.cs
- ImageListStreamer.cs
- ActivityDesigner.cs
- Rfc2898DeriveBytes.cs
- ExceptionUtility.cs
- SoapAttributeOverrides.cs
- UpDownEvent.cs
- XmlElementAttributes.cs
- ConsumerConnectionPoint.cs