当前位置: 首页>>代码示例>>C#>>正文


C# FixedPage.Measure方法代码示例

本文整理汇总了C#中System.Windows.Documents.FixedPage.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# FixedPage.Measure方法的具体用法?C# FixedPage.Measure怎么用?C# FixedPage.Measure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.FixedPage的用法示例。


在下文中一共展示了FixedPage.Measure方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePawnTicketContent

        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;
        }
开发者ID:RayMetz100,项目名称:hyperpawn,代码行数:25,代码来源:PawnTicketTry1.cs

示例2: CreateFifthPageContent

    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;
    }
开发者ID:vronikp,项目名称:EventRegistration,代码行数:25,代码来源:DrawingTest.xaml.cs

示例3: Xps_Click

        private void Xps_Click(object sender, RoutedEventArgs e)
        {
            FixedPage page = new FixedPage() { Background = Brushes.White, Width = Dpi * PaperWidth, Height = Dpi * PaperHeight };

            TextBlock tbTitle = new TextBlock { Text = "My InkCanvas Sketch", FontSize = 24, FontFamily = new FontFamily("Arial") };
            FixedPage.SetLeft(tbTitle, Dpi * 0.75);
            FixedPage.SetTop(tbTitle, Dpi * 0.75);
            page.Children.Add((UIElement)tbTitle);

            var toPrint = myInkCanvasBorder;
            myGrid.Children.Remove(myInkCanvasBorder);

            FixedPage.SetLeft(toPrint, Dpi * 2);
            FixedPage.SetTop(toPrint, Dpi * 2);
            page.Children.Add(toPrint);

            Size sz = new Size(Dpi * PaperWidth, Dpi * PaperHeight);
            page.Measure(sz);
            page.Arrange(new Rect(new Point(), sz));
            page.UpdateLayout();

            var filepath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "PrintingTest");
            if (!File.Exists(filepath))
                Directory.CreateDirectory(filepath);
            var filename = System.IO.Path.Combine(filepath, "myXpsFile.xps");

            FixedDocument doc = new FixedDocument();

            PageContent pageContent = new PageContent();
            ((System.Windows.Markup.IAddChild)pageContent).AddChild(page);
            doc.Pages.Add(pageContent);

            XpsDocument xpsd = new XpsDocument(filename, FileAccess.Write);
            XpsDocument.CreateXpsDocumentWriter(xpsd).Write(doc);               //requires System.Printing namespace

            xpsd.Close();

            PrintDialog printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == true)
                printDialog.PrintQueue.AddJob("MyInkCanvas print job", filename, true);

            page.Children.Remove(toPrint);
            myGrid.Children.Add(toPrint);
        }
开发者ID:nanomouse,项目名称:stratasys,代码行数:44,代码来源:Window3.xaml.cs

示例4: PrintDocument

        private void PrintDocument()
        {
            FixedDocument fixedDocument = new FixedDocument();
            fixedDocument.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);

            foreach (BitmapSource bitmapSource in this.m_BitmapSourceList)
            {
                PageContent pageContent = new PageContent();

                FixedPage fixedPage = new FixedPage();
                fixedPage.Background = Brushes.White;
                fixedPage.Width = 96 * 8.5;
                fixedPage.Height = 96 * 11;

                Image image = new Image();
                image.Width = 96 * 8;
                image.Height = 96 * 10.5;
                image.Source = bitmapSource;

                FixedPage.SetLeft(image, 96 * .25);
                FixedPage.SetTop(image, 96 * .25);
                fixedPage.Children.Add((UIElement)image);

                ((IAddChild)pageContent).AddChild(fixedPage);
                fixedDocument.Pages.Add(pageContent);

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

            PrintDialog printDialog = new PrintDialog();
            printDialog.ShowDialog();
            printDialog.PrintDocument(fixedDocument.DocumentPaginator, "Print TIF Document");
        }
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:36,代码来源:TifDocumentViewer.xaml.cs

