29/05/2009

WANTED: Windows Error Collage

I need new desktop wallpaper.

And you know you're a nerd when you have a vision that this wallpaper should be a collage of all the worst Windows error prompts imaginable.

Ideally the collage would have a background with a Windows Blue screen.

Then, as if this ask makes absolutely no sense already I want as many verbose Windows Error dialog messages stacked on top of the blue screen as possible.

The idea is that the log on dialog should be obscured by the plethora or other error messages.

This collage should look so horrible that it will be a deterrent for anyone to use the computer.

This is a moronic idea - but if anyone has seen something like this, please leave a comment.

Over And Out

22/05/2009

WARNING - DO NOT BUY SOFTWARE FROM: Websupergoo.com

I would rec against buying software from this company. I've now logged four bugs in their PDF product.

I'm sure it's useful for some things - but it is very inconsistent, buggy and if I had a choice, I'd never use it again. Unfortunately it's the only product on the market that can render SVG inside a PDF - so I'm stuck with it.

The following bugs were initially denied by ABCpdf support. I was wrong, they were right type of issue resolution. To their credit they managed to fix 1 of the issues, but they deny the existence of all other issues:

Fatal ExecutionExceptions
1) ABCpdf6 is crashing the .Net Runtime with Fatal ExecutionExceptions. If anyone has encountered an ExecutionException they know this is about as bad as it gets - it crashes the .Net runtime, it crashes the web server etc. etc. etc. Websupergoo support denied the existence of this issue for months. To reproduce this issue, download ABCpdf6, download .Net 3.5 SP1, run a project in VS2008 and hit stop button half way through some long process. Restart the application ... kaboom explosion ... Well guess what - they figured it out and fixed it in ABCpdf7.

Line Counts Fail
2) ABCpdf7 is not capable of counting the number of lines of text that have been written to a text area. Moreover, Websupergoo support denies this is an issue -> actually suggesting I use the line counts for another VERY important part of my application. I've uploaded an example of the incorrect line counts at my live space here:
http://cid-cd836a97f80e0c35.skydrive.live.com/self.aspx/Public/HeightProblemExample.zip

Text Height Methods Fail
3) ABCpdf7 is not capable of determining with accuracy the dimensions of text that has been written to a text area (esp when line spacing is specified). Moreover, Websupergoo support denies this is an issue -> they suggest I use line counts (which are also broken) to determine the height of a text area. They are morons, they don't read their support requests, and they are incapable of resolving any problems in what would be considered a reasonable amount of time. I've uploaded an example of the height calculation issues at my live space here:
http://cid-cd836a97f80e0c35.skydrive.live.com/self.aspx/Public/HeightProblemExample.zip

Cache is Completely Broken
4) ABCpdf6 is not capable of clearing it's cache properly, moreover, cache settings that Websupergoo claims to do things - do not do what they say they do. Websupergoo support denies this issue, are insulting by pointing users to obvious documentation - but even when all the settings are setup precisely to their requirements we still have to reboot the webserver to clear the cache. Unfortunately I don't have an example of this behavior - but you can see for yourself by going to their site and merely running the cache examples. It does not work consistently at all.

As to not complain complain complain - I assume idiots will always be idiots and business people will sell pretty much anything any idiot (like me) are willing to buy at the highest cost possible.

Solution To Text Height issues:
I'm providing a solution to accurately predict the height of text in ABCpdf7. Websupergoo is incapable of doing this - therefore - I've been forced to apply some really ugly inefficient methodolgy to correct their issue. I've uploaded an example of the fix to my live space here:
http://cid-cd836a97f80e0c35.skydrive.live.com/self.aspx/Public/TextHeightSolution.zip

I am purposely blasting this group as they have provided such low quality support. Every reply is insulting and the only way to get them to take your requests seriously is to kick and scream, kick and scream, kick and scream. May be at some point I'll get to chat with their top level support people - but even at that - these people deny the issues in their application and do not help users move forward.

If you don't believe me take a look at the examples they provide with the ABCpdf7 trial download. 1988 called and they want their coding conventions back!

Over And Out

