Example #1
0
        public void HaveGridLengthOfThreeWhenParsingStars()
        {
            var result = AutoGrid.Parse("*,*,*,*");

            result.ToList().ForEach(x =>
                                    x.Should().Be(new GridLength(1, GridUnitType.Star)));
        }
Example #2
0
        public void HaveGridLengthOfThreeWhenParsingNumbers()
        {
            var result = AutoGrid.Parse("3,3,3,3");

            result.ToList().ForEach(x =>
                                    x.Should().Be(new GridLength(3)));
        }
Example #3
0
 public AutoGridWithTwoStarColumnsShould()
 {
     _sut = new AutoGrid();
     _sut.Children.Add(new Button());
     _sut.Children.Add(new Button());
     _sut.Columns = "*,*";
     _sut.PerformLayout();
 }
Example #4
0
 public when_mixed_row_definition_and_column_count_are_set()
 {
     Subject = new AutoGrid();
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Rows = "10";
     Subject.PerformLayout();
 }
Example #5
0
 public AutoGridWithStarColumnsAndVerticalOrientationShould()
 {
     Subject = new AutoGrid();
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Orientation = Orientation.Vertical;
     Subject.Rows        = "*,*";
     Subject.PerformLayout();
 }
Example #6
0
 public AutoGridWithStarAndAutoColumnsAndVerticalOrientationShould()
 {
     _sut = new AutoGrid();
     _sut.Children.Add(new Button());
     _sut.Children.Add(new Button());
     _sut.Orientation = Orientation.Vertical;
     _sut.Columns     = "*,Auto";
     _sut.PerformLayout();
 }
Example #7
0
 public AutoGridWithRowAndColumnDefinitionsShould()
 {
     Subject = new AutoGrid();
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Rows    = "10";
     Subject.Columns = "100,*";
     Subject.PerformLayout();
 }
Example #8
0
 public when_rows_are_defined_and_adding_many_elements_with_one_missing()
 {
     Subject = new AutoGrid();
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Columns = "100,*";
     Subject.PerformLayout();
 }
Example #9
0
 public when_setting_one_row_height_and_adding_many_elements()
 {
     Subject = new AutoGrid();
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Children.Add(new Button());
     Subject.Columns = "100,*";
     Subject.PerformLayout();
 }
Example #10
0
        public when_overriding_column_width()
        {
            Subject = new AutoGrid();
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            var additionalElement = new TextBlock();

            AutoGrid.SetColumnWidthOverride(additionalElement, new GridLength(1, GridUnitType.Star));
            Subject.Children.Add(additionalElement);
            Subject.Rows        = "*";
            Subject.ColumnWidth = GridLength.Auto;
            Subject.PerformLayout();
        }
Example #11
0
        public when_overriding_row_height_and_vertical()
        {
            Subject             = new AutoGrid();
            Subject.Orientation = Orientation.Vertical;
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            var additionalElement = new TextBlock();

            AutoGrid.SetRowHeightOverride(additionalElement, new GridLength(1, GridUnitType.Star));
            Subject.Children.Add(additionalElement);
            Subject.Columns   = "*";
            Subject.RowHeight = GridLength.Auto;
            Subject.PerformLayout();
        }
Example #12
0
        public when_rows_are_defined_with_column_span_and_adding_many_elements()
        {
            Subject = new AutoGrid();
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            var spannedElement = new Button();

            Grid.SetColumnSpan(spannedElement, 2);
            Subject.Children.Add(spannedElement);
            Subject.Columns = "100,*";
            Subject.PerformLayout();
        }
Example #13
0
        public when_adding_additional_elements_outside_auto_assignment()
        {
            Subject = new AutoGrid();
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            var additionalElement = new TextBlock();

            AutoGrid.SetAutoIndex(additionalElement, false);
            Grid.SetColumn(additionalElement, 0);
            Grid.SetRow(additionalElement, 0);
            Grid.SetColumnSpan(additionalElement, 1);
            Subject.Children.Add(additionalElement);
            Subject.Columns = "100,100";
            Subject.PerformLayout();
        }
Example #14
0
        /// <summary>
        /// 使用 AutoGrid 来生成表单。
        /// </summary>
        /// <param name="detailView"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        protected FrameworkElement GenerateGridEditors(DetailLogicalView detailView, IEnumerable <WPFEntityPropertyViewMeta> properties)
        {
            var panel = new AutoGrid
            {
                ColumnsCount = detailView.CalculateColumnsCount(properties),
                Orientation  = detailView.Meta.DetailAsHorizontal ? Orientation.Horizontal : Orientation.Vertical
            };

            foreach (var propertyView in properties)
            {
                panel.Children.Add(new EditorHost {
                    EntityProperty = propertyView
                });
            }

            return(EnableScoller(panel, panel.Orientation));
        }
Example #15
0
        public WhenRowSpanningWithMultipleColumnsVertical()
        {
            Subject = new AutoGrid
            {
                Rows        = "Auto,Auto",
                Orientation = Orientation.Vertical,
            };
            var wideButton = new Button();

            Grid.SetColumnSpan(wideButton, 99);
            Subject.Children.Add(wideButton);
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.PerformLayout();
        }
Example #16
0
        public WhenRowSpanningWithMultipleColumns()
        {
            Subject = new AutoGrid
            {
                Columns     = "Auto,Auto,Auto",
                Orientation = Orientation.Horizontal,
            };
            var tallButton = new Button();

            Grid.SetRowSpan(tallButton, 99);
            Subject.Children.Add(tallButton);
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.Children.Add(new Button());
            Subject.PerformLayout();
        }