Exemple #1
0
        public void BuildTiles(IEnumerable <object> tiles)
        {
            try
            {
                if (tiles == null || tiles.Count() == 0)
                {
                    Children?.Clear();
                }

                // Wipe out the previous row definitions if they're there.
                RowDefinitions?.Clear();

                var enumerable   = tiles as IList ?? tiles.ToList();
                var numberOfRows = Math.Ceiling(enumerable.Count / (float)MaxColumns);

                for (var i = 0; i < numberOfRows; i++)
                {
                    RowDefinitions?.Add(new RowDefinition {
                        Height = TileHeight
                    });
                }

                for (var index = 0; index < enumerable.Count; index++)
                {
                    var column = index % MaxColumns;
                    var row    = (int)Math.Floor(index / (float)MaxColumns);

                    var tile = BuildTile(enumerable[index]);

                    Children?.Add(tile, column, row);
                }
            }
            catch { // can throw exceptions if binding upon disposal
            }
        }
Exemple #2
0
        public void BuildTiles(IEnumerable <object> tiles)
        {
            try
            {
                if (tiles == null || tiles.Count() == 0)
                {
                    Children?.Clear();
                }

                var t     = ItemsSource.GetType();
                var isObs = t.GetTypeInfo().IsGenericType&& ItemsSource.GetType().GetGenericTypeDefinition() == typeof(ObservableCollection <>);
                if (isObs)
                {
                    ObservableSource = new ObservableCollection <object>(ItemsSource.Cast <object>());
                }

                // Wipe out the previous definitions if they're there.
                RowDefinitions?.Clear();
                ColumnDefinitions?.Clear();

                var enumerable   = ObservableSource as IList ?? tiles.ToList();
                var numberOfRows = Math.Ceiling(enumerable.Count / (float)MaxColumns);

                for (var i = 0; i < MaxColumns; i++)
                {
                    ColumnDefinitions.Add(new ColumnDefinition {
                        Width = GridLength.Star
                    });
                }

                for (var i = 0; i < numberOfRows; i++)
                {
                    RowDefinitions?.Add(new RowDefinition {
                        Height = TileHeight
                    });
                }

                for (var index = 0; index < enumerable.Count; index++)
                {
                    var column = index % MaxColumns;
                    var row    = (int)Math.Floor(index / (float)MaxColumns);

                    var tile = BuildTile(enumerable[index]);

                    Children.Add(tile, column, row);
                }
                //ForceLayout();
            }
            catch
            { // can throw exceptions if binding upon disposal
              /*throw new Exception(" Unhandled excepection while building tiles");*/
            }
        }
        private void GenerateRows()
        {
            RowCount = (int)Math.Ceiling((double)InternalItems.Count / ColumnCount);
            if (RowCount != RowDefinitions.Count)
            {
                // Create rows
                RowDefinitions?.Clear();

                for (int i = 0; i < RowCount; i++)
                {
                    RowDefinitions?.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Star)
                    });
                }
            }
        }
