public void Test7() { Action <string> debugOut = (s) => _outputHelper.WriteLine(s); var c = new RoslynCodeBase(debugOut); _control0 = c; c.JTF2 = _f.JTF2; // c.JTF = new JoinableTaskFactory(new JoinableTaskContext()); c.SourceText = File.ReadAllText(@"C:\temp\dockingmanager.cs"); var StartTime = DateTime.MinValue; c.AddHandler(RoslynCodeBase.RenderStartEvent, new RoutedEventHandler((sender, args) => { StartTime = DateTime.Now; Debug.WriteLine("render start"); })); c.AddHandler(RoslynCodeBase.RenderCompleteEvent, new RoutedEventHandler((sender, args) => { var span = DateTime.Now - StartTime; Debug.WriteLine("render complete " + span); })); c.JTF.Run(c.UpdateFormattedTextAsync); WriteDocument(c); }
private static void WriteDocument(RoslynCodeBase b) { var bDocumentPaginator = b.DocumentPaginator; if (bDocumentPaginator == null) { throw new InvalidOperationException("No paginator"); } // var dg = new PrintDialog(); // dg.PrintDocument(bDocumentPaginator, ""); var cTempDoc12Xps = @"c:\temp\doc12.xps"; File.Delete(cTempDoc12Xps); var _xpsDocument = new XpsDocument(cTempDoc12Xps, FileAccess.ReadWrite); var xpsdw = XpsDocument.CreateXpsDocumentWriter(_xpsDocument); if (bDocumentPaginator != null) { xpsdw.Write(bDocumentPaginator); } _xpsDocument.Close(); }
private async Task M1() { cb = new RoslynCodeBase(DebugFn) { JTF2 = JTF2, SourceText = Filename != null?File.ReadAllText(Filename) : "", DocumentTitle = Filename ?? "Untitled", Rectangle = new Rectangle(), FontSize = 14.0, FontFamily = new FontFamily("Lucida Console") }; await cb.UpdateFormattedTextAsync(); DirectoryInfo d = new DirectoryInfo(@"C:\temp\code"); LocalPrintServer s = new LocalPrintServer(); // var pdfQueues = s.GetPrintQueues().Where(queue => queue.FullName.ToLowerInvariant().Contains("pdf") && !queue.IsInError && !queue.IsOffline).ToList(); // PrintDialog pd1 = new PrintDialog(); //pd1.ShowDialog(); _dp = new RoslynPaginator(cb); PageCount = _dp.PageCount; // pd1.PrintDocument(_dp, "code"); // PrintQueue q; // if (pdfQueues.Count() == 1) // { // q = pdfQueues.First(); // } // else // { // q = pdfQueues.Skip(1).First(); // } var tf = Path.Combine(d.FullName, Path.ChangeExtension(Path.GetFileName(Path.GetTempFileName()), ".xps")); //Path.GetTempFileName(); var _xpsDocument = new XpsDocument(tf, FileAccess.ReadWrite); var xpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(_xpsDocument); xpsDocumentWriter.Write(_dp); _xpsDocument.Close(); var f2 = Path.Combine(d.FullName, Path.ChangeExtension(Path.GetFileName(Path.GetTempFileName()), ".xps")); File.Copy(tf, f2); var f3 = Path.Combine(d.FullName, Path.ChangeExtension(Path.GetFileName(Path.GetTempFileName()), ".xps")); File.Copy(tf, f3); // var j = q.AddJob("code", f2, false); //j.Commit(); _xps2 = new XpsDocument(f2, FileAccess.Read); DocView.Document = _xps2.GetFixedDocumentSequence(); // grid.Children.Remove(cb); // DocView.Document = cb; var b1 = _dp._bmp; ImageBrush b2 = new ImageBrush(b1); rect2.Fill = b2; AllPagesBitmap = b1; b2.Stretch = Stretch.Uniform; CurPage = 0; }