예제 #1
0
        public void ApplyPreviewStyle()
        {
            Grid         g        = GridSplitterTest.CreateGrid(2, 2, 100, 100);
            GridSplitter splitter = GridSplitterTest.CreateGridSplitterThroughCode(1, 1, 1, null, null, 10.0, null, HorizontalAlignment.Left, new SolidColorBrush(Colors.Cyan), true);

            splitter.PreviewStyle = XamlReader.Load(Resource.GridSplitter_PreviewStyle) as Style;
            g.Children.Add(splitter);

            TestPanel.Children.Add(g);

            // Wait until the splitter style got applied
            DateTime timeout = DateTime.Now.AddMilliseconds(StyleApplicationTimeout);

            EnqueueConditional(() => (splitter.Template != null) || (DateTime.Now > timeout));

            EnqueueCallback(() => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)));

            // Give time for the preview style to get applied (if required)
            timeout = DateTime.Now.AddMilliseconds(StyleApplicationTimeout);
            EnqueueConditional(() => (splitter._resizeData.PreviewControl.Template != null) || (DateTime.Now > timeout));

            EnqueueCallback(delegate
            {
                Assert.IsNotNull(splitter._resizeData.PreviewControl.Template, "The template should have been set if the style was applied.");
            });

            EnqueueCallback(() => TestPanel.Children.Remove(g));
            EnqueueTestComplete();
        }
예제 #2
0
        public void TemplateOrientation()
        {
            Grid         g        = GridSplitterTest.CreateGrid(2, 2, 100.0, 100.0);
            GridSplitter splitter = GridSplitterTest.CreateGridSplitterThroughCode(1, 1, 1, 1, 10.0, 10.0, VerticalAlignment.Stretch, HorizontalAlignment.Left, new SolidColorBrush(Colors.Green), true);

            g.Children.Add(splitter);

            this.CreateAsyncTest(g,
                                 () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)),
                                 delegate
            {
                Assert.AreEqual(Visibility.Collapsed, splitter._resizeData.PreviewControl._elementHorizontalTemplateFrameworkElement.Visibility);
                Assert.AreEqual(Visibility.Visible, splitter._resizeData.PreviewControl._elementVerticalTemplateFrameworkElement.Visibility);
            },
                                 () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(5.0, 6.0)),
                                 () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(5.0, 6.0, false)),
                                 () => splitter.HorizontalAlignment = HorizontalAlignment.Stretch,
                                 () => splitter.VerticalAlignment   = VerticalAlignment.Top,
                                 () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)),
                                 delegate
            {
                Assert.AreEqual(Visibility.Visible, splitter._resizeData.PreviewControl._elementHorizontalTemplateFrameworkElement.Visibility);
                Assert.AreEqual(Visibility.Collapsed, splitter._resizeData.PreviewControl._elementVerticalTemplateFrameworkElement.Visibility);
            });
        }
예제 #3
0
        public void BindToValidGridSplitter()
        {
            Grid         g        = GridSplitterTest.CreateGrid(2, 2, 100, 100);
            GridSplitter splitter = GridSplitterTest.CreateGridSplitterThroughCode(1, 1, 1, null, null, 10.0, null, HorizontalAlignment.Left, new SolidColorBrush(Colors.Cyan), true);

            g.Children.Add(splitter);
            PreviewControl preview = new PreviewControl();

            this.CreateAsyncTest(g,
                                 () => preview.Bind(splitter),
                                 delegate
            {
                Assert.AreEqual(50.0, preview.Height, "Height should be half the height of the grid");
                Assert.AreEqual(10.0, preview.Width, "Width should be the width of the GridSplitter");
                Assert.AreEqual(50.0, (double)preview.GetValue(Canvas.LeftProperty), "Left position should be on left edge of the second column");
                Assert.AreEqual(50.0, (double)preview.GetValue(Canvas.TopProperty), "Top position should be on top edge of the second row");
            });
        }