Ejemplo n.º 1
0
        /// <summary>
        /// The write table.
        /// </summary>
        /// <param name="t">
        /// The t.
        /// </param>
        public void WriteTable(Table t)
        {
            var p      = new System.Windows.Documents.Paragraph();
            var figure = new Figure();
            var table  = new System.Windows.Documents.Table();

            // if (t.HasHeader())
            // {
            // var trg1 = new TableRowGroup();
            // SetStyle(trg1, Style.TableHeaderStyle);
            // var r = new TableRow();
            // foreach (var c in columns)
            // {
            // var cell = new TableCell();
            // var run = new Run() { Text = c.Header };
            // cell.Blocks.Add(new System.Windows.Documents.Paragraph(run));
            // r.Cells.Add(cell);
            // }
            // trg1.Rows.Add(r);
            // table.RowGroups.Add(trg1);
            // }
            var trg2 = new TableRowGroup();

            // SetStyle(trg2, Style.TableTextStyle);
            foreach (var row in t.Rows)
            {
                var r = new TableRow();
                if (row.IsHeader)
                {
                    SetStyle(r, row.IsHeader ? this.Style.TableHeaderStyle : this.Style.TableTextStyle);
                }

                for (int j = 0; j < t.Columns.Count; j++)
                {
                    TableCell c    = row.Cells[j];
                    var       cell = new System.Windows.Documents.TableCell();
                    var       run  = new Run {
                        Text = c.Content
                    };
                    cell.Blocks.Add(new System.Windows.Documents.Paragraph(run));
                    r.Cells.Add(cell);
                }

                trg2.Rows.Add(r);
            }

            table.RowGroups.Add(trg2);

            figure.Blocks.Add(this.CreateParagraph(t.Caption, this.Style.FigureTextStyle));
            figure.Blocks.Add(table);
            p.Inlines.Add(figure);
            this.doc.Blocks.Add(p);
        }
Ejemplo n.º 2
0
        public void DrawFigure(Figure figure)
        {
            var polygon = new Polygon();
            figure.Vertex()
                .Select(a => new Point(300 + a.XX * 50, 300 + a.YY * 50))
                .ToList<Point>()
                .ForEach(polygon.Points.Add);
            polygon.Stroke = figure.Color();
            polygon.Fill = figure.Color();
            polygon.StrokeThickness = 0.35;
            canvas.Children.Add(polygon);   

        }
Ejemplo n.º 3
0
     // ------------------------------------------------------------------
     // Width figure size calculation
     // ------------------------------------------------------------------
     internal static double CalculateFigureWidth(StructuralCache structuralCache, Figure figure, FigureLength figureLength, out bool isWidthAuto)
     {
         double value;
 
         isWidthAuto = figureLength.IsAuto ? true : false;
 
         // Check figure's horizontal anchor. If anchored to page, use page width to format
 
         FigureHorizontalAnchor horizontalAnchor = figure.HorizontalAnchor;
 
         if(figureLength.IsPage || (figureLength.IsAuto && IsHorizontalPageAnchor(horizontalAnchor)))
         {
             value = structuralCache.CurrentFormatContext.PageWidth * figureLength.Value;
         }
         else if (figureLength.IsAbsolute)
         {
             value = CalculateFigureCommon(figureLength);
         }
         else // figureLength.IsColumn || figureLength.IsContent || figureLength.IsAuto 
         {
             double columnWidth, gap, rule;
             int cColumns;
 
             GetColumnMetrics(structuralCache, out cColumns, out columnWidth, out gap, out rule);
 
             if (figureLength.IsContent || (figureLength.IsAuto && IsHorizontalContentAnchor(horizontalAnchor)))
             {
                 // Use content width for figure
                 value = (columnWidth * cColumns + gap * (cColumns - 1)) * figureLength.Value;
             }
             else // figureLength.IsColumn || figureLength.IsAuto
             {
                 // We do this to prevent a 2.0 columns from spanning 2.0 + gap, so we just check for edge
                 double lengthValue = figureLength.Value;
 
                 int columnGapsSpanned = (int) lengthValue;
                 if(columnGapsSpanned == lengthValue && columnGapsSpanned > 0)
                 {
                     columnGapsSpanned -= 1;
                 }
 
                 value = (columnWidth * lengthValue) + gap * columnGapsSpanned;
             }
         }
 
         Invariant.Assert(!DoubleUtil.IsNaN(value));
 
         return value;
     }
