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

Archive for the 'coding' 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% [?]

Finally an Acid test I’m excited about

Thursday, January 10th, 2008

Now that all major browsers support the Acid2, or at least have announced they have development builds that pass it, Ian “Hixie” Hickson has begun work on the Acid3. The exciting news is that it is going to focus on ECMAScript (aka. Javascript) and the DOM. The first two Acid tests focused mostly on error handling and emerging technologies of CSS. A lot of people tend to assume that if you pass the Acid tests your browser is standards compliant but they fail to realise that CSS is only a portion of Web Standards. They are important, don’t get me wrong, but most browsers are progressing along with support these days and I’m excited the focus is being shifted to an area that is somewhat neglected.

I do a lot of development in ECMAScript and work heavily in the DOM so it’s no end of frustration to support all browser’s quirks. Having the next Acid test focus on this makes me giddy, this will hopefully force Microsoft to support DOM levels 2 and 3, as of right now they only support DOM level 1 and poorly. I’m sure the guys that develop libraries like Prototype.js and jQuery will be equally as excited.

Technorati Tags: , , , , , , , , , ,

Popularity: 80% [?]

Find the position of an element in the DOM [Javascript]

Tuesday, October 23rd, 2007

I ran into a problem of placing an element I created via javascript, it was a calender for a date picker. I wanted the calender to appear directly under the textbox that would accept the selection from the user. This is a deceptively tricky thing to do on websites. This is because it doesn’t store the Top and Left of the element relative to the Top/Left of the current window, rather it stores the Top and Left relative to it’s offsetParent. What’s an offsetParent? It’s the property of an element whose parent affects it’s positioning, this can be it’s actual parent but it can also be a parent further up the tree depending on if it affects its offsetLeft and offsetTop peroperties. If an element is positioned fixed its offsetParent will be null, so you won’t always have to traverse to the top of the DOM tree to get the actual offset of your element relative to the window.

(more…)

Popularity: 87% [?]

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.