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); }); }
public void GridSplitterTest() { Grid grid = new Grid(); grid.Height = 100.0; grid.Width = 100.0; grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); GridSplitter splitter = new GridSplitter(); splitter.SetValue(Grid.ColumnProperty, 1); splitter.SetValue(Grid.RowSpanProperty, 2); splitter.Width = 5.0; splitter.ShowsPreview = true; splitter.HorizontalAlignment = HorizontalAlignment.Left; grid.Children.Add(splitter); this.CreateAsyncTest(grid, () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(5.0, 6.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(5.0, 6.0, false)), delegate { Assert.IsNull(splitter._resizeData, "The stored ResizeData instance should be gone since the resize operation is over."); Assert.AreEqual(55.0, grid.ColumnDefinitions[0].ActualWidth, "The first column should have had the new width committed."); Assert.AreEqual(45.0, grid.ColumnDefinitions[1].ActualWidth, "The second column should have had the new width committed."); }); }
public void MouseCompleteResizeColumns() { Grid g = CreateGrid(2, 2, 100.0, 100.0); GridSplitter splitter = CreateGridSplitterThroughCode(1, 2, 5.0, HorizontalAlignment.Left, null, false); g.Children.Add(splitter); this.CreateAsyncTest(g, () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(5.0, 6.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(5.0, 6.0, false)), delegate { Assert.IsNull(splitter._resizeData, "The stored ResizeData instance should be gone since the resize operation is over."); Assert.AreEqual(55.0, g.ColumnDefinitions[0].ActualWidth, "The first column should have had the new width committed."); Assert.AreEqual(45.0, g.ColumnDefinitions[1].ActualWidth, "The second column should have had the new width committed."); }); }
public void MouseResizeColumns() { Grid g = CreateGrid(2, 2, 100.0, 100.0); GridSplitter splitter = CreateGridSplitterThroughCode(1, 2, 5.0, HorizontalAlignment.Left, null, false); g.Children.Add(splitter); this.CreateAsyncTest(g, () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(5.0, 6.0)), delegate { Assert.IsNotNull(splitter._resizeData.Definition1.AsColumnDefinition, "Definition1 should be a column."); Assert.AreEqual(55.0, splitter._resizeData.Definition1.AsColumnDefinition.ActualWidth, "Definition1 should have increased by the drag delta amount."); Assert.IsNotNull(splitter._resizeData.Definition2.AsColumnDefinition, "Definition2 should be a column."); Assert.AreEqual(45.0, splitter._resizeData.Definition2.AsColumnDefinition.ActualWidth, "Definition2 should have decreased by the drag delta amount."); }); }
public void VariableNumbersOfColumnsAndRows() { // Check the cases where a vertical GridSplitter is used in a Grid with 0,1, and n columns // and when a horizontal GridSplitter is used in a Grid with 0,1, and n rows. bool result; Grid g = CreateGrid(2, 0, 100.0, 100.0); GridSplitter splitter = CreateGridSplitterThroughCode(1, 0, null, null, null, null, VerticalAlignment.Top, HorizontalAlignment.Stretch, null, true); g.Children.Add(splitter); this.CreateAsyncTest(g, delegate { result = GridSplitter.DoubleUtil.AreClose(g.RowDefinitions[0].ActualHeight, 50.0); Assert.IsTrue(result, "ActualHeight should be same as the desired height."); }, () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(0.0, 10.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(0.0, 0.0, false)), delegate { result = GridSplitter.DoubleUtil.AreClose(g.RowDefinitions[0].ActualHeight, 60.0); Assert.IsTrue(result, "ActualHeight should be same as the desired height."); }, () => g.ColumnDefinitions.Add(new ColumnDefinition()), () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(0.0, -15.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(0.0, 0.0, false)), delegate { result = GridSplitter.DoubleUtil.AreClose(g.RowDefinitions[0].ActualHeight, 45.0); Assert.IsTrue(result, "ActualHeight should be same as the desired height."); }, () => g.ColumnDefinitions.Add(new ColumnDefinition()), () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(0.0, 25.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(0.0, 0.0, false)), delegate { result = GridSplitter.DoubleUtil.AreClose(g.RowDefinitions[0].ActualHeight, 70.0); Assert.IsTrue(result, "ActualHeight should be same as the desired height."); }, () => g.RowDefinitions.Clear(), () => splitter.VerticalAlignment = VerticalAlignment.Stretch, () => splitter.HorizontalAlignment = HorizontalAlignment.Left, () => splitter.SetValue(Grid.RowProperty, 0), () => splitter.SetValue(Grid.ColumnProperty, 1), delegate { result = GridSplitter.DoubleUtil.AreClose(g.ColumnDefinitions[0].ActualWidth, 50.0); Assert.IsTrue(result, "ActualWidth should be same as the desired width."); }, () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(10.0, 0.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(0.0, 0.0, false)), delegate { result = GridSplitter.DoubleUtil.AreClose(g.ColumnDefinitions[0].ActualWidth, 60.0); Assert.IsTrue(result, "ActualWidth should be same as the desired width."); }, () => g.RowDefinitions.Add(new RowDefinition()), () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(-15.0, 0.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(0.0, 0.0, false)), delegate { result = GridSplitter.DoubleUtil.AreClose(g.ColumnDefinitions[0].ActualWidth, 45.0); Assert.IsTrue(result, "ActualWidth should be same as the desired width."); }, () => g.RowDefinitions.Add(new RowDefinition()), () => splitter.DragValidator_DragStartedEvent(splitter, new DragStartedEventArgs(0.0, 0.0)), () => splitter.DragValidator_DragDeltaEvent(splitter, new DragDeltaEventArgs(25.0, 0.0)), () => splitter.DragValidator_DragCompletedEvent(splitter, new DragCompletedEventArgs(0.0, 0.0, false)), delegate { result = GridSplitter.DoubleUtil.AreClose(g.ColumnDefinitions[0].ActualWidth, 70.0); Assert.IsTrue(result, "ActualWidth should be same as the desired width."); }); }