Exemplo n.º 1
0
        public GridBody(DataGrid grid, StackList stack /*, Grid mask*/)
        {
            DataGrid  = grid;
            StackList = stack;

            Children.Add(stack);
            AddStaticLines();

            foreach (var line in allLines)
            {
                line.InputTransparent = true;
                line.BackgroundColor  = DataGrid.BorderColor;

                Children.Add(line);
            }
        }
Exemplo n.º 2
0
        public GridRow(object context, StackList host, int id, bool showBottomLine, bool isAutoNumber)
        {
            Context        = context;
            BindingContext = context;
            DataGrid       = host.DataGrid;
            Index          = id;
            isLineVisible  = showBottomLine;

            IsClippedToBounds = true;
            VerticalOptions   = LayoutOptions.Start;
            HorizontalOptions = LayoutOptions.FillAndExpand;
            Cells             = new GridCell[DataGrid.Columns.Count];

            // Triggers event
            if (context is INotifyPropertyChanged model && DataGrid.RowTriggers.Count > 0)
            {
                model.PropertyChanged += (obj, e) => RowTrigger.SetTriggerStyle(this, e.PropertyName);
            }

            // Selection box
            SelectionBox = new BoxView();
            SelectionBox.InputTransparent = true;
            SelectionBox.BackgroundColor  = Color.Transparent;
            Children.Add(SelectionBox);

            // Init cells
            for (int i = 0; i < DataGrid.Columns.Count; i++)
            {
                var column = DataGrid.Columns[i];
                var cell   = new GridCell(this, column);

                Children.Add(cell.Wrapper);
                Children.Add(cell.Content);
                Cells[i] = cell;
            }

            // Add tap system event
            if (DataGrid.TapColor != Color.Default ||
                DataGrid.CommandLongTapItem != null ||
                DataGrid.CommandSelectedItem != null)
            {
                Touch.SetHost(this, DataGrid);
            }

            //Touch.SetSelect(this, new Command(ActionRowSelect));

            //if (DataGrid.TapColor != Color.Default)
            //    Touch.SetColor(this, DataGrid.TapColor);

            //if (DataGrid.CommandSelectedItem != null)
            //    Touch.SetTap(this, DataGrid.CommandSelectedItem);

            //if (DataGrid.CommandLongTapItem != null)
            //    Touch.SetLongTap(this, DataGrid.CommandLongTapItem);


            // Create horizontal line table
            Line = new BoxView();
            Line.BackgroundColor  = DataGrid.BorderColor;
            Line.HeightRequest    = DataGrid.BorderWidth;
            Line.InputTransparent = true;
            Children.Add(Line);

            // Auto number
            if (DataGrid.IsAutoNumberCalc && isAutoNumber)
            {
                UpdateAutoNumeric(Index);
            }

            // find FIRST active trigger
            if (this.DataGrid.RowTriggers.Count > 0)
            {
                foreach (var trigg in this.DataGrid.RowTriggers)
                {
                    if (trigg.CheckTriggerActivated(BindingContext))
                    {
                        this.EnabledTrigger = trigg;
                        break;
                    }
                }
            }

            // Render style
            UpdateStyle();
        }