Saturday, November 03, 2007

ReOrderList replacement and other AJAX.NET Fun

Having gotten fairly annoyed with the flaky-ness of the AJAX.NET ReOrderList control (among others) I've decided to take a look at building my own. Having had a look at a really great tutorial on javascript drag and drop code:
http://www.webreference.com/programming/javascript/mk/column2/
I've built a couple of custom controls; DragItem and DragContainer. These are part of an in-dev solution I'm building to provide myself (and anyone bothered enough to read on) with lightweight AJAX controls. Mostly because I want to understand the intricacies of this black magic, but partly because I believe the javascript libraries provided by the AJAX Toolkit to be too heavy for inidividual control use.

To justify myself here: I love the Ajax Control Toolkit and think MS are doing a brilliant job, especially when there are kits like:
http://www.telerik.com/
out there. But, and this is big, the dynamically provided javascript libraries which the API requires each browser page to download (assuming the ScriptManager control is placed) are too big. I want a small piece of script, perhaps placed within the page, rather than a seperate file, to perform efficient, fast actions, not replace most of the js API in the browser and watch/handle a million things I'm probably not even aware are going on. Not that I mind those features being there when they're needed!

Anyway, here's a list which might be useful to some:
http://ajaxpatterns.org/DotNet_Ajax_Frameworks

And here's the solution download for my own .NET AJAX controls:
http://home.freeuk.com/eudoxus/JsWebSite.rar

Saturday, October 06, 2007

UnbindablePanel

To download the example solution click here: http://home.freeuk.com/eudoxus/JsWebSite.rar

[EDIT 03/11/2007] This link has been changed to include the code provided in my most recent Ajax-oriented post: ReOrderList replacement and other AJAX.NET Fun

I've been trying to get a Repeater to bind it's DataSource to contained controls for differing content. What I mean, there, is that if the DataSource has objects of different type I want to render a different data binding within the ItemTemplate depending on the type of data in the current DataItem. [Skip the next two paragraphs to get to the interesting bit.]

