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
- HitTestWithGeometryDrawingContextWalker.cs
- BinaryMethodMessage.cs
- WebPartTransformerCollection.cs
- ConnectorRouter.cs
- GridItemProviderWrapper.cs
- mactripleDES.cs
- ProtocolReflector.cs
- UIElementCollection.cs
- OciHandle.cs
- ClaimComparer.cs
- PatternMatcher.cs
- StackOverflowException.cs
- SafeLocalMemHandle.cs
- DataContractSerializerFaultFormatter.cs
- ApplyTemplatesAction.cs
- CultureTableRecord.cs
- FloaterBaseParagraph.cs
- PointIndependentAnimationStorage.cs
- DependencyPropertyChangedEventArgs.cs
- SetterBaseCollection.cs
- ImageSource.cs
- DataGridColumn.cs
- SafeSecurityHandles.cs
- XmlCDATASection.cs
- StyleTypedPropertyAttribute.cs
- UncommonField.cs
- WorkflowCompensationBehavior.cs
- Speller.cs
- SessionStateSection.cs
- DrawingContextDrawingContextWalker.cs
- EventProviderClassic.cs
- ObsoleteAttribute.cs
- MsmqIntegrationChannelListener.cs
- ExceptionWrapper.cs
- DisplayInformation.cs
- ItemCollection.cs
- Label.cs
- SchemaTableOptionalColumn.cs
- CryptoApi.cs
- RectAnimationBase.cs
- DebugViewWriter.cs
- TempEnvironment.cs
- TrustManager.cs
- Knowncolors.cs
- ToolStripHighContrastRenderer.cs
- DbMetaDataColumnNames.cs
- NavigationProperty.cs
- DrawingContext.cs
- SerialPort.cs
- XPathDocumentBuilder.cs
- ViewgenGatekeeper.cs
- RuntimeVariablesExpression.cs
- CommonDialog.cs
- ThaiBuddhistCalendar.cs
- webeventbuffer.cs
- IntegrationExceptionEventArgs.cs
- GridViewColumn.cs
- RuntimeResourceSet.cs
- BindingElementExtensionElement.cs
- ObjectQuery.cs
- ThreadStartException.cs
- TextRangeEditLists.cs
- ColumnTypeConverter.cs
- VisualTreeHelper.cs
- __ComObject.cs
- XPathMultyIterator.cs
- SponsorHelper.cs
- DirectoryNotFoundException.cs
- KnownBoxes.cs
- PaperSource.cs
- ChangeDirector.cs
- ListArgumentProvider.cs
- AssemblyAttributes.cs
- DesignTimeParseData.cs
- ToolStripContentPanelDesigner.cs
- ScriptManager.cs
- ResumeStoryboard.cs
- PolyQuadraticBezierSegment.cs
- SendMailErrorEventArgs.cs
- StandardCommandToolStripMenuItem.cs
- DataGridColumnReorderingEventArgs.cs
- OleStrCAMarshaler.cs
- RepeaterItemEventArgs.cs
- MonikerUtility.cs
- XmlAttributeAttribute.cs
- EditorPartCollection.cs
- ConstrainedDataObject.cs
- FolderNameEditor.cs
- QuarticEase.cs
- NameSpaceExtractor.cs
- JsonGlobals.cs
- FlowThrottle.cs
- KoreanCalendar.cs
- MailFileEditor.cs
- ProvideValueServiceProvider.cs
- DataServiceQueryProvider.cs
- RegistrySecurity.cs
- WebRequestModuleElement.cs
- LinqDataSourceStatusEventArgs.cs
- DynamicPropertyHolder.cs