コード例 #1
3
        public static FixedDocument CreateFixedDocument(double pageWidth, double pageHeight, UIElement content)
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }

            if (pageWidth <= 0 || pageHeight <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            RenderTargetBitmap renderTarget = new RenderTargetBitmap(Convert.ToInt32(content.RenderSize.Width), Convert.ToInt32(content.RenderSize.Height),
                Constants.ScreenDPI, Constants.ScreenDPI, PixelFormats.Pbgra32);
            renderTarget.Render(content);

            FixedDocument doc = new FixedDocument();
            Size pageSize = new Size(pageWidth, pageHeight);
            doc.DocumentPaginator.PageSize = pageSize;
            FixedPage fixedPage = new FixedPage();
            fixedPage.Width = pageWidth;
            fixedPage.Height = pageHeight;
            Image image = new Image();
            image.Height = pageHeight;
            image.Width = pageWidth;
            image.Stretch = Stretch.Uniform;
            image.StretchDirection = StretchDirection.Both;
            image.Source = renderTarget;
            fixedPage.Children.Add(image);

            PageContent pageContent = new PageContent();
            ((IAddChild)pageContent).AddChild(fixedPage);
            doc.Pages.Add(pageContent);
            return doc;
        }
コード例 #2
0
        public PageBuilder(double width, double height, int marginsLeft, int marginsTop, int marginsRight, int marginsBottom, ContentControl frame)
        {
            _page = new PageContent();
              _fixedPage = new FixedPage {Background = Brushes.White, Width = width, Height = height};

              _repeater = new Repeater();
              var repeatContainer = new Grid {Margin = new Thickness(marginsLeft, marginsTop, marginsRight, marginsBottom)};
              repeatContainer.Children.Add(_repeater);

              frame.SetValue(FixedPage.LeftProperty, 0.00);
              frame.SetValue(FixedPage.TopProperty, 0.00);
              frame.SetValue(FrameworkElement.WidthProperty, _fixedPage.Width);
              frame.SetValue(FrameworkElement.HeightProperty, _fixedPage.Height);

              _fixedPage.Children.Add(frame);
              ((IAddChild)_page).AddChild(_fixedPage);

              frame.Content = repeatContainer;

              frame.Measure(new Size(width, height));
              frame.Arrange(new Rect(0, 0, width, height));

              _repeater.Width = repeatContainer.ActualWidth;
              _repeater.Height = repeatContainer.ActualHeight;
        }
コード例 #3
0
ファイル: home.xaml.cs プロジェクト: sumit10/BMS
 private void print_btn_Click(object sender, RoutedEventArgs e)
 {
     try
      {
             report.report_cr_dr p = new BMS.report.report_cr_dr();
         p.lst_balance.ItemsSource = dr;
         p.r_date.Content = DateTime.Now.Date.ToShortDateString();
         p.r_name.Content = "Top Debitors";
         PrintDialog pd = new PrintDialog();
         FixedDocument document = new FixedDocument();
         document.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);
         FixedPage page1 = new FixedPage();
         page1.Width = document.DocumentPaginator.PageSize.Width;
         page1.Height = document.DocumentPaginator.PageSize.Height;
         Canvas can = p.layout;
         page1.Children.Add(can);
         PageContent page1Content = new PageContent();
         ((IAddChild)page1Content).AddChild(page1);
         document.Pages.Add(page1Content);
         pd.PrintDocument(document.DocumentPaginator, "My first document");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Sorry some system error has occour please try again");
     }
 }
コード例 #4
0
    private FixedPage CreateFifthPageContent()
    {
      //PageContent pageContent = new PageContent();
      FixedPage fixedPage = new FixedPage();
      UIElement visual = BuildDrawing(); // CreateThirdVisual(false);

      FixedPage.SetLeft(visual, 0);
      FixedPage.SetTop(visual, 0);

      double pageWidth = 96 * 8.5;
      double pageHeight = 96 * 11;

      fixedPage.Width = pageWidth;
      fixedPage.Height = pageHeight;

      fixedPage.Children.Add((UIElement)visual);

      Size sz = new Size(8.5 * 96, 11 * 96);
      fixedPage.Measure(sz);
      fixedPage.Arrange(new Rect(new Point(), sz));
      fixedPage.UpdateLayout();

      //((IAddChild)pageContent).AddChild(fixedPage);
      return fixedPage;
    }
コード例 #5
0
ファイル: FileHelper.cs プロジェクト: mydipcom/MEIKReport
        public static bool SaveXPS(FixedPage page, bool isSaved)
        {
            FixedDocument fixedDoc = new FixedDocument();//创建一个文档
            fixedDoc.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);

            PageContent pageContent = new PageContent();
            ((IAddChild)pageContent).AddChild(page);
            fixedDoc.Pages.Add(pageContent);//将对象加入到当前文档中

            string containerName = GetXPSFromDialog(isSaved);
            if (containerName != null)
            {
                try
                {
                    File.Delete(containerName);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }

                XpsDocument _xpsDocument = new XpsDocument(containerName, FileAccess.Write);

                XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);
                xpsdw.Write(fixedDoc);//写入XPS文件
                _xpsDocument.Close();
                return true;
            }
            else return false;
        }
コード例 #6
0
        private PageContent CreatePawnTicketContent()
        {
            PageContent pageContent = new PageContent();
            FixedPage fixedPage = new FixedPage();
            UIElement visual = PawnTicketUIElement();

            FixedPage.SetLeft(visual, 0);
            FixedPage.SetTop(visual, 0);

            double pageWidth = 96 * 8.5;
            double pageHeight = 96 * 11;

            fixedPage.Width = pageWidth;
            fixedPage.Height = pageHeight;

            fixedPage.Children.Add((UIElement)visual);

            Size sz = new Size(8.5 * 96, 11 * 96);
            fixedPage.Measure(sz);
            fixedPage.Arrange(new Rect(new Point(), sz));
            fixedPage.UpdateLayout();

            ((IAddChild)pageContent).AddChild(fixedPage);
            return pageContent;
        }
コード例 #7
0
 public void AddPage(int docIndex, FixedPage page)
 {
     var rollUpFixedDocument = _documents[docIndex];
     TestForExistingPages(rollUpFixedDocument);
     rollUpFixedDocument.Pages.Add(new RollUpFixedPage(page));
     _fixedDocumentSequence = null;
 }
コード例 #8
0
ファイル: XpsHelper.cs プロジェクト: cipjota/Chronos
        public static FixedDocument FixedDocumentFromImageStream(Stream[] ImagesStream)
        {
            FixedDocument fdReturn = new FixedDocument();

            foreach (Stream streamImage in ImagesStream)
            {
                FixedPage fpFromImage = new FixedPage();

                var bitImage = new BitmapImage();
                bitImage.BeginInit();
                bitImage.StreamSource = streamImage;
                bitImage.DecodePixelWidth = 250;
                bitImage.CacheOption = BitmapCacheOption.OnLoad;
                bitImage.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
                bitImage.EndInit();
                bitImage.StreamSource.Seek(0, System.IO.SeekOrigin.Begin);
                bitImage.Freeze();

                var tempImage = new System.Windows.Controls.Image { Source = bitImage };
                //var imageObject = new ImageObject(tempImage, fileName);

                fpFromImage.Children.Add(tempImage);
                fdReturn.Pages.Add(new PageContent() { Child = fpFromImage });

                bitImage.StreamSource.Dispose();
            }

            return fdReturn;
        }
