本文整理汇总了C#中System.Windows.Documents.FixedDocument类的典型用法代码示例。如果您正苦于以下问题:C# FixedDocument类的具体用法?C# FixedDocument怎么用?C# FixedDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FixedDocument类属于System.Windows.Documents命名空间,在下文中一共展示了FixedDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateFixedDocument
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;
}
开发者ID:brunoklein99,项目名称:nikon-camera-control,代码行数:35,代码来源:DocumentUtility.cs
示例2: ShowFixedDocument
/// <summary>
/// Displays the <see cref="FixedDocument" /> in a <see cref="DocumentViewer" />
/// </summary>
/// <param name="fixedDocument">The fixed document to display.</param>
/// <param name="title">Title of the preview window</param>
/// <param name="windowProvider">An implementation for creating a customized window. If null, default implementation is used.</param>
public static void ShowFixedDocument(FixedDocument fixedDocument, string title, IWindowProvider windowProvider = null)
{
var tempFileName = Path.GetTempFileName();
WriteXps(fixedDocument, tempFileName);
ShowXps(tempFileName, title, windowProvider);
}
开发者ID:xxMUROxx,项目名称:Mairegger.Printing,代码行数:13,代码来源:XPSHelper.cs
示例3: btnPrint_Click_1
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");
}
}
开发者ID:jaggavarapu,项目名称:AirlineReservation,代码行数:25,代码来源:OrderSummaryPage.xaml.cs
示例4: GenerateFixedDocumentFromText
/// <summary>
/// Builds FixedDocument from string.
/// </summary>
/// <param name="text">Text to use.</param>
/// <returns>FixedDocument of text.</returns>
public static FixedDocument GenerateFixedDocumentFromText(string text)
{
FixedDocument document = new FixedDocument();
PageContent content = GeneratePageFromText(text);
document.Pages.Add(content);
return document;
}
开发者ID:KFreon,项目名称:Useful-C-Sharp-Collection,代码行数:12,代码来源:Documents.cs
示例5: SaveFixedDocumentAsTiff
public static void SaveFixedDocumentAsTiff(FixedDocument document, string outputFileName)
{
int pages = document.DocumentPaginator.PageCount;
TiffBitmapEncoder encoder = new TiffBitmapEncoder();
encoder.Compression = TiffCompressOption.Ccitt4;
for (int pageNum = 0; pageNum < pages; pageNum++)
{
DocumentPage docPage = document.DocumentPaginator.GetPage(pageNum);
RenderTargetBitmap renderTarget =
new RenderTargetBitmap((int)(docPage.Size.Width * 300 / 96),
(int)(docPage.Size.Height * 300 / 96),
300d, // WPF (Avalon) units are 96dpi based
300d,
System.Windows.Media.PixelFormats.Default);
renderTarget.Render(docPage.Visual);
encoder.Frames.Add(BitmapFrame.Create(renderTarget));
}
FileStream outputFileStream = new FileStream(outputFileName, FileMode.Create);
encoder.Save(outputFileStream);
outputFileStream.Close();
}
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:26,代码来源:FileConversionHelper.cs
示例6: Start
public override void Start()
{
base.Start();
document = new FixedDocument();
// point 595x842
// 827/1169
// A4 paper is 210mm x 297mm
//8.2 inch x 11.6 inch
//1240 px x 1754 px
/*
iTextSharp uses a default of 72 pixels per inch.
792 would be 11", or the height of a standard Letter size paper." +
595 would be 8.264",
which is the standard width of A4 size paper.
Using 595 x 792 as the page size would be a cheap and dirty way
to ensure that you could print on either A4 or Letter
without anything getting cut off. –
*/
docCreator.PageSize = new System.Windows.Size(reportSettings.PageSize.Width,reportSettings.PageSize.Height);
document.DocumentPaginator.PageSize = docCreator.PageSize;
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:26,代码来源:FixedDocumentRenderer.cs
示例7: FixedDocumentFromImageStream
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;
}
开发者ID:cipjota,项目名称:Chronos,代码行数:29,代码来源:XpsHelper.cs
示例8: print_btn_Click
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");
}
}
开发者ID:sumit10,项目名称:BMS,代码行数:26,代码来源:home.xaml.cs
示例9: Convert
public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
{
var document = value as Document;
if (document == null)
return null;
FrameworkContentElement content;
DocumentRenderTargetBase target;
if (DocumentType == PresentationDocumentType.FixedDocument) {
var fixedDocument = new FixedDocument();
target = new FixedDocumentRenderTarget(fixedDocument);
content = fixedDocument;
}
else {
var flowDocument = new FlowDocument();
target = new FlowDocumentRenderTarget(flowDocument);
content = flowDocument;
}
target.Background = Background;
target.FontFamily = FontFamily;
target.FontSize = FontSize;
target.FontStretch = FontStretch;
target.FontStyle = FontStyle;
target.FontWeight = FontWeight;
ConsoleRenderer.RenderDocument(document, target, new Rect(new Size(ConsoleWidth, Size.Infinity)));
return content;
}
开发者ID:jhorv,项目名称:CsConsoleFormat,代码行数:30,代码来源:DocumentConverter.cs
示例10: SaveXPS
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;
}
开发者ID:mydipcom,项目名称:MEIKReport,代码行数:30,代码来源:FileHelper.cs
示例11: CreateFixedDocument
static FixedDocument CreateFixedDocument(ReportSettings reportSettings)
{
var document = new FixedDocument();
document.DocumentPaginator.PageSize = new System.Windows.Size(reportSettings.PageSize.Width,
reportSettings.PageSize.Height);
return document;
}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:7,代码来源:PreviewViewModel.cs
示例12: AddPageToDocument
static void AddPageToDocument(FixedDocument fixedDocument,FixedPage page)
{
PageContent pageContent = new PageContent();
((IAddChild)pageContent).AddChild(page);
fixedDocument.Pages.Add(pageContent);
}
开发者ID:ichengzi,项目名称:SharpDevelop,代码行数:7,代码来源:WpfExporter.cs
示例13: PrintPreview_Click
private void PrintPreview_Click(object sender, RoutedEventArgs e)
{
var printdialog = new PrintDialog();
if (printdialog.ShowDialog() != true) { return; }
var doc = new FixedDocument();
doc.DocumentPaginator.PageSize = new Size(printdialog.PrintableAreaWidth, printdialog.PrintableAreaHeight);
var queue = printdialog.PrintQueue;
var caps = queue.GetPrintCapabilities();
var area = caps.PageImageableArea;
var marginwidth = (printdialog.PrintableAreaWidth - caps.PageImageableArea.ExtentWidth) / 2.0;
var marginheight = (printdialog.PrintableAreaHeight - caps.PageImageableArea.ExtentHeight) / 2.0;
double gutter;
if (!Double.TryParse(GutterWidthTextbox.Text, out gutter)) { gutter = 0.25; }
// Translate inches to device independent pixels
gutter *= 96.0;
var opts = new PrintOptions
{
PrintableWidth = area.ExtentWidth,
PrintableHeight = area.ExtentHeight,
MarginWidth = marginwidth,
MarginHeight = marginheight,
Gutter = gutter
};
var category = (CardCategory)DataContext;
category.AddPagesToDocument(doc, opts, category.SelectedCards);
var preview = new PrintPreview();
preview.Document = doc;
preview.ShowDialog();
}
开发者ID:dyselon,项目名称:cscribe,代码行数:33,代码来源:PrintSelectedOptions.xaml.cs
示例14: printing_2
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();
}
开发者ID:K0lyuchiy,项目名称:Tass,代码行数:59,代码来源:print.cs
示例15: GenerateReport
protected FixedDocument GenerateReport(Func<int, object> frameDataContext, Size paperSize, Margins margins, IEnumerable records)
{
var document = new FixedDocument();
document.DocumentPaginator.PageSize = new Size(DPI * paperSize.Width, DPI * paperSize.Height);
foreach (var page in CreatePages(frameDataContext, paperSize, margins, records))
{
document.Pages.Add(page);
}
return document;
}
开发者ID:frederiksen,项目名称:Task-Card-Creator,代码行数:10,代码来源:ReportFromTemplate.cs
示例16: OnLoaded
public void OnLoaded(object sender, RoutedEventArgs args)
{
XpsDocument document = new XpsDocument(Window1.CombineFileInCurrentDirectory("CSharp 3.0 Specification.xps"), System.IO.FileAccess.Read);
FixedDocument doc = new FixedDocument();
FixedDocumentSequence fixedDoc = document.GetFixedDocumentSequence();
viewer.Document = fixedDoc;
viewer.FitToHeight();
}
开发者ID:dingxinbei,项目名称:OLdBck,代码行数:10,代码来源:UCFixedDocument.xaml.cs
示例17: Run
public override void Run () {
Document = new FixedDocument();
foreach (var page in Pages) {
IAcceptor acceptor = page as IAcceptor;
if (acceptor != null) {
visitor.Visit(page);
}
AddPageToDocument(Document,visitor.FixedPage);
}
}
开发者ID:Rew,项目名称:SharpDevelop,代码行数:10,代码来源:WpfExporter.cs
示例18: CreatePages
private static int CreatePages(DefinitionsForPrintWithXAMLControls XAMLDefinitionsForOnePage,
FixedDocument PageDocumentToPrint, double MaxOHeight,
List<Object> printCollection, ObservableCollection<object> PageCollection,
String HeadLineText, int NumberOfPages = 0)
{
int CountedNumberOfPages = 0;
double RemainingHeight = 0;
List<CommonPageFooter> CreatetedFooterPages = new List<CommonPageFooter>();
PageCollection.Add(new CommonPageHeader() { HeadLineText = HeadLineText });
foreach (object ControlToPrint in printCollection)
{
PageCollection.Add(ControlToPrint);
XAMLDefinitionsForOnePage.Measure(new Size(PAPER_SIZE_WIDTH, PAPER_SIZE_HEIGHT));
XAMLDefinitionsForOnePage.Arrange(new Rect(new Point(), new Size(PAPER_SIZE_WIDTH, PAPER_SIZE_HEIGHT)));
XAMLDefinitionsForOnePage.UpdateLayout();
double width = XAMLDefinitionsForOnePage.DesiredSize.Width;
double height = XAMLDefinitionsForOnePage.DesiredSize.Height;
RemainingHeight = MaxOHeight - height;
if (height > MaxOHeight)
{
PageCollection.Remove(ControlToPrint);
CreatetedFooterPages.Add(new CommonPageFooter());
PageCollection.Add(CreatetedFooterPages.Last());
XAMLDefinitionsForOnePage = GenerateNewContent(PageDocumentToPrint);
PageCollection = XAMLDefinitionsForOnePage.GlobalContainer.ItemsSource as ObservableCollection<object>;
PageCollection.Add(new CommonPageHeader() { HeadLineText = HeadLineText});
PageCollection.Add(ControlToPrint);
XAMLDefinitionsForOnePage.Measure(new Size(PAPER_SIZE_WIDTH, PAPER_SIZE_HEIGHT));
XAMLDefinitionsForOnePage.Arrange(new Rect(new Point(), new Size(PAPER_SIZE_WIDTH, PAPER_SIZE_HEIGHT)));
XAMLDefinitionsForOnePage.UpdateLayout();
CountedNumberOfPages++;
}
}
CreatetedFooterPages.Add(new CommonPageFooter() { DistanceToLastLineValue = RemainingHeight - 20});
PageCollection.Add(CreatetedFooterPages.Last());
CountedNumberOfPages++;
int WorkingPageNumber = 0;
foreach (CommonPageFooter Footer in CreatetedFooterPages)
{
Footer.NumberOfPages = CountedNumberOfPages;
Footer.PageNumber = ++WorkingPageNumber;
}
foreach (PageContent Page in PageDocumentToPrint.Pages)
{
Page.Measure(new Size(PAPER_SIZE_WIDTH, PAPER_SIZE_HEIGHT));
Page.Arrange(new Rect(new Point(), new Size(PAPER_SIZE_WIDTH, PAPER_SIZE_HEIGHT)));
Page.UpdateLayout();
}
return CountedNumberOfPages;
}
开发者ID:heinzsack,项目名称:DEV,代码行数:54,代码来源:CommonXpsPrinter.cs
示例19: PrivateCreatePagesFromFixedDocument
private void PrivateCreatePagesFromFixedDocument(FixedDocument fixedDocument)
{
foreach (var pageContent in fixedDocument.Pages)
{
Pages.Add(((IUriContext) pageContent).BaseUri != null
? new RollUpFixedPage(pageContent.Source, ((IUriContext) pageContent).BaseUri)
: new RollUpFixedPage(pageContent.Child));
}
Source = null;
BaseUri = null;
}
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:11,代码来源:RollupFixedDocument.cs
示例20: GenerateFixedDocumentFromFile
/// <summary>
/// Builds FixedDocument from file.
/// </summary>
/// <param name="filename">Path of file to use.</param>
/// <param name="err">Error container.</param>
/// <returns>FixedDocument of file.</returns>
public static FixedDocument GenerateFixedDocumentFromFile(string filename, out string err)
{
FixedDocument doc = new FixedDocument();
string text = null;
// KFreon: Set error if necessary
if ((err = UsefulThings.General.ReadTextFromFile(filename, out text)) == null)
doc = GenerateFixedDocumentFromText(text);
return doc;
}
开发者ID:KFreon,项目名称:Useful-C-Sharp-Collection,代码行数:17,代码来源:Documents.cs
注:本文中的System.Windows.Documents.FixedDocument类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论