06/05/2009

.Net Custom Panel Control with Transparent Background (no png's, css hacks, or problems)

I'm making a really quick post on how you can wrap the jQuery fadeBack control into a .Net Web Custom Control. If you haven't read the article on the fadeBack control, you will have to go here and grab the source.

Save the scripts in a script folder inside your Web Site / Web Application.

To use this control you need to add a reference to the Web Server Control project you have built the code in.

To use this control in your WebForm please Register the Web Server Control dll and namespace on the page like:
<%@ Register Assembly="<<NAME OF WEB SERVER CONTROL PROJECT DLL>>" Namespace="<< THE NAME OF THE NAMESPACE>>" TagPrefix="ctl" %>

Then you can start using the control like so:

<ctl:TransBackPanel ID="backTest" runat="server"
Width="400px" Opacity="20" BackColor="Aquamarine"
BorderColor="Red" BorderWidth="10px" BorderStyle="Solid">
<ctl:TransBackPanel ID="TransBackPanel1" runat="server"
Width="300px" Opacity="20" BackColor="Red"
BorderColor="Green" BorderWidth="10px" BorderStyle="Solid">
<div>Hello World!</div>
</ctl:TransBackPanel>
</ctl:TransBackPanel>

Below is the source code for the .Net Web Custom Control, add this to a Web Server Control project and build:

[ToolboxData("<{0}:TransBackPanel runat=server></{0}:TransBackPanel>")]
public class TransBackPanel : Panel
{

// the jQuery script reference
public const string JQUERY_KEY = "jquery-1.3.2.min.js";
public const string JQUERY_URL = "script/jquery-1.3.2.min.js";

// the transparent background plugin reference
public const string TRANSBACKPANEL_KEY = "jQuery.fadeBack.js";
public const string TRANSBACKPANEL_URL = "script/jQuery.fadeBack.js";

/// <summary>
/// Declare a local variable with the default opacity
/// </summary>
private int _Opacity = 20;

/// <summary>
/// Get / Set opacity to an int - 100 to 0 with 100 being a completely transparent background.
/// </summary>
public int Opacity { get { return _Opacity; } set { _Opacity = value; } }

/// <summary>
/// Override the create child controls method and add the scripts from our constants
/// </summary>
protected override void CreateChildControls()
{

// Register jQuery like so
if (!Page.ClientScript.IsClientScriptIncludeRegistered(JQUERY_KEY))
Page.ClientScript.RegisterClientScriptInclude(JQUERY_KEY, JQUERY_URL);

// Register the fade back external script
if (!Page.ClientScript.IsClientScriptIncludeRegistered(TRANSBACKPANEL_KEY))
Page.ClientScript.RegisterClientScriptInclude(TRANSBACKPANEL_KEY, TRANSBACKPANEL_URL);

base.CreateChildControls();
}

/// <summary>
/// Render the panel control
/// </summary>
/// <param name="writer"></param>
protected override void Render(HtmlTextWriter writer)
{

// Register the startup script to fade the background to another color
if (!Page.ClientScript.IsStartupScriptRegistered(this.ID))
Page.ClientScript.RegisterStartupScript(typeof(string), this.ID, GetOnloadScript(), true);

base.Render(writer);

}

/// <summary>
/// Produce a jQuery on load thingy to geter done.
/// </summary>
/// <returns></returns>
private string GetOnloadScript()
{
return "$(document).ready(function() {\n" +
"$('#" + this.ClientID + "').fadeBack({opacity:" + Convert.ToDouble(Opacity) / 100 + "});\n" +
"});";
}

}

JavaScript: jQuery Plugin to fade Background but not Content: no css hacks, no *.png files, no problems ...

UPDATE: the toNum method must be changed to this:

function toNum(strNum) {
if (strNum && strNum != "") {
var i = parseFloat(strNum);
if (i.toString() == "NaN")
return 0;
else
return i;
}
return 0;
};


I scoured the web in search of a jQuery plugin that allows me to fade the background but not the contents of a div. I found this article: Cross Browser Transparent Background with jQuery, no css hacks, no *.png files by Mihaistancu and noted that there were a lot of problems with the plugin. It didn't work for me -> but I'm sure it's great code once I figure out the particulars.

I decided to write my own plugin that can take some of these issues into account. The below jQuery plugin has been tested in IE7, Firefox, Opera and Safari and it works.

It takes padding and borders into account so your padding will be enforced and so will your background borders (background can have borders!!). Infact, anything that is not a child element will be applied to the background fade.

How it works:
1) Get the dimensions of TheDiv we want to fade (top, left, height, width - if these are not set in css it will default to the default style for that html element type).
2) Get the inner html of TheDiv and add it to a NewDiv (with id: TheDiv.id + "_content"), and append that NewDiv to TheDiv's parent.
3) Fade TheDiv out ...

