Live writer 2011, 代码染色测试

 

            PrintPreview cw = new PrintPreview();
            cw.ShowPreview(rtb);
            cw.HasCloseButton = false;

            //Hook up a handler to the Closed event before we display the PrintPreview window by calling the Show() method.
            cw.Closed += (t, a) =>
            {
                if (cw.DialogResult.Value)
                {
                    PrintDocument theDoc = new PrintDocument();
                    theDoc.PrintPage += (s, args) =>
                    {
                        args.PageVisual = rtb;
                        args.HasMorePages = false;
                    };

                    theDoc.EndPrint += (s, args) =>
                    {
                        MessageBox.Show("The document printed successfully", "Text Editor", MessageBoxButton.OK);
                    };

                    theDoc.Print("Silverlight 4 Text Editor");
                    ReturnFocus();
                }
            };
            cw.Show();

posted on 2010-10-12 22:07  无法显示此网页  阅读(200)  评论(0编辑  收藏  举报

导航