コード例 #9
0
        private void btnPrint_Click_1(object sender, RoutedEventArgs e)
        {
            var printControl = new SummaryControl();
            printControl.DataContext = _reservation;
            printControl.Width = 8.27 * 96;
            printControl.Height = 11.69 * 96;

            //Create a fixed Document and Print the document
            FixedDocument fixedDoc = new FixedDocument();
            PageContent pageContent = new PageContent();
            FixedPage fixedPage = new FixedPage();
            fixedPage.Height = 11.69 * 96;
            fixedPage.Width = 8.27 * 96;

            fixedPage.Children.Add(printControl);
            ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
            fixedDoc.Pages.Add(pageContent);

            PrintDialog dialog = new PrintDialog();
            if (dialog.ShowDialog() == true)
            {
                //dialog.PrintVisual(_PrintCanvas, "My Canvas");
                dialog.PrintDocument(fixedDoc.DocumentPaginator, "Print label");
            }
        }
コード例 #10
0
		public static FixedPage CreateFixedPage(ExportPage exportPage) {
			var fixedPage = new FixedPage();
			fixedPage.Width = exportPage.Size.ToWpf().Width;
			fixedPage.Height = exportPage.Size.ToWpf().Height;
			fixedPage.Background = new SolidColorBrush(System.Drawing.Color.White.ToWpf());
			return fixedPage;
		}
コード例 #11
0
        private void btnXpsDocumentWriter_Click(object sender, RoutedEventArgs e)
        {
            using (Package xpsPackage = Package.Open("Out.xps", FileMode.Create,
                           FileAccess.ReadWrite))
            using (XpsDocument doc = new XpsDocument(xpsPackage))
            {

                FixedPage page = new FixedPage();
                Canvas canvas = new Canvas();
                canvas.Width = 600;
                canvas.Height = 400;
                page.Children.Add(canvas);
                Rectangle rect = new Rectangle();
                Canvas.SetLeft(rect, 50);
                Canvas.SetTop(rect, 50);
                rect.Width = 200;
                rect.Height = 100;
                rect.Stroke = Brushes.Black;
                rect.StrokeThickness = 1;
                canvas.Children.Add(rect);
                XpsDocumentWriter documentWriter =
                XpsDocument.CreateXpsDocumentWriter(doc);
                documentWriter.Write(page);

                doc.CoreDocumentProperties.Description = "Rectangle Output";
            }
        }
コード例 #12
0
        private static IDocumentPaginatorSource CreateDesignTimeDocument(Size pageSize)
        {
            var document = new FixedDocument();
            document.DocumentPaginator.PageSize = pageSize;

            // ---- Page 1
            var page1 = new FixedPage { Width = pageSize.Width, Height = pageSize.Height };

            var page1Text = new TextBlock
            {
                FontSize = 16,
                Margin = new Thickness(96),
                Text = "Lorem ipsum dolor sit amet."
            };
            page1.Children.Add(page1Text);

            var page1Content = new PageContent();
            ((IAddChild)page1Content).AddChild(page1);
            document.Pages.Add(page1Content);

            // ---- Page 2
            // ...

            return document;
        }
コード例 #13
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var dialog = new PrintDialog();
            document.DocumentPaginator.PageSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);
            fixedPage = new FixedPage
            {
                Height = document.DocumentPaginator.PageSize.Height,
                Width = document.DocumentPaginator.PageSize.Width
            };
            grid = new Grid();
            grid.Arrange(new Rect(0, 0, fixedPage.Width, fixedPage.Height));
            fixedPage.Children.Add(grid);
            pageContent = new PageContent { Child = fixedPage };
            pageContent.Arrange(new Rect(0, 0, fixedPage.Width, fixedPage.Height));
            fixedPage.Margin = new Thickness(20, 44, 20, 44);

            for (int i = 0; i < totalRows; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition());
            }
            for (int j = 0; j < totalColumns; j++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            document.Pages.Add(pageContent);
        }
コード例 #14
0
ファイル: WpfExporter.cs プロジェクト: ichengzi/SharpDevelop
        static void AddPageToDocument(FixedDocument fixedDocument,FixedPage page)
        {
            PageContent pageContent = new PageContent();
            ((IAddChild)pageContent).AddChild(page);

            fixedDocument.Pages.Add(pageContent);
        }
コード例 #15
0
ファイル: FixedSOMElement.cs プロジェクト: JianwenSun/cc
        //--------------------------------------------------------------------
        //
        // Public Properties
        //
        //---------------------------------------------------------------------

        #region Static methods

        public static FixedSOMElement CreateFixedSOMElement(FixedPage page, UIElement uiElement, FixedNode fixedNode, int startIndex, int endIndex)
        {
            FixedSOMElement element = null;
            if (uiElement is Glyphs)
            {
                Glyphs glyphs = uiElement as Glyphs;
                if (glyphs.UnicodeString.Length > 0)
                {
                    GlyphRun glyphRun = glyphs.ToGlyphRun();
                    Rect alignmentBox = glyphRun.ComputeAlignmentBox();
                    alignmentBox.Offset(glyphs.OriginX, glyphs.OriginY);
                    GeneralTransform transform = glyphs.TransformToAncestor(page);
                    
                    if (startIndex < 0)
                    {
                        startIndex = 0;
                    }
                    if (endIndex < 0)
                    {
                        endIndex = glyphRun.Characters == null ? 0 : glyphRun.Characters.Count;
                    }
                    element = FixedSOMTextRun.Create(alignmentBox, transform, glyphs, fixedNode, startIndex, endIndex, false);
                }
            }
            else if (uiElement is Image)
            {
                element = FixedSOMImage.Create(page, uiElement as Image, fixedNode);
            }
            else if (uiElement is Path)
            {
                element = FixedSOMImage.Create(page, uiElement as Path, fixedNode);
            }
            return element;
        }
コード例 #16
0
ファイル: print.cs プロジェクト: K0lyuchiy/Tass
        public void printing_2(Grid grid_table_print)
        {
            DocumentViewer documentViewer1 = new DocumentViewer();
            FixedDocument fixedDoc = new FixedDocument();
            PageContent pgc = new PageContent();
            FixedPage fxp = new FixedPage();
            //A4
            fxp.Width = 11.69 * 96;
            fxp.Height = 8.27 * 96;

            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Vertical;
            panel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            panel.Width = (11.69 * 96) * 0.9;
            panel.Orientation = Orientation.Vertical;
            Thickness margin = panel.Margin;
            margin.Bottom = 0;
            margin.Left = 50;
            margin.Top = 50;
            margin.Right = 25;
            panel.Margin = margin;
            BitmapImage bmp_ = new BitmapImage();
            Label test_lb = new Label();
            test_lb.Content = "\n\n\t\t\tРежим расчетов \n \tОцифровка в автоматическом режиме";
            margin = test_lb.Margin;
            margin.Bottom = 50;
            margin.Left = 50;
            margin.Top = 50;
            margin.Right = 0;
            test_lb.BorderThickness = margin;

            panel.Children.Add(test_lb);

            ImageSource imageSource = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + "\\file.jpg"));

            Image img = new Image();
            img.Source = imageSource;
            panel.Children.Add(img);

            Grid grid_table_print_copy = new Grid();// { DataContext = grid_table_print.DataContext };
            string gridXaml = XamlWriter.Save(grid_table_print);
            StringReader stringReader = new StringReader(gridXaml);
            XmlReader xmlReader = XmlReader.Create(stringReader);
            grid_table_print_copy = (Grid)XamlReader.Load(xmlReader);

            panel.Children.Add(grid_table_print_copy);

            fxp.Children.Add(panel);

            ((System.Windows.Markup.IAddChild)pgc).AddChild(fxp);
            fixedDoc.Pages.Add(pgc);

            documentViewer1.Document = fixedDoc;
            Window ShowWindow = new Window();
            ShowWindow.Width = 850;
            ShowWindow.Height = 850;
            ShowWindow.Content = documentViewer1;
            ShowWindow.Show();
        }