Give it a shot and let me know what you think.

You can call the plugin like so:

$(document).ready(function() {
$("#outer").fadeBack();
});

You can download a zip file example /plugin from my Windows Live Space here.

You can see the raw plugin source code below:

(function($) {


$.fn.fadeBack = function(options) {

var _s = $.extend($.fn.fadeBack.defaultOptions, options);

return this.each(function() {

var t = $(this);
var oh = t.height();
var ow = t.width();
var ih = t.html();
var p = t.parent();
var tl = t.position();
var id = t[0].id + "_content";

t.css({ height: oh, width: ow }).html("").fadeTo("fast", _s.opacity);

var padding = dimSum(getPadding(t), getBorderSizes(t));

var ncss = { top: tl.top, left: tl.left,
position: "absolute", height: oh, width: ow,
paddingTop: padding.top, paddingBottom: padding.bottom,
paddingLeft: padding.left, paddingRight: padding.right };

$("
" + ih + "
").css(ncss).appendTo(p);

});

function dimSum(dim1, dim2) {
return { top: dim1.top + dim2.top,
bottom: dim1.bottom + dim2.bottom,
left: dim1.left + dim2.top,
right: dim1.right + dim2.right
}
};

function getBorderSizes(sel) {
return {
top: toNum(sel.css("borderTopWidth")),
bottom: toNum(sel.css("borderBottomWidth")),
left: toNum(sel.css("borderLeftWidth")),
right: toNum(sel.css("borderRightWidth"))
};
};

function getPadding(sel) {
return { top: toNum(sel.css("paddingTop")),
bottom: toNum(sel.css("paddingTop")),
left: toNum(sel.css("paddingLeft")),
right: toNum(sel.css("paddingRight"))
};
};

function toNum(strNum) {
if (strNum && strNum != "") {
var i = parseFloat(strNum);
if (i.toString() == "NaN")
return 0;
else
return i;
}
return 0;
};

}

})(jQuery);

$.fn.fadeBack.defaultOptions = { opacity: 0.4 }

Over and Out

01/05/2009

JavaScript: Chaining Cancelable Events - If you're not first, you're last

Another quick post on cancelable events in JavaScript. An example of a cancelable event is the keydown method. If I return false from a keydown method JavaScript will not allow the action of that keydown event to proceed. For example, I could return false on a document keydown event to cancel the ctrl+c behaviour etc. etc.

The following is a nice method I've built and tested only in IE 7 which allows users to chain JavaScript events together.

Obviously this could be compressed significantly.

addToObject: the HtmlElement we want to attach the cancelable event to.

eventName: the name of the event we want to trap.

methodDelegate: a JavaScript function delegate / closure for the JavaScript method to attach to the event.

order: First or Last. You can build on this however you want.

Enjoy,

function AddCancelableEvent(addToObject, eventName, methodDelegate, order) {
if (addToObject[eventName] != null) {
var oe = addToObject[eventName];
if (order == "first")
addToObject[eventName] = function(e) {
var r = methodDelegate(e);
if (r == false) return false;
return oe(e);
};
else // "if you're not first you're last" - Ricky Bobby
addToObject[eventName] = function(e) {
var r = oe(e);
if (r == false) return false;
return methodDelegate(e);
};

} else {
addToObject[eventName] = methodDelegate;
}
};


Over And Out