本文整理汇总了C#中System.Windows.Documents.FixedPage.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# FixedPage.UpdateLayout方法的具体用法?C# FixedPage.UpdateLayout怎么用?C# FixedPage.UpdateLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.FixedPage
的用法示例。
在下文中一共展示了FixedPage.UpdateLayout方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: CreateXpsDocument
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;
}
示例4: 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);
}
示例5: 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");
}
示例6: ArrangePage
public static void ArrangePage(Size pageSize, FixedPage page)
{
page.Measure(pageSize);
page.Arrange(new Rect(new System.Windows.Point(), pageSize));
page.UpdateLayout();
}
示例7: 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;
}
示例8: 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
//.........这里部分代码省略.........
示例9: Window_Initialized
private void Window_Initialized(object sender, EventArgs e)
{
//ConvertWordDocToXPSDoc("H:\\资料\\客户端流程设计.doc");
//Uri source = new Uri(@"http://www.jjgjt.com/download/1.xps");
//FtpWeb fw = new FtpWeb("www.jjgjt.com:8889", @"xps/", "Huiyou", "huiyouhuiyou");
//Stream stream=fw.DownloadStream("1.xps");
//if (stream != null)
//{
// System.IO.Packaging.Package package = System.IO.Packaging.Package.Open(stream,FileMode.Open);
// string memoryStreamUri = "memorystream://printstream";
// Uri packageUri = new Uri(memoryStreamUri);
// System.IO.Packaging.PackageStore.AddPackage(packageUri, package);
// XpsDocument xps = new XpsDocument(package,System.IO.Packaging.CompressionOption.SuperFast, memoryStreamUri);
//string memoryStreamUri = "memorystream://printstream";
//Uri packageUri = new Uri(memoryStreamUri);
//MemoryStream ms=new MemoryStream(Properties.Resources._1);
//System.IO.Packaging.Package package = System.IO.Packaging.Package.Open(ms,FileMode.Open);
//System.IO.Packaging.PackageStore.AddPackage(packageUri, package);
//foreach(System.IO.Packaging.PackagePart pp in package.GetParts())
//{
// MessageBox.Show(pp.ContentType);
//}
FixedPage fp = new FixedPage();
Label ll = new Label();
ll.Content = "测试数据可以吗?" + Environment.NewLine + "回车换行可以吗?";
ll.Margin = new Thickness(20, 40, 20, 40);
fp.Children.Add(ll);
fp.UpdateLayout();
PageContent pc = new PageContent();
((System.Windows.Markup.IAddChild)pc).AddChild(fp);
FixedDocument fd = new FixedDocument();
fd.Pages.Add(pc);
FixedDocumentSequence fds = new FixedDocumentSequence();
((System.Windows.Markup.IAddChild)fds).AddChild(fd);
documentViewer1.Document=fds;
//System.Net.NetworkInformation.NetworkInterface[] nics = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
//foreach( System.Net.NetworkInformation.NetworkInterface ni in nics )
//{
// MessageBox.Show(ni.Description);
// System.Net.NetworkInformation.PhysicalAddress address = ni.GetPhysicalAddress();
// byte[] bytes = address.GetAddressBytes();
// StringBuilder sb=new StringBuilder();
// for (int i = 0; i < bytes.Length; i++)
// {
// sb.Append(bytes[i].ToString("X2"));
// if(i<bytes.Length-1)
// sb.Append("-");
// }
// MessageBox.Show(sb.ToString());
//}
//fd. = "1234";
//}
//else
// MessageBox.Show(FtpWeb.error);
}
示例10: 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);
}
示例11: 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);
}
示例12: CreateXpsDocument
private IDocumentPaginatorSource CreateXpsDocument(string ss, string ssname)
{
FixedPage fp = new FixedPage();
Label ll = new Label();
ll.Content = ssname + Environment.NewLine + Environment.NewLine + ss;
ll.Margin = new Thickness(20, 40, 20, 40);
fp.Children.Add(ll);
fp.UpdateLayout();
PageContent pc = new PageContent();
((System.Windows.Markup.IAddChild)pc).AddChild(fp);
FixedDocument fd = new FixedDocument();
fd.Pages.Add(pc);
return fd;
}