コード例 #17
0
 /// <summary>
 /// Creates a FixedPage from string.
 /// </summary>
 /// <param name="text">Text of page.</param>
 /// <returns>FixedPage from text.</returns>
 public static FixedPage CreateFixedPage(string text)
 {
     FixedPage page = new FixedPage();
     TextBlock block = new TextBlock();
     block.Inlines.Add(text);
     page.Children.Add(block);
     return page;
 }
コード例 #18
0
ファイル: WpfVisitor.cs プロジェクト: lvv83/SharpDevelop
		public override void Visit(ExportPage page){
			fixedPage = FixedDocumentCreator.CreateFixedPage(page);
			FixedPage = fixedPage;
			foreach (var element in page.ExportedItems) {
				AsAcceptor(element).Accept(this);
				fixedPage.Children.Add(sectionCanvas);
			}
		}
コード例 #19
0
        public override void SetSize(FixedPage fixedPage)
        {
            var converter = new LengthConverter();

            // ReSharper disable once PossibleNullReferenceException
            fixedPage.Width = (double)converter.ConvertFromInvariantString("29.7cm");
            // ReSharper disable once PossibleNullReferenceException
            fixedPage.Height = (double)converter.ConvertFromInvariantString("21cm");
        }
コード例 #20
0
		void CreatePageInternal(FixedPage page, ExporterCollection items)
		{
			foreach (var element in items)
			{
				var item = ItemFactory(element);
				if (item != null) {
					FixedPage.SetLeft(item,element.StyleDecorator.Location.X );
					FixedPage.SetTop(item,element.StyleDecorator.Location.Y);
					page.Children.Add(item);
				}
			}
		}
コード例 #21
0
ファイル: printtest.xaml.cs プロジェクト: sumit10/BMS
        private void PrintSimpleTextButton_Click(object sender, RoutedEventArgs e)
        {
            //    PrintDialog printDlg = new PrintDialog();

            //    // Create a FlowDocument dynamically.
            //    FlowDocument doc = CreateFlowDocument();
            //    doc.Name = "FlowDoc";

            //    // Create IDocumentPaginatorSource from FlowDocument
            //    IDocumentPaginatorSource idpSource = doc;

            //    // Call PrintDocument method to send document to printer
            //    printDlg.PrintDocument(idpSource.DocumentPaginator, "Hello WPF Printing.");
            PrintDialog pd = new PrintDialog();
            if (pd.ShowDialog() != true) return;
            FixedDocument document = new FixedDocument();
            document.DocumentPaginator.PageSize = new Size(8.5,11);
            FixedPage page1 = new FixedPage();
            page1.Width = document.DocumentPaginator.PageSize.Width;
            page1.Height = document.DocumentPaginator.PageSize.Height;
            Canvas can = new Canvas();
            TextBlock page1Text = new TextBlock();
            page1Text.Text = "This is the first page";
            page1Text.FontSize = 10; // 30pt text
            page1Text.Margin = new Thickness(5, 20, 30, 10);
            can.Children.Add(page1Text);
             // 1 inch margin
            //page1.Children.Add(page1Text);
            page1.Width = document.DocumentPaginator.PageSize.Width;
            page1.Height = document.DocumentPaginator.PageSize.Height;
            TextBlock page2Text = new TextBlock();
            page2Text.Text = "This is the first page";
            page2Text.FontSize = 40; // 30pt text
            page2Text.Margin = new Thickness(5, 20, 30, 10); // 1 inch margin
            can.Children.Add(page2Text);
            page1.Children.Add(can);
            PageContent page1Content = new PageContent();
            ((IAddChild)page1Content).AddChild(page1);
            document.Pages.Add(page1Content);
            //FixedPage page2 = new FixedPage();
            //page2.Width = document.DocumentPaginator.PageSize.Width;
            //page2.Height = document.DocumentPaginator.PageSize.Height;
            //TextBlock page2Text = new TextBlock();
            //page2Text.Text = "This is NOT the first page";
            //page2Text.FontSize = 40;
            //page2Text.Margin = new Thickness(96);
            //page2.Children.Add(page2Text);
            //PageContent page2Content = new PageContent();
            //((IAddChild)page2Content).AddChild(page2);
            //document.Pages.Add(page2Content);
            pd.PrintDocument(document.DocumentPaginator, "My first document");
        }
コード例 #22
0
 //--------------------------------------------------------------------
 //
 // Ctor
 //
 //---------------------------------------------------------------------
 #region Ctor
 internal PageContentAsyncResult(AsyncCallback callback, object state, Dispatcher dispatcher, Uri baseUri, Uri source, FixedPage child)
 {
     this._dispatcher = dispatcher;
     this._isCompleted = false;
     this._completedSynchronously = false;
     this._callback = callback;
     this._asyncState = state;
     this._getpageStatus = GetPageStatus.Loading;
     this._child  = child;
     this._baseUri = baseUri;
     Debug.Assert(source == null || source.IsAbsoluteUri);
     this._source = source;
 }
コード例 #23
0
        public void Create()
        {
            var uri    = new Uri("pack://application:,,,/ypi_client_order.xps");
            var stream = System.Windows.Application.GetResourceStream(uri).Stream;

            System.IO.Packaging.Package package1 = System.IO.Packaging.Package.Open(stream);
            System.IO.Packaging.PackageStore.AddPackage(uri, package1);
            var xpsDoc = new XpsDocument(package1, System.IO.Packaging.CompressionOption.Maximum, uri.AbsoluteUri);
            var fixedDocumentSequenceO = xpsDoc.GetFixedDocumentSequence();

            MemoryStream xpsStream       = new MemoryStream();
            Package      package2        = Package.Open(xpsStream, FileMode.Create);
            string       memoryStreamUri = "memorystream://printstream";
            Uri          packageUri      = new Uri(memoryStreamUri);

            PackageStore.AddPackage(packageUri, package2);
            XpsDocument       doc    = new XpsDocument(package2, CompressionOption.Fast, memoryStreamUri);
            XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);

            System.Windows.Documents.Serialization.SerializerWriterCollator vxpsd = writer.CreateVisualsCollator();
            int pageno = 1;

            foreach (System.Windows.Documents.DocumentReference r in fixedDocumentSequenceO.References)
            {
                System.Windows.Documents.FixedDocument d = r.GetDocument(false);
                foreach (System.Windows.Documents.PageContent pc in d.Pages)
                {
                    System.Windows.Documents.FixedPage fixedPage = pc.GetPageRoot(false);
                    double width           = fixedPage.Width;
                    double height          = fixedPage.Height;
                    System.Windows.Size sz = new System.Windows.Size(width, height);
                    fixedPage.Measure(sz);
                    fixedPage.Arrange(new System.Windows.Rect(new System.Windows.Point(), sz));
                    fixedPage.UpdateLayout();
                    ContainerVisual newpage = new ContainerVisual();
                    newpage.Children.Add(fixedPage);
                    newpage.Children.Add(CreateWatermark(400, 400, "hello world"));
                    pageno++;
                    vxpsd.Write(newpage);

                    //PackageStore.RemovePackage(packageUri);
                    //doc.Close();
                }
            }

            doc.Close();
            xpsStream.Position = 0;
            Package     finalPackage          = Package.Open(xpsStream, FileMode.Open);
            XpsDocument finalDoc              = new XpsDocument(finalPackage, CompressionOption.Fast, memoryStreamUri);
            var         fixedDocumentSequence = xpsDoc.GetFixedDocumentSequence();
        }
コード例 #24
0
        /// <summary>
        /// Render a UIElement such that the visual tree is generated, 
        /// without actually displaying the UIElement
        /// anywhere
        /// </summary>
        public static void CreateVisualTree(this UIElement element)
        {
            var fixedDoc = new FixedDocument();
            var pageContent = new PageContent();
            var fixedPage = new FixedPage();
            fixedPage.Children.Add(element);
            ((IAddChild)pageContent).AddChild(fixedPage);
            fixedDoc.Pages.Add(pageContent);

            var f = new XpsSerializerFactory();
            using(var s = new MemoryStream())
            {
                var w = f.CreateSerializerWriter(s);
                w.Write(fixedDoc);
            }
        }
