Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / System / Windows / Documents / ColumnResizeAdorner.cs / 1 / ColumnResizeAdorner.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Adorner for column resize.
//
// History:
// 08/19/2004 : ghermann - Created
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using MS.Win32;
using MS.Internal;
namespace System.Windows.Documents.Internal
{
internal class ColumnResizeAdorner : Adorner
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// C'tor for adorner
///
///
/// FramwerokElement with TextView to which this element is attached
/// as adorner.
///
internal ColumnResizeAdorner(UIElement scope) : base(scope)
{
Debug.Assert(scope != null);
// position
_pen = new Pen(new SolidColorBrush(Colors.LightSlateGray), 2.0);
_x = Double.NaN;
_top = Double.NaN;
_height = Double.NaN;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Add a transform so that the adorner is in right spot.
///
///
/// The transform applied to the object the adorner adorns
///
///
/// Transform to apply to the adorner
///
public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
{
GeneralTransformGroup group;
TranslateTransform translation;
group = new GeneralTransformGroup();
translation = new TranslateTransform(_x, _top);
group.Children.Add(translation);
if (transform != null)
{
group.Children.Add(transform);
}
return group;
}
#endregion Public Methods
//------------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------
#region Protected Methods
protected override void OnRender(DrawingContext drawingContext)
{
// Render as a 2 pixel wide rect, one pixel in each bordering char bounding box.
drawingContext.DrawLine(_pen, new Point(0, 0),
new Point(0, _height));
}
#endregion Protected Events
//-----------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
///
/// Updates position for adorner.
///
///
///
internal void Update(double newX)
{
if(_x != newX)
{
_x = newX;
AdornerLayer adornerLayer;
adornerLayer = VisualTreeHelper.GetParent(this) as AdornerLayer;
if (adornerLayer != null)
{
// It may be null when TextBox is detached from a tree
adornerLayer.Update(AdornedElement);
adornerLayer.InvalidateVisual();
}
}
}
internal void Initialize(UIElement renderScope, double xPos, double yPos, double height)
{
Debug.Assert(_adornerLayer == null, "Attempt to overwrite existing AdornerLayer!");
_adornerLayer = AdornerLayer.GetAdornerLayer(renderScope);
if (_adornerLayer != null)
{
_adornerLayer.Add(this);
}
_x = xPos;
_top = yPos;
_height = height;
}
internal void Uninitialize()
{
if (_adornerLayer != null)
{
_adornerLayer.Remove(this);
_adornerLayer = null;
}
}
#endregion Internal methods
//-----------------------------------------------------
//
// Private Methods
//
//-----------------------------------------------------
#region Private Methods
#endregion Private methods
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
// x position
private double _x;
// top position
private double _top;
// height
private double _height;
private Pen _pen;
// Cached adornerlayer
private AdornerLayer _adornerLayer;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Adorner for column resize.
//
// History:
// 08/19/2004 : ghermann - Created
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using MS.Win32;
using MS.Internal;
namespace System.Windows.Documents.Internal
{
internal class ColumnResizeAdorner : Adorner
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// C'tor for adorner
///
///
/// FramwerokElement with TextView to which this element is attached
/// as adorner.
///
internal ColumnResizeAdorner(UIElement scope) : base(scope)
{
Debug.Assert(scope != null);
// position
_pen = new Pen(new SolidColorBrush(Colors.LightSlateGray), 2.0);
_x = Double.NaN;
_top = Double.NaN;
_height = Double.NaN;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Add a transform so that the adorner is in right spot.
///
///
/// The transform applied to the object the adorner adorns
///
///
/// Transform to apply to the adorner
///
public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
{
GeneralTransformGroup group;
TranslateTransform translation;
group = new GeneralTransformGroup();
translation = new TranslateTransform(_x, _top);
group.Children.Add(translation);
if (transform != null)
{
group.Children.Add(transform);
}
return group;
}
#endregion Public Methods
//------------------------------------------------------
//
// Protected Methods
//
//------------------------------------------------------
#region Protected Methods
protected override void OnRender(DrawingContext drawingContext)
{
// Render as a 2 pixel wide rect, one pixel in each bordering char bounding box.
drawingContext.DrawLine(_pen, new Point(0, 0),
new Point(0, _height));
}
#endregion Protected Events
//-----------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
///
/// Updates position for adorner.
///
///
///
internal void Update(double newX)
{
if(_x != newX)
{
_x = newX;
AdornerLayer adornerLayer;
adornerLayer = VisualTreeHelper.GetParent(this) as AdornerLayer;
if (adornerLayer != null)
{
// It may be null when TextBox is detached from a tree
adornerLayer.Update(AdornedElement);
adornerLayer.InvalidateVisual();
}
}
}
internal void Initialize(UIElement renderScope, double xPos, double yPos, double height)
{
Debug.Assert(_adornerLayer == null, "Attempt to overwrite existing AdornerLayer!");
_adornerLayer = AdornerLayer.GetAdornerLayer(renderScope);
if (_adornerLayer != null)
{
_adornerLayer.Add(this);
}
_x = xPos;
_top = yPos;
_height = height;
}
internal void Uninitialize()
{
if (_adornerLayer != null)
{
_adornerLayer.Remove(this);
_adornerLayer = null;
}
}
#endregion Internal methods
//-----------------------------------------------------
//
// Private Methods
//
//-----------------------------------------------------
#region Private Methods
#endregion Private methods
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
// x position
private double _x;
// top position
private double _top;
// height
private double _height;
private Pen _pen;
// Cached adornerlayer
private AdornerLayer _adornerLayer;
#endregion Private Fields
}
}
// 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
- SettingsPropertyIsReadOnlyException.cs
- InternalEnumValidator.cs
- PngBitmapEncoder.cs
- CodeTypeMember.cs
- IntSecurity.cs
- graph.cs
- TemplateBuilder.cs
- InstanceDescriptor.cs
- InternalBufferOverflowException.cs
- DataGridViewDataConnection.cs
- SmtpDigestAuthenticationModule.cs
- UnaryNode.cs
- ToolboxComponentsCreatingEventArgs.cs
- DbDataAdapter.cs
- HitTestFilterBehavior.cs
- DBConnectionString.cs
- RoutedUICommand.cs
- CodeTypeParameterCollection.cs
- Quaternion.cs
- MetadataArtifactLoaderCompositeFile.cs
- UpdateManifestForBrowserApplication.cs
- PrimitiveType.cs
- TableProviderWrapper.cs
- DataGridViewComboBoxCell.cs
- SoapTypeAttribute.cs
- ValueTypeFixupInfo.cs
- ParallelSeparator.xaml.cs
- AttributeData.cs
- IPPacketInformation.cs
- DispatcherExceptionEventArgs.cs
- QueryAccessibilityHelpEvent.cs
- DataGridRowDetailsEventArgs.cs
- SmiRequestExecutor.cs
- ManagementBaseObject.cs
- Logging.cs
- LoginCancelEventArgs.cs
- SchemaElementDecl.cs
- Int32RectConverter.cs
- AsyncCompletedEventArgs.cs
- ToolStripSettings.cs
- Policy.cs
- MapPathBasedVirtualPathProvider.cs
- UserControlParser.cs
- MatcherBuilder.cs
- _ConnectionGroup.cs
- ExpressionNormalizer.cs
- KoreanLunisolarCalendar.cs
- StringSource.cs
- CodeNamespace.cs
- ParentUndoUnit.cs
- ToolboxDataAttribute.cs
- DataGridViewSelectedCellCollection.cs
- ApplicationSecurityManager.cs
- Hashtable.cs
- ByValueEqualityComparer.cs
- AnnotationService.cs
- Keyboard.cs
- IndexedGlyphRun.cs
- PropertyKey.cs
- ImageSource.cs
- VisualProxy.cs
- MetricEntry.cs
- complextypematerializer.cs
- Codec.cs
- FixedSOMPageConstructor.cs
- CookieProtection.cs
- ToolBarButtonClickEvent.cs
- BinaryFormatter.cs
- WebResponse.cs
- AnnotationHighlightLayer.cs
- InternalMappingException.cs
- XmlWellformedWriter.cs
- SoapFormatter.cs
- ActivitySurrogate.cs
- ComplexTypeEmitter.cs
- UtilityExtension.cs
- FileDialog.cs
- TextBoxLine.cs
- GetCryptoTransformRequest.cs
- CursorInteropHelper.cs
- XPathDocumentNavigator.cs
- StartFileNameEditor.cs
- SqlClientFactory.cs
- ObjectQuery.cs
- ManagementException.cs
- SqlTransaction.cs
- FixedSOMContainer.cs
- WebPartVerbsEventArgs.cs
- CryptoApi.cs
- Wildcard.cs
- Thread.cs
- InputLanguageProfileNotifySink.cs
- CipherData.cs
- Classification.cs
- assertwrapper.cs
- ReadOnlyAttribute.cs
- ReadOnlyDataSourceView.cs
- WriteableOnDemandPackagePart.cs
- WindowsIdentity.cs
- Automation.cs