- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
print barcode labels in vb.net Figure 10-12. Opening Notepad from Silverlight in C#
Figure 10-12. Opening Notepad from Silverlight PDF-417 2d Barcode Drawer In C#.NET Using Barcode printer for Visual Studio .NET Control to generate, create PDF-417 2d barcode image in .NET framework applications. www.OnBarcode.comScan PDF 417 In C# Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comCHAPTER 10 SYSTEM INTEGRATION AND DEVICE SUPPORT
Generate Barcode In C# Using Barcode encoder for Visual Studio .NET Control to generate, create Barcode image in .NET framework applications. www.OnBarcode.comBarcode Printer In Visual C# Using Barcode drawer for Visual Studio .NET Control to generate, create Barcode image in .NET framework applications. www.OnBarcode.comDropping Files on a Silverlight Application
Printing PDF-417 2d Barcode In C#.NET Using Barcode generator for .NET framework Control to generate, create PDF 417 image in Visual Studio .NET applications. www.OnBarcode.comMatrix 2D Barcode Printer In C#.NET Using Barcode generation for VS .NET Control to generate, create Matrix image in Visual Studio .NET applications. www.OnBarcode.comA feature that users have grown very accustomed to in desktop applications is the ability to drag files directly onto the application and have some action take place. With web applications, in contrast, you ve always been restricted to browse functionality, which is not efficient or intuitive to users. Silverlight 4, however, supports the ability to drag files directly onto a Silverlight application. Currently this is limited to files, but you can see from the API that future releases of Silverlight will most likely support additional types. To enable drop functionality in your application, you need only enable one property on your UI element, AllowDrop. If you set AllowDrop to true on your element, your application can immediately access the drop target functionality. Once AllowDrop has been set, you have a number of events that will allow you to work with file(s) dropped onto your application. The DragEnter, DragLeave and DragOver events are fired during the drag process, but the primary event we are concerned with is the Drop event that occurs when a file is actually dropped onto our control. Data Matrix 2d Barcode Generator In C#.NET Using Barcode creation for .NET Control to generate, create Data Matrix 2d barcode image in VS .NET applications. www.OnBarcode.comLeitcode Printer In C#.NET Using Barcode encoder for .NET Control to generate, create Leitcode image in VS .NET applications. www.OnBarcode.comDrop Event
Making PDF 417 In Java Using Barcode printer for Java Control to generate, create PDF417 image in Java applications. www.OnBarcode.comPrinting PDF-417 2d Barcode In None Using Barcode creator for Font Control to generate, create PDF417 image in Font applications. www.OnBarcode.comThe Drop event occurs when a file is dropped onto a control with AllowDrop enabled. This is the primary event that is used in enabling Silverlight as a drop target. From within the Drop event you can get information about the file list from the DropEventArgs.Data property. Let s get a closer look at enabling file drop in a Silverlight application by running through an example. Scanning QR Code 2d Barcode In C# Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comBarcode Generator In VS .NET Using Barcode creation for ASP.NET Control to generate, create Barcode image in ASP.NET applications. www.OnBarcode.comTry It Out: Enabling an Application As a Drop Target
Code 39 Generator In None Using Barcode generation for Font Control to generate, create Code-39 image in Font applications. www.OnBarcode.comPrint Barcode In Java Using Barcode encoder for Android Control to generate, create Barcode image in Android applications. www.OnBarcode.comIn this example, we ll create a simple Silverlight application that contains a TextBlock. We will then enable the application as a drop target and when a file is dropped, if it is a text document with extension *.txt, we will display the contents of the file in the TextBlock control. Let s get started. 1. Create a new Silverlight application in Visual Studio 2010. Name it SilverlightDropTarget and allow Visual Studio to create an ASP.NET web application called SilverlightDropTarget.Web to host your application. When the project is created, you should be looking at the MainPage.xaml file. First, set the AllowDrop property for the Grid to True. Then, within the LayoutRoot Grid of the Silverlight page, add a TextBlock named FileContents, and set the Margin to 10 and the TextWrapping property to Wrap. <Grid AllowDrop="True" x:Name="LayoutRoot" Background="White"> <TextBlock Margin="10" TextWrapping="Wrap" Name="FileContents" /> </Grid> 3. Now turn your attention to the code behind, MainPage.xaml.cs. First add a using reference to the System.IO namespace, then wire up the Drop event in the constructor. Read ANSI/AIM Code 128 In Java Using Barcode decoder for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comUCC.EAN - 128 Decoder In VB.NET Using Barcode scanner for .NET Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comCHAPTER 10 SYSTEM INTEGRATION AND DEVICE SUPPORT
EAN-13 Generator In Java Using Barcode encoder for Java Control to generate, create GS1 - 13 image in Java applications. www.OnBarcode.comBarcode Printer In VS .NET Using Barcode generator for Reporting Service Control to generate, create Barcode image in Reporting Service applications. www.OnBarcode.compublic MainPage() { InitializeComponent(); LayoutRoot.Drop += new DragEventHandler(LayoutRoot_Drop); } 4. Next, in the LayoutRoot_Drop event, we ll start to work with the dropped file(s). First, we ll make certain that the data dropped on the application is not null. Next, we ll create an IDataObject set to the DragEventArgs.Data property passed into the event. We can then get the collection of files dropped using the GetData method. void LayoutRoot_Drop(object sender, DragEventArgs e) { if (e.Data != null) { IDataObject obj = e.Data; FileInfo[] files = obj.GetData(DataFormats.FileDrop) as FileInfo[]; } 5. } Print GS1 - 13 In None Using Barcode generator for Online Control to generate, create EAN-13 image in Online applications. www.OnBarcode.com2D Printer In .NET Framework Using Barcode generation for .NET framework Control to generate, create Matrix 2D Barcode image in .NET framework applications. www.OnBarcode.comOnce we have a collection of files, we can create a foreach statement to step through each file within our collection. For each instance, we will inspect the file extension. If the extension is .txt, we will open the file using a StreamReader and read the contents of the file. Once we have read the contents, we will set that to the Text property of the FileContents TextBlock. void LayoutRoot_Drop(object sender, DragEventArgs e) { if (e.Data != null) { IDataObject obj = e.Data; FileInfo[] files = obj.GetData(DataFormats.FileDrop) as FileInfo[]; foreach (FileInfo file in files) { if (file.Extension.Equals(".txt")) { using (Stream stream = file.OpenRead()) { using (StreamReader reader = new StreamReader(stream)) { FileContents.Text = reader.ReadToEnd(); } } } } } }
|
|