encode.toteek.com

.NET/ASP.NET/C#/VB.NET PDF Document SDK

The March CTP of Atlas has a minor bug that requires you to use a Virtualearth.net CSS script on the page; otherwise, you will have problems dragging and zooming the map. You can include this script in your page using the following tag in your HTML <head> section: <link type="text/css" href=http://dev.virtualearth.net/standard/v2/MapControl.css rel="stylesheet" /> Listing 10-1 shows the complete code for a simple page that includes everything you need to display a simple Atlas map, including references and the necessary Atlas ScriptManager control. Listing 10-1. Simple Page Containing an Atlas-Based Map <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Atlas Map of Seattle Area</title> <link type="text/css" href="http://dev.virtualearth.net/standard/v2/MapControl.css" rel="stylesheet" /> </head> <body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" > <Scripts> <atlas:ScriptReference ScriptName="AtlasUIMap" /> </Scripts> </atlas:ScriptManager> <div id="MyMap" style="height:400px;width:400px; "> </div> </form> <script type="text/xml-script"> <page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <components> <virtualEarthMap id="MyMap" latitude="48" longitude="-122" mapStyle="Road" zoomLevel="9">

insert barcode in excel 2016, microsoft barcode control 15.0 excel 2010, excel barcodes free, barcode activex control for excel 2010, excel formula barcode check digit, free barcode generator excel 2010, barcode add in for excel 2003, how to use barcode font in excel 2010, excel vba barcode generator, excel barcode font 2016,

} bytesToRead -= bytesRead;

int bytesReadFromThisFile = 0; while (bytesReadFromThisFile < buffer.Length) { int bytesThisRead = file.Content.Read( buffer, bytesReadFromThisFile, buffer.Length - bytesReadFromThisFile); if (bytesThisRead == 0) { break; } bytesReadFromThisFile += bytesThisRead; } if (bytesReadFromThisFile < buffer.Length && bytesReadFromThisFile < bytesToRead) { throw new InvalidOperationException( "Unexpected end of file - did a file change "); } bytesRead = bytesReadFromThisFile; // Will be same for all files

foreach (var sourceFileEntry in potentiallyMatched) { byte[] sourceFileContent = fileBuffers[sourceFileEntry.Key]; for (int otherIndex = 0; otherIndex < sourceFileEntry.Value.Count; ++otherIndex) { byte[] otherFileContent = fileBuffers[sourceFileEntry.Value[otherIndex]]; for (int i = 0; i < bytesRead; ++i) { if (sourceFileContent[i] != otherFileContent[i]) { sourceFileEntry.Value.RemoveAt(otherIndex); otherIndex -= 1; if (sourceFileEntry.Value.Count == 0) { sourceFilesWithNoMatches.Add(sourceFileEntry.Key); } break; } } }

Figure 14-3. A URL and its parts When you receive a URL from the user, you can feed it to the QUrl constructor and then ask the isValid method whether the URL can be interpreted. This is what happens in the getClicked slot shown in Listing 14-12. The dialog is shown in action in Figure 14-4. The URL is entered into a QLineEdit widget and is passed to the constructor of the QUrl object. The

} foreach (FileContents fileWithNoMatches in sourceFilesWithNoMatches) { potentiallyMatched.Remove(fileWithNoMatches); } // Don't bother with the rest of the file if there are // not further potential matches if (potentiallyMatched.Count == 0) { break; } sourceFilesWithNoMatches.Clear();

}

}

second constructor arguments tell the QUrl class to be tolerant. The alternative to being tolerant is strict, and this mode is set by passing the QUrl::StrictMode value to the constructor. The tolerant mode compensates for common mistakes encountered in URLs entered by users.

Rather than reading entire files at once, we allocate small buffers, and read in 1 KB at a time As with the previous version, this new one works through all the files of a particular name and size simultaneously, so we allocate a buffer for each file We then loop round, reading in a buffer s worth from each file, and perform comparisons against just that buffer (weeding out any nonmatches) We keep going round until we either determine that none of the files match or reach the end of the files Notice how each stream remembers its position for us, with each Read starting where the previous one left off.

</virtualEarthMap> </components> </page> </script> </body> </html> Figure 10-2 shows the results of running this page.

And since we ensure that we read exactly the same quantity from all the files for each chunk (either 1 KB, or however much is left when we get to the end of the file), all the streams advance in unison This code has a somewhat more complex structure than before The all-in-memory version in Example 11-39 had three loops the outer one advanced one byte at a time, and then the inner two worked through the various potential match combinations But because the outer loop in Example 11-44 advances one chunk at a time, we end up needing an extra inner loop to compare all the bytes in a chunk We could have simplified this by only ever reading a single byte at a time from the streams, but in fact, this chunking has delivered a significant performance improvement.

Testing against a folder full of source code, media resources, and compilation output containing 4,500 files (totaling about 500 MB), the all-in-memory version took about 17 seconds to find all the duplicates, but the stream version took just 35 seconds! Profiling the code revealed that this performance improvement was entirely a result of the fact that we were comparing the bytes in chunks So for this particular application, the additional complexity was well worth it (Of course, you should always measure your own code against representative problems techniques that work well in one scenario don t necessarily perform well everywhere).

What if we wanted to step forward or backward in the file We can do that with the Seek method. Let s imagine we want to print out the first 100 bytes of each file that we reject, for debug purposes. We can add some code to our CompareBytes method to do that, as Example 11-45 shows.

   Copyright 2020.