protected override Size ArrangeOverride(Size finalSize) { BaseArea.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); if (AutoMatic == true) { DispalyArea.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); ImageListViewer.Arrange(new Rect(0, 0, 0, 0)); } else { DispalyArea.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height - 158)); ImageListViewer.Arrange(new Rect(0, finalSize.Height - 158, finalSize.Width, 158)); } img1.Height = DispalyArea.ActualHeight; img1.Width = DispalyArea.ActualWidth; img2.Height = DispalyArea.ActualHeight; img2.Width = DispalyArea.ActualWidth; scalelatetrans1.CenterX = DispalyArea.ActualWidth / 2; scalelatetrans1.CenterY = DispalyArea.ActualHeight / 2; scalelatetrans2.CenterX = DispalyArea.ActualWidth / 2; scalelatetrans2.CenterY = DispalyArea.ActualHeight / 2; return(finalSize); }
public void ScrollViewerComputedVisibilityTest() { string text = @" <ScrollViewer xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' Width='200' Height='100' HorizontalScrollBarVisibility='Auto' VerticalScrollBarVisibility='Auto'> <ScrollViewer.Template> <ControlTemplate TargetType='{x:Type ScrollViewer}'> <ScrollContentPresenter x:Name='PART_ScrollContentPresenter' Content='{TemplateBinding Content}'/> </ControlTemplate> </ScrollViewer.Template> <Border x:Name='border'/> </ScrollViewer>"; ScrollViewer scrollViewer = XamlLoader.Load(XamlParser.Parse(text)) as ScrollViewer; scrollViewer.IsRootElement = true; scrollViewer.Measure(Size.Infinity); scrollViewer.Arrange(new Rect(scrollViewer.DesiredSize)); Border border = NameScope.GetNameScope(scrollViewer).FindName("border") as Border; border.Width = 10; border.Height = 10; Assert.AreEqual(Visibility.Collapsed, scrollViewer.ComputedHorizontalScrollBarVisibility); Assert.AreEqual(Visibility.Collapsed, scrollViewer.ComputedVerticalScrollBarVisibility); Assert.AreEqual(border.Width, scrollViewer.ExtentWidth); Assert.AreEqual(border.Height, scrollViewer.ExtentHeight); border.Width = 1000; border.Height = 1000; Assert.AreEqual(Visibility.Visible, scrollViewer.ComputedHorizontalScrollBarVisibility); Assert.AreEqual(Visibility.Visible, scrollViewer.ComputedVerticalScrollBarVisibility); Assert.AreEqual(border.Width, scrollViewer.ExtentWidth); Assert.AreEqual(border.Height, scrollViewer.ExtentHeight); border.Width = 10; border.Height = 1000; Assert.AreEqual(Visibility.Collapsed, scrollViewer.ComputedHorizontalScrollBarVisibility); Assert.AreEqual(Visibility.Visible, scrollViewer.ComputedVerticalScrollBarVisibility); Assert.AreEqual(border.Width, scrollViewer.ExtentWidth); Assert.AreEqual(border.Height, scrollViewer.ExtentHeight); border.Width = 1000; border.Height = 10; Assert.AreEqual(Visibility.Visible, scrollViewer.ComputedHorizontalScrollBarVisibility); Assert.AreEqual(Visibility.Collapsed, scrollViewer.ComputedVerticalScrollBarVisibility); Assert.AreEqual(border.Width, scrollViewer.ExtentWidth); Assert.AreEqual(border.Height, scrollViewer.ExtentHeight); }
protected override Size ArrangeOverride(Size finalSize) { if ((finalSize.Width > 0) && (finalSize.Height > 0)) { double width = finalSize.Width - Padding.Left - Padding.Right; double height = finalSize.Height - Padding.Top - Padding.Bottom; if ((width > 0) && (height > 0)) { wrapper.Arrange(new Rect(Padding.Left, Padding.Top, width, height)); } else { wrapper.Arrange(new Rect(0, 0, 0, 0)); } ArrangeBackground(finalSize); } return(finalSize); }
protected override Size ArrangeOverride(Size finalSize) { if (!finalSize.IsEmpty) { wrapper.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height)); return(finalSize); } else { return(new Size(0, 0)); } }
/// <summary> /// Normally the presentation framework would arrange our child objects /// based on their visible size. Since we are tyring to show scrolling /// beyond that size, we override the ArrangeOverride method to layout /// elements in an arrangement that is larger than the screen. /// </summary> /// <param name="arrangeWidth"></param> /// <param name="arrangeHeight"></param> protected override void ArrangeOverride(int arrangeWidth, int arrangeHeight) { base.ArrangeOverride(arrangeWidth, arrangeHeight); // Set the ScrollViewer's width and height to allow room for // the scroll bars. _viewer.Width = arrangeWidth - _vScrollWidth; _viewer.Height = arrangeHeight - _hScrollHeight; _viewer.Arrange(0, 0, _viewer.Width, _viewer.Height); // Set the ScrollText's width and height to be twice as big as the // allowed area. ScrollText.Width = arrangeWidth * 2; ScrollText.Height = arrangeHeight * 2; ScrollText.UpdateLayout(); }
public void ScrollViewerSize() { StackPanel stackPanel; ScrollContentPresenter scrollContentPresenter; ScrollViewer scrollViewer; stackPanel = new StackPanel(); stackPanel.Height = 600; scrollContentPresenter = new ScrollContentPresenter(); scrollContentPresenter.Content = stackPanel; scrollViewer = new ScrollViewer(); scrollViewer.Content = scrollContentPresenter; scrollViewer.Measure(new Vector2(100, 300)); scrollViewer.Arrange(new BoundingRectangle(0, 0, 100, 300)); Assert.AreEqual(100, scrollViewer.ActualWidth); Assert.AreEqual(300, scrollViewer.ActualHeight); Assert.AreEqual(0, scrollContentPresenter.Extent.X); Assert.AreEqual(600, scrollContentPresenter.Extent.Y); Assert.AreEqual(100, scrollContentPresenter.Viewport.X); Assert.AreEqual(300, scrollContentPresenter.Viewport.Y); Assert.AreEqual(0, scrollContentPresenter.Offset.X); Assert.AreEqual(0, scrollContentPresenter.Offset.Y); scrollContentPresenter.SetVerticalOffset(100); Assert.AreEqual(0, scrollContentPresenter.Offset.X); Assert.AreEqual(100, scrollContentPresenter.Offset.Y); Assert.AreEqual(100, scrollContentPresenter.Viewport.X); Assert.AreEqual(300, scrollContentPresenter.Viewport.Y); }
public void TestScrolling() { const float elementWidth = 100; const float elementHeight = 200; const float elementDepth = 300; var rand = new Random(); var scrollViewer = new ScrollViewer { ScrollMode = ScrollingMode.HorizontalVertical, Width = elementWidth, Height = elementHeight, Depth = elementDepth }; scrollViewer.Measure(Vector3.Zero); scrollViewer.Arrange(Vector3.Zero, false); // tests that no crashes happen with no content scrollViewer.ScrollTo(rand.NextVector3()); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollOf(rand.NextVector3()); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.Horizontal); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.InDepth); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToEnd(Orientation.Horizontal); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToEnd(Orientation.InDepth); Assert.AreEqual(Vector3.Zero, ScrollPosition); // tests with an arranged element const float contentWidth = 1000; const float contentHeight = 2000; const float contentDepth = 3000; var content = new ContentDecorator { Width = contentWidth, Height = contentHeight, Depth = contentDepth }; scrollViewer.Content = content; scrollViewer.Measure(Vector3.Zero); scrollViewer.Arrange(Vector3.Zero, false); var scrollValue = new Vector3(123, 456, 789); scrollViewer.ScrollTo(scrollValue); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToEnd(Orientation.Horizontal); Assert.AreEqual(new Vector3(contentWidth - elementWidth, scrollValue.Y, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToEnd(Orientation.Vertical); Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToEnd(Orientation.InDepth); Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.Horizontal); Assert.AreEqual(new Vector3(0, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.Vertical); Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.InDepth); Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollOf(scrollValue); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); // tests with an not arranged element content.InvalidateArrange(); scrollViewer.ScrollTo(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollOf(2 * scrollValue); scrollViewer.ScrollTo(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollToEnd(Orientation.Horizontal); scrollViewer.ScrollToEnd(Orientation.Vertical); scrollViewer.ScrollToEnd(Orientation.InDepth); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollToBeginning(Orientation.Horizontal); scrollViewer.ScrollToBeginning(Orientation.Vertical); scrollViewer.ScrollToBeginning(Orientation.InDepth); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollOf(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollToBeginning(Orientation.Horizontal); scrollViewer.ScrollToBeginning(Orientation.Vertical); scrollViewer.ScrollToBeginning(Orientation.InDepth); scrollViewer.ScrollOf(scrollValue); scrollViewer.ScrollOf(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(2 * scrollValue.X, 2 * scrollValue.Y, 0), scrollViewer.ScrollPosition); }
public void TestScrolling() { const float elementWidth = 100; const float elementHeight = 200; const float elementDepth = 300; var rand = new Random(); var scrollViewer = new ScrollViewer { ScrollMode = ScrollingMode.HorizontalVertical, Width = elementWidth, Height = elementHeight, Depth = elementDepth }; scrollViewer.Measure(Vector3.Zero); scrollViewer.Arrange(Vector3.Zero, false); // tests that no crashes happen with no content scrollViewer.ScrollTo(rand.NextVector3()); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollOf(rand.NextVector3()); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.Horizontal); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.InDepth); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToEnd(Orientation.Horizontal); Assert.AreEqual(Vector3.Zero, ScrollPosition); scrollViewer.ScrollToEnd(Orientation.InDepth); Assert.AreEqual(Vector3.Zero, ScrollPosition); // tests with an arranged element const float contentWidth = 1000; const float contentHeight = 2000; const float contentDepth = 3000; var content = new ContentDecorator { Width = contentWidth, Height = contentHeight, Depth = contentDepth }; scrollViewer.Content = content; scrollViewer.Measure(Vector3.Zero); scrollViewer.Arrange(Vector3.Zero, false); var scrollValue = new Vector3(123, 456, 789); scrollViewer.ScrollTo(scrollValue); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToEnd(Orientation.Horizontal); Assert.AreEqual(new Vector3(contentWidth - elementWidth, scrollValue.Y, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToEnd(Orientation.Vertical); Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToEnd(Orientation.InDepth); Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.Horizontal); Assert.AreEqual(new Vector3(0, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.Vertical); Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollToBeginning(Orientation.InDepth); Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition); scrollViewer.ScrollOf(scrollValue); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); // tests with an not arranged element content.InvalidateArrange(); scrollViewer.ScrollTo(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollOf(2*scrollValue); scrollViewer.ScrollTo(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollToEnd(Orientation.Horizontal); scrollViewer.ScrollToEnd(Orientation.Vertical); scrollViewer.ScrollToEnd(Orientation.InDepth); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(contentWidth - elementWidth, contentHeight - elementHeight, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollToBeginning(Orientation.Horizontal); scrollViewer.ScrollToBeginning(Orientation.Vertical); scrollViewer.ScrollToBeginning(Orientation.InDepth); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(0, 0, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollOf(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(scrollValue.X, scrollValue.Y, 0), scrollViewer.ScrollPosition); content.InvalidateArrange(); scrollViewer.ScrollToBeginning(Orientation.Horizontal); scrollViewer.ScrollToBeginning(Orientation.Vertical); scrollViewer.ScrollToBeginning(Orientation.InDepth); scrollViewer.ScrollOf(scrollValue); scrollViewer.ScrollOf(scrollValue); scrollViewer.Arrange(Vector3.Zero, false); Assert.AreEqual(new Vector3(2*scrollValue.X, 2*scrollValue.Y, 0), scrollViewer.ScrollPosition); }