2014-01-09 2 views
1

Silverlight를 처음 사용합니다. 인쇄 할 때 DatePicker 아이콘을 제거해야합니다. 그래서 나는이 코드를 인쇄 할 때 아이콘을 없애기 위해 썼다. 인쇄 대화 상자에서 인쇄 버튼을 클릭하면 올바르게 작동합니다. 하지만 인쇄 대화 상자를 닫으면 날짜 선택기 아이콘이 나타나지 않습니다. 인쇄 대화 상자의 가까운 이벤트에 코드를 작성해야합니다. 인쇄 대화 상자의 이벤트를 찾을 수 없습니다. Silverlight에서 인쇄 대화 상자 닫기 이벤트를 처리하는 방법 5

인쇄 코드입니다 :

private StackPanel Downloaded_Data(StackPanel Sp_Element) 
    { 
     foreach (UIElement ele in Sp_Element.Children) 
     { 
      if (ele is FirstPageTC) 
      { 
       if ((ele as FirstPageTC).Content is StackPanel) 
        Downloaded_Data((ele as FirstPageTC).Content as StackPanel); 
       if ((ele as FirstPageTC).Content is Grid) 
        Download_Grid((ele as FirstPageTC).Content as Grid); 
      } 
      if (ele is Blank_Page) 
      { 
       if ((ele as Blank_Page).Content1 is StackPanel) 
        Downloaded_Data((ele as Blank_Page).Content1 as StackPanel); 
       if ((ele as Blank_Page).Content1 is Grid) 
        Download_Grid((ele as Blank_Page).Content1 as Grid); 
      } 


      if (ele is DatePicker) 
      { 
       DatePicker s = ele as DatePicker; 
       s.Style = App.Current.Resources["DateStyle"] as Style; 
       // s.Background = new SolidColorBrush(Color.FromArgb(255, 143, 188, 143)); 
      } 

      if (ele is StackPanel) 
      { 
       Downloaded_Data(ele as StackPanel); 
      } 
      if (ele is Grid) 
      { 
       Download_Grid(ele as Grid); 
      } 
     } 
     return Sp_Element; 
    } 

    public void Download_Grid(Grid grid_down) 
    { 
     foreach (UIElement ele in grid_down.Children) 
     { 
      if (ele is Border) 
      { 
       UIElement ele_b = (ele as Border).Child; 
       if (ele_b is DatePicker) 
       { 
        DatePicker s = ele_b as DatePicker; 

        s.Style = App.Current.Resources["DateStyle"] as Style; 
        // s.Background = new SolidColorBrush(Color.FromArgb(255, 143, 188, 143)); 
       } 

       //here 
       if (ele_b is Grid) 
       { 
        Download_Grid(ele_b as Grid); 
       } 
       if (ele_b is StackPanel) 
       { 
        Downloaded_Data(ele_b as StackPanel); 
       } 
      } 
     } 
    } 

    private void Downloaded_Datepicker(StackPanel Sp_Element) 
    { 
     foreach (UIElement ele in Sp_Element.Children) 
     { 
      if (ele is FirstPageTC) 
      { 
       if ((ele as FirstPageTC).Content is StackPanel) 
        Downloaded_Datepicker((ele as FirstPageTC).Content as StackPanel); 
       if ((ele as FirstPageTC).Content is Grid) 
        Download_GridDate((ele as FirstPageTC).Content as Grid); 
      } 
      if (ele is Blank_Page) 
      { 
       if ((ele as Blank_Page).Content1 is StackPanel) 
        Downloaded_Datepicker((ele as Blank_Page).Content1 as StackPanel); 
       if ((ele as Blank_Page).Content1 is Grid) 
        Download_GridDate((ele as Blank_Page).Content1 as Grid); 
      } 


      if (ele is DatePicker) 
      { 
       DatePicker s = ele as DatePicker; 

       s.Style = App.Current.Resources["DateNormal"] as Style; 
      } 

      if (ele is StackPanel) 
      { 
       Downloaded_Datepicker(ele as StackPanel); 
      } 
      if (ele is Grid) 
      { 
       Download_GridDate(ele as Grid); 
      } 
     } 

    } 

    public void Download_GridDate(Grid grid_down) 
    { 
     foreach (UIElement ele in grid_down.Children) 
     { 
      if (ele is Border) 
      { 
       UIElement ele_b = (ele as Border).Child; 
       if (ele_b is DatePicker) 
       { 
        DatePicker s = ele_b as DatePicker; 
        s.Style = App.Current.Resources["DateNormal"] as Style; 

       } 

       //here 
       if (ele_b is Grid) 
       { 
        Download_GridDate(ele_b as Grid); 
       } 
       if (ele_b is StackPanel) 
       { 
        Downloaded_Datepicker(ele_b as StackPanel); 
       } 
      } 
     } 
    } 

    public void PrintPage(StackPanel sp_Print) 
    { 
     foreach (UIElement sp_Element in sp_Print.Children) 
     { 
      if (sp_Element is StackPanel) 
      { 
       StackPanel printableSpnel=Downloaded_Data(sp_Element as StackPanel); 
       //sp_Printing[count] = sp_Element as StackPanel; 
       //count = count + 1;  
       sp_Printing[count] = printableSpnel; 
       count = count + 1; 
      } 
     } 
     WithDatePickerIcon = sp_Print as StackPanel; 
     print_Doc.PrintPage += new EventHandler<PrintPageEventArgs>(print_Doc_PrintPage); 
     print_Doc.Print("REOSK Printing"); 
    } 

    void print_Doc_PrintPage(object sender, PrintPageEventArgs e) 
    { 

     if (count == i) 
     {     
      e.PageVisual = sp_Printing[i]; 
      e.HasMorePages = false; 
      Downloaded_Datepicker(WithDatePickerIcon as StackPanel); 
     }    
     else 
     {  
      e.PageVisual = sp_Printing[i];     
      e.HasMorePages = true; 
      i = i + 1; 
      Downloaded_Datepicker(WithDatePickerIcon as StackPanel); 
     } 
    } 

답변

0
나는 완전히 당신의 코드를 이해 말할 수는 없지만, 아마 당신의 문제가 그 문제 하나 중요한 것이 있습니다

:

당신은 shouldn은 PrintDocument에서 BeginPrint 이벤트가 호출되지 않으면 가정 인쇄에서 프로그램 상태를 수정하기 시작합니다 (인쇄 버튼을 비활성화하거나 아무 것도 표시하지 않음). EndPrint 이벤트에서 사용자가 수행 한 모든 작업이 정상으로 복귀됩니다.

PrintPage 메서드의 대부분 (PrintPage*s*?이라고 말하면 안 됨)은 BeginPrint 이벤트를 수신하는 처리기에 있어야합니다.

인쇄 API의 작업 클라이언트는이 세 가지 이벤트를 모두 청취해야합니다. Print에 대한 호출이 아닌 BeginPrint으로 인쇄가 시작됩니다. 사용자는 경험 한대로 취소를 클릭하여 인쇄를 중단 할 수 있습니다.