Exemple #4
0
        private void PrepareColumnAndRowLayout()
        {
            // Recreate columns and rows only after dimensions changed.
            if (_actualWidth == ActualWidth && _actualHeight == ActualHeight)
            {
                return;
            }
            _actualWidth  = ActualWidth;
            _actualHeight = ActualHeight;

            ColumnDefinitions.Clear();
            RowDefinitions.Clear();

            double           headerWidth     = HeaderWidth;
            ColumnDefinition rowHeaderColumn = new ColumnDefinition {
                Width = new GridLength(GridUnitType.Pixel, headerWidth)
            };

            ColumnDefinitions.Add(rowHeaderColumn);

            double rowHeight = ActualHeight / _numberOfRows;
            double colWidth  = (ActualWidth - headerWidth) / _numberOfColumns;

            for (int c = 0; c < _numberOfColumns; c++)
            {
                ColumnDefinition cd = new ColumnDefinition {
                    Width = new GridLength(GridUnitType.Pixel, colWidth)
                };
                ColumnDefinitions.Add(cd);
            }
            for (int r = 0; r < _numberOfRows; r++)
            {
                RowDefinition cd = new RowDefinition {
                    Height = new GridLength(GridUnitType.Pixel, rowHeight)
                };
                RowDefinitions.Add(cd);
            }

            RecreateAndArrangeChildren();
        }
 void UpdateMarginChildren()
 {
     margins = wpfTextViewMarginProviderCollection.Margins;
     if (!isHorizontal)
     {
         ColumnDefinitions.Clear();
         Children.Clear();
         for (int i = 0; i < margins.Length; i++)
         {
             var info = margins[i];
             var elem = info.Margin.VisualElement;
             SetRow(elem, 0);
             SetRowSpan(elem, 1);
             SetColumn(elem, i);
             SetColumnSpan(elem, 1);
             Children.Add(elem);
             ColumnDefinitions.Add(new ColumnDefinition {
                 Width = new GridLength(info.Metadata.GridCellLength, info.Metadata.GridUnitType)
             });
         }
     }
     else
     {
         RowDefinitions.Clear();
         Children.Clear();
         for (int i = 0; i < margins.Length; i++)
         {
             var info = margins[i];
             var elem = info.Margin.VisualElement;
             SetRow(elem, i);
             SetRowSpan(elem, 1);
             SetColumn(elem, 0);
             SetColumnSpan(elem, 1);
             Children.Add(elem);
             RowDefinitions.Add(new RowDefinition {
                 Height = new GridLength(info.Metadata.GridCellLength, info.Metadata.GridUnitType)
             });
         }
     }
 }
Exemple #6
0
            public MeasureDefinitionsGrid()
            {
                RowDefinitions.Add(new RowDefinition());
                ColumnDefinitions.Add(new ColumnDefinition());
                Children.Add(new TestButton());
                Measure(new Size(100, 100));
                Assert.AreEqual(measure_constraint.Width, 100, "1");
                Assert.AreEqual(measure_result.Width, Utility.GetEmptyButtonSize(), "2");
                Assert.AreEqual(measure_result.Height, Utility.GetEmptyButtonSize(), "3");
                Assert.AreEqual(DesiredSize.Width, Utility.GetEmptyButtonSize(), "4");
                Assert.AreEqual(DesiredSize.Height, Utility.GetEmptyButtonSize(), "5");
                Window w = new Window();

                w.Content = this;
                w.Show();
                Measure(new Size(100, 100));
                Assert.AreEqual(measure_constraint.Width, 100, "6");
                Assert.AreEqual(measure_result.Width, Utility.GetEmptyButtonSize(), "7");
                Assert.AreEqual(measure_result.Height, Utility.GetEmptyButtonSize(), "8");
                Assert.AreEqual(DesiredSize.Width, Utility.GetEmptyButtonSize(), "9");
                Assert.AreEqual(DesiredSize.Height, Utility.GetEmptyButtonSize(), "10");
            }
Exemple #7
0
        protected override Size MeasureOverride(Size constraint)
        {
            UpdateChildren();

            var children   = Children.OfType <UIElement>();
            var uiElements = children.ToList();

            if (uiElements.Any())
            {
                var maxRowIndex = uiElements.Max(GetRow);

                for (var i = RowDefinitions.Count; i <= maxRowIndex; i++)
                {
                    RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });
                }
            }

            return(base.MeasureOverride(constraint));
        }
Exemple #8
0
        public DocumentPaneGroup() : base(new DocumentContainer())
        {
            IsHighlighted = false;
            Border.SetResourceReference(Border.CornerRadiusProperty, "DocumentPaneCornerRadius");
            Border.SetResourceReference(Border.BorderBrushProperty, "DocumentPaneBorderBrush");
            Border.SetResourceReference(Border.BorderThicknessProperty, "DocumentPaneBorderThickness");

            (IViewContainer as DocumentContainer).DisplayGeneralMenu = DisplayGeneralMenu;

            VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            HorizontalAlignment = HorizontalAlignment.Stretch;

            ColumnDefinition columnDefinition = new ColumnDefinition();

            columnDefinition.Width = new GridLength(Border.BorderThickness.Left, GridUnitType.Pixel);
            ColumnDefinitions.Add(columnDefinition);

            columnDefinition       = new ColumnDefinition();
            columnDefinition.Width = new GridLength(1, GridUnitType.Star);
            ColumnDefinitions.Add(columnDefinition);

            columnDefinition       = new ColumnDefinition();
            columnDefinition.Width = new GridLength(Border.BorderThickness.Right, GridUnitType.Pixel);
            ColumnDefinitions.Add(columnDefinition);

            RowDefinitions.Add(new RowDefinition());
            RowDefinitions[0].Height = new GridLength(Border.BorderThickness.Top, GridUnitType.Pixel);
            RowDefinitions.Add(new RowDefinition());
            RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star);
            RowDefinitions.Add(new RowDefinition());
            RowDefinitions[2].Height = new GridLength(Border.BorderThickness.Bottom, GridUnitType.Pixel);

            IViewContainer.SelectionChanged += DocumentContainer_SelectionChanged;
            Grid.SetRow(IViewContainer as System.Windows.UIElement, 1);
            Grid.SetColumn(IViewContainer as System.Windows.UIElement, 1);
            Grid.SetColumnSpan(IViewContainer as System.Windows.UIElement, ColumnDefinitions.Count - 2);

            IsHighlighted = false;
        }
