Grid Content;
UIElement Child;
UIElement Child2;
public bool dialogresult;
int Pgs;
public void Subject(Grid content, UIElement child, UIElement child2, int pages)
{
Content = content;
Child = child;
Child2 = child2;
Pgs = pages;
}
public void Printing()
{
#region 2pgs
if (Pgs == 2)
{
var dialog = new SaveFileDialog();
dialog.AddExtension = true;
dialog.DefaultExt = "pdf";
dialog.Filter = "PDF Document (*.pdf)|*.pdf";
//dialog.ShowDialog();
if (dialog.ShowDialog() == true)
{
dialogresult = true;
PrintDialog printDialog = new PrintDialog();
FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
PrintDialog printDlg = new PrintDialog();
Size pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);
PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
Size visibleSize = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
//var visual = Child as UIElement;
(Content).Children.Remove(Child);
fixedPage.Children.Add(Child);
((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
fixedDoc.Pages.Add(pageContent);
FixedPage fixedPage1 = new FixedPage();
PageContent pageContent1 = new PageContent();
//var visual2 = Child2 as UIElement;
(Content).Children.Remove(Child2);
fixedPage1.Children.Add(Child2);
((System.Windows.Markup.IAddChild)pageContent1).AddChild(fixedPage1);
fixedDoc.Pages.Add(pageContent1);
//write to PDF file
string tempFilename = "temp.Xps";
File.Delete(tempFilename);
XpsDocument xpsd = new XpsDocument(tempFilename, FileAccess.ReadWrite);
XpsDocumentWriter xw = XpsDocument.CreateXpsDocumentWriter(xpsd);
xw.Write(fixedDoc);
xpsd.Close();
PdfSharp.Xps.XpsConverter.Convert(tempFilename, dialog.FileName, 1);}
}
}
我尝试为每个“楼层”创建我的House多个GridView显示信息 但是后来,我已经意识到设置多个gridview这样会使代码混乱并设置多个功能是浪费时间。无论如何将其视为1 GridView?每个楼层的所有gridview都显示相同的内容。但由于分离“它是哪个楼层?”我必须这样做