Ejemplo n.º 4
0
        // ------------------------------------------------------------------
        // Height figure size calculation
        // ------------------------------------------------------------------
        internal static double CalculateFigureHeight(StructuralCache structuralCache, Figure figure, FigureLength figureLength, out bool isHeightAuto)
        {
            double value; 

            if(figureLength.IsPage) 
            { 
                value = (structuralCache.CurrentFormatContext.PageHeight) * figureLength.Value;
            }
            else if(figureLength.IsContent) // Column to be treated same as content
            {
                Thickness pageMargin = structuralCache.CurrentFormatContext.PageMargin;

                value = (structuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom) * figureLength.Value;
            }
            else if (figureLength.IsColumn)
            {
                // Height is calculated based on column width, since column height is the same as content. Per spec.
                // Retrieve all column metrics for current page
                int cColumns;
                double columnWidth;
                double gap;
                double rule;
                FigureHelper.GetColumnMetrics(structuralCache, out cColumns, out columnWidth, out gap, out rule);

                // We do this to prevent a 2.0 columns from spanning 2.0 + gap, so we just check for edge
                double lengthValue = figureLength.Value;
                if (lengthValue > cColumns)
                {
                    lengthValue = cColumns;
                }
                int columnGapsSpanned = (int)lengthValue;
                if (columnGapsSpanned == lengthValue && columnGapsSpanned > 0)
                {
                    columnGapsSpanned -= 1;
                }

                value = (columnWidth * lengthValue) + gap * columnGapsSpanned;
            }
            else
            {
                value = FigureHelper.CalculateFigureCommon(figureLength);
            }

            if(!DoubleUtil.IsNaN(value))
            {
                FigureVerticalAnchor verticalAnchor = figure.VerticalAnchor;

                // Value is in pixels. Now we limit value to max out depending on anchoring.
                if(FigureHelper.IsVerticalPageAnchor(verticalAnchor))
                {
                    value = Math.Max(1, Math.Min(value, structuralCache.CurrentFormatContext.PageHeight));
                }
                else // Column and paragraph anchoring still max out at content height
                {
                    Thickness pageMargin = structuralCache.CurrentFormatContext.PageMargin;
                    value = Math.Max(1, Math.Min(value, structuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom));
                }

                TextDpi.EnsureValidPageWidth(ref value);

                isHeightAuto = false;
            }
            else
            {
                value = structuralCache.CurrentFormatContext.PageHeight;
                isHeightAuto = true;
            }

            return value;
        }
        private void DrawTab()
        {
            ImageBrush One = new ImageBrush
                {
                    ImageSource =
                      new BitmapImage(
                        new Uri(@"pack://*****:*****@"pack://application:,,,/Images/ChordBG.png", UriKind.RelativeOrAbsolute)
                      )
                };

                tbl.CellSpacing = 2;

                tbl.Margin = new Thickness(0, 10, 0, 0);
                // tbl.Background = new Brush("Images/ChordBG.png");
                for (int x = 0; x < 7; x++)
                {
                    tbl.Columns.Add(new TableColumn());
                    tbl.Columns[tbl.Columns.Count - 1].Width = new GridLength(23);
                }
                tbl.Columns[0].Width = new GridLength(18);
                // Create and add an empty TableRowGroup to hold the table's Rows.
                tbl.RowGroups.Add(new TableRowGroup());
                // Add the first (title) row.
                for (int i = 0; i < 7; i++)
                {
                    TableRow currentRow = new TableRow();
                    tbl.RowGroups[0].Rows.Add(currentRow);

                    for (int j = 0; j < 7; j++)
                    {
                        TableCell cell = new TableCell();
                        currentRow.Cells.Add(cell);
                        cell.BorderThickness = new Thickness(0);
                        cell.Padding = new Thickness(0, 0, 0, 0);
                    }
                }

                // Fill table with fingering values
                string[] vals = Fingering.Split('/');
                string b = vals.Where(a => !a.Contains("-1") && a.Split(',')[0] != "0").Last();
                int MinFrett = Convert.ToInt32(b.Split(',')[0]);

                // Showing the starting Frett
                Paragraph paragraph2 = new Paragraph();
                paragraph2.Inlines.Add(new Run(MinFrett.ToString()));
                tbl.RowGroups[0].Rows[1].Cells[0].Blocks.Add(paragraph2);

                // Showing finger positions
                foreach (string val in vals)
                {
                    string[] points = val.Split(',');
                    if (points.Length == 2)
                    {
                        int ColumnIndex = Math.Abs(Convert.ToInt32(points[1]) - 6);
                        if (points[0] == "-1")
                        {
                            Paragraph paragraph = new Paragraph();
                            paragraph.Inlines.Add(new Run("X"));
                            tbl.RowGroups[0].Rows[0].Cells[ColumnIndex].Blocks.Add(paragraph);
                        }
                        else
                        {
                            Paragraph paragraph = new Paragraph();
                            paragraph.Inlines.Add(new Run("O"));
                            tbl.RowGroups[0].Rows[0].Cells[ColumnIndex].Blocks.Add(paragraph);
                        }
                    }
                    else
                    {
                        int RowIndex = Convert.ToInt32(points[0]) - MinFrett + 1;
                        int ColumnIndex = Math.Abs(Convert.ToInt32(points[1]) - 6);

                        Paragraph paragraph = new Paragraph();
                        paragraph.Inlines.Add(new Run(points[2]));
                        tbl.RowGroups[0].Rows[RowIndex].Cells[ColumnIndex].Blocks.Add(paragraph);

                    }
                }

                fig.Blocks.Add(tbl);
                Paragraph MainParag = new Paragraph(fig);
                doc1.Blocks.Add(MainParag);

            }
        }
 Inline Render(HTMLImageElement element)
 {
     var f = new Figure();
     f.FlowDirection = FlowDirection.LeftToRight;
     var container = new BlockUIContainer();
     var img = new Image();
     img.Stretch = Stretch.None;
     var src = new BitmapImage();
     src.BeginInit();
     src.UriSource = new Uri(url, Sanitize(element.Src));
     src.EndInit();
     f.Blocks.Add(container);
     container.Child = img;
     img.Source = src;
     return f;
 }
        /// <summary>
        /// The write table.
        /// </summary>
        /// <param name="t">
        /// The t.
        /// </param>
        public void WriteTable(Table t)
        {
            var p = new System.Windows.Documents.Paragraph();
            var figure = new Figure();
            var table = new System.Windows.Documents.Table();

            // if (t.HasHeader())
            // {
            // var trg1 = new TableRowGroup();
            // SetStyle(trg1, Style.TableHeaderStyle);
            // var r = new TableRow();
            // foreach (var c in columns)
            // {
            // var cell = new TableCell();
            // var run = new Run() { Text = c.Header };
            // cell.Blocks.Add(new System.Windows.Documents.Paragraph(run));
            // r.Cells.Add(cell);
            // }
            // trg1.Rows.Add(r);
            // table.RowGroups.Add(trg1);
            // }
            var trg2 = new TableRowGroup();

            // SetStyle(trg2, Style.TableTextStyle);
            foreach (var row in t.Rows)
            {
                var r = new TableRow();
                if (row.IsHeader)
                {
                    SetStyle(r, row.IsHeader ? this.Style.TableHeaderStyle : this.Style.TableTextStyle);
                }

                for (int j = 0; j < t.Columns.Count; j++)
                {
                    TableCell c = row.Cells[j];
                    var cell = new System.Windows.Documents.TableCell();
                    var run = new Run { Text = c.Content };
                    cell.Blocks.Add(new System.Windows.Documents.Paragraph(run));
                    r.Cells.Add(cell);
                }

                trg2.Rows.Add(r);
            }

            table.RowGroups.Add(trg2);

            figure.Blocks.Add(this.CreateParagraph(t.Caption, this.Style.FigureTextStyle));
            figure.Blocks.Add(table);
            p.Inlines.Add(figure);
            this.doc.Blocks.Add(p);
        }