Exemple #9
0
            public ShowGridLinesGrid()
            {
                Assert.AreEqual(VisualChildrenCount, 0, "1");
                ShowGridLines = true;
                Assert.AreEqual(VisualChildrenCount, 0, "2");
                RowDefinitions.Add(new RowDefinition());
                Assert.AreEqual(VisualChildrenCount, 0, "3");
                Window w = new Window();

                w.Content = this;
                w.Show();
                Assert.AreEqual(VisualChildrenCount, 1, "4");
                Visual visual = GetVisualChild(0);

                Assert.IsTrue(visual is DrawingVisual, "4 1");
                DrawingVisual drawing_visual = (DrawingVisual)visual;

                Assert.IsNull(drawing_visual.Drawing, "4 2");
                ShowGridLines = false;
                Assert.AreEqual(VisualChildrenCount, 1, "5");
                RowDefinitions.Add(new RowDefinition());
                Assert.AreEqual(VisualChildrenCount, 1, "6");
                w.Content = null;
                Assert.AreEqual(VisualChildrenCount, 1, "7");
                visual = GetVisualChild(0);
                Assert.IsTrue(visual is DrawingVisual, "8");
                Assert.IsNull(Grid.ShowGridLinesProperty.DefaultMetadata.PropertyChangedCallback, "9");
                Assert.IsNull(Grid.ShowGridLinesProperty.ValidateValueCallback, "10");
                Assert.IsFalse(Grid.ShowGridLinesProperty.DefaultMetadata is FrameworkPropertyMetadata, "11");
                Assert.AreNotSame(Grid.ShowGridLinesProperty.DefaultMetadata, Grid.ShowGridLinesProperty.GetMetadata(typeof(Grid)), "12");
                FrameworkPropertyMetadata grid_metadata = (FrameworkPropertyMetadata)Grid.ShowGridLinesProperty.GetMetadata(typeof(Grid));

                Assert.IsNotNull(grid_metadata.PropertyChangedCallback, "13");
                Assert.IsFalse(grid_metadata.AffectsArrange, "14");
                Assert.IsFalse(grid_metadata.AffectsMeasure, "15");
                Assert.IsFalse(grid_metadata.AffectsParentArrange, "16");
                Assert.IsFalse(grid_metadata.AffectsParentMeasure, "17");
                Assert.IsFalse(grid_metadata.AffectsRender, "18");
            }
