Beispiel #1
0
        internal void FillTable(TableDataSet dataSet)
        {
            int i = 0;

            // Fill 0 column
            for (i = 0; i < RowCount; i++)
            {
                if (!dataSet.IsInRange(i))
                {
                    break;
                }

                var control = new TextBlock();
                control.Text        = dataSet[i, 0];
                control.FontFamily  = TableFontFamily;
                control.FontSize    = TableFontSize;
                control.FontStyle   = TableFontStyle == FontStyles.Italic ? FontStyles.Italic : FontStyles.Normal;
                control.FontWeight  = TableFontWeight;
                control.FontStretch = TableFontStretch;

                Grid.SetColumn(control, 0);
                Grid.SetRow(control, i);
                TableGrid.Children.Add(control);
            }

            // Fill 2 column
            for (i = 0; i < RowCount; i++)
            {
                if (!dataSet.IsInRange(i))
                {
                    break;
                }

                var control = new TextBlock();
                control.HorizontalAlignment = HorizontalAlignment.Left;
                control.Text        = dataSet[i, 1];
                control.FontFamily  = TextFontFamily;
                control.FontSize    = TextFontSize;
                control.FontStyle   = TextFontStyle == FontStyles.Italic ? FontStyles.Italic : FontStyles.Normal;
                control.FontWeight  = TextFontWeight;
                control.FontStretch = TextFontStretch;
                Grid.SetColumn(control, 2);
                Grid.SetRow(control, i);
                TableGrid.Children.Add(control);
            }

            ActualRowCount = i;

            // Fill 1 column
            GridSplitter gs = new GridSplitter();

            gs.Name                = "GridSplitter";
            gs.Focusable           = false;
            gs.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            Grid.SetColumn(gs, 1);
            Grid.SetRowSpan(gs, RowCount);
            TableGrid.Children.Add(gs);
            TableGrid.UpdateLayout();
        }
Beispiel #2
0
        private int FillTable(DrawingContext ctx, TableInfo ci, TableDataSet dataSet, int seek = 0, Point mediaOffset = new Point())
        {
            int i = 0;

            for (i = 0; i < ci.RowCount; i++)
            {
                if (!dataSet.IsInRange(i + seek))
                {
                    break;
                }

                var text = new FormattedText(dataSet[i + seek, 0], System.Globalization.CultureInfo.CurrentCulture,
                                             FlowDirection.LeftToRight,
                                             new Typeface(
                                                 new FontFamily(ci.FontFamily),
                                                 ci.FontStyle == FontStyles.Italic.ToString() ? FontStyles.Italic : FontStyles.Normal,
                                                 FontWeight.FromOpenTypeWeight(OverrideFontWeight == 0 ? ci.FontOpenTypeWeight : OverrideFontWeight),
                                                 FontStretch.FromOpenTypeStretch(ci.FontOpenTypeStretch)),
                                             Helper.ToEmSize(ci.FontSize, m_DpiY), Brushes.Black);

                var orig = ci.Location();
                var loc  = new Point(orig.X, orig.Y + ci.RowPixelHeight * i);
                loc.X += mediaOffset.X;
                loc.Y += mediaOffset.Y;

                ctx.DrawText(text, loc);
            }

            // Fill 2 column
            for (i = 0; i < ci.RowCount; i++)
            {
                if (!dataSet.IsInRange(i + seek))
                {
                    break;
                }

                var text = new FormattedText(dataSet[i + seek, 1], System.Globalization.CultureInfo.CurrentCulture,
                                             FlowDirection.LeftToRight,
                                             new Typeface(
                                                 new FontFamily(ci.TextFontFamily),
                                                 ci.TextFontStyle == FontStyles.Italic.ToString() ? FontStyles.Italic : FontStyles.Normal,
                                                 FontWeight.FromOpenTypeWeight(OverrideFontWeight == 0 ? ci.TextFontOpenTypeWeight : OverrideFontWeight),
                                                 FontStretch.FromOpenTypeStretch(ci.TextFontOpenTypeStretch)),
                                             Helper.ToEmSize(ci.TextFontSize, m_DpiY), Brushes.Black);

                var orig = ci.Location();
                var loc  = new Point(orig.X + ci.Col0Width + ci.Col1Width, orig.Y + ci.RowPixelHeight * i);
                loc.X += mediaOffset.X;
                loc.Y += mediaOffset.Y;

                ctx.DrawText(text, loc);
            }

            return(i + seek);
        }
Beispiel #3
0
        internal void Initialize(int rowCount, double rowHeight, GridLength col0Width, GridLength col1Width, GridLength col2Width, TableDataSet dataSet, ref int seek)
        {
            int i = 0;

            RowCount       = rowCount;
            RowHeight      = rowHeight;
            RowPixelHeight = rowHeight * MainWindow.DpiY / 2.54d / 100d;

            ColumnDefinition c1 = new ColumnDefinition();

            c1.Width = col0Width;// new GridLength(col0Width, GridUnitType.Auto);
            ColumnDefinition c2 = new ColumnDefinition();

            c2.Width = col1Width;// new GridLength(col1Width, GridUnitType.Auto);
            ColumnDefinition c3 = new ColumnDefinition();

            c3.Width = col2Width;// new GridLength(col2Width, GridUnitType.Auto);

            TableGrid.ColumnDefinitions.Add(c1);
            TableGrid.ColumnDefinitions.Add(c2);
            TableGrid.ColumnDefinitions.Add(c3);

            for (i = 0; i < rowCount; i++)
            {
                RowDefinition row = new RowDefinition();
                row.Height = new GridLength(RowPixelHeight, GridUnitType.Pixel);
                TableGrid.RowDefinitions.Add(row);
            }

            // Fill 0 column
            for (i = 0; i < rowCount; i++)
            {
                if (!dataSet.IsInRange(i + seek))
                {
                    break;
                }

                var control = new TextBlock();
                control.Text        = dataSet[i + seek, 0];
                control.FontFamily  = TableFontFamily;
                control.FontSize    = TableFontSize;
                control.FontStyle   = TableFontStyle == FontStyles.Italic ? FontStyles.Italic : FontStyles.Normal;
                control.FontWeight  = TableFontWeight;
                control.FontStretch = TableFontStretch;

                Grid.SetColumn(control, 0);
                Grid.SetRow(control, i);
                TableGrid.Children.Add(control);
            }

            // Fill 2 column
            for (i = 0; i < rowCount; i++)
            {
                if (!dataSet.IsInRange(i + seek))
                {
                    break;
                }

                var control = new TextBlock();
                control.HorizontalAlignment = HorizontalAlignment.Left;
                control.Text        = dataSet[i + seek, 1];
                control.FontFamily  = TableFontFamily;
                control.FontSize    = TableFontSize;
                control.FontStyle   = TableFontStyle == FontStyles.Italic ? FontStyles.Italic : FontStyles.Normal;
                control.FontWeight  = TableFontWeight;
                control.FontStretch = TableFontStretch;
                Grid.SetColumn(control, 2);
                Grid.SetRow(control, i);
                TableGrid.Children.Add(control);
            }

            // Fill 1 column
            GridSplitter gs = new GridSplitter();

            gs.Name                = "GridSplitter";
            gs.Focusable           = false;
            gs.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;

            Grid.SetColumn(gs, 1);
            Grid.SetRowSpan(gs, rowCount);
            TableGrid.Children.Add(gs);
            TableGrid.UpdateLayout();

            seek += i;
        }