Ejemplo n.º 8
0
        private void DrawTab()
        {
            FlowDocument doc1 = new FlowDocument();
            doc1.ColumnWidth = 180;
            FlowDocReader.Document = null;
            FlowDocReader.Document = doc1;
            FlowDocReader.Zoom = 40;

            Chords chrd = new Chords();

            TotalLbl.Content = "Results Found: " + Solutions.Count + "  -  Set of Notes: " + chrd.AllChords[Pitches[0]] + "-" + chrd.AllChords[Pitches[1]] + "-" + chrd.AllChords[Pitches[2]];

            List<Paragraph> content = new List<Paragraph>();

            // if re-order based on difficulty
            if (OrderCombo.SelectedIndex == 1)
                ReOrder();
            else
                FinalSolutions = Solutions.OrderBy(a => Convert.ToInt32(a.Split('/').Where(b => b.Split(',')[0] != "-1" && b.Split(',')[0] != "0").Last().Split(',')[0])).ToList();

            for (int k = 0; k < FinalSolutions.Count; k++)
            {
                Figure fig = new Figure();
                fig.CanDelayPlacement = false;
                // Create Table ...
                Table tbl = new Table();
                tbl.FontSize = 14;
                tbl.Background = new ImageBrush
                {
                    Stretch = Stretch.Fill,
                    ImageSource =
                      new BitmapImage(
                        new Uri(@"pack://application:,,,/Images/ChordBG.png", UriKind.RelativeOrAbsolute)
                      )
                };

                tbl.CellSpacing = 2;

                tbl.Margin = new Thickness(0, 0, 0, 0);
                // tbl.Background = new Brush("Images/ChordBG.png");
                for (int x = 0; x < 7; x++)
                {
                    tbl.Columns.Add(new TableColumn());
                    tbl.Columns[tbl.Columns.Count - 1].Width = new GridLength(23);
                }
                tbl.Columns[0].Width = new GridLength(18);
                // Create and add an empty TableRowGroup to hold the table's Rows.
                tbl.RowGroups.Add(new TableRowGroup());
                // Add the first (title) row.
                for (int i = 0; i < 7; i++)
                {
                    TableRow currentRow = new TableRow();
                    tbl.RowGroups[0].Rows.Add(currentRow);

                    for (int j = 0; j < 7; j++)
                    {
                        TableCell cell = new TableCell();
                        currentRow.Cells.Add(cell);
                        cell.BorderThickness = new Thickness(0);
                        cell.Padding = new Thickness(0, 0, 0, 0);
                    }
                }

                // Fill table with fingering values
                string[] vals = FinalSolutions[k].Split('/');
                string b = vals.Where(a => !a.Contains("-1") && a.Split(',')[0] != "0").Last();
                int MinFrett = Convert.ToInt32(b.Split(',')[0]);

                // Showing the starting Frett
                Paragraph paragraph2 = new Paragraph();
                paragraph2.Inlines.Add(new Run(MinFrett.ToString()));
                tbl.RowGroups[0].Rows[1].Cells[0].Blocks.Add(paragraph2);

                // Showing finger positions
                for (int i = 0; i < vals.Length; i++)
                {
                    string[] points = vals[i].Split(',');
                    if (points.Length == 2)
                    {
                        int ColumnIndex = Math.Abs(Convert.ToInt32(points[1]) - 6);
                        if (points[0] == "-1")
                        {
                            Paragraph paragraph = new Paragraph();
                            paragraph.Inlines.Add(new Run("X"));
                            tbl.RowGroups[0].Rows[0].Cells[ColumnIndex].Blocks.Add(paragraph);
                        }
                        else
                        {
                            Paragraph paragraph = new Paragraph();
                            paragraph.Inlines.Add(new Run("O"));
                            tbl.RowGroups[0].Rows[0].Cells[ColumnIndex].Blocks.Add(paragraph);
                        }
                    }
                    else
                    {
                        int RowIndex = Convert.ToInt32(points[0]) - MinFrett + 1;
                        int ColumnIndex = Math.Abs(Convert.ToInt32(points[1]) - 6);

                        Paragraph paragraph = new Paragraph();
                        paragraph.Inlines.Add(new Run(points[2]));
                        tbl.RowGroups[0].Rows[RowIndex].Cells[ColumnIndex].Blocks.Add(paragraph);

                    }
                }

                fig.Blocks.Add(tbl);
                Paragraph MainParagh = new Paragraph(fig);
                doc1.Blocks.Add(MainParagh);
                //content.Add(MainParagh);

            }

            //doc1.Blocks.AddRange(content);
        }