Exemple #10
0
        /// <summary>
        /// Recalc layout
        /// </summary>
        public void RecalcLayout()
        {
            const int MAX_ROWS = 100;
            var       cells    = new GridCellArray(MAX_ROWS, ColumnCount * 2);
            var       children = Children.OfType <FrameworkElement>().ToArray();

            cells.PlaceElements(children);

            RowDefinitions.Clear();
            ColumnDefinitions.Clear();
            for (int i = 0; i < ColumnCount; i++)
            {
                ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
                ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }
            for (int i = 0; i < cells.RowCount; i++)
            {
                RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
            }

            foreach (var cell in cells.EnumCells().Where(x => x.Element != null))
            {
                var elem = cell.Element;
                SetRow(cell.Element, cell.Row);
                SetColumn(cell.Element, cell.Column);

                elem.SetUserProperty(MarginProperty, ChildMargin);
                if (elem is Label)
                {
                    elem.SetUserProperty(HorizontalAlignmentProperty, HorizontalAlignment.Right);
                }
            }
        }
        public LabelledControl(GeneralControl Control, string Label)
        {
            _Label      = Label;
            ControlView = Control;
            LabelView   = new GeneralLabel()
            {
                Text = Label
            };

            //Setup grid definitions
            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });

            //Setup Grid columns
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });

            //Setup views
            LabelSide = eLabelSide.Left;
        }
        public void SetupThePuzzleGridStructure()
        {
            // Define rows and columns in the Grid
            for (int row = 0; row < dimmension; row++)
            {
                RowDefinition r = new RowDefinition();
                r.Height = GridLength.Auto;
                RowDefinitions.Add(r);

                ColumnDefinition c = new ColumnDefinition();
                c.Width = GridLength.Auto;
                ColumnDefinitions.Add(c);
            }

            Style buttonStyle = (Style)Resources["CellButtonStyle"];

            // Now add the buttons in
            int i = 1;

            for (int row = 0; row < dimmension; row++)
            {
                for (int col = 0; col < dimmension; col++)
                {
                    Button b = new Button();
                    b.FontSize = 24;

                    b.Style = buttonStyle;

                    b.SetValue(RowProperty, row);
                    b.SetValue(ColumnProperty, col);


                    i++;

                    Children.Add(b);
                }
            }
        }
Exemple #13
0
        public TEditorHtmlView()
        {
            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });

            _displayWebView = new WebView()
            {
                HeightRequest = 200
            };
            EditButton = new Button
            {
                Text          = "Uredi",
                HeightRequest = 40,
                Command       = new Command(async(obj) =>
                {
                    await ShowTEditor();
                }),
                TextColor         = Color.White,
                BackgroundColor   = Color.FromHex("#1C6EBC"),
                HorizontalOptions = LayoutOptions.End,
                IsVisible         = false
            };
            this.Children.Add(EditButton, 1, 0);

            SetRow(_displayWebView, 1);
            SetColumnSpan(_displayWebView, 2);
            this.Children.Add(_displayWebView);
        }
Exemple #14
0
        public PagerView()
        {
            RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            Natrag = new Button
            {
                Text      = "Natrag",
                IsEnabled = false
            };
            Natrag.Clicked += Natrag_Clicked;
            Naprijed        = new Button
            {
                Text      = "Naprijed",
                IsEnabled = false
            };
            Naprijed.Clicked += Naprijed_Clicked;
            Tekst             = new Label
            {
                Text = trenutno + "/" + ukupno,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                FontSize          = 15
            };
            Children.Add(Natrag, 0, 0);
            Children.Add(Tekst, 1, 0);
            Children.Add(Naprijed, 2, 0);
        }
Exemple #15
0
        public MultiGrid(int rows, int columns, int size)
        {
            tiles = new Tile[rows, columns];

            for (int i = 0; i < rows; i++)
            {
                RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(size, GridUnitType.Pixel)
                });
            }
            for (int i = 0; i < columns; i++)
            {
                ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(size, GridUnitType.Pixel)
                });
            }
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    Tile tile = new Tile(j, i);
                    tiles[i, j] = tile;

                    Children.Add(tile);
                    SetRow(tile, i);
                    SetColumn(tile, j);
                }
            }

            Height = size * rows;
            Width  = size * columns;

            Rows    = rows;
            Columns = columns;
            Size    = size;
        }