示例5: ArrangePage

		public static void ArrangePage(Size pageSize, FixedPage page)
		{
			page.Measure(pageSize);
			page.Arrange(new Rect(new System.Windows.Point(), pageSize));
			page.UpdateLayout();
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:6,代码来源:FixedDocumentCreator.cs

示例6: DdlUpdated

        /// <summary>
        /// Called when the Ddl property has changed.
        /// </summary>
        void DdlUpdated()
        {
            if (_ddl != null)
            {
                _document = DdlReader.DocumentFromString(_ddl);
                _renderer = new DocumentRenderer(_document);

                //this.renderer.PrivateFonts = this.privateFonts;
                _renderer.PrepareDocument();

                //IDocumentPaginatorSource source = this.documentViewer.Document;

                //IDocumentPaginatorSource source = this.documentViewer.Document;

                int pageCount = _renderer.FormattedDocument.PageCount;
                if (pageCount == 0)
                    return;

                // HACK: hardcoded A4 size
                //double pageWidth = XUnit.FromMillimeter(210).Presentation;
                //double pageHeight = XUnit.FromMillimeter(297).Presentation;
                //Size a4 = new Size(pageWidth, pageHeight);

                XUnit pageWidth, pageHeight;
                Size size96 = GetSizeOfPage(1, out pageWidth, out pageHeight);

                FixedDocument fixedDocument = new FixedDocument();
                fixedDocument.DocumentPaginator.PageSize = size96;

                for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++)
                {
                    try
                    {
                        size96 = GetSizeOfPage(1, out pageWidth, out pageHeight);

                        DrawingVisual dv = new DrawingVisual();
                        DrawingContext dc = dv.RenderOpen();
                        //XGraphics gfx = XGraphics.FromDrawingContext(dc, new XSize(XUnit.FromMillimeter(210).Point, XUnit.FromMillimeter(297).Point), XGraphicsUnit.Point);
                        XGraphics gfx = XGraphics.FromDrawingContext(dc, new XSize(pageWidth.Point, pageHeight.Presentation), XGraphicsUnit.Point);
                        _renderer.RenderPage(gfx, pageNumber, PageRenderOptions.All);
                        dc.Close();

                        // Create page content
                        PageContent pageContent = new PageContent();
                        pageContent.Width = size96.Width;
                        pageContent.Height = size96.Height;
                        FixedPage fixedPage = new FixedPage();
                        fixedPage.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0xFE, 0xFE, 0xFE));

                        UIElement visual = new DrawingVisualPresenter(dv);
                        FixedPage.SetLeft(visual, 0);
                        FixedPage.SetTop(visual, 0);

                        fixedPage.Width = size96.Width;
                        fixedPage.Height = size96.Height;

                        fixedPage.Children.Add(visual);

                        fixedPage.Measure(size96);
                        fixedPage.Arrange(new Rect(new Point(), size96));
                        fixedPage.UpdateLayout();

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

                        fixedDocument.Pages.Add(pageContent);
                    }
                    catch (Exception)
                    {
                        // eat exception
                    }

                    viewer.Document = fixedDocument;
                }
            }
            else
                viewer.Document = null;
        }
开发者ID:Sl0vi,项目名称:MigraDoc,代码行数:80,代码来源:DocumentPreview.xaml.cs