Having failed to try this by forcing Panel, PlaceHolder, MultiView/View and Wizard/StepTemplate from binding in anything other than a straightforward way (I hate it when future me can't follow younger me code!) I decided to try my latest trick...

Ok, I can't believe I didn't realise this before (or perhaps a more obvious solution - which, no, I still haven't discovered), but inheritting Panel and adding or overriding to get the functionality you want is just about the best way to make accessible, functional custom controls! They have data containers, can be bound, are supported by VS GUI and everyone understands them.

So, the situation is thus; I have bound a Repeater to a DataSource which provides an enumeration of objects which have different properties. This could be a random collection of DateTime, String and DataRow objects, or anything. Don't ask why, I just want to do it.

My solution is, essentially, to make a Panel which will not bind it's child controls if told not to. To decide whether it should or not, we simply check the class type, an identity or type field, property or namespace, etc.

So, first we inherit the Panel control:

public class UnbindablePanel : Panel

Then we have to provide a property which will determine whether or not the child controls found within the Panel will be databound:

private bool _allowChildBinding = true;
public virtual bool AllowChildBinding
{
get
{
return _allowChildBinding;
}
set
{
_allowChildBinding = value;
}
}

And finally, override the DataBindChildren() method to avoid the databinding if needed:

protected override void DataBindChildren()
{
if (AllowChildBinding)
{
base.DataBindChildren();
}
}

There is a little extra; in order to ensure the Panel is not visible at all, you might want to include a property/method combo to ensure the visibility matches the databound true/false value. This would stop any non-databound controls from being seen, but as such, is not absolutely necessary and is not the driving force behind this class.

To download the example solution click here: http://home.freeuk.com/eudoxus/JsWebSite1.rar

Thursday, July 12, 2007

Finally got Microsoft Bluetooth Generic and ActiveSync working again!

My story so far to repairing bluetooth and activesync when they absolutely refuse to play ball...

Prologue:
(1) Disabled Microsoft ActiveSync to stop my mobile synchronising every time I wanted to charge it.
(2) Updated all software via Windows Update, including Bluetooth drivers.

Synopsis:
(1) ActiveSync refused to work again, even with repeated un-installs and re-installs.
(2) My ePox BT-DG03 Bluetooth USB Dongle stopped working because the latest Microsoft Bluetooth drivers are now called ABE Bluetooth Controller and don't work with it (these replaced the previous Windows XP SP2 bluetooth drivers "Generic Bluetooth Radio" and "Microsoft Bluetooth Enumerator".)

Today:
(1) Took a complete, clean copy of my C:\Windows\Inf, C:\Windows\System32 and all sub-folders onto my iPod and brought them in.
(2) Uninstalled ActiveSync and all associated Bluetooth drivers (Add/Remove Programs and Device Manager.)
(3) Connected Device via USB cable; Machine should recognise Generic RNDIS device and ask for drivers, etc.
(4) PLugged-in bluetooth dongle; Machine should again recognise bluetooth device and ask for drivers, etc.

The Secret:
When drivers are asked for;
(1) Un-install all the existing device drivers to avoid conflicts.
(2) From device manager, perform Update Drivers.
(3) Select "Install from a list or specific location (Advanced)."
(4) Select "Don't search. I will choose the driver to install."
(5) Click "Have disc".
(6) Browse to your backed-up copy of C:\Windows\Inf and select the file "drvindex.inf".
(7) From then on it should find the correct devices and all you have to do is show it where to find the right files.

I had to do this 2 or 3 times before the driver installs stuck, but now it's fairly happy and I can just plug the dongle and mobile phone in and no more reinstalls need to take place.

The key files I found are:
Bluetooth Device;
(1) rfcomm.sys (system32\drivers)
(2) wshBth.dll (system32)
(3) irftp.exe (system32)
(4) irmon.dll (system32)
Standard Modem over Bluetooth link;
(1) bthmodem.sys (system32\drivers)

Be warned, there are more files the auto-installer will ask for, but if/when I need to do this again, I'll try and note them all down.

Epilogue:
(1) I've had one instance where the bluetooth dongle needed to be reinstalled, but with care and forethought, the right drivers can be picked - this is down to selecting Show All Devices (when the option is presented) and always selecting \Inf\drvindex.inf, to give the auto-install the best chance of finding the right driver.

Saturday, July 07, 2007

iTunes Remote Control

Well, after a lot of help from the http://www.32feet.net/ forums, not forgetting Mr. Peter Foot himself, and late night messing, I've finally got a working version of my iTunes remote control (kinda) finished.
Ok, for those interested enough, there's a log window, which shouldn't dump out too much; volume controls work, but there's a bug in that once a volume or position value gets changed, messages start getting thrown back and forth- Once I've re-worked the request and response formats I'll be fixing the synchronisation issues. The format issue will also allow the playlist window to function by feeding from partial list messages.
There is also an iPod look-a-like dialog, which will in time provide full control. This will be waiting until after the other functions/bugs have been sorted out.
You can download the current version here: http://home.freeuk.com/eudoxus/BtChat.2007-07-07.001.rar
Again, thanks to everyone on the 32feet.net forums who helped!
Matt.

Thursday, July 05, 2007

Bluetooth iTunes Remote for Windows Mobile 5.0

Yep, I've been developing (and having problems with) a .NET/C# iTunes remote control for Windows Mobile 5.0. For my own reference, here's the download: http://home.freeuk.com/eudoxus/BtChat.iTunesRemote.2007-07-05.001.rar

[EDIT] This has no changed to: http://home.freeuk.com/eudoxus/BtChat.2007-07-07.001.rar
Please see post for update: http://springboardpillow.blogspot.com/2007/07/itunes-remote-control.html

In theory, I've got the whole thing working:

Queued message sending (from the client) to avoid blocking the BT device
Threaded timer updates of the display
Error log dialog
Back/Next/Play/Pause/Volume/Time controls
Track/Artist/Album display

The problem I'm facing right now is that bluetooth has completely failed on my work machine and I'm finding that the only drivers which work are the Generic Bluetooth Radio and Microsoft Bluetooth Enumerator - which should be one driver and are ONLY available via Windows Update - and of course have now been replaced by a broken driver called ABE.

To add to the fun threading seems to lock up when I kick off my own thread on the device side of the application, as if the two threads used for monitoring in-coming messages are the only threads I'm allowed to run. I'm not sure, but I think it might be the BtListener thread which is causing problems, however the forums say otherwise.

Wednesday, June 20, 2007

Infinities Loop Auto Complete Extender

I've been reading with interest, for a while now, that http://weblogs.asp.net/infinitiesloop/ has a rather nice textbox auto-complete extender. Lots of people have had lots to say on the matter, so I'll be short: I've had trouble getting the code provided to build and run, even with the assistance of the links provided on the blog entries.

The most useful entries (to date) appear to be:

http://weblogs.asp.net/infinitiesloop/archive/2006/11/15/ASP.NET-Ajax-Beta_3A00_-AutoCompleteBehavior-without-a-Web-Service.aspx
http://lvildosola.blogspot.com/2007/01/how-to-get-smartautocompleteextender.html

Having downloaded the files I played around and got it all nicely working. I really have to hand it to I.L. because having state information available where the http://ajax.asp.net/ajaxtoolkit/ forces you to use a webservice (and thus lose all context of the user's session, etc) if invaluable.

My personal use for the context is to specify a locale for the searching of brands where users in different locales would get different results. I think the most obvious would be the searching of a user's personal history of textual terms.

Anyway, I've got the solution and all the .dll files required, in a .rar here:
http://home.freeuk.com/eudoxus/MattsSmartAutoCompleteRTM.rar

Thursday, May 24, 2007

Loader Lock exception in windows applications

Blatantly ripped from: http://www.thezbuffer.com/articles/304.aspx


Error Message:

LoaderLock was detected
Message: DLL '.......\Microsoft.DirectX.Direct3D.dll' is attempting
managed execution inside OS Loader lock. Do not attempt to run
managed code inside a DllMain or image initialization function since
doing so can cause the application to hang.A Loader lock is one of the Managed Debugging Assistants (MDAs) that were added to VS2005 to help find hard to debug runtime issues. There is code in all Managed DirectX 1.1 assemblies that causes this MDA to fire. Microsoft have confirmed they are aware of the problem. However I do not expect to see a fix for MDX 1.1 since current efforts are focused on MDX2.0/XNA Framework, it ONLY affects code run under the debugger (i.e. it won't happen when users run your EXE) and there is a trivial workaround. I'm not sure of exact reproduction steps - it appears to fire on some projects and not on others.

To work around the problem you have several choices:

Go back to using VS2003 and .Net 1.1
Use MDX 2.0. Note that MDX 2.0 will never actually ship as it is being transformed into the XNA framework.
Disable the loader lock MDA. Debug/Exceptions (ctrl-D, E), Open the Managed Debugging Assistants tree node and uncheck Loader Lock. This setting is per solution so it will only affect this solution.
Versions affected:All .Net 1.1 Managed DirectX assemblies when used with Visual Studio 2005 and .Net 2.0.


My apologies, but I will get around to writing my own piece on this particular exception and it's foibles myself when I've got time!

Monday, January 29, 2007

Top 10 Worst Album Covers Of All Time

Yeah, I know, it's a complete waste of an entry, I just wanted to try out the new blogger engine and thangs, y'all know.

Check out http://salamitsunami.com/archives/91 for some laughs, old though I know it is. Maybe I can generate some hits, but then again, people might start reading this drivel.

Onk.