Ejemplo n.º 9
0
        /// <summary>Re-creates the actual paragraph inlines based on the HTML as well as leading and trailing inlines</summary>
        /// <param name="source">Special Paragraph object</param>
        /// <param name="e">Event arguments</param>
        private static void RepopulateBlocks(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            var section = source as HtmlSection;
            if (section == null) return;

            section.Blocks.Clear();
            var blocks = section.Html.ToBlocks(section.LeadingParagraphHtml, section.TrailingParagraphHtml, section.TrimLeadingParagraphSpaces, section.TrimLeadingParagraphTabs).ToList();
            if (blocks.Count > 0)
            {
                section.Blocks.AddRange(blocks);

                if (section.LeadingBlock != null)
                {
                    var paragraph = section.Blocks.FirstBlock as Paragraph;
                    if (paragraph == null)
                    {
                        paragraph = new Paragraph();
                        section.Blocks.Add(paragraph);
                    }

                    var figure = new Figure
                        {
                            HorizontalAnchor = FigureHorizontalAnchor.ColumnLeft,
                            VerticalAnchor = FigureVerticalAnchor.ParagraphTop,
                            Width = new FigureLength(section.LeadingBlockWidth),
                            Margin = new Thickness(0),
                            Padding = new Thickness(0)
                        };
                    figure.Blocks.Add(section.LeadingBlock);
                    if (paragraph.Inlines.FirstInline != null) paragraph.Inlines.InsertBefore(paragraph.Inlines.FirstInline, figure);
                    else paragraph.Inlines.Add(figure);
                }
            }

            if (!string.IsNullOrEmpty(section.Html2))
            {
                var blocks2 = section.Html2.ToBlocks(string.Empty, string.Empty, section.TrimLeadingParagraphSpaces, section.TrimLeadingParagraphTabs).ToList();
                if (blocks2.Count > 0)
                    section.Blocks.AddRange(blocks2);

                if (section.Style2 != null)
                    foreach (var block in blocks2)
                        block.Style = section.Style2;
            }
        }
