Exemple #1
0
        private void MenuItem_Click_2(object sender, RoutedEventArgs e)
        {
            PrintDialog pd = new PrintDialog();

            pd.PageRangeSelection   = PageRangeSelection.AllPages;
            pd.UserPageRangeEnabled = true;
            if (pd.ShowDialog() == false)
            {
                return;
            }
            FooPrintText printtext = new FooPrintText();

            printtext.Document           = this.fooTextBox.Document;
            printtext.Font               = this.fooTextBox.FontFamily;
            printtext.FontSize           = this.fooTextBox.FontSize;
            printtext.DrawLineNumber     = this.fooTextBox.DrawLineNumber;
            printtext.Header             = "header";
            printtext.Footer             = "footter";
            printtext.LineBreakMethod    = this.fooTextBox.LineBreakMethod;
            printtext.LineBreakCharCount = this.fooTextBox.LineBreakCharCount;
            printtext.MarkURL            = true;
            printtext.Hilighter          = this.fooTextBox.Hilighter;
            printtext.Foreground         = this.fooTextBox.Foreground;
            printtext.URL           = this.fooTextBox.URL;
            printtext.Comment       = this.fooTextBox.Comment;
            printtext.Keyword1      = this.fooTextBox.Keyword1;
            printtext.Keyword2      = this.fooTextBox.Keyword2;
            printtext.Litral        = this.fooTextBox.Literal;
            printtext.FlowDirection = this.fooTextBox.FlowDirection;
            if (pd.PageRangeSelection == PageRangeSelection.AllPages)
            {
                printtext.StartPage = -1;
                printtext.EndPage   = -1;
            }
            else
            {
                printtext.StartPage = pd.PageRange.PageFrom;
                printtext.EndPage   = pd.PageRange.PageTo;
            }
            printtext.PageRect = new Rect(0, 0, pd.PrintableAreaWidth, pd.PrintableAreaHeight);
            printtext.Print(pd);
        }