コード例 #25
0
ファイル: XpsDoc.cs プロジェクト: dingxinbei/OLdBck
        public static IDocumentPaginatorSource CreateXpsDocument(string ss, string ssname)
        {
            FixedPage fp = new FixedPage();
            TextBox ll = new TextBox();
            ll.Margin = new Thickness(20, 40, 20, 40);
            fp.Children.Add(ll);
            fp.UpdateLayout();

            ll.TextWrapping = TextWrapping.WrapWithOverflow;
            ll.Text = ssname + Environment.NewLine + Environment.NewLine + ss;
            PageContent pc = new PageContent();
            ((System.Windows.Markup.IAddChild)pc).AddChild(fp);
            FixedDocument fd = new FixedDocument();
            fd.Pages.Add(pc);
            return fd;
        }
コード例 #26
0
ファイル: PrintForm.xaml.cs プロジェクト: BdGL3/CXPortal
        public List<PageContent> PrintPage()
        {
            List<PageContent> Pages = new List<PageContent>();

            PrintDialog printDialog = new PrintDialog();

            foreach (ImageInfo imageInfo in OCRImages_ListBox.SelectedItems)
            {
                PageContent pageContent = new PageContent();
                FixedPage fixedPage = new FixedPage();

                bool rotate = false;

                double width = printDialog.PrintableAreaWidth;
                double height = printDialog.PrintableAreaHeight;

                if (imageInfo.imageSource.Width > imageInfo.imageSource.Height)
                {
                    width = printDialog.PrintableAreaHeight;
                    height = printDialog.PrintableAreaWidth;
                    rotate = true;
                }

                PrintPreview printPreview = new PrintPreview(m_CaseObject, width, height);
                printPreview.SetImage(imageInfo.imageSource);

                fixedPage.Children.Add((UIElement)printPreview);

                if (rotate)
                {
                    double pageWidth = printDialog.PrintableAreaWidth;
                    double pageHeight = printDialog.PrintableAreaHeight;

                    TranslateTransform tt = new TranslateTransform((pageWidth - pageHeight) / 2, (pageHeight - pageWidth) / 2);
                    printPreview.RenderTransform = tt;

                    RotateTransform rotateTransform = new RotateTransform(-90D, pageWidth / 2D, pageHeight / 2D);
                    fixedPage.RenderTransform = rotateTransform;
                }

                ((IAddChild)pageContent).AddChild(fixedPage);

                Pages.Add(pageContent);
            }

            return Pages;
        }
コード例 #27
0
ファイル: ReportPage.cs プロジェクト: WilliamCopland/YPILIS
        /// <summary>default constructor
        /// </summary>
        /// <param name="header">page header object</param>
        /// <param name="footer">page footer object</param>
        public ReportPage(HeaderFooterBase header, HeaderFooterBase footer)
        {
            PageContent = new PageContent();
            FixedPage = new FixedPage() { Background = Brushes.White, Width = m_DisplayResolution * m_PageWidth, Height = m_DisplayResolution * m_PageHeight };
            ((IAddChild)PageContent).AddChild(FixedPage);

            m_HeaderGrid = new Grid();
            m_FooterGrid = new Grid();
            BodyGrid = XPSHelper.GetGrid(0, 1);

            header.Write(m_HeaderGrid);
            footer.Write(m_FooterGrid);

            WriteItemToPage(m_HeaderGrid, m_PageTopMargin, m_PageTopMargin);
            WriteItemToPage(BodyGrid, m_PageLeftMargin, m_HeaderGrid.ActualHeight / m_DisplayResolution + m_HeaderToBodyGap);
            WriteItemToPage(m_FooterGrid, m_PageLeftMargin, double.MinValue, double.MinValue, m_PageBottomMargin);
        }
コード例 #28
0
        /// <summary>
        /// PrintDialogを使用した印刷を行います。
        /// </summary>
        private void PrintDocument()
        {
            var dlg = new PrintDialog();
            if (dlg.ShowDialog() == true)
            {
                var page = new FixedPage();
                page.Children.Add(new SampleReport());

                var cont = new PageContent();
                cont.Child = page;

                var doc = new FixedDocument();
                doc.Pages.Add(cont);

                dlg.PrintDocument(doc.DocumentPaginator, "Print1");
            }
        }
コード例 #29
0
ファイル: PrintForm.xaml.cs プロジェクト: BdGL3/CXPortal
        public List<PageContent> PrintPage()
        {
            List<PageContent> Pages = new List<PageContent>();

            PrintDialog printDialog = new PrintDialog();

            PageContent pageContent = new PageContent();
            FixedPage fixedPage = new FixedPage();

            BitmapSource displayAreaSource = RenderVisaulToBitmap(m_FormHost, (int)m_FormHost.ActualWidth, (int)m_FormHost.ActualHeight);

            bool rotate = false;

            double width = printDialog.PrintableAreaWidth;
            double height = printDialog.PrintableAreaHeight;

            if (displayAreaSource.Width > displayAreaSource.Height)
            {
                width = printDialog.PrintableAreaHeight;
                height = printDialog.PrintableAreaWidth;
                rotate = true;
            }

            PrintPreview printPreview = new PrintPreview(m_CaseObject, width, height);
            printPreview.SetImage(displayAreaSource);

            fixedPage.Children.Add((UIElement)printPreview);

            if (rotate)
            {
                double pageWidth = printDialog.PrintableAreaWidth;
                double pageHeight = printDialog.PrintableAreaHeight;

                TranslateTransform tt = new TranslateTransform((pageWidth - pageHeight) / 2, (pageHeight - pageWidth) / 2);
                printPreview.RenderTransform = tt;

                RotateTransform rotateTransform = new RotateTransform(-90D, pageWidth / 2D, pageHeight / 2D);
                fixedPage.RenderTransform = rotateTransform;
            }

            ((IAddChild)pageContent).AddChild(fixedPage);

            Pages.Add(pageContent);

            return Pages;
        }
コード例 #30
0
ファイル: FixedSOMImage.cs プロジェクト: sjyanxin/WPFSource
        //------------------------------------------------------------------- 
        //
        // Public Methods
        //
        //--------------------------------------------------------------------- 

        #region Public Methods 
 
        public static FixedSOMImage Create(FixedPage page, Image image, FixedNode fixedNode)
        { 
            Uri imageUri = null;
            if (image.Source is BitmapImage)
            {
                BitmapImage imageSource = image.Source as BitmapImage; 
                imageUri = imageSource.UriSource;
            } 
            else if (image.Source is BitmapFrame) 
            {
                BitmapFrame imageSource = image.Source as BitmapFrame; 
                imageUri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute);
            }
            Rect sourceRect = new Rect(image.RenderSize);
 
            GeneralTransform transform = image.TransformToAncestor(page);
            return new FixedSOMImage(sourceRect, transform, imageUri, fixedNode, image); 
        } 
コード例 #31
0
        internal void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
        {
            _menus = e.ExtraData as ObservableCollection<MenuEntry>;

            _fixedDocument = new FixedDocument();
            var pageContent1 = new PageContent();
            _fixedDocument.Pages.Add(pageContent1);
            var page1 = new FixedPage();
            pageContent1.Child = page1;
            page1.Children.Add(GetHeaderContent());
            page1.Children.Add(GetLogoContent());
            page1.Children.Add(GetDateContent());
            page1.Children.Add(GetMenuContent());

            viewer.Document = _fixedDocument;

            NavigationService.LoadCompleted -= NavigationService_LoadCompleted;
        }
