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);
}
}