Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / View / AutoScrollHelper.cs / 1305376 / AutoScrollHelper.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.View { using System; using System.Windows; using System.Windows.Media; using System.Windows.Controls; using System.Windows.Input; internal static class AutoScrollHelper { const int scrollBuffer = 30; public static void AutoScroll(MouseEventArgs e, DependencyObject element) { FrameworkElement logicalView = element as FrameworkElement; while (element != null) { element = VisualTreeHelper.GetParent(element); if (element != null && element is ScrollViewer) { break; } } ScrollViewer scrollViewer = element as ScrollViewer; if (scrollViewer != null) { AutoScroll(e.GetPosition(scrollViewer), scrollViewer, logicalView != null ? e.GetPosition(logicalView) : (Point?)null, logicalView, 25, 25, 1); } } public static void AutoScroll(DragEventArgs e, ScrollViewer scrollViewer) { AutoScroll(e.GetPosition (scrollViewer), scrollViewer, null, null, 50, 50, 10); } static void AutoScroll(Point positionInScrollViewer, ScrollViewer scrollViewer, Point? positionInLogicalView, FrameworkElement logicalView, double scrollOnDragThresholdX, double scrollOnDragThresholdY, int scrollOnDragOffset) { double scrollViewerWidth = scrollViewer.ActualWidth; double scrollViewerHeight = scrollViewer.ActualHeight; double logicalViewWidth = 0; double logicalViewHeight = 0; if (logicalView != null) { logicalViewWidth = logicalView.ActualWidth; logicalViewHeight = logicalView.ActualHeight; } int heightToScroll = 0; int widthToScroll = 0; if (positionInScrollViewer.X > (scrollViewerWidth - scrollOnDragThresholdX) && (positionInLogicalView == null || positionInLogicalView.Value.X < (logicalViewWidth - scrollBuffer))) { widthToScroll = scrollOnDragOffset; } else if (positionInScrollViewer.X < scrollOnDragThresholdX && (positionInLogicalView == null || positionInLogicalView.Value.X > scrollBuffer)) { widthToScroll = -scrollOnDragOffset; } if (positionInScrollViewer.Y > (scrollViewerHeight - scrollOnDragThresholdY) && (positionInLogicalView == null || positionInLogicalView.Value.Y < logicalViewHeight - scrollBuffer)) { heightToScroll = scrollOnDragOffset; } else if (positionInScrollViewer.Y < scrollOnDragThresholdY && (positionInLogicalView == null || positionInLogicalView.Value.Y > scrollBuffer)) { heightToScroll = -scrollOnDragOffset; } if (widthToScroll != 0 || heightToScroll != 0) { scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + heightToScroll); scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + widthToScroll); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlResolver.cs
- XmlUTF8TextWriter.cs
- SchemaImporter.cs
- CanonicalFormWriter.cs
- FixedSOMLineCollection.cs
- FrameworkContextData.cs
- TypeBuilder.cs
- MobileControlBuilder.cs
- _Rfc2616CacheValidators.cs
- GregorianCalendar.cs
- DocumentEventArgs.cs
- ViewKeyConstraint.cs
- Stack.cs
- QilLiteral.cs
- DateTime.cs
- DynamicILGenerator.cs
- Column.cs
- ServiceBusyException.cs
- RawStylusActions.cs
- EntityContainerEmitter.cs
- ISAPIApplicationHost.cs
- XmlNodeList.cs
- ConfigurationStrings.cs
- CngProperty.cs
- InvalidAsynchronousStateException.cs
- TabItemWrapperAutomationPeer.cs
- SoapReflectionImporter.cs
- MarkupCompilePass2.cs
- TagPrefixCollection.cs
- TransformDescriptor.cs
- OracleTransaction.cs
- ComAwareEventInfo.cs
- unitconverter.cs
- SmtpAuthenticationManager.cs
- SoapSchemaExporter.cs
- HostAdapter.cs
- TargetException.cs
- HWStack.cs
- DataGridClipboardHelper.cs
- TickBar.cs
- WebSysDescriptionAttribute.cs
- MeasureItemEvent.cs
- NonBatchDirectoryCompiler.cs
- Renderer.cs
- NetSectionGroup.cs
- Transform3D.cs
- ConstraintConverter.cs
- X509ChainElement.cs
- FacetEnabledSchemaElement.cs
- IPGlobalProperties.cs
- ServiceEndpointAssociationProvider.cs
- PrinterResolution.cs
- LinqDataSource.cs
- DnsPermission.cs
- wgx_sdk_version.cs
- XamlToRtfWriter.cs
- InstancePersistence.cs
- EventLog.cs
- OleDbError.cs
- NavigatingCancelEventArgs.cs
- GraphicsContext.cs
- CheckBoxStandardAdapter.cs
- UnhandledExceptionEventArgs.cs
- LineProperties.cs
- GZipStream.cs
- XamlParser.cs
- TaiwanLunisolarCalendar.cs
- RegisteredExpandoAttribute.cs
- ChannelManager.cs
- LostFocusEventManager.cs
- PeerNameRegistration.cs
- TabItemAutomationPeer.cs
- DataTemplateSelector.cs
- XmlSerializerNamespaces.cs
- PerformanceCounterManager.cs
- Themes.cs
- MulticastNotSupportedException.cs
- DbException.cs
- AutoGeneratedFieldProperties.cs
- CustomValidator.cs
- ProxyWebPartManagerDesigner.cs
- AndCondition.cs
- DrawingContextWalker.cs
- VBCodeProvider.cs
- FontUnitConverter.cs
- PnrpPeerResolver.cs
- Type.cs
- Point3DAnimationUsingKeyFrames.cs
- ProgressBarBrushConverter.cs
- ValidatingReaderNodeData.cs
- CrossAppDomainChannel.cs
- PointValueSerializer.cs
- Matrix3DStack.cs
- WebEvents.cs
- TableColumn.cs
- UnSafeCharBuffer.cs
- Tablet.cs
- InfiniteIntConverter.cs
- XmlWriter.cs
- SiteMapNode.cs