コード例 #32
0
        public static void DoItTTT()
        {
            string filename    = "c:\\tmp\\goof.xps";
            string newFilename = "c:\\tmp\\new_goof.xps";

            XpsDocument xpsOld = new XpsDocument(filename, System.IO.FileAccess.Read);

            System.Windows.Documents.FixedDocumentSequence seqOld = xpsOld.GetFixedDocumentSequence();
            System.IO.Packaging.Package container = System.IO.Packaging.Package.Open(newFilename, System.IO.FileMode.Create);
            XpsDocumentWriter           writer    = XpsDocument.CreateXpsDocumentWriter(new XpsDocument(container));

            System.Windows.Documents.Serialization.SerializerWriterCollator vxpsd = writer.CreateVisualsCollator();
            int pageno = 1;

            foreach (System.Windows.Documents.DocumentReference r in seqOld.References)
            {
                System.Windows.Documents.FixedDocument d = r.GetDocument(false);
                foreach (System.Windows.Documents.PageContent pc in d.Pages)
                {
                    System.Windows.Documents.FixedPage fixedPage = pc.GetPageRoot(false);
                    double width           = fixedPage.Width;
                    double height          = fixedPage.Height;
                    System.Windows.Size sz = new System.Windows.Size(width, height);
                    fixedPage.Measure(sz);
                    fixedPage.Arrange(new System.Windows.Rect(new System.Windows.Point(), sz));
                    fixedPage.UpdateLayout();
                    ContainerVisual newpage = new ContainerVisual();
                    newpage.Children.Add(fixedPage);
                    newpage.Children.Add(CreateWatermark(400, 400, "hello world"));
                    pageno++;
                    vxpsd.Write(newpage);
                }
            }
            vxpsd.EndBatchWrite();
            container.Close();
            xpsOld.Close();
        }
コード例 #33
0
        // Token: 0x06002EA1 RID: 11937 RVA: 0x000D2BCC File Offset: 0x000D0DCC
        internal void GetMultiHighlights(FixedTextPointer start, FixedTextPointer end, Dictionary <FixedPage, ArrayList> highlights, FixedHighlightType t, Brush foregroundBrush, Brush backgroundBrush)
        {
            if (start.CompareTo(end) > 0)
            {
                FixedTextPointer fixedTextPointer = start;
                start = end;
                end   = fixedTextPointer;
            }
            int num  = 0;
            int num2 = 0;

            FixedSOMElement[] array;
            if (this._GetFixedNodesForFlowRange(start, end, out array, out num, out num2))
            {
                for (int i = 0; i < array.Length; i++)
                {
                    FixedSOMElement fixedSOMElement = array[i];
                    FixedNode       fixedNode       = fixedSOMElement.FixedNode;
                    FixedPage       fixedPage       = this.FixedDocument.SyncGetPageWithCheck(fixedNode.Page);
                    if (fixedPage != null)
                    {
                        DependencyObject element = fixedPage.GetElement(fixedNode);
                        if (element != null)
                        {
                            int       num3 = 0;
                            UIElement element2;
                            int       num4;
                            if (element is Image || element is Path)
                            {
                                element2 = (UIElement)element;
                                num4     = 1;
                            }
                            else
                            {
                                Glyphs glyphs = element as Glyphs;
                                if (glyphs == null)
                                {
                                    goto IL_144;
                                }
                                element2 = (UIElement)element;
                                num3     = fixedSOMElement.StartIndex;
                                num4     = fixedSOMElement.EndIndex;
                            }
                            if (i == 0)
                            {
                                num3 = num;
                            }
                            if (i == array.Length - 1)
                            {
                                num4 = num2;
                            }
                            ArrayList arrayList;
                            if (highlights.ContainsKey(fixedPage))
                            {
                                arrayList = highlights[fixedPage];
                            }
                            else
                            {
                                arrayList = new ArrayList();
                                highlights.Add(fixedPage, arrayList);
                            }
                            FixedSOMTextRun fixedSOMTextRun = fixedSOMElement as FixedSOMTextRun;
                            if (fixedSOMTextRun != null && fixedSOMTextRun.IsReversed)
                            {
                                int num5 = num3;
                                num3 = fixedSOMElement.EndIndex - num4;
                                num4 = fixedSOMElement.EndIndex - num5;
                            }
                            FixedHighlight value = new FixedHighlight(element2, num3, num4, t, foregroundBrush, backgroundBrush);
                            arrayList.Add(value);
                        }
                    }
                    IL_144 :;
                }
            }
        }