Ejemplo n.º 10
0
        private void displayHelp(String title)
        {
            // Load and display the RTF file.
            Uri uri = new Uri("pack://application:,,,/Helps/"+title+"Text.rtf");
            StreamResourceInfo info = Application.GetResourceStream(uri);
            using (StreamReader txtReader = new StreamReader(info.Stream))
            {
                _txtHelpContent.Text = txtReader.ReadToEnd();
                try
                {
                    BitmapImage bitmap = new BitmapImage(new Uri("pack://application:,,,/Helps/" + title + ".png"));
                    if (bitmap != null)
                    {
                        Paragraph para = new Paragraph();
                        para.Inlines.Add(new Run("Image "));
                        fld.Blocks.Add(para);

                        // Add an image
                        para = new Paragraph();
                        Image image = new Image();
                        image.Source = bitmap;
                        Figure figure = new Figure();
                        figure.Width = new FigureLength(200);
                        BlockUIContainer container = new BlockUIContainer(image);
                        figure.Blocks.Add(container);
                        para.Inlines.Add(figure);
                        fld.Blocks.Add(para);
                    }
                }
                catch (Exception e)
                {}
            }
        }
Ejemplo n.º 11
0
        public static string ExportToXaml_MultiColumn(OutlinerDocument Document, MainWindow wnd)
        {
            FlowDocument wholeDocument = new FlowDocument();
            wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily;
            wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize;

            List<OutlinerNote> linearList = new List<OutlinerNote>();
            DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false);

            double totalWidth = 0;
            for (int i = 0; i < Document.ColumnDefinitions.Count; i++)
                totalWidth += Document.ColumnDefinitions[i].Width;

            //temporary
            //pageWidth = totalWidth;
            // just random
            if (totalWidth == 0)
                totalWidth = 300;

            Table table = new Table();
            table.LineHeight = 1;
            table.Margin = new Thickness(0);
            table.Padding = new Thickness(0);
            wholeDocument.Blocks.Add(table);
            for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
            {
                int columnId = wnd.GetColumnIdByView(i);
                TableColumn column = new TableColumn();
                //column.Width = new GridLength(Document.ColumnDefinitions[columnId].Width * pageWidth / totalWidth, GridUnitType.Pixel);
                column.Width = new GridLength(Document.ColumnDefinitions[columnId].Width / totalWidth, GridUnitType.Star);
                //column.Width = new GridLength(0, GridUnitType.Auto);
                table.Columns.Add(column);
            }

            // add column headers
            if (Document.ColumnDefinitions.Count > 1)
            {
                TableRowGroup rowGroup = new TableRowGroup();
                table.RowGroups.Add(rowGroup);

                TableRow row = new TableRow();
                rowGroup.Rows.Add(row);
                for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++)
                {
                    int columnId = wnd.GetColumnIdByView(i);
                    row.Cells.Add(new TableCell(new Paragraph(new Run(Document.ColumnDefinitions[columnId].ColumnName))));
                }
            }

            TableRowGroup mainRowGroup = new TableRowGroup();
            table.RowGroups.Add(mainRowGroup);

            // add all other columns
            for (int i = 0; i < linearList.Count; i++)
            {
                TableRow tableRow = new TableRow();
                OutlinerNote note = linearList[i];

                if (note.IsEmpty)
                {
                    tableRow.Cells.Add(new TableCell(new Paragraph()));
                    mainRowGroup.Rows.Add(tableRow);
                    continue;
                }

                for (int c = 0; c < wnd.OutlinerTreeColumns.Count; c++)
                {
                    int columnId = wnd.GetColumnIdByView(c);

                    FlowDocument flowDocument = linearList[i].Columns[columnId].ColumnData as FlowDocument;
                    if (flowDocument == null)
                    {
                        tableRow.Cells.Add(new TableCell());
                        continue;
                    }

                    double indent = (Math.Max(0, note.Level - 1)) * 20;

                    TableCell cell = new TableCell();
                    tableRow.Cells.Add(cell);

                    Section section = XamlReader.Load(ExportToXaml_Printing.TransformFlowDocumentToSection(flowDocument)) as Section;
                    if (section == null)
                        continue;

                    if (columnId != 0)
                        cell.Blocks.Add(section);
                    else
                    {
                        Paragraph para = new Paragraph();
                        para.Margin = new Thickness(indent, 0, 0, 0);

                        Image expImage = new Image();
                        expImage.Margin = new Thickness(0, 2, 0, 0);
                        expImage.Width = 14;
                        expImage.Height = 14;
                        expImage.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

                        BitmapImage bImage = new BitmapImage();

                        if (note.SubNotes.Count == 0)
                            bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/bullet.png");
                        else
                        {
                            if (note.IsExpanded)
                                bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_expanded.png");
                            else
                                bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_collapsed.png");
                        }

                        expImage.Source = bImage;
                        expImage.Stretch = Stretch.None;
                        para.Inlines.Add(expImage);

                        if (Document.CheckboxesVisble)
                        {
                            Image checkBox = new Image();
                            checkBox.Margin = new Thickness(0, 2, 0, 0);
                            checkBox.Width = 14;
                            checkBox.Height = 14;
                            checkBox.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

                            var checkSource = new BitmapImage();
                            if (note.IsChecked == true)
                                checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_checked.png");
                            else
                                checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_unchecked.png");

                            checkBox.Source = checkSource;
                            checkBox.Stretch = Stretch.None;
                            para.Inlines.Add(checkBox);
                        }

                        Paragraph par = new Paragraph();

                        Figure fig1 = new Figure();
                        fig1.Margin = new Thickness(0);
                        fig1.HorizontalAnchor = FigureHorizontalAnchor.PageLeft;
                        fig1.Blocks.Add(para);

                        Figure fig2 = new Figure();
                        fig2.Margin = new Thickness(0);
                        fig2.HorizontalAnchor = FigureHorizontalAnchor.PageLeft;
                        fig2.Blocks.Add(section);

                        par.Inlines.Add(fig1);
                        par.Inlines.Add(fig2);

                        cell.Blocks.Add(par);
                    }
                }

                mainRowGroup.Rows.Add(tableRow);
                if (note.HasInlineNote)
                    ExportToXaml_Printing.AddInlineNote(mainRowGroup.Rows, note, true);
            }

            MemoryStream outStream = new MemoryStream();
            XmlWriterSettings settings = new XmlWriterSettings();
            //settings.Indent = true;
            XmlWriter writer = XmlWriter.Create(outStream, settings);
            XamlDesignerSerializationManager manager = new XamlDesignerSerializationManager(writer);
            XamlWriter.Save(wholeDocument, manager);

            outStream.Seek(0, SeekOrigin.Begin);
            StreamReader reader = new StreamReader(outStream);
            return reader.ReadToEnd();
        }
