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
- DataViewManager.cs
- MsmqIntegrationSecurityMode.cs
- TraceData.cs
- ImageBrush.cs
- ExpandSegmentCollection.cs
- ChangeBlockUndoRecord.cs
- DoubleLink.cs
- assertwrapper.cs
- Floater.cs
- CacheModeValueSerializer.cs
- DefaultValueAttribute.cs
- EventNotify.cs
- TemplatedWizardStep.cs
- ListControlDataBindingHandler.cs
- ToggleButton.cs
- Site.cs
- Menu.cs
- Typeface.cs
- DateTimeUtil.cs
- D3DImage.cs
- ModelTreeEnumerator.cs
- XmlDigitalSignatureProcessor.cs
- SwitchLevelAttribute.cs
- AnnotationDocumentPaginator.cs
- DataGridTextBox.cs
- ThreadStaticAttribute.cs
- HtmlWindowCollection.cs
- SystemIPInterfaceStatistics.cs
- BufferedStream.cs
- ServiceObjectContainer.cs
- DataExpression.cs
- safelink.cs
- WCFModelStrings.Designer.cs
- KnownTypesProvider.cs
- Misc.cs
- OpenFileDialog.cs
- GZipStream.cs
- IconEditor.cs
- RelatedCurrencyManager.cs
- UnsafeNativeMethods.cs
- PrePostDescendentsWalker.cs
- BitmapPalette.cs
- RequiredFieldValidator.cs
- TemplateBamlTreeBuilder.cs
- StringUtil.cs
- UriTemplateLiteralQueryValue.cs
- FixedSOMTableCell.cs
- DPCustomTypeDescriptor.cs
- nulltextnavigator.cs
- SymbolDocumentGenerator.cs
- AttributeExtensions.cs
- _BufferOffsetSize.cs
- DataGridViewCellValueEventArgs.cs
- ClientRuntimeConfig.cs
- InheritanceContextChangedEventManager.cs
- OptimalBreakSession.cs
- CodeSnippetExpression.cs
- SqlServer2KCompatibilityAnnotation.cs
- Util.cs
- WebResourceAttribute.cs
- SqlServices.cs
- OracleFactory.cs
- NumberFormatInfo.cs
- ExternalException.cs
- GraphicsState.cs
- FixedSOMLineCollection.cs
- QilGenerator.cs
- ScriptingJsonSerializationSection.cs
- XamlBuildProvider.cs
- TabOrder.cs
- HighlightVisual.cs
- FilteredDataSetHelper.cs
- MultiView.cs
- RelativeSource.cs
- HandlerFactoryCache.cs
- GetIsBrowserClientRequest.cs
- PeerCollaboration.cs
- LookupBindingPropertiesAttribute.cs
- ToolboxService.cs
- TypeUtil.cs
- AttributeData.cs
- FullTrustAssembliesSection.cs
- MailDefinition.cs
- Enlistment.cs
- ConsoleCancelEventArgs.cs
- MediaPlayerState.cs
- PersonalizationDictionary.cs
- unsafenativemethodsother.cs
- LayoutEvent.cs
- BoundField.cs
- HitTestFilterBehavior.cs
- LogicalChannel.cs
- RootBrowserWindowProxy.cs
- Timer.cs
- Bezier.cs
- CharKeyFrameCollection.cs
- OutputCacheProfile.cs
- SubqueryRules.cs
- FileUpload.cs
- HttpServerChannel.cs