示例7: SaveToXps

        //*************************************************************************
        //  Method: SaveToXps()
        //
        /// <summary>
        /// Saves the graph to the specified XPS file.
        /// </summary>
        ///
        /// <param name="imageSize">
        /// Size of the XPS image, in WPS units.
        /// </param>
        ///
        /// <param name="fileName">
        /// File name to save to.
        /// </param>
        ///
        /// <remarks>
        /// This could conceivably be put in the base-class NodeXLControl class,
        /// but that would force all users of the control to add references to the
        /// XPS assemblies.
        /// </remarks>
        //*************************************************************************
        public void SaveToXps(
            Size imageSize,
            String fileName
            )
        {
            Debug.Assert( !String.IsNullOrEmpty(fileName) );
            AssertValid();

            CheckIfLayingOutGraph("SaveToXps");

            // This control will be rehosted by a FixedPage.  It can't be a child
            // of logical trees, so disconnect it from its parent after saving the
            // current vertex locations.

            LayoutSaver oLayoutSaver = new LayoutSaver(this.Graph);

            Debug.Assert(this.Parent is Panel);
            Panel oParentPanel = (Panel)this.Parent;
            UIElementCollection oParentChildren = oParentPanel.Children;
            Int32 iChildIndex = oParentChildren.IndexOf(this);
            oParentChildren.Remove(this);

            GraphImageCenterer oGraphImageCenterer = new GraphImageCenterer(this);

            FixedDocument oFixedDocument = new FixedDocument();
            oFixedDocument.DocumentPaginator.PageSize = imageSize;
            PageContent oPageContent = new PageContent();

            FixedPage oFixedPage = new FixedPage();
            oFixedPage.Width = imageSize.Width;
            oFixedPage.Height = imageSize.Height;

            this.Width = imageSize.Width;
            this.Height = imageSize.Height;

            // Adjust the control's translate transforms so that the image will be
            // centered on the same point on the graph that the control is centered
            // on.

            oGraphImageCenterer.CenterGraphImage(imageSize);

            oFixedPage.Children.Add(this);
            oFixedPage.Measure(imageSize);

            oFixedPage.Arrange(new System.Windows.Rect(
            new System.Windows.Point(), imageSize) );

            oFixedPage.UpdateLayout();

            ( (System.Windows.Markup.IAddChild)oPageContent ).AddChild(
            oFixedPage);

            oFixedDocument.Pages.Add(oPageContent);

            try
            {
            XpsDocument oXpsDocument = new XpsDocument(fileName,
                FileAccess.Write);

            XpsDocumentWriter oXpsDocumentWriter =
                XpsDocument.CreateXpsDocumentWriter(oXpsDocument);

            oXpsDocumentWriter.Write(oFixedDocument);
            oXpsDocument.Close();
            }
            finally
            {
            // Reconnect the NodeXLControl to its original parent.  Reset the
            // size to Auto in the process.

            oFixedPage.Children.Remove(this);
            this.Width = Double.NaN;
            this.Height = Double.NaN;
            oGraphImageCenterer.RestoreCenter();
            oParentChildren.Insert(iChildIndex, this);

            // The graph may have shrunk when it was connected to the
            // FixedPage, and even though it will be expanded to its original
            // dimensions when UpdateLayout() is called below, the layout may
//.........这里部分代码省略.........
开发者ID:haisreekanth,项目名称:NetMap,代码行数:101,代码来源:ExcelTemplateNodeXLControl.cs

示例8: SaveXps

    /// <summary>
    /// Renders the current visual as a FixedPage and save it as XPS file.
    /// </summary>
    public void SaveXps()
    {
      XpsDocument xpsDocument = new XpsDocument(Path.Combine(OutputDirectory, Name + ".xps"), FileAccess.ReadWrite);
      PageContent pageContent = new PageContent();

      FixedPage fixedPage = new FixedPage();
      fixedPage.Width = WidthInPU;
      fixedPage.Height = HeightInPU;
      fixedPage.Background = Brushes.Transparent;

      // Visuals needs a UIElement as drawing container
      VisualPresenter presenter = new VisualPresenter();
      presenter.AddVisual(this.visual);

      FixedPage.SetLeft(presenter, 0);
      FixedPage.SetTop(presenter, 0);
      fixedPage.Children.Add(presenter);

      // Perform layout
      Size size = new Size(WidthInPU, HeightInPU);
      fixedPage.Measure(size);
      fixedPage.Arrange(new Rect(new Point(), size));
      fixedPage.UpdateLayout();

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

      FixedDocument fixedDocument = new FixedDocument();
      fixedDocument.DocumentPaginator.PageSize = size;
      fixedDocument.Pages.Add(pageContent);

      // Save as XPS file
      XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
      xpsWriter.Write(fixedDocument);
      xpsDocument.Close();

      // Must call at least two times GC.Collect this to get access to the xps file even I write synchronously. This is a bug in WPF.
      // Vista 64 .NET 3.5 SP1 installed
      xpsDocument = null;
      xpsWriter = null;
      GC.Collect(10, GCCollectionMode.Forced);
      GC.Collect(10, GCCollectionMode.Forced);
      //GC.Collect(10, GCCollectionMode.Forced);
      //GC.Collect(10, GCCollectionMode.Forced);
    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:47,代码来源:TestBase.cs

示例9: OnRender

    internal void OnRender()
    {
      if (RenderEvent != null)
      {
        //IDocumentPaginatorSource source = this.documentViewer.Document;

        DrawingVisual dv = new DrawingVisual();
        DrawingContext dc = dv.RenderOpen();

        XGraphics gfx = XGraphics.FromDrawingContext(dc,
          new XSize(XUnit.FromMillimeter(210).Point, XUnit.FromMillimeter(297).Point), XGraphicsUnit.Point);
        try
        {
          RenderEvent(gfx);
        }
        catch { }
        dc.Close();
        //DrawingGroup dg = dv.Drawing;

        // Create page content
        PageContent pageContent = new PageContent();
        FixedPage fixedPage = new FixedPage();
        fixedPage.Background = Brushes.GhostWhite;
        //UIElement visual = dv; // CreateSecondVisual(false);

        UIElement visual = new DrawingVisualPresenter(dv);
        FixedPage.SetLeft(visual, 0);
        FixedPage.SetTop(visual, 0);

        double pageWidth = XUnit.FromMillimeter(210).Presentation;
        double pageHeight = XUnit.FromMillimeter(297).Presentation;

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

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

        Size size = new Size(pageWidth, pageHeight);
        fixedPage.Measure(size);
        fixedPage.Arrange(new Rect(new Point(), size));
        fixedPage.UpdateLayout();

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

        FixedDocument fixedDocument = new FixedDocument();
        fixedDocument.DocumentPaginator.PageSize = size;

        fixedDocument.Pages.Add(pageContent);

        this.documentViewer.Document = fixedDocument;

        string savedButton = System.Windows.Markup.XamlWriter.Save(fixedDocument);
      }
      else
        this.documentViewer.Document = null;



      //base.OnRender(drawingContext);
      ////drawingContext.DrawLine(new Pen(Brushes.Green, 10), new Point(10, 10), new Point(100, 150));

      //drawingContext.PushTransform(new ScaleTransform(0.75, 0.75));
      //XGraphics gfx = XGraphics.FromDrawingContext(drawingContext, new XSize(100, 100), XGraphicsUnit.Millimeter);
      //if (RenderEvent != null)
      //{
      //  try
      //  {
      //    RenderEvent(gfx);
      //  }
      //  catch
      //  {
      //    RenderEvent = null;
      //  }
      //}
      //else
      //  Draw(gfx);
    }
开发者ID:vronikp,项目名称:EventRegistration,代码行数:77,代码来源:WpfPreview.xaml.cs

示例10: ShowPrintContent

        /// <summary>
        /// 显示打印内容
        /// </summary>
        private void ShowPrintContent()
        {
            int TotalPageCount = 2; //总页数
            int TotalCount = 0;     //记录总条数

           
            #region 加载页面内容
            

            #region 页面参数

            List<FixedPage> vpages = new List<FixedPage>();
            FixedPage curPage = null;

            Size pageSize = new Size();
            Thickness pageMargin = new Thickness();

            pageSize.Width = Objtoobj.objectToDouble("823");
            pageSize.Height = Objtoobj.objectToDouble("1120");
            pageMargin = Objtoobj.strToThicknewss("10");
            #endregion

            #region 页面
            for (int i = 0; i < TotalPageCount; i++)
            {
                FixedPage vpage = new FixedPage();
                vpage.RenderSize = pageSize;
                vpage.Measure(pageSize);
                vpage.Width = pageSize.Width;
                vpage.Height = pageSize.Height;
                vpages.Add(vpage);
                //curPage = vpage;
            }

            curPage=vpages[0];
            #endregion

            #region 拼接
          
            #region 标题
            TextBlock tbTitle = new TextBlock();
            tbTitle.Text = "北京市积水潭医院";

            tbTitle.Margin = new Thickness(320,10,0,0);
            tbTitle.FontSize = 20;
            tbTitle.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            tbTitle.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            tbTitle.TextAlignment = System.Windows.TextAlignment.Center;
            curPage.Children.Add(tbTitle);
            #endregion

            TextBlock vt = new TextBlock();
            vt.FontFamily = new FontFamily("宋体");
            Line line = new Line();
            int selectIndex = 0;
            foreach (FixedPage item in vpages)
            {
                selectIndex++;
                curPage = item;

                #region 页码
                vt = new TextBlock();
                vt.Text =  selectIndex + "/";
                vt.Margin = new Thickness(680, 1080, 0, 0);
                vt.FontSize = 12;
                vt.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                vt.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                curPage.Children.Add(vt);

                vt = new TextBlock();
                vt.Text =  TotalPageCount.ToString() ;
                vt.Margin = new Thickness(695, 1080, 0, 0);
                vt.FontSize = 12;
                vt.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                vt.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                curPage.Children.Add(vt);
                #endregion

                if (selectIndex == 1)
                {

                    #region 标题
                    vt = new TextBlock();
                    vt.Text = "康复医学科";
                    vt.Margin = new Thickness(350, 40, 0, 0);
                    vt.FontSize = 20;
                    vt.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                    vt.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                    curPage.Children.Add(vt);
                    #endregion

                    #region 患者信息

                    vt = new TextBlock();
                    vt.Text = "姓   名: " + ModuleConstant.Syspatient.UserName;
                    vt.Margin = new Thickness(45, 80, 0, 0);
                    vt.FontSize = 12;
//.........这里部分代码省略.........
开发者ID:wybq68,项目名称:DIH_LUMBARROBAT,代码行数:101,代码来源:PrintTest.cs

示例11: ShowPrintContent

        /// <summary>
        /// 显示打印内容
        /// </summary>
        private void ShowPrintContent()
        {
            int TotalPageCount = 0; //总页数
            int TotalCount = 0;     //记录总条数

            if (FitResultList.Count > 0)
            {
                TotalCount = FitResultList.Count;
                int indexTemp = 0;
                if (TotalCount > 4)
                {
                    indexTemp = TotalCount - 4;
                    if (indexTemp % 5 == 0)
                    {
                        TotalPageCount = indexTemp / 5 + 1;
                    }
                    else
                    {
                        TotalPageCount = indexTemp / 5 + 2;
                    }
                }
            }
            #region 加载页面内容
            

            #region 页面参数

            List<FixedPage> vpages = new List<FixedPage>();
            FixedPage curPage = null;

            Size pageSize = new Size();
            Thickness pageMargin = new Thickness();

            pageSize.Width = Objtoobj.objectToDouble("823");
            pageSize.Height = Objtoobj.objectToDouble("1120");
            pageMargin = Objtoobj.strToThicknewss("10");
            #endregion

            #region 页面
            for (int i = 0; i < TotalPageCount; i++)
            {
                FixedPage vpage = new FixedPage();
                vpage.RenderSize = pageSize;
                vpage.Measure(pageSize);
                vpage.Width = pageSize.Width;
                vpage.Height = pageSize.Height;
                vpages.Add(vpage);
                //curPage = vpage;
            }

            curPage=vpages[0];
            #endregion

            #region 拼接
          
            double nleft = 20;
            double ntop = 200;

            #region 标题
            TextBlock tbTitle = new TextBlock();
            tbTitle.Text = "评测报告";

            tbTitle.Margin = new Thickness(330,10,0,0);
            tbTitle.FontSize = 34;
            tbTitle.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            tbTitle.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            tbTitle.TextAlignment = System.Windows.TextAlignment.Center;
            curPage.Children.Add(tbTitle);
            #endregion

            TextBlock vt = new TextBlock();
            Line line = new Line();
            int selectIndex = 0;
            foreach (FixedPage item in vpages)
            {
                selectIndex++;
                curPage = item;

                #region 页码
                vt = new TextBlock();
                vt.Text = "第" + selectIndex + "页";
                vt.Margin = new Thickness(630, 1080, 0, 0);
                vt.FontSize = 20;
                vt.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                vt.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                curPage.Children.Add(vt);

                vt = new TextBlock();
                vt.Text = "共" + TotalPageCount + "页";
                vt.Margin = new Thickness(695, 1080, 0, 0);
                vt.FontSize = 20;
                vt.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                vt.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                curPage.Children.Add(vt);
                #endregion

                if (selectIndex == 1)
//.........这里部分代码省略.........
开发者ID:wybq68,项目名称:DIH_LUMBARROBAT,代码行数:101,代码来源:ReportPrintViewModel.cs


注:本文中的System.Windows.Documents.FixedPage.Measure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。