コード例 #34
0
        internal void RenderFlowNode(DrawingContext dc)
        {
            FormattedText ft;
            FixedNode     fixedNode;

            FixedSOMElement[] somElements;
            String            ouptputString;
            FixedElement      fixedElement;
            Random            random = new Random();

            CultureInfo EnglishCulture = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS;

            FixedPage fp = _fixedTextBuilder.FixedTextContainer.FixedDocument.GetFixedPage(PageIndex);
            //
            //Iterate through flow node to draw Transparent Rect and draw its index
            //
            Point    prevTextPoint = new Point(0, 0);
            DpiScale dpi           = fp.GetDpi();

            for (int i = FlowStart.Fp; i <= FlowEnd.Fp; i++)
            {
                FlowNode fn = _fixedTextBuilder.FixedFlowMap[i];
                switch (fn.Type)
                {
                case FlowNodeType.Boundary:
                case FlowNodeType.Virtual:
                    // this two cases won't happen.
                    Debug.Assert(false);
                    break;

                case FlowNodeType.Start:
                case FlowNodeType.End:
                {
                    fixedElement = fn.Cookie as FixedElement;
                    String typeString = fixedElement.Type.ToString();
                    int    indexofDot = typeString.LastIndexOf('.');
                    ouptputString = String.Format("{0}-{1}",
                                                  fn.ToString(),
                                                  typeString.Substring(indexofDot + 1));

                    ft = new FormattedText(ouptputString,
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkGreen,
                                           dpi.PixelsPerDip);
                    // Ideally, for FlowNodeType.Start, this should find next FlowNode with physical location,
                    // and draw it around the physical location.
                    prevTextPoint = CreateFromLastTextPoint(prevTextPoint);

                    dc.DrawText(ft, prevTextPoint);
                    break;
                }

                case FlowNodeType.Noop:
                    ft = new FormattedText(fn.ToString(),
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkGreen,
                                           dpi.PixelsPerDip);
                    prevTextPoint = CreateFromLastTextPoint(prevTextPoint);
                    dc.DrawText(ft, prevTextPoint);
                    break;

                case FlowNodeType.Run:
                    //
                    // Paint the region. The rect is the union of child glyphs.
                    //

                    Glyphs glyphs;
                    Rect   flowRunBox = Rect.Empty;
                    Rect   glyphBox;
                    somElements = _fixedTextBuilder.FixedFlowMap.FlowNodes[fn.Fp].FixedSOMElements;

                    foreach (FixedSOMElement currentSomeElement in somElements)
                    {
                        FixedNode currentFixedNode = currentSomeElement.FixedNode;
                        int       startIndex       = currentSomeElement.StartIndex;
                        int       endIndex         = currentSomeElement.EndIndex;

                        // same as (_IsBoundaryFixedNode(currentFixedNode))
                        if (currentFixedNode.Page == FixedFlowMap.FixedOrderStartPage ||
                            currentFixedNode.Page == FixedFlowMap.FixedOrderEndPage ||
                            currentFixedNode[1] == FixedFlowMap.FixedOrderStartVisual ||
                            currentFixedNode[1] == FixedFlowMap.FixedOrderEndVisual)
                        {
                            continue;
                        }

                        glyphs = fp.GetGlyphsElement(currentFixedNode);
                        Debug.Assert(glyphs != null);

                        glyphBox = FixedTextView._GetGlyphRunDesignRect(glyphs, startIndex, endIndex);
                        if (!glyphBox.IsEmpty)
                        {
                            GeneralTransform g = glyphs.TransformToAncestor(fp);

                            glyphBox = g.TransformBounds(glyphBox);
                        }

                        flowRunBox.Union(glyphBox);
                    }

                    if (flowRunBox.IsEmpty)
                    {
                        Debug.Assert(false);
                    }
                    prevTextPoint.X = flowRunBox.Right;
                    prevTextPoint.Y = flowRunBox.Bottom - random.Next(15);

                    // Draw something the upper left corner of region.
                    ft = new FormattedText(fn.ToString() + "-" + Convert.ToString((int)(fn.Cookie)) +
                                           "-" + Convert.ToString(somElements.Length),
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkBlue,
                                           dpi.PixelsPerDip);
                    dc.DrawText(ft, prevTextPoint);

                    Pen pen = new Pen(Brushes.Blue, 2);
                    flowRunBox.Inflate(random.Next(3), random.Next(3));
                    DrawRectOutline(dc, pen, flowRunBox);
                    break;

                case FlowNodeType.Object:
                    //
                    // Find the mapping fixed node
                    //
                    somElements = _fixedTextBuilder.FixedFlowMap.FlowNodes[fn.Fp].FixedSOMElements;

                    foreach (FixedSOMElement currentSomeElement in somElements)
                    {
                        fixedNode = currentSomeElement.FixedNode;

                        DependencyObject dependencyObject = fp.GetElement(fixedNode);

                        Image image = dependencyObject as Image;
                        Path  path  = dependencyObject as Path;

                        if (image != null || path != null)
                        {
                            Rect imageRect, boundingRect = Rect.Empty;
                            //
                            // Get Image bounding box.
                            //
                            GeneralTransform transform = ((Visual)dependencyObject).TransformToAncestor(fp);
                            // You can't use GetContentBounds inside OnRender
                            if (image != null)
                            {
                                boundingRect = new Rect(0, 0, image.Width, image.Height);
                            }
                            else
                            {
                                boundingRect = path.Data.Bounds;
                            }

                            if (!boundingRect.IsEmpty)
                            {
                                imageRect = transform.TransformBounds(boundingRect);

                                // Image might overlap, inflate the box.
                                imageRect.Inflate(3, 3);
                                dc.DrawRectangle(Brushes.CadetBlue, null, imageRect);

                                prevTextPoint.X = imageRect.Right;
                                prevTextPoint.Y = imageRect.Top;
                            }
                        }
                        else
                        {
                            //
                            // If the object is the Image type(that is not likey).
                            // Use the last Point to infer a comment area!
                            //
                            Debug.Assert(false);
                        }

                        fixedElement = fn.Cookie as FixedElement;
                        ft           = new FormattedText(fn.ToString(),
                                                         EnglishCulture,
                                                         FlowDirection.LeftToRight,
                                                         new Typeface("Courier New"),
                                                         8,
                                                         Brushes.DarkGreen,
                                                         dpi.PixelsPerDip);
                        dc.DrawText(ft, prevTextPoint);
                    }

                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
            }
        }
コード例 #35
0
 // Token: 0x06002CE4 RID: 11492 RVA: 0x000CA9D1 File Offset: 0x000C8BD1
 internal FixedDocumentPage(FixedDocument panel, FixedPage page, Size fixedSize, int index) : base(page, fixedSize, new Rect(fixedSize), new Rect(fixedSize))
 {
     this._panel = panel;
     this._page  = page;
     this._index = index;
 }
コード例 #36
0
 public FixedDSBuilder(FixedPage fp, StoryFragments sf)
 {
     _nameHashTable  = new Dictionary <String, NameHashFixedNode>();
     _fixedPage      = fp;
     _storyFragments = sf;
 }
コード例 #37
0
        internal void RenderFixedNode(DrawingContext dc)
        {
            //
            //Iterate through fix node to draw red dotted line
            //
            CultureInfo EnglishCulture = System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS;

            int lineCount = _lineResults.Length;

            if (lineCount == 0)
            {
                return;
            }

            FixedNode fixedStartPage = _lineResults[0].Start;
            FixedNode fixedEndPage   = _lineResults[lineCount - 1].End;

            FixedNode[]   fixedNodes = _fixedTextBuilder.FixedFlowMap.FixedOrderGetRangeNodes(fixedStartPage, fixedEndPage);
            FixedPage     fp         = _fixedTextBuilder.FixedTextContainer.FixedDocument.GetFixedPage(PageIndex);
            FormattedText ft;
            Point         prevTextPoint = new Point(0, 0);
            DpiScale      dpi           = fp.GetDpi();

            foreach (FixedNode currentFixedNode in fixedNodes)
            {
                if (currentFixedNode.Page == FixedFlowMap.FixedOrderStartPage)
                {
                    prevTextPoint.X = prevTextPoint.Y = 0;
                    ft = new FormattedText("FixedOrderStartPage",
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkViolet,
                                           dpi.PixelsPerDip);
                    dc.DrawText(ft, prevTextPoint);
                    continue;
                }
                if (currentFixedNode.Page == FixedFlowMap.FixedOrderEndPage)
                {
                    prevTextPoint.X = fp.Width - 100;
                    prevTextPoint.Y = fp.Height - 10;
                    ft = new FormattedText("FixedOrderEndPage",
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkViolet,
                                           dpi.PixelsPerDip);
                    dc.DrawText(ft, prevTextPoint);
                    continue;
                }
                if (currentFixedNode[1] == FixedFlowMap.FixedOrderStartVisual ||
                    currentFixedNode[1] == FixedFlowMap.FixedOrderEndVisual)
                {
                    prevTextPoint.X = 2;
                    prevTextPoint.Y = prevTextPoint.Y + 10;
                    String outputString = currentFixedNode[1] == FixedFlowMap.FixedOrderStartVisual ?
                                          "FixedOrderStartVisual" : "FixedOrderEndVisual";
                    ft = new FormattedText(outputString,
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkViolet,
                                           dpi.PixelsPerDip);
                    dc.DrawText(ft, prevTextPoint);
                    continue;
                }

                DependencyObject dependencyObject = fp.GetElement(currentFixedNode);

                Image image = dependencyObject as Image;
                if (image != null)
                {
                    GeneralTransform transform = image.TransformToAncestor(fp);
                    // You can't use GetContentBounds inside OnRender
                    Rect boundingRect = new Rect(0, 0, image.Width, image.Height);
                    Rect imageRect    = transform.TransformBounds(boundingRect);

                    if (!imageRect.IsEmpty)
                    {
                        // Image might overlap, inflate the box.
                        imageRect.Inflate(1, 1);

                        Pen pen = new Pen(Brushes.DarkMagenta, 1.5);
                        DrawRectOutline(dc, pen, imageRect);

                        prevTextPoint.X = imageRect.Right;
                        prevTextPoint.Y = imageRect.Bottom - 10;
                    }
                    else
                    {
                        prevTextPoint.X = 2;
                        prevTextPoint.Y = prevTextPoint.Y + 10;
                    }
                    ft = new FormattedText(currentFixedNode.ToString(),
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkViolet,
                                           dpi.PixelsPerDip);
                    dc.DrawText(ft, prevTextPoint);
                    continue;
                }
                Path path = dependencyObject as Path;
                if (path != null)
                {
                    GeneralTransform transform = path.TransformToAncestor(fp);
                    // You can't use GetContentBounds inside OnRender
                    Rect boundingRect = path.Data.Bounds;
                    Rect imageRect    = transform.TransformBounds(boundingRect);

                    if (!imageRect.IsEmpty)
                    {
                        // Image might overlap, inflate the box.
                        imageRect.Inflate(1, 1);

                        Pen pen = new Pen(Brushes.DarkMagenta, 1.5);
                        DrawRectOutline(dc, pen, imageRect);

                        prevTextPoint.X = imageRect.Right;
                        prevTextPoint.Y = imageRect.Bottom - 10;
                    }
                    else
                    {
                        prevTextPoint.X = 2;
                        prevTextPoint.Y = prevTextPoint.Y + 10;
                    }
                    ft = new FormattedText(currentFixedNode.ToString(),
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkViolet,
                                           dpi.PixelsPerDip);
                    dc.DrawText(ft, prevTextPoint);
                    continue;
                }
                Glyphs glyphs = dependencyObject as Glyphs;
                if (glyphs != null)
                {
                    GlyphRun run = glyphs.ToGlyphRun();
                    if (run != null)
                    {
                        Rect glyphBox = run.ComputeAlignmentBox();
                        glyphBox.Offset(glyphs.OriginX, glyphs.OriginY);
                        GeneralTransform transform = glyphs.TransformToAncestor(fp);
                        //
                        // Draw it using the dotted red line
                        //
                        Pen       pen = new Pen(Brushes.Red, 0.5);
                        Transform t   = transform.AffineTransform;
                        if (t != null)
                        {
                            dc.PushTransform(t);
                        }
                        else
                        {
                            dc.PushTransform(Transform.Identity);
                        }
                        DrawRectOutline(dc, pen, glyphBox);

                        prevTextPoint.X = glyphBox.Right;
                        prevTextPoint.Y = glyphBox.Bottom;
                        transform.TryTransform(prevTextPoint, out prevTextPoint);
                        dc.Pop(); // transform
                    }
                    else
                    {
                        prevTextPoint.X = 2;
                        prevTextPoint.Y = prevTextPoint.Y + 10;
                    }

                    ft = new FormattedText(currentFixedNode.ToString(),
                                           EnglishCulture,
                                           FlowDirection.LeftToRight,
                                           new Typeface("Courier New"),
                                           8,
                                           Brushes.DarkViolet,
                                           dpi.PixelsPerDip);
                    dc.DrawText(ft, prevTextPoint);
                    continue;
                }

                //
                // For anything else, there is this code to draw ...
                //
                prevTextPoint.X = 2;
                prevTextPoint.Y = prevTextPoint.Y + 10;
                ft = new FormattedText(currentFixedNode.ToString(),
                                       EnglishCulture,
                                       FlowDirection.LeftToRight,
                                       new Typeface("Courier New"),
                                       8,
                                       Brushes.DarkViolet,
                                       dpi.PixelsPerDip);
                dc.DrawText(ft, prevTextPoint);
            }
        }
コード例 #38
0
        System.Windows.UIElement System.Windows.Documents.IFixedNavigate.FindElementByID(string elementID, out FixedPage rootFixedPage)
        {
            rootFixedPage = default(FixedPage);

            return(default(System.Windows.UIElement));
        }
コード例 #39
0
        //--------------------------------------------------------------------
        //
        // Constructors
        //
        //---------------------------------------------------------------------

        #region Constructors

        /// <summary>
        ///     HighlightVisual construction
        /// </summary>
        /// <param name="panel">FixedDocument where selection is taking place</param>
        /// <param name="page">FixedPage that is being highlighted</param>
        internal HighlightVisual(FixedDocument panel, FixedPage page) : base(page)
        {
            _panel = panel;
            _page  = page;
        }
コード例 #40
0
        // Token: 0x06002EF2 RID: 12018 RVA: 0x000D4194 File Offset: 0x000D2394
        private bool _GetNextLineGlyphs(ref FixedPosition fixedp, ref LogicalDirection edge, double suggestedX, LogicalDirection scanDir)
        {
            int  num    = 1;
            int  page   = fixedp.Page;
            bool result = false;

            FixedNode[] nextLine = this.Container.FixedTextBuilder.GetNextLine(fixedp.Node, scanDir == LogicalDirection.Forward, ref num);
            if (nextLine != null && nextLine.Length != 0)
            {
                FixedPage fixedPage = this.Container.FixedDocument.SyncGetPage(page, false);
                if (double.IsInfinity(suggestedX))
                {
                    suggestedX = 0.0;
                }
                Point     point     = new Point(suggestedX, 0.0);
                Point     point2    = new Point(suggestedX, 1000.0);
                FixedNode fixedNode = nextLine[0];
                Glyphs    g         = null;
                double    num2      = double.MaxValue;
                double    xoffset   = 0.0;
                for (int i = nextLine.Length - 1; i >= 0; i--)
                {
                    FixedNode fixedNode2    = nextLine[i];
                    Glyphs    glyphsElement = fixedPage.GetGlyphsElement(fixedNode2);
                    if (glyphsElement != null)
                    {
                        GeneralTransform generalTransform = fixedPage.TransformToDescendant(glyphsElement);
                        Point            inPoint          = point;
                        Point            inPoint2         = point2;
                        if (generalTransform != null)
                        {
                            generalTransform.TryTransform(inPoint, out inPoint);
                            generalTransform.TryTransform(inPoint2, out inPoint2);
                        }
                        double   num3     = (inPoint2.X - inPoint.X) / (inPoint2.Y - inPoint.Y);
                        GlyphRun glyphRun = glyphsElement.ToGlyphRun();
                        Rect     rect     = glyphRun.ComputeAlignmentBox();
                        rect.Offset(glyphsElement.OriginX, glyphsElement.OriginY);
                        double num4;
                        double num5;
                        if (num3 > 1000.0 || num3 < -1000.0)
                        {
                            num4 = 0.0;
                            num5 = ((inPoint.Y > rect.Y) ? (inPoint.Y - rect.Bottom) : (rect.Y - inPoint.Y));
                        }
                        else
                        {
                            double num6 = (rect.Top + rect.Bottom) / 2.0;
                            num4 = inPoint.X + num3 * (num6 - inPoint.Y);
                            num5 = ((num4 > rect.X) ? (num4 - rect.Right) : (rect.X - num4));
                        }
                        if (num5 < num2)
                        {
                            num2      = num5;
                            xoffset   = num4;
                            fixedNode = fixedNode2;
                            g         = glyphsElement;
                            if (num5 <= 0.0)
                            {
                                break;
                            }
                        }
                    }
                }
                int offset;
                this._GlyphRunHitTest(g, xoffset, out offset, out edge);
                fixedp = new FixedPosition(fixedNode, offset);
                result = true;
            }
            return(result);
        }
コード例 #41
0
 // Token: 0x06002D13 RID: 11539 RVA: 0x000CB603 File Offset: 0x000C9803
 public FixedDSBuilder(FixedPage fp, StoryFragments sf)
 {
     this._nameHashTable  = new Dictionary <string, FixedDSBuilder.NameHashFixedNode>();
     this._fixedPage      = fp;
     this._storyFragments = sf;
 }
コード例 #42
0
        // If return false, nothing has been modified, which implies out of page boundary
        // The input of suggestedX is in the VisualRoot's cooridnate system
        private bool _GetNextLineGlyphs(ref FixedPosition fixedp, ref LogicalDirection edge, double suggestedX, LogicalDirection scanDir)
        {
            int  count     = 1;
            int  pageIndex = fixedp.Page;
            bool moved     = false;

            FixedNode[] fixedNodes = Container.FixedTextBuilder.GetNextLine(fixedp.Node, (scanDir == LogicalDirection.Forward), ref count);

            if (fixedNodes != null && fixedNodes.Length > 0)
            {
                FixedPage page = Container.FixedDocument.SyncGetPage(pageIndex, false);
                // This line contains multiple Glyhs. Scan backward
                // util we hit the first one whose OriginX is smaller
                // then suggestedX;
                if (Double.IsInfinity(suggestedX))
                {
                    suggestedX = 0;
                }
                Point topOfPage   = new Point(suggestedX, 0);
                Point secondPoint = new Point(suggestedX, 1000);

                FixedNode hitNode         = fixedNodes[0];
                Glyphs    hitGlyphs       = null;
                double    closestDistance = Double.MaxValue;
                double    xoffset         = 0;

                for (int i = fixedNodes.Length - 1; i >= 0; i--)
                {
                    FixedNode node = fixedNodes[i];
                    Glyphs    g    = page.GetGlyphsElement(node);
                    if (g != null)
                    {
                        GeneralTransform transform = page.TransformToDescendant(g);
                        Point            pt1       = topOfPage;
                        Point            pt2       = secondPoint;
                        if (transform != null)
                        {
                            transform.TryTransform(pt1, out pt1);
                            transform.TryTransform(pt2, out pt2);
                        }
                        double invSlope = (pt2.X - pt1.X) / (pt2.Y - pt1.Y);
                        double xoff, distance;

                        GlyphRun run = g.ToGlyphRun();
                        Rect     box = run.ComputeAlignmentBox();
                        box.Offset(g.OriginX, g.OriginY);

                        if (invSlope > 1000 || invSlope < -1000)
                        {
                            // special case for vertical text
                            xoff     = 0;
                            distance = (pt1.Y > box.Y) ? (pt1.Y - box.Bottom) : (box.Y - pt1.Y);
                        }
                        else
                        {
                            double centerY = (box.Top + box.Bottom) / 2;
                            xoff     = pt1.X + invSlope * (centerY - pt1.Y);
                            distance = (xoff > box.X) ? (xoff - box.Right) : (box.X - xoff);
                        }

                        if (distance < closestDistance)
                        {
                            closestDistance = distance;
                            xoffset         = xoff;
                            hitNode         = node;
                            hitGlyphs       = g;

                            if (distance <= 0)
                            {
                                break;
                            }
                        }
                    }
                }

                Debug.Assert(hitGlyphs != null);

                int charIdx;
                _GlyphRunHitTest(hitGlyphs, xoffset, out charIdx, out edge);

                fixedp = new FixedPosition(hitNode, charIdx);
                moved  = true;
            }

            return(moved);
        }
コード例 #43
0
 //--------------------------------------------------------------------
 //
 // Ctor
 //
 //---------------------------------------------------------------------
 #region Ctor
 internal PageContentAsyncResult(AsyncCallback callback, object state, Dispatcher dispatcher, Uri baseUri, Uri source, FixedPage child)
 {
     this._dispatcher             = dispatcher;
     this._isCompleted            = false;
     this._completedSynchronously = false;
     this._callback      = callback;
     this._asyncState    = state;
     this._getpageStatus = GetPageStatus.Loading;
     this._child         = child;
     this._baseUri       = baseUri;
     Debug.Assert(source == null || source.IsAbsoluteUri);
     this._source = source;
 }
コード例 #44
0
        // Get the highlights, in Glyphs granularity, that covers this range
        internal void GetMultiHighlights(FixedTextPointer start, FixedTextPointer end, Dictionary <FixedPage, ArrayList> highlights, FixedHighlightType t,
                                         Brush foregroundBrush, Brush backgroundBrush)
        {
            Debug.Assert(highlights != null);
            if (start.CompareTo(end) > 0)
            {
                // make sure start <= end
                FixedTextPointer temp = start;
                start = end;
                end   = temp;
            }

            FixedSOMElement[] elements;
            //Start and end indices in selection for first and last FixedSOMElements respectively
            int startIndex = 0;
            int endIndex   = 0;

            if (_GetFixedNodesForFlowRange(start, end, out elements, out startIndex, out endIndex))
            {
                for (int i = 0; i < elements.Length; i++)
                {
                    FixedSOMElement elem = elements[i];

                    FixedNode fn = elem.FixedNode;
                    // Get the FixedPage if possible
                    FixedPage page = this.FixedDocument.SyncGetPageWithCheck(fn.Page);
                    if (page == null)
                    {
                        continue;
                    }

                    DependencyObject o = page.GetElement(fn);
                    if (o == null)
                    {
                        continue;
                    }

                    int       beginOffset = 0;
                    int       endOffset;
                    UIElement e;
                    if (o is Image || o is Path)
                    {
                        e         = (UIElement)o;
                        endOffset = 1;
                    }
                    else
                    {
                        Glyphs g = o as Glyphs;
                        if (g == null)
                        {
                            continue;
                        }
                        e           = (UIElement)o;
                        beginOffset = elem.StartIndex;
                        endOffset   = elem.EndIndex;
                    }

                    if (i == 0)
                    {
                        beginOffset = startIndex;
                    }

                    if (i == elements.Length - 1)
                    {
                        endOffset = endIndex;
                    }

                    ArrayList lfs;
                    if (highlights.ContainsKey(page))
                    {
                        lfs = highlights[page];
                    }
                    else
                    {
                        lfs = new ArrayList();
                        highlights.Add(page, lfs);
                    }

                    FixedSOMTextRun textRun = elem as FixedSOMTextRun;
                    if (textRun != null && textRun.IsReversed)
                    {
                        int oldBeginOffset = beginOffset;
                        beginOffset = elem.EndIndex - endOffset;
                        endOffset   = elem.EndIndex - oldBeginOffset;
                    }

                    FixedHighlight fh = new FixedHighlight(e, beginOffset, endOffset, t, foregroundBrush, backgroundBrush);
                    lfs.Add(fh);
                }
            }
        }
コード例 #45
0
        // Token: 0x06002CC1 RID: 11457 RVA: 0x000C9D38 File Offset: 0x000C7F38
        internal ContentPosition GetObjectPosition(object o)
        {
            if (o == null)
            {
                throw new ArgumentNullException("o");
            }
            DependencyObject dependencyObject = o as DependencyObject;

            if (dependencyObject == null)
            {
                throw new ArgumentException(SR.Get("FixedDocumentExpectsDependencyObject"));
            }
            FixedPage fixedPage = null;
            int       num       = -1;

            if (dependencyObject != this)
            {
                DependencyObject dependencyObject2 = dependencyObject;
                while (dependencyObject2 != null)
                {
                    fixedPage = (dependencyObject2 as FixedPage);
                    if (fixedPage != null)
                    {
                        num = this.GetIndexOfPage(fixedPage);
                        if (num >= 0)
                        {
                            break;
                        }
                        dependencyObject2 = fixedPage.Parent;
                    }
                    else
                    {
                        dependencyObject2 = LogicalTreeHelper.GetParent(dependencyObject2);
                    }
                }
            }
            else if (this.Pages.Count > 0)
            {
                num = 0;
            }
            FixedTextPointer fixedTextPointer = null;

            if (num >= 0)
            {
                FlowPosition flowPosition       = null;
                System.Windows.Shapes.Path path = dependencyObject as System.Windows.Shapes.Path;
                if (dependencyObject is Glyphs || dependencyObject is Image || (path != null && path.Fill is ImageBrush))
                {
                    FixedPosition fixedPosition = new FixedPosition(fixedPage.CreateFixedNode(num, (UIElement)dependencyObject), 0);
                    flowPosition = this.FixedContainer.FixedTextBuilder.CreateFlowPosition(fixedPosition);
                }
                if (flowPosition == null)
                {
                    flowPosition = this.FixedContainer.FixedTextBuilder.GetPageStartFlowPosition(num);
                }
                fixedTextPointer = new FixedTextPointer(true, LogicalDirection.Forward, flowPosition);
            }
            if (fixedTextPointer == null)
            {
                return(ContentPosition.Missing);
            }
            return(fixedTextPointer);
        }
コード例 #46
0
 internal GetPageRootCompletedEventArgs(FixedPage page, Exception error, bool cancelled, object userToken)
     : base(error, cancelled, userToken)
 {
     _page = page;
 }