コード例 #1
0
        public Document CreateDocumentFluent(Data data)
        {
            var cellHeaderThickness = new LineThickness(LineWidth.Single, LineWidth.Double);

            return(new Document {
                Color = White, Background = Black,
                Children =
                {
                    "Hello world!",
                    new Div {
                        Values = { Green,                             TextWrap.CharWrap             },
                        Children = { data.Unicode.Normalize(NormalizationForm.FormD) }
                    },
                    new Div {
                        Values = { DarkYellow,                        TextWrap.CharWrap             },
                        Children = { data.Unicode.Normalize(NormalizationForm.FormC) }
                    },
                    new List(data.Items.Select(d => new Div(d.Name))),
                    new Div(data.Items.Select(d => d.Name + " ")),
                    new Grid {
                        Columns = { -1,                                                      -1, -1 },
                        Children =
                        {
                            new Cell("Id")
                            {
                                Stroke = cellHeaderThickness
                            },
                            new Cell("Name")
                            {
                                Stroke = cellHeaderThickness
                            },
                            new Cell("Value")
                            {
                                Stroke = cellHeaderThickness
                            },
                            data.Items.Select(d => new[] {
                                new Cell(d.Id)
                                {
                                    Values =             { Yellow,Align.Right                                  }
                                },
                                new Cell(d.Name)
                                {
                                    Values =             { Gray }
                                },
                                new Cell(d.Value)
                                {
                                    Values =             { Gray }
                                },
                            }),
                        },
                    },
                    new Grid {
                        Stroke = LineThickness.None,
                        Columns = { -1,                                                      -1, -1 },
                        Children =
                        {
                            new Div("Id"),     new Div("Name"),                            new Div("Value"),
                            data.Items.Select(d => new[] {
                                new Div(d.Id), new Div(d.Name),                            new Div(d.Value),
                            }),
                        },
                    },
                    new Dock {
                        Width = 80,                                   Values = { Align.Left, Gray.On(Blue)},
                        Children =
                        {
                            new Div    {
                                Width = 20,                           Margin = new Thickness(1, 1, 0, 1), Padding = 1,
                                Values ={ DockTo.Left,      Gray.On(DarkBlue),               TextWrap.CharWrap},
                                Children ={ LoremIpsumCharWrap(data) },
                            },
                            new Div    {
                                Height = 10,                          Margin = new Thickness(1, 1, 1, 0), Padding = 1,
                                Values ={ DockTo.Top,       Gray.On(DarkBlue)             },
                                Children ={ LoremIpsumWordWrapWithSpaces(data) },
                            },
                            new Div    {
                                Width = 20,                           Margin = new Thickness(0, 1, 1, 1), Padding = 1,
                                Values ={ DockTo.Right,     Gray.On(DarkBlue)             },
                                Children ={ LoremIpsumWordWrapWithZeroWidthSpaces(data) },
                            },
                            new Div    {
                                Height = 10,                          Margin = new Thickness(1, 0, 1, 1), Padding = 1,
                                Values ={ DockTo.Bottom,    Gray.On(DarkBlue)             },
                                Children ={ LoremIpsumWordWrapWithNoBreakSpaces(data) },
                            },
                            new Border {
                                Margin = 1,                           Padding = 1,
                                Shadow = new Thickness(-1,        -1, 1, 1), Stroke = LineThickness.Single,
                                Values ={ Gray.On(DarkCyan) },
                                Children ={ LoremIpsumWordWrapWithSoftHyphens(data) },
                            }
                        },
                    },
                    "",
                    new Absolute {
                        Width = 80,                                   Height = 43, Values = { Align.Left, Gray.On(Blue)},
                        Children =
                        {
                            new Div    {
                                Width = 38,                           Height = 20, Padding = 1,
                                Values ={ Gray.On(DarkBlue),      TextWrap.CharWrap,                   Absolute.LeftProperty == 1,  Absolute.TopProperty == 1},
                                Children ={ LoremIpsumCharWrap(data) },
                            },
                            new Div    {
                                Width = 38,                           Height = 20, Padding = 1,
                                Values ={ Gray.On(DarkBlue),      TextWrap.CharWrap,                   Absolute.LeftProperty == 1,  Absolute.BottomProperty == 1},
                                Children ={ LoremIpsumWordWrapWithSpaces(data) },
                            },
                            new Div    {
                                Width = 38,                           Height = 20, Padding = 1,
                                Values ={ Gray.On(DarkBlue),      TextWrap.CharWrap,                   Absolute.RightProperty == 1, Absolute.TopProperty == 1},
                                Children ={ LoremIpsumWordWrapWithZeroWidthSpaces(data) },
                            },
                            new Div    {
                                Width = 38,                           Height = 20, Padding = 1,
                                Values ={ Gray.On(DarkBlue),      TextWrap.CharWrap,                   Absolute.RightProperty == 1, Absolute.BottomProperty == 1},
                                Children ={ LoremIpsumWordWrapWithNoBreakSpaces(data) },
                            },
                            new Border {
                                Width = 38,                           Height = 20, Padding = 1,
                                Shadow = new Thickness(-1,          -1, 1, 1), Stroke = LineThickness.Single,
                                Values ={ Gray.On(DarkCyan),      Absolute.LeftProperty == 21,         Absolute.TopProperty == 11 },
                                Children ={ LoremIpsumWordWrapWithSoftHyphens(data) },
                            },
                        },
                    },
                }
            });
        }