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
- DataGridViewCheckBoxCell.cs
- ToolStripMenuItemCodeDomSerializer.cs
- CodeEventReferenceExpression.cs
- ColumnResult.cs
- HtmlInputControl.cs
- SoapEnvelopeProcessingElement.cs
- FormViewPageEventArgs.cs
- PatternMatcher.cs
- LinqDataSourceContextEventArgs.cs
- AppDomainGrammarProxy.cs
- IERequestCache.cs
- FormsAuthenticationConfiguration.cs
- DragDeltaEventArgs.cs
- SecondaryIndexDefinition.cs
- XmlSchemas.cs
- WebPartsPersonalization.cs
- EnumMemberAttribute.cs
- FieldToken.cs
- SiteMapSection.cs
- MetadataCache.cs
- PropertyChangedEventArgs.cs
- InputLanguage.cs
- SerializerDescriptor.cs
- EncryptedKey.cs
- BamlMapTable.cs
- TemplateAction.cs
- AnnotationComponentManager.cs
- SHA1.cs
- Utilities.cs
- TdsParserHelperClasses.cs
- SystemColors.cs
- SafeLocalMemHandle.cs
- PointAnimationUsingKeyFrames.cs
- ProjectionPathBuilder.cs
- ResourceContainer.cs
- Trace.cs
- Debug.cs
- FontNameConverter.cs
- RemotingException.cs
- PlainXmlDeserializer.cs
- DispatcherProcessingDisabled.cs
- OleDbConnectionInternal.cs
- VectorConverter.cs
- TextRunCache.cs
- MouseWheelEventArgs.cs
- X509WindowsSecurityToken.cs
- ErrorProvider.cs
- _TimerThread.cs
- BindingCollection.cs
- ScriptingJsonSerializationSection.cs
- SHA256Managed.cs
- DocumentAutomationPeer.cs
- SymbolEqualComparer.cs
- TcpClientSocketManager.cs
- RegexWorker.cs
- ToolZone.cs
- ViewRendering.cs
- WebPartConnectionsConfigureVerb.cs
- Panel.cs
- HtmlTableRow.cs
- ControlUtil.cs
- xdrvalidator.cs
- Decimal.cs
- DelegateSerializationHolder.cs
- AppDomainAttributes.cs
- DependencyPropertyChangedEventArgs.cs
- NullableDecimalAverageAggregationOperator.cs
- DelegateOutArgument.cs
- ZoneLinkButton.cs
- TextEditorThreadLocalStore.cs
- JsonReader.cs
- SystemSounds.cs
- MarginCollapsingState.cs
- AppDomainFactory.cs
- TextBoxBaseDesigner.cs
- InvokePattern.cs
- SqlErrorCollection.cs
- ElementMarkupObject.cs
- ConfigXmlComment.cs
- DetailsViewRowCollection.cs
- CoTaskMemSafeHandle.cs
- Frame.cs
- ZipIOExtraFieldZip64Element.cs
- DataPagerFieldCollection.cs
- PKCS1MaskGenerationMethod.cs
- AsyncOperationContext.cs
- DurableEnlistmentState.cs
- AdobeCFFWrapper.cs
- GridViewSortEventArgs.cs
- InternalDispatchObject.cs
- OdbcEnvironment.cs
- StorageConditionPropertyMapping.cs
- WebPartActionVerb.cs
- ElementHost.cs
- TrustManagerPromptUI.cs
- Vector3DAnimationBase.cs
- XmlUtil.cs
- ListDataBindEventArgs.cs
- HtmlDocument.cs
- LedgerEntry.cs