Invisible if css is enabled, don't click
This shouldn't be displaying, if you have css disabled, don't click

Archive for the 'VB.NET' Category

Make VS.NET 2008 intellisense a little more intelligent

Thursday, September 11th, 2008

Looking for a solution to Visual Studio 2008’s Intellisense’s poor performance while editing large HTML documents I came across an awesome discovery. You can extend the intellisense to include jQuery (well any framework provided you have it properly documented.) This is awesome because even though I love the new Ajax Control Toolkit in VS.NET 2008 it just doesn’t hold a candle to jQuery and it’s plethora of plugins.

To gain this functionality, first grab the intellisense stub from InfoBasis’ jQuery Intellisense Header Generator, or as I lovingly call it, Ijihg. [Direct Link]

Add it to your project and then the really easy part, drag the file into the javascript file(s) you wish to enable jQuery intellisense on, or you can type in the reference manually

  1. /// <reference path="jquery.intellisense.js" />

You should get something looking like:

And that’s all there is too it. Once you begin coding intellisense will pick up jQuery and make your life a little bit easier. Here’s a couple screens to give you an idea of what you can expect:

Technorati Tags: , ,

Popularity: 21% [?]

Printing multi-frame Tiff images in VB.NET with multiple orientations

Friday, August 3rd, 2007

This is a continuation of “Printing multi-frame Tiff images in VB.NET to a certain printer tray.” A problem came up that I hadn’t accounted for and my client came back to me. I was worried I’d have to implement a solution that actually rotated the image, requiring some crazy math voodoo that I prefer to leave to the math to math programmers. Luckily the solution is much more simple.

There’s one problem I found out, you can’t change print settings after you start the printjob in the PrintPage sub, after quite a bit of searching I found that there is another sub QueryPageSettings that allows you to make changes.

Following the previous code we need to make a single change:

  1. Private Sub printDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printDoc.PrintPage
  2.    tiffImage.SelectActiveFrame(FrameDimension.Page, start - 1) ‘<– comment this out
  3.    start += skip
  4.    e.Graphics.DrawImage(tiffImage, 0, 0)
  5.    If (start < tiffImage.GetFrameCount(FrameDimension.Page)) Then
  6.       e.HasMorePages = True
  7.    Else
  8.       e.HasMorePages = False
  9.    End If
  10. End Sub

And then we need add the QueryPageSettings sub, it’s actually another event of the printdocument so in the IDE you can select the event instead.

  1.    Private Sub printDoc_QueryPageSettings(ByVal sender As Object, ByVal e As System.Drawing.Printing.QueryPageSettingsEventArgs) Handles printDoc.QueryPageSettings
  2.     tiffImage.SelectActiveFrame(FrameDimension.Page, start - 1)
  3.     Console.Write(String.Format("Frame Dimensions: {0} x {1} ", tiffImage.Width, tiffImage.Height))
  4.     If tiffImage.Width > tiffImage.Height Then
  5.         e.PageSettings.Landscape = True
  6.         Console.Write("Orientation: Landscape ")
  7.     Else
  8.         e.PageSettings.Landscape = False
  9.         Console.Write("Orientation: Portrait ")
  10.     End If
  11. End Sub

As you can see that’s all there is to it, you compare the width and height of the image and if the width is wider than the height you enable landscape orientation in the pageSettings. The reason we commented out the line in the PrintPage sub was because we are now setting the active frame in the new sub. QueryPageSettings is raised before every PrintPage event so you have time to make adjustments to your print settings on the fly.

One issue I noticed, however, is that the image gets offset by a small amount (about 20-30px) and parts of the image can get cut off. As a result I’ve also done some calculations to resize the images width and height to fit the page and the following line:

  1. e.Graphics.DrawImage(tiffImage, 0, 0)

Needs to be changed to:

  1. e.Graphics.DrawImage(tiffImage, offsetX, offsetY, width, height)

The width and height integers are in hundredths of inches, so an 8.5″ x 11″ sheet is represented by width = 850 and height = 1100. There’s some math involved to figure out the ratio to scale the image to the size of paper you’re printing to, but since I’m using only 8.5″ x 11″ I just forced the variables to be 830 x 1070 (or 1070 x 830 if landscape,) it’s arbitrary but my program is just a stop gap until they get a more permanent solution in place.

Technorati Tags: , , ,

Popularity: 100% [?]

Printing multi-frame Tiff images in VB.NET to a certain printer tray

Wednesday, March 7th, 2007

A part of work I was asked to create a simple program that prints a multi-frame Tiff image from the file system to a (user-definable) printer and specific tray and to add some fun the ability to specify which page to start on and the ability to skip X number of pages between.

This is a edge case and finding the information was a huge task, while I do program VB.NET some (I know and use at least four languages,) I am mainly a web app programmer so I don’t know much about image manipulation and printing, I feared I would be heading into Win32 API land and flash backs of my days as a VB6 programmer came flooding back.

Luckily it wasn’t that hard, getting the correct information and merging it together was 95% of my battle. Following the jump will reveal the secrets.

(more…)

Popularity: 89% [?]

We did not invent the algorithm. The algorithm killed Jeeves. The algorithm constantly finds Jesus. This is not the algorithm. This is close.