Ejemplo n.º 12
0
        public static string ExportToXaml_SingleColumn(OutlinerDocument Document, MainWindow wnd)
        {
            FlowDocument wholeDocument = new FlowDocument();
            wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily;
            wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize;

            List<OutlinerNote> linearList = new List<OutlinerNote>();
            DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false);

            // add all other columns
            for (int i = 0; i < linearList.Count; i++)
            {
                OutlinerNote note = linearList[i];

                if (note.IsEmpty)
                {
                    wholeDocument.Blocks.Add(new Paragraph());
                    continue;
                }

                FlowDocument flowDocument = linearList[i].Columns[0].ColumnData as FlowDocument;
                if (flowDocument == null)
                    continue;

                Section section = XamlReader.Load(ExportToXaml_Printing.TransformFlowDocumentToSection(flowDocument)) as Section;
                if (section == null)
                    continue;

                double indent = (Math.Max(0, note.Level - 1)) * 20;
                Paragraph para = new Paragraph();
                para.Margin = new Thickness(indent, 0, 0, 0);
                Image expImage = new Image();
                expImage.Margin = new Thickness(0, 2, 0, 0);
                expImage.Width = 14;
                expImage.Height = 14;
                expImage.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

                BitmapImage bImage = new BitmapImage();

                if (note.SubNotes.Count == 0)
                    bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/bullet.png");
                else
                {
                    if (note.IsExpanded)
                        bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_expanded.png");
                    else
                        bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_collapsed.png");
                }

                expImage.Source = bImage;
                expImage.Stretch = Stretch.None;
                para.Inlines.Add(expImage);

                if (Document.CheckboxesVisble)
                {
                    Image checkBox = new Image();
                    checkBox.Margin = new Thickness(0, 2, 0, 0);
                    checkBox.Width = 14;
                    checkBox.Height = 14;
                    checkBox.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

                    var checkSource = new BitmapImage();
                    if (note.IsChecked == true)
                        checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_checked.png");
                    else
                        checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_unchecked.png");

                    checkBox.Source = checkSource;
                    checkBox.Stretch = Stretch.None;
                    para.Inlines.Add(checkBox);
                }

                Paragraph par = new Paragraph();
                Figure fig1 = new Figure();
                fig1.Margin = new Thickness(0);
                fig1.Padding = new Thickness(0);
                fig1.HorizontalAnchor = FigureHorizontalAnchor.PageLeft;
                fig1.Blocks.Add(para);

                Figure fig2 = new Figure();
                fig2.Margin = new Thickness(0);
                fig2.Padding = new Thickness(0);
                fig2.HorizontalAnchor = FigureHorizontalAnchor.PageLeft;
                fig2.Blocks.Add(section);

                par.Inlines.Add(fig1);
                par.Inlines.Add(fig2);
                wholeDocument.Blocks.Add( new Section(par));
            }

            MemoryStream outStream = new MemoryStream();
            XmlWriterSettings settings = new XmlWriterSettings();
            //settings.Indent = true;
            XmlWriter writer = XmlWriter.Create(outStream, settings);
            XamlDesignerSerializationManager manager = new XamlDesignerSerializationManager(writer);
            XamlWriter.Save(wholeDocument, manager);

            outStream.Seek(0, SeekOrigin.Begin);
            StreamReader reader = new StreamReader(outStream);
            return reader.ReadToEnd();
        }