示例#1
0
 internal Rows(DataGridPanel panel, int defaultSize) : base(panel, defaultSize)
 {
 }
示例#2
0
        public virtual Thickness GetCellPadding(DataGrid grid, DataGridPanel panel, CellRange rng)
        {
            var p = _padding;

            return p;
        }
示例#3
0
        void CreateCellContent(DataGrid grid, DataGridPanel panel, Border bdr, CellRange rng)
        {
            // get row and column
            var r = panel.Rows[rng.Row];
            var c = panel.Columns[rng.Column];
            //var gr = r as GroupRow;

            // honor user templates (if the row has a backing data item)
            if (r.DataItem != null && c.CellTemplate != null && panel.CellType == CellType.Cell)
            {
                bdr.Padding = GetTemplatePadding(bdr.Padding);
                bdr.Child = GetTemplatedCell(grid, c.CellTemplate);
                return;
            }

            // get binding, unbound value for the cell
            var b = r.DataItem != null ? c.Binding : null;
            var ubVal = r.DataItem != null ? null : panel[rng.Row, rng.Column];

            // get foreground brush taking selected state into account
            var fore = GetForegroundBrush(grid, r, rng, grid.Foreground);

            // handle non-text types
            var type = c.DataType;
            TextBlock tb = null;
            CheckBox chk = null;
            if (// not a group, or hierarchical
                panel.CellType == CellType.Cell &&
                (type == typeof(bool) || type == typeof(bool?))) // and bool
            {
                // Boolean cells: use CheckBox
                chk = new CheckBox();
                chk.IsThreeState = type == typeof(bool?);
                chk.HorizontalAlignment = HorizontalAlignment.Center;
                chk.VerticalAlignment = VerticalAlignment.Center;
                chk.MinWidth = 32;

                chk.HorizontalAlignment = HorizontalAlignment.Stretch;
                chk.VerticalAlignment = VerticalAlignment.Stretch;
                chk.Margin = new Thickness(0, -10, 0, -10);

                chk.IsHitTestVisible = false;
                chk.IsTabStop = false;
                if (fore != null)
                {
                    chk.Foreground = fore;
                }

                bdr.Child = chk;
                if (b != null)
                {
                    chk.SetBinding(CheckBox.IsCheckedProperty, b);
                }
                else
                {
                    var value = ubVal as bool?;
                    chk.IsChecked = value;
                }
            }
            else
            {
                // use TextBlock for everything else (even empty cells)
                tb = new TextBlock();
                tb.VerticalAlignment = VerticalAlignment.Center;
                if (fore != null)
                {
                    tb.Foreground = fore;
                }
                bdr.Child = tb;

                // bound values
                if (b != null)
                {
                    // apply binding
                    tb.SetBinding(TextBlock.TextProperty, b);
                }
                else if (ubVal != null) // unbound values
                {
                    // get column format from column and/or binding
                    tb.Text = r.GetDataFormatted(c);
                }
            }

        }
示例#4
0
 internal void DisposeCell(DataGridPanel panel, FrameworkElement cell)
 {
     var cf = GetCellFactory();
     cf.DisposeCell(this, panel.CellType, cell);
 }
示例#5
0
 internal FrameworkElement CreateCell(DataGridPanel panel, CellRange rng)
 {
     var cf = GetCellFactory();
     return cf.CreateCell(this, panel.CellType, rng);
 }
示例#6
0
        private void InitializePanel()
        {
            _cellPanel = new DataGridPanel(this, CellType.Cell, Consts.ROWHEIGHT, Consts.COLUMNWIDTH);

            _columnHeaderPanel = new DataGridPanel(this, CellType.ColumnHeader, Consts.ROWHEIGHT, Consts.COLUMNWIDTH);
            _columnHeaderPanel.Columns = _cellPanel.Columns;

            _columnHeaderPanel.Rows.Add(new Row());


            _columnHeaderPanel.Tapped += _columnHeaderPanel_Tapped;
            _cellPanel.LayoutUpdated += _cellPanel_LayoutUpdated;
            _cellPanel.Tapped += _cellPanel_Tapped;

            #region frozen
            _canvas = new Canvas();
            _lnFX = new Line();
            _lnFX.Visibility = Visibility.Collapsed;
            _lnFX.StrokeThickness = 1;
            _canvas.Children.Add(_lnFX);

            _lnFY = new Line();
            _lnFY.Visibility = Visibility.Collapsed;
            _lnFY.StrokeThickness = 1;
            _canvas.Children.Add(_lnFY);
            #endregion

            #region More Columns

            #endregion

        }
示例#7
0
 internal RowCols(DataGridPanel panel, int defaultSize)
 {
     _panel   = panel;
     _defSize = defaultSize;
 }
示例#8
0
 internal Columns(DataGridPanel panel, int defaultSize) : base(panel, defaultSize)
 {
 }
示例#9
0
        void CreateCellContent(DataGrid grid, DataGridPanel panel, Border bdr, CellRange rng)
        {
            // get row and column
            var r = panel.Rows[rng.Row];
            var c = panel.Columns[rng.Column];

            //var gr = r as GroupRow;

            // honor user templates (if the row has a backing data item)
            if (r.DataItem != null && c.CellTemplate != null && panel.CellType == CellType.Cell)
            {
                bdr.Padding = GetTemplatePadding(bdr.Padding);
                bdr.Child   = GetTemplatedCell(grid, c.CellTemplate);
                return;
            }

            // get binding, unbound value for the cell
            var b     = r.DataItem != null ? c.Binding : null;
            var ubVal = r.DataItem != null ? null : panel[rng.Row, rng.Column];

            // get foreground brush taking selected state into account
            var fore = GetForegroundBrush(grid, r, rng, grid.Foreground);

            // handle non-text types
            var       type = c.DataType;
            TextBlock tb   = null;
            CheckBox  chk  = null;

            if (                                                 // not a group, or hierarchical
                panel.CellType == CellType.Cell &&
                (type == typeof(bool) || type == typeof(bool?))) // and bool
            {
                // Boolean cells: use CheckBox
                chk = new CheckBox();
                chk.IsThreeState        = type == typeof(bool?);
                chk.HorizontalAlignment = HorizontalAlignment.Center;
                chk.VerticalAlignment   = VerticalAlignment.Center;
                chk.MinWidth            = 32;

                chk.HorizontalAlignment = HorizontalAlignment.Stretch;
                chk.VerticalAlignment   = VerticalAlignment.Stretch;
                chk.Margin = new Thickness(0, -10, 0, -10);

                chk.IsHitTestVisible = false;
                chk.IsTabStop        = false;
                if (fore != null)
                {
                    chk.Foreground = fore;
                }

                bdr.Child = chk;
                if (b != null)
                {
                    chk.SetBinding(CheckBox.IsCheckedProperty, b);
                }
                else
                {
                    var value = ubVal as bool?;
                    chk.IsChecked = value;
                }
            }
            else
            {
                // use TextBlock for everything else (even empty cells)
                tb = new TextBlock();
                tb.VerticalAlignment = VerticalAlignment.Center;
                if (fore != null)
                {
                    tb.Foreground = fore;
                }
                bdr.Child = tb;

                // bound values
                if (b != null)
                {
                    // apply binding
                    tb.SetBinding(TextBlock.TextProperty, b);
                }
                else if (ubVal != null) // unbound values
                {
                    // get column format from column and/or binding
                    tb.Text = r.GetDataFormatted(c);
                }
            }
        }
示例#10
0
        public virtual Thickness GetCellPadding(DataGrid grid, DataGridPanel panel, CellRange rng)
        {
            var p = _padding;

            return(p);
        }