Exemple #16
0
        protected override Size MeasureOverride(Size constraint)
        {
            var columns = Math.Max(1, Math.Round(constraint.Width / 500.0, 0));

            columns = Math.Min(Children.Count, columns);
            var rows = Math.Round(0.5 + Children.Count / columns, 0);

            ColumnDefinitions.Clear();
            RowDefinitions.Clear();
            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });

            for (int i = 0; i < columns; i++)
            {
                ColumnDefinitions.Add(new ColumnDefinition());
            }

            var c = 0;
            var r = 0;

            foreach (var e in Children.OfType <DependencyObject>())
            {
                e.SetValue(ColumnProperty, c);
                e.SetValue(RowProperty, r);

                c++;
                if (c >= columns)
                {
                    c = 0;
                    r++;
                    RowDefinitions.Add(new RowDefinition {
                        Height = GridLength.Auto
                    });
                }
            }
            return(base.MeasureOverride(constraint));
        }
        public SnackbarLayout(string message, string actionButtonText, Func <Task> action)
        {
            RowDefinitions.Add(new RowDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
#if UWP
            var messageLabel = new TextBlock()
            {
                Text = message
            };
#else
            var messageLabel = new Label()
            {
                Content = message
            };
#endif
            Children.Add(messageLabel);
            SetRow(messageLabel, 0);
            SetColumn(messageLabel, 0);
            if (!string.IsNullOrEmpty(actionButtonText) && action != null)
            {
                var button = new Button
                {
                    Content = actionButtonText,
                    Command = new Forms.Command(async() =>
                    {
                        OnSnackbarActionExecuted?.Invoke();
                        await action();
                    })
                };
                Children.Add(button);
                SetRow(button, 0);
                SetColumn(button, 1);
            }
        }
Exemple #18
0
        public void InitializeComponent()
        {
            ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());
            ColumnDefinitions.Add(new ColumnDefinition());

            RowDefinitions.Add(new RowDefinition(new GridLength(new Length(40, Unit.Px))));
            RowDefinitions.Add(new RowDefinition(new GridLength(new Length(40, Unit.Px))));
            RowDefinitions.Add(new RowDefinition(new GridLength(new Length(1, Unit.Fr))));

            AddTitle("Direction:", 0, 0);

            var e_direction_row = AddOption("Row", 1, 0, FlexDirection.Row, ChangeDirection);

            AddOption("Reverse Row", 2, 0, FlexDirection.RowReverse, ChangeDirection);
            AddOption("Column", 3, 0, FlexDirection.Column, ChangeDirection);
            AddOption("Reverse Column", 4, 0, FlexDirection.ColumnReverse, ChangeDirection);

            AddTitle("Wrap:", 0, 1);

            var e_wrapping_no = AddOption("No Wrap", 1, 1, FlexWrapping.NoWrap, ChangeWrapping);

            AddOption("Wrap", 2, 1, FlexWrapping.Wrap, ChangeWrapping);
            AddOption("Reverse Wrap", 3, 1, FlexWrapping.WrapReverse, ChangeWrapping);

            e_flex = new Flex()
            {
                Direction = FlexDirection.RowReverse,
                Wrapping  = FlexWrapping.WrapReverse,
            };

            Children.Add(e_flex, new Grid.Anchor(0, 5, 2, 1));

            SelectDirection(e_direction_row);
            SelectWrapping(e_wrapping_no);
        }
Exemple #19
0
        // конструктор
        public GameGrid()
        {
            Width = Height = 600;
            for (int gridSize = 0; gridSize < dimension; gridSize++)
            {
                ColumnDefinitions.Add(new ColumnDefinition());
                RowDefinitions.Add(new RowDefinition());
            }

            Random rand = new Random();

            for (int columnCount = 0; columnCount < dimension; columnCount++)
            {
                for (int rowCount = 0; rowCount < dimension; rowCount++)
                {
                    do
                    {
                        string color = imageList[rand.Next(0, 5)];
                        PlaceTImage(rowCount, columnCount, color);
                    } while (CheckThrees(rowCount, columnCount));
                }
            }
        }
    protected override Size MeasureOverride(Size constraint)
    {
        RowDefinitions.Clear();
        int rowCount = this.Children.Count / 3;

        if (this.Children.Count % 3 != 0)
        {
            rowCount += 1;
        }
        while (RowDefinitions.Count < rowCount)
        {
            RowDefinitions.Add(new RowDefinition());
        }
        foreach (var child in this.Children)
        {
            int gridCell = ArrangeGrid.GetGridCell((UIElement)child);
            int gridRow  = gridCell / 3;
            int gridCol  = gridCell % 3;
            ((UIElement)child).SetValue(Grid.RowProperty, gridRow);
            ((UIElement)child).SetValue(Grid.ColumnProperty, gridCol);
        }
        return(base.MeasureOverride(constraint));
    }
 public ElementGrid()
 {
     IsItemsHost = true;
     for (int i = 0; i < 19; ++i)
     {
         ColumnDefinition cd = new ColumnDefinition();
         // Note: default cd.Width = 1, and GridUnitType = Star
         if (i == 0)
         {
             cd.Width = new GridLength(30, GridUnitType.Pixel);
         }
         ColumnDefinitions.Add(cd);
     }
     for (int i = 0; i < 11; ++i)
     {
         RowDefinition rd = new RowDefinition();
         if (i == 0)
         {
             rd.Height = new GridLength(30, GridUnitType.Pixel);
         }
         RowDefinitions.Add(rd);
     }
 }
        public RxGrid(string rows, string columns)
        {
            var converter = new GridLengthTypeConverter();

            foreach (var rowDefinition in rows.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                     .Select(_ => (GridLength)converter.ConvertFromInvariantString(_))
                     .Select(_ => new RowDefinition()
            {
                Height = _
            }))
            {
                RowDefinitions.Add(rowDefinition);
            }
            foreach (var columnDefinition in columns.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                     .Select(_ => (GridLength)converter.ConvertFromInvariantString(_))
                     .Select(_ => new ColumnDefinition()
            {
                Width = _
            }))
            {
                ColumnDefinitions.Add(columnDefinition);
            }
        }
