Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / TextBoxBaseDesigner.cs / 1 / TextBoxBaseDesigner.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
namespace System.Windows.Forms.Design {
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms.Design.Behavior;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
///
///
///
/// Provides a designer that can design components
/// that extend TextBoxBase.
///
internal class TextBoxBaseDesigner : ControlDesigner {
public TextBoxBaseDesigner() {
AutoResizeHandles = true;
}
///
///
/// Adds a baseline SnapLine to the list of SnapLines related
/// to this control.
///
public override IList SnapLines {
get {
ArrayList snapLines = base.SnapLines as ArrayList;
int baseline = DesignerUtils.GetTextBaseline(Control, System.Drawing.ContentAlignment.TopLeft);
BorderStyle borderStyle = BorderStyle.Fixed3D;
PropertyDescriptor prop = TypeDescriptor.GetProperties(Component)["BorderStyle"];
if (prop != null) {
borderStyle = (BorderStyle)prop.GetValue(Component);
}
if (borderStyle == BorderStyle.None) {
baseline += 0;
}
else if (borderStyle == BorderStyle.FixedSingle) {
baseline += 2;
}
else if (borderStyle == BorderStyle.Fixed3D) {
baseline += 3;
}
else {
Debug.Fail("Unknown borderstyle");
baseline += 0;
}
snapLines.Add(new SnapLine(SnapLineType.Baseline, baseline, SnapLinePriority.Medium));
return snapLines;
}
}
private string Text {
get {
return Control.Text;
}
set {
Control.Text = value;
// This fixes bug #48462. If the text box is not wide enough to display all of the text,
// then we want to display the first portion at design-time. We can ensure this by
// setting the selection to (0, 0).
//
((TextBoxBase)Control).Select(0, 0);
}
}
private bool ShouldSerializeText() {
return TypeDescriptor.GetProperties(typeof(TextBoxBase))["Text"].ShouldSerializeValue(Component);
}
[SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")]
private void ResetText() {
Control.Text = "";
}
///
///
/// We override this so we can clear the text field set by controldesigner.
///
public override void InitializeNewComponent(IDictionary defaultValues) {
base.InitializeNewComponent(defaultValues);
PropertyDescriptor textProp = TypeDescriptor.GetProperties(Component)["Text"];
if (textProp != null && textProp.PropertyType == typeof(string) && !textProp.IsReadOnly && textProp.IsBrowsable) {
textProp.SetValue(Component, "");
}
}
protected override void PreFilterProperties(IDictionary properties) {
base.PreFilterProperties(properties);
PropertyDescriptor prop;
// Handle shadowed properties
//
string[] shadowProps = new string[] {
"Text",
};
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(TextBoxBaseDesigner), prop, empty);
}
}
}
///
///
/// Retrieves a set of rules concerning the movement capabilities of a component.
/// This should be one or more flags from the SelectionRules class. If no designer
/// provides rules for a component, the component will not get any UI services.
///
public override SelectionRules SelectionRules {
get {
SelectionRules rules = base.SelectionRules;
object component = Component;
rules |= SelectionRules.AllSizeable;
PropertyDescriptor prop = TypeDescriptor.GetProperties(component)["Multiline"];
if (prop != null) {
Object value = prop.GetValue(component);
if (value is bool && (bool)value == false) {
PropertyDescriptor propAuto = TypeDescriptor.GetProperties(component)["AutoSize"];
if (propAuto != null) {
Object auto = propAuto.GetValue(component);
//VSWhidbey #369288
if (auto is bool && (bool)auto == true) {
rules &= ~(SelectionRules.TopSizeable | SelectionRules.BottomSizeable);
}
}
}
}
return rules;
}
}
}
}
// 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
- RuleElement.cs
- SqlUnionizer.cs
- DataExpression.cs
- PropertyGridView.cs
- Vector.cs
- PerformanceCounterCategory.cs
- ButtonBaseAdapter.cs
- DocumentSequenceHighlightLayer.cs
- XmlWriterTraceListener.cs
- DbMetaDataCollectionNames.cs
- ContentType.cs
- CompModSwitches.cs
- SafeArrayTypeMismatchException.cs
- CounterSampleCalculator.cs
- XmlnsDictionary.cs
- FileSystemEventArgs.cs
- BrushConverter.cs
- HealthMonitoringSection.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- MDIWindowDialog.cs
- Freezable.cs
- QueryAccessibilityHelpEvent.cs
- TextServicesCompartmentEventSink.cs
- CriticalFinalizerObject.cs
- GridViewPageEventArgs.cs
- BindingContext.cs
- WindowsFormsHost.cs
- ElementMarkupObject.cs
- AvTraceFormat.cs
- OracleParameter.cs
- ImageAnimator.cs
- XmlSchemaFacet.cs
- MetadataWorkspace.cs
- DesignerDataStoredProcedure.cs
- updatecommandorderer.cs
- MiniParameterInfo.cs
- EventItfInfo.cs
- XmlSchemaCompilationSettings.cs
- TargetFrameworkAttribute.cs
- MultiSelectRootGridEntry.cs
- LinkLabelLinkClickedEvent.cs
- MessagePropertyDescriptionCollection.cs
- PackageRelationshipCollection.cs
- BaseValidator.cs
- ConnectionsZone.cs
- ExceptionCollection.cs
- DataServiceClientException.cs
- TreeNodeClickEventArgs.cs
- InProcStateClientManager.cs
- WpfKnownMemberInvoker.cs
- ThemeInfoAttribute.cs
- ComplexLine.cs
- ScaleTransform3D.cs
- HttpModulesSection.cs
- TargetParameterCountException.cs
- DeploymentSection.cs
- SemanticTag.cs
- BaseHashHelper.cs
- PenLineJoinValidation.cs
- ProgressBar.cs
- DataRelationCollection.cs
- ListBoxDesigner.cs
- TemplateDefinition.cs
- BulletDecorator.cs
- EncodingStreamWrapper.cs
- SafeCryptoHandles.cs
- XmlDeclaration.cs
- Model3DGroup.cs
- OpenFileDialog.cs
- ToolStripManager.cs
- FocusTracker.cs
- PatternMatcher.cs
- TextTreeInsertElementUndoUnit.cs
- CharacterHit.cs
- ListView.cs
- ContextDataSourceContextData.cs
- DelayedRegex.cs
- URLMembershipCondition.cs
- NativeMethods.cs
- SettingsPropertyValue.cs
- EmbeddedMailObject.cs
- sqlser.cs
- WasAdminWrapper.cs
- BigInt.cs
- GeneralTransformGroup.cs
- FileRecordSequenceHelper.cs
- GridLengthConverter.cs
- SessionStateUtil.cs
- OleServicesContext.cs
- ConditionCollection.cs
- TriggerActionCollection.cs
- RowToFieldTransformer.cs
- DebuggerAttributes.cs
- ConvertBinder.cs
- ResXResourceWriter.cs
- PositiveTimeSpanValidator.cs
- NotSupportedException.cs
- ColumnResizeAdorner.cs
- ProxyDataContractResolver.cs
- Debug.cs