Esempio n. 1
0
        public TextCell(
            string text,
            Gdk.Color textColor,
            string detail,
            Gdk.Color detailColor)
        {
            _root = new VBox();

            var span = new Span()
            {
                FontSize = 12,
                Text     = text ?? string.Empty
            };

            _textLabel = new Gtk.Label();
            _textLabel.SetAlignment(0, 0);
            _textLabel.ModifyFg(StateType.Normal, textColor);
            _textLabel.SetTextFromSpan(span);

            _root.PackStart(_textLabel, false, false, 0);

            _detailLabel = new Gtk.Label();
            _detailLabel.SetAlignment(0, 0);
            _detailLabel.ModifyFg(StateType.Normal, detailColor);
            _detailLabel.Text = detail ?? string.Empty;

            _root.PackStart(_detailLabel, true, true, 0);

            Add(_root);
        }
Esempio n. 2
0
        private void UpdateIsGroupHeader(bool isGroupHeader)
        {
            if (_textLabel != null)
            {
                var span = new Span()
                {
                    FontSize = isGroupHeader ? 18 : 12,
                    Text     = _textLabel.Text ?? string.Empty
                };

                _textLabel.SetTextFromSpan(span);
            }
        }
Esempio n. 3
0
        public ImageCell(
            Gdk.Pixbuf image,
            string text,
            Gdk.Color textColor,
            string detail,
            Gdk.Color detailColor)
        {
            _root = new HBox();
            Add(_root);

            _imageControl        = new Gtk.Image();
            _imageControl.Pixbuf = image;

            _root.PackStart(_imageControl, false, false, 0);

            _vertical = new VBox();

            var span = new Span()
            {
                FontSize = 12,
                Text     = text ?? string.Empty
            };

            _textLabel = new Gtk.Label();
            _textLabel.SetAlignment(0, 0);
            _textLabel.ModifyFg(StateType.Normal, textColor);
            _textLabel.SetTextFromSpan(span);

            _vertical.PackStart(_textLabel, false, false, 0);

            _detailLabel = new Gtk.Label();
            _detailLabel.SetAlignment(0, 0);
            _detailLabel.ModifyFg(StateType.Normal, detailColor);
            _detailLabel.Text = detail ?? string.Empty;

            _vertical.PackStart(_detailLabel, true, true, 0);

            _root.PackStart(_vertical, false, false, 0);
        }
Esempio n. 4
0
        void RefreshSource(TableRoot source)
        {
            // Clear
            _cells.Clear();

            foreach (var child in _root.AllChildren)
            {
                _root.RemoveFromContainer((Widget)child);
            }

            // Add Title
            if (!string.IsNullOrEmpty(source.Title))
            {
                var titleSpan = new Span()
                {
                    FontSize = 16,
                    Text     = source.Title ?? string.Empty
                };

                Gtk.Label title = new Gtk.Label();
                title.SetAlignment(0, 0);
                title.SetTextFromSpan(titleSpan);
                _root.PackStart(title, false, false, 0);
            }

            // Add Table Section
            for (int i = 0; i < source.Count; i++)
            {
                if (source[i] is TableSection tableSection)
                {
                    var tableSectionSpan = new Span()
                    {
                        FontSize  = 12,
                        Text      = tableSection.Title ?? string.Empty,
                        TextColor = tableSection.TextColor
                    };

                    // Table Section Title
                    Gtk.Label sectionTitle = new Gtk.Label();
                    sectionTitle.SetAlignment(0, 0);
                    sectionTitle.SetTextFromSpan(tableSectionSpan);
                    _root.PackStart(sectionTitle, false, false, 0);

                    // Table Section Separator
                    EventBox separator = new EventBox
                    {
                        HeightRequest = 1
                    };

                    separator.ModifyBg(StateType.Normal, Color.Black.ToGtkColor());
                    _root.PackStart(separator, false, false, 0);

                    // Cells
                    _cells.Clear();

                    for (int j = 0; j < tableSection.Count; j++)
                    {
                        var cell = tableSection[j];

                        var renderer =
                            (Cells.CellRenderer)Internals.Registrar.Registered.GetHandlerForObject <IRegisterable>(cell);
                        var nativeCell = renderer.GetCell(cell, null, null);

                        if (nativeCell != null)
                        {
                            nativeCell.ButtonPressEvent += (sender, args) =>
                            {
                                if (sender is CellBase gtkCell && gtkCell.Cell != null)
                                {
                                    var selectedCell = gtkCell.Cell;

                                    OnItemTapped?.Invoke(this, new ItemTappedEventArgs(selectedCell));
                                }
                            };
                            _cells.Add(nativeCell);
                        }
                    }

                    foreach (var cell in _cells)
                    {
                        _root.PackStart(cell, false, false, 0);
                    }
                }

                // Refresh
                _root.ShowAll();
            }
        }