Exemple #23
0
        protected override void OnVisualChildrenChanged(System.Windows.DependencyObject visualAdded, System.Windows.DependencyObject visualRemoved)
        {
            base.OnVisualChildrenChanged(visualAdded, visualRemoved);

            var curRow = -1;
            var curCol = 1;

            RowDefinitions.Clear();

            if (Children is not null)
            {
                foreach (System.Windows.UIElement curChild in Children)
                {
                    if (curCol == 0)
                    {
                        curCol = 1;
                    }
                    else
                    {
                        curCol = 0;
                        curRow++;
                        RowDefinitions.Add(new RowDefinition()
                        {
                            Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Auto)
                        });
                    }

                    Grid.SetRow(curChild, curRow);
                    Grid.SetColumn(curChild, curCol);
                }
            }

            RowDefinitions.Add(new RowDefinition()
            {
                Height = new System.Windows.GridLength(1, System.Windows.GridUnitType.Star)
            });
        }
Exemple #24
0
        public DataGrid()
        {
            RowSpacing = 0;
            RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
            RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });

            // Head Grid (1)
            headGrid = new GridHead(this);
            SetRow(headGrid, 0);
            Children.Add(headGrid);

            // Stack list (3)
            stackList = new StackList(this);

            // Body Grid (2)
            bodyGrid = new GridBody(this, stackList);
            bodyGrid.VerticalOptions = LayoutOptions.Start;

            // Scroll (1)
            mainScroll = new GridScroll();
            SetRow(mainScroll, 1);
            mainScroll.Content = bodyGrid;
            this.Children.Add(mainScroll);

            // Abs bottom line
            absoluteBottom = new BoxView();
            absoluteBottom.SetBinding(Grid.BackgroundColorProperty, new Binding(nameof(BorderColor), source: this));
            absoluteBottom.SetBinding(Grid.HeightRequestProperty, new Binding(nameof(BorderWidth), source: this));
            absoluteBottom.VerticalOptions = LayoutOptions.EndAndExpand;
            absoluteBottom.HorizontalOptions = LayoutOptions.FillAndExpand;
            absoluteBottom.TranslationY = BorderWidth * 0.1;
            SetRow(absoluteBottom, 1);
            this.Children.Add(absoluteBottom);

            mainScroll.SizeChanged += CheckWrapperBottomVisible;
            stackList.SizeChanged += CheckWrapperBottomVisible;
        }
            public MyTemplate()
            {
                var cstar = new ColumnDefinition {
                    Width = new GridLength(2, GridUnitType.Star)
                };

                ColumnDefinitions.Add(cstar);
                ColumnDefinitions.Add(cstar);

                var rstar = new RowDefinition {
                    Height = new GridLength(2, GridUnitType.Star)
                };

                RowDefinitions.Add(rstar);
                RowDefinitions.Add(rstar);

                var image = new Image();

                image.Aspect = Aspect.AspectFill;
                image.SetBinding(Image.SourceProperty, new Binding("Image", converter: TimestampConverter));

                var labelTop = new Label();

                labelTop.LineBreakMode = LineBreakMode.NoWrap;
                labelTop.FontSize      = 16;
                labelTop.SetBinding(Label.TextProperty, new Binding("Text", converter: DebugConverter));

                var labelBottom = new Label();

                labelBottom.LineBreakMode = LineBreakMode.NoWrap;
                labelBottom.FontSize      = 13;
                labelBottom.SetBinding(Label.TextProperty, new Binding("Description", converter: DebugConverter));

                Children.Add(image, 0, 1, 0, 2);
                Children.Add(labelTop, 1, 2, 0, 1);
                Children.Add(labelBottom, 1, 2, 1, 2);
            }
