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
- SettingsSection.cs
- TextEffectResolver.cs
- PolyLineSegment.cs
- DesignerHierarchicalDataSourceView.cs
- X509CertificateClaimSet.cs
- TagMapCollection.cs
- CLRBindingWorker.cs
- ListViewItemSelectionChangedEvent.cs
- RenderTargetBitmap.cs
- BinaryFormatterWriter.cs
- AutomationEventArgs.cs
- NaturalLanguageHyphenator.cs
- EdmPropertyAttribute.cs
- ToolStripItemTextRenderEventArgs.cs
- _NegoState.cs
- DropTarget.cs
- DefaultValueConverter.cs
- HttpResponseBase.cs
- TrackBarRenderer.cs
- ProfileManager.cs
- DomNameTable.cs
- StandardToolWindows.cs
- TCPListener.cs
- SplineKeyFrames.cs
- ResourceDictionary.cs
- EncryptedXml.cs
- KeyManager.cs
- _ConnectStream.cs
- ArcSegment.cs
- SamlAttributeStatement.cs
- DataControlField.cs
- LocatorBase.cs
- ConstraintEnumerator.cs
- HtmlLinkAdapter.cs
- figurelength.cs
- ContainerFilterService.cs
- InvalidPrinterException.cs
- EnumConverter.cs
- WebPartEditorCancelVerb.cs
- ExtendedTransformFactory.cs
- ToolStripSplitButton.cs
- TypeDelegator.cs
- EntityParameter.cs
- XamlReader.cs
- ValueType.cs
- KnownColorTable.cs
- SpinLock.cs
- HierarchicalDataSourceDesigner.cs
- DefaultDialogButtons.cs
- XDRSchema.cs
- NamespaceExpr.cs
- SignedXml.cs
- WebPartConnectionsCancelEventArgs.cs
- LineInfo.cs
- PipeSecurity.cs
- WindowsIPAddress.cs
- OracleEncoding.cs
- DecimalFormatter.cs
- DictionaryChange.cs
- DataGridViewRow.cs
- ObjectAnimationUsingKeyFrames.cs
- PaintValueEventArgs.cs
- XmlArrayItemAttribute.cs
- Composition.cs
- CacheOutputQuery.cs
- RemoteWebConfigurationHostStream.cs
- ResXResourceWriter.cs
- FillBehavior.cs
- AssociatedControlConverter.cs
- HwndPanningFeedback.cs
- ServiceManagerHandle.cs
- Matrix.cs
- ListMarkerLine.cs
- NavigateEvent.cs
- UnsafePeerToPeerMethods.cs
- DataTemplate.cs
- FormattedTextSymbols.cs
- StateChangeEvent.cs
- OptimizedTemplateContentHelper.cs
- DataGridAddNewRow.cs
- VerificationAttribute.cs
- FrameworkContentElement.cs
- LayoutEditorPart.cs
- ButtonPopupAdapter.cs
- RtfToXamlReader.cs
- DataControlPagerLinkButton.cs
- HitTestWithPointDrawingContextWalker.cs
- RoleService.cs
- IOException.cs
- ConfigurationException.cs
- CultureSpecificCharacterBufferRange.cs
- TransactionBridge.cs
- Polyline.cs
- ImageSourceConverter.cs
- SplashScreen.cs
- MDIClient.cs
- DataGridViewRowPrePaintEventArgs.cs
- EventHandlerList.cs
- PrintingPermission.cs
- PaintEvent.cs