In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "what is the difference and relationship between Silverlight4 and Flex4 printing functions", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn about "what are the differences and connections between Silverlight4 and Flex4 printing functions".
There is a big competition between Silverlight4 and Flex4 printing functions.
Silverlight has been launched as a new technology for three years. In the early version of Silverlight, everyone thought that the function of Silverlight could not be compared with Flex, but also could not surpass Flex. In November 2009, Microsoft launched a test version of Silverlight4, which once attracted the attention of many developers with its powerful functions. Many functions that were once supported under Flex can now be realized under Silverlight, and there are some new functions that Flex can not achieve. For example, Silverlight4's COM components interact with each other, from desktop drag-and-drop objects to Silverlight applications. In order to make more developers understand the Silverlight development platform, I will make a series of comparisons between Silverlight4 and Flex4, hoping to help developers learn more about the new features of Silverlight. In this article, we will compare the printing functions of Silverlight4 and Flex4.
Silverlight4 printing function
The printing function of Silverlight4 is controlled by PrintDocument class. To achieve the printing function, you need to follow the following steps:
Step 1: create the PrintDocument object
Step 2: set the document name in the PrintDocument object
Step 3: add event handles to PrintPage events, as well as StartPrint and EndPrint events
Step 4: in the PrintPage print event, create a print window, which will appear as the parent window, and you can add content or controls you want to print to the print window. For example, create a StackPanel, and then add a content control to the StackPanel that you want to print
Step 5: if HasMorePages is True when printing, multiple pages are supported for printing
Step 6: repeat steps 4 and 5 to achieve complete Silverlight4 printing
It seems that these steps are not very simple. Here is a routine code that will print out "HelloWorld" when you click the print button.
UsingSystem; usingSystem.Windows; usingSystem.Windows.Controls; usingSystem.Windows.Printing; namespaceHelloPrinter {publicpartialclassMainPage:UserControl {publicMainPage () {InitializeComponent ();} privatevoidbutton1_Click (objectsender,RoutedEventArgse) {PrintDocumentprintDoc=newPrintDocument (); printDoc.DocumentName= "HelloWorldfromSilverlight"; printDoc.PrintPage+=newEventHandler (printDoc_PrintPage); printDoc.Print ();} voidprintDoc_PrintPage (objectsender,PrintPageEventArgse) {StackPanelpanel=newStackPanel () {OrientationOrientation=Orientation.Horizontal} Panel.Children.Add (newTextBlock () {Text= "Hello", FontFamily=newSystem.Windows.Media.FontFamily ("Arial"), FontSize=12}); panel.Children.Add (newTextBlock () {Text= "World", FontFamily=newSystem.Windows.Media.FontFamily ("Arial"), FontSize=12}); e.PageVisualfields; e.HasMorePagesfalse;}
When the button is clicked, the print event handle is called. During the printing process, Silverlight will automatically set the width and height of the print window. You can get the width and height of the printed page in the print event through the PrintableArea property.
Flex4 printing function
The printing function of Flex4 is similar to that of Silverlight4, but the implementation is different. The printing function of Flex4 is not event-driven. The basic steps are as follows:
Step 1: create a FlexPrintJob object that can be thought of as the PrintDocument of Silverlight
Step 2: use a Boolean variable to control the format of the picture to be printed, such as a vector map or a bitmap
Step 3: call the Start () method in FlexPrintJob, and a prompt window will pop up, asking if you want to start printing, select OK, and you will start printing.
Step 4: create a print object and add the print object to the reality list
Step 5: add objects to the print page using addObject () in FlexPrintJob
Step 6: call the send () method in FlexPrintJob to print the added print page
Step 7: after printing, delete the printed view object
The button event code is provided below. After clicking the button, "HelloWorld" will be printed.
Protectedfunctionbutton1_clickHandler (event:MouseEvent): void {varjob:FlexPrintJob=newFlexPrintJob (); job.printAsBitmap=false; if (job.start ()) {vargroup:HGroup=newHGroup (); group.height=job.pageHeight; group.width=job.pageWidth; vartext:SimpleText=newSimpleText (); text.text= "Hello"; text.setStyle ("fontFamily", "Arial"); text.setStyle ("fontSize", 12); group.addElement (text); text=newSimpleText (); text.setStyle ("fontFamily", "Arial") Text.setStyle ("fontSize", 12); text.text= "World"; group.addElement (text); addElement (group); job.addObject (group,FlexPrintJobScaleType.NONE); job.send (); removeElement (group);}
Comparing the above two groups of print codes, we can see that Flex printing requires some more parameters, mainly because:
1. In Flex printing, you need to set the print format, bitmap mode or vector map mode.
2.Flex does not support automatically setting the width and height of printed objects in the printed page.
The above is all the contents of this article entitled "what are the differences and connections between Silverlight4 and Flex4 printing functions?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.