Exemple #26
0
        public NPicker()
        {
            InitializeComponent();

            HeightRequest             = 75;
            _mainPicker.HeightRequest = 50;
            _mainPicker.Margin        = new Thickness(0);
            _pickerLabel.Margin       = new Thickness(20, 0, 0, 0);

            _mainPicker.SelectedIndexChanged += OnIndexChanged;

            SetBorderFrame();
            SetContentFrame();


            _mainPicker.HorizontalOptions = LayoutOptions.FillAndExpand;
            _mainPicker.VerticalOptions   = LayoutOptions.FillAndExpand;

            Children.Add(_pickerLabel);
            Children.Add(_borderFrame);

            ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Star
            });
            RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(2, GridUnitType.Star)
            });
            RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(5, GridUnitType.Star)
            });

            SetRow(_pickerLabel, 0);
            SetRow(_borderFrame, 1);
        }
        public UiEncodingCharactersControl()
        {
            #region Construct

            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });

            _mainControls = new LazyArray <UiEncodingMainCharacterControl>(ProvideMainControl);
            _mainPanel    = UiStackPanelFactory.Create(Orientation.Vertical);
            AddUiElement(_mainPanel, 0, 0);

            _additionalControls = new LazyArray <UiEncodingAdditionalCharacterControl>(ProvideAdditionalControl);
            _additionalPanel    = UiStackPanelFactory.Create(Orientation.Vertical);
            AddUiElement(_additionalPanel, 1, 0);

            #endregion
        }
Exemple #28
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            RowDefinitions.Clear();

            int cols = Math.Max(1, ColumnDefinitions.Count);

            int index = 0;

            for (int i = 0; i < Children.Count; i++)
            {
                if (index % cols == 0)
                {
                    RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });
                }
                UIElement child = Children[i];
                SetRow(child, RowDefinitions.Count - 1);
                SetColumn(child, index - ((RowDefinitions.Count - 1) * cols));
                index += GetColumnSpan(child);
            }
        }
        private void ResizeGrid()
        {
            if (_keys == null)
            {
                Reset();
                return;
            }

            // Make sure there's the right number of rows
            var rowCount = _keys.Max(x => x.GridRow) + 1;

            for (var rowsToAdd = rowCount - RowDefinitions.Count; rowsToAdd > 0; rowsToAdd--)
            {
                // Add the extra Row
                RowDefinitions.Add(new RowDefinition());
            }
            for (var rowsToRemove = RowDefinitions.Count - rowCount; rowsToRemove > 0; rowsToRemove--)
            {
                // Remove the extra Row
                RowDefinitions.RemoveAt(0);
            }

            // Make sure there's the right number of cols
            var colCount = _keys.Max(x => x.GridColumn) + 1;

            for (var colsToAdd = colCount - ColumnDefinitions.Count; colsToAdd > 0; colsToAdd--)
            {
                // Add the extra Column
                ColumnDefinitions.Add(new ColumnDefinition());
            }
            for (var colsToRemove = ColumnDefinitions.Count - colCount; colsToRemove > 0; colsToRemove--)
            {
                // Remove the extra Column
                ColumnDefinitions.RemoveAt(0);
            }
        }
        protected void SetOrientation(Orientation orientation)
        {
            _orientation = orientation;
            ColumnDefinitions.Clear();
            RowDefinitions.Clear();

            if (orientation == Orientation.Horizontal)
            {
                for (int i = 0; i < 3; i++)
                {
                    RowDefinitions.Add(new RowDefinition());
                }
                RowDefinitions[1].Height = new GridLength(splitterSize);
            }
            else
            {
                RowDefinitions.Clear();
                for (int i = 0; i < 3; i++)
                {
                    ColumnDefinitions.Add(new ColumnDefinition());
                }
                ColumnDefinitions[1].Width = new GridLength(splitterSize);
            }
        }