2011-08-06 10 views
0

목표 :
는 WPFWPF에서 라인을 만드는 방법

에 A4 크기의 PDF 파일에서 reciept 만들기

문제 :
문서에 걸쳐 라인을 구현하는 방법을 알고하지 마십시오. 해당 문서는 pdf 파일로 생성됩니다.

문서에 적용해야하지만 줄이 아닌 텍스트와 그림을 만들고 구현하는 방법을 알고 있습니다.

enter image description here 이 텍스트 위의이 그림은 소스 코드에서 가로줄이 없습니다. 다시 말하지만, 행 사이에 가로 질러 선을 만드는 방법은 무엇입니까?

// Fullmetalboy

namespace MediaStore.MenuCheckout 
{ 
    /// <summary> 
    /// Interaction logic for Reciept.xaml 
    /// </summary> 
    public partial class Reciept : UserControl 
    { 

     private Testt _Testt; 
     private ManagerCart _myManagerCart; 
     private ManagerProduct_SaleAndProductQuantity _myManagerProduct_SaleAndProductQuantity; 

     public Reciept(Testt pTestt, ManagerCart pManagerCart, ManagerProduct_SaleAndProductQuantity pManagerProduct_SaleAndProductQuantity) 
     { 
      InitializeComponent(); 

      _Testt = pTestt; 

      _myManagerCart = pManagerCart; 
      _myManagerProduct_SaleAndProductQuantity = pManagerProduct_SaleAndProductQuantity; 
     } 

     private void btnClose_Click(object sender, RoutedEventArgs e) 
     { 
      _Testt.Close(); 
     } 


     private int _header1 = 75; 
     private int _header2 = 200; 
     private int _header3 = 280; 
     private int _header4 = 480; 
     private int _header5 = 570; 
     private int _rowY = 60; 


     private void btnPrint_Click(object sender, RoutedEventArgs e) 
     { 

      PrintDialog myPrintDialog = new PrintDialog(); 

      if (myPrintDialog.ShowDialog() == true) 
      { 
       // Create a myDrawingVisual for the page. 
       DrawingVisual myDrawingVisual = new DrawingVisual(); 

       // Get the drawing context 
       using (DrawingContext myDrawingContext = myDrawingVisual.RenderOpen()) 
       { 

        // Create headline 

        FormattedText headArticleNumber = new FormattedText("Article number", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                   new Typeface("Verdana"), 12, Brushes.Black); 

        FormattedText headQuantity = new FormattedText("Quantity", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                    new Typeface("Verdana"), 12, Brushes.Black); 

        FormattedText headName = new FormattedText("Name", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
              new Typeface("Verdana"), 12, Brushes.Black); 

        FormattedText headPriceQTY = new FormattedText("Price/QTY", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                    new Typeface("Verdana"), 12, Brushes.Black); 

        FormattedText headSum = new FormattedText("Sum", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                   new Typeface("Verdana"), 12, Brushes.Black); 





        Point myPoint1 = new Point(_header1, _rowY); 
        Point myPoint2 = new Point(_header2, _rowY); 
        Point myPoint3 = new Point(_header3, _rowY); 
        Point myPoint4 = new Point(_header4, _rowY); 
        Point myPoint5 = new Point(_header5, _rowY); 

        // Draw the content. 
        myDrawingContext.DrawText(headArticleNumber, myPoint1); 
        myDrawingContext.DrawText(headQuantity, myPoint2); 
        myDrawingContext.DrawText(headName, myPoint3); 
        myDrawingContext.DrawText(headPriceQTY, myPoint4); 
        myDrawingContext.DrawText(headSum, myPoint5); 



        foreach(var a in _myManagerCart.GetAllProductFromCartList()) 
        { 
         FormattedText articleNumber = new FormattedText(a._articleNumber.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                     new Typeface("Verdana"), 12, Brushes.Black); 

         FormattedText name = new FormattedText(a._name, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                   new Typeface("Verdana"), 12, Brushes.Black); 

         FormattedText price = new FormattedText(a._price.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                   new Typeface("Verdana"), 12, Brushes.Black); 

         FormattedText quantity = new FormattedText(a._quantity.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                    new Typeface("Verdana"), 12, Brushes.Black); 

         FormattedText sum = new FormattedText(a._sum.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                   new Typeface("Verdana"), 12, Brushes.Black); 


         _rowY = _rowY + 60; 

         myPoint1 = new Point(_header1, _rowY); 
         myPoint2 = new Point(_header2, _rowY); 
         myPoint3 = new Point(_header3, _rowY); 
         myPoint4 = new Point(_header4, _rowY); 
         myPoint5 = new Point(_header5, _rowY); 

         myDrawingContext.DrawText(articleNumber, myPoint1); 
         myDrawingContext.DrawText(quantity, myPoint2); 
         myDrawingContext.DrawText(name, myPoint3); 
         myDrawingContext.DrawText(price, myPoint4); 
         myDrawingContext.DrawText(sum, myPoint5); 
        } 


        SalesTrans mySalesTrans = _myManagerProduct_SaleAndProductQuantity.RetrieveLatestReceiptInfo(); 

        FormattedText totalCost = new FormattedText("Total cost: " + mySalesTrans._totalCost.ToString() + " dollar", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                   new Typeface("Verdana"), 14, Brushes.Black); 

        totalCost.SetFontWeight(FontWeights.Bold); 


        FormattedText receiptNumber = new FormattedText("Reciept number: " + mySalesTrans._receiptNumber.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                    new Typeface("Verdana"), 12, Brushes.Black); 

        FormattedText salesDate = new FormattedText("Date: " + mySalesTrans._salesDate.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, 
                   new Typeface("Verdana"), 12, Brushes.Black); 


        Point myPoint = new Point(_header5, _rowY + 80); 
        myDrawingContext.DrawText(totalCost, myPoint); 

        myPoint = new Point(_header5, _rowY + 120); 
        myDrawingContext.DrawText(receiptNumber, myPoint); 

        myPoint = new Point(_header5, _rowY + 160); 
        myDrawingContext.DrawText(salesDate, myPoint); 

        int sdf = 23; 


       } 

       // Print the myDrawingVisual. 
       myPrintDialog.PrintVisual(myDrawingVisual, "Receipt"); 
      } 


     } 


    } 
} 

답변

1

WPF의 기본 그림은 Overview

입니다.
+0

더 이해하기 쉽도록 더 많은 정보를 추가했습니다. –

4

사물을 분리하는 단지 수평선 더 많은 제어가 필요한 경우 다음 그렇지 않으면

<Separator/> 

를 사용하는 경우는 다음 라인 제어

<Line X1="0" X2="200" Y1="0" Y2="0" Stroke="Black" StrokeThickness="2" /> 
있다
+0

더 이해하기 쉬운 정보를 추가했습니다. –

관련 문제