Tuesday, November 02, 2004

New Toys! NEW TOYS!!

Well, after my birthday, I've got myself a couple of new toys to be playing with.

SQL Server Developer Edition. SQL Server's one of those biiig gaps in my skills. Although I've read quite a lot (and even used quite a bit) about database design, normalisation, stored procedures security and stuff, it's always been using Access to put together DB's on MSDE. I never even SAW query analyser until just a couple of months ago.

But that's been cured now. I've got a proper DBMS now, so that's alright.

Microsoft Flight Simulator 2004. Now this has got me all excited. This has got me out of bed early. This is a sexy mother of a game. It's really boring at times - Watching the AutoPilot steer you from Plymouth (my home town) to Exeter (where the ladies of Plymouth go for a day shopping) isn't really that exciting. But I'm stil getting over the novelty of being able to take off from Plymouth Airport, fly over the Tamar river, buzz the very same bridge that my dad goes over to get to work every day and land in a town I once sang in (they have a cathedral there, and I sang in it once.). It's got some really cool real world maps and stuff, and it covers THE ENTIRE WORLD! I'm quite impressed, anyway.

Oh yeah, and I got some SQL Server books as well. I'm currently reading Professional SQL Server Programming. It's quite good.

Expect some posts in the future about SQL and MSFS (apart from the usual .NET ramblings, rants and misc. stuff).

Although they won't be particularly frequent - for some reason, I seem to have been really really busy for the past few weeks. I'm hoping it doesn't last!

Saturday, October 30, 2004

More piratical pics!

Just a quicky...

One of my pirate mates, Mark, has put together a few more pics and video from my party. It's here. Check it out. His video's better than mine!

Friday, October 29, 2004

Good to be pushed sometimes...

I sent the link to my birthday pics to a few friends of mine last night, and immediately JML got back to me via IM.

JML's a top guy. A real diamond. He's the IT manager where I used to work, and one of the only people from there whoI stil see regularly. Mrs Mawoo tells me he's the only person on the planet who I can talk to on the phone, as well.

So anyway, JML gets back to me immediately and says 'Can I offer some constructive criticism? Your pictures look shit. What interpolation did you use on them?' So I said I used the default compression, and promptly went out and tried to find out how I can apply a different algorithm to the images being shrunk (Curse you JML! I was about to go and watch some CSI!).

Good job I did, though, because I learnt a really cool, and quite fundamental thing.

System.Drawing.Graphics.FromImage() Doesn't give you a new blank canvas
Rather, it takes your blank canvas (or your canvas with an image on it) and allows you to use GDI+ to play about with it. Everything you do, though, every string you draw, every change you make, is made to the original image, not to a new one. To give an example:

Dim pic as Image
pic = pic.FromFile("C:\Monkey.jpg")
Dim little As New Bitmap(CInt(pic.Width / 4), CInt(pic.Height / 4))
Dim g As Graphics = Graphics.FromImage(little)
With g
.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
End With
g.DrawImage(pic, 0, 0, little.Width, little.Height)
little.Save("C:\SmallMonkey.jpg")


Now, yesterday, I would have said 'What? What are you doing saving a blank bitmap?'. That what it looked like to me. If you read through the code, it looks like the sequence of events is this:

  1. Open the original Image File
  2. Create a new blank Bitmap object 1/4 the size of the original
  3. Create a new Graphics Object, copying into it the blank cnvas you've just created
  4. Draw the image etc. on the new Graphics image, leaving the original blank bitmap (little) untouched
  5. Save the blank bitmap (little)
That's what it looked like to me, anyway.

I used to imaging the Graphics object as a posh bitmap, a bitmap tat you could do some whizzy things to, like write text on it and things like that. I now understand much differently. Rather than imagine the Graphics object as a blank canvas, I rather imagine it kind of like the team of robot arms that run around cars, welding bits together. You know the ones. When the car stops on the conveyor belt, and then a squad of robot arms comes out and welds, glues and paints everything before the car moves off again. That's how I visualize it now. Robot arms. With the car (or Bitmap, in this case) in the middle. Neato. And it answered a lot of questions.

This bit on MSDN helped me out a bit too.

It left me in a really good mood. For some sick reason, I actually get quite a buzz when I find out something new. I'm still really lazy, though. I wouldn't have played about with the Graphics object and found out what a cool thing it is without JML telling me 'Dude, your pictures are shit! Sort them out.' Thanks!

Just needed to share.

Thursday, October 28, 2004

Happy Birthday to me!!

Well it was my birthday last week, and after having a bit of a mare trying to get my pictures shrunk to web-size, I've finally got them online here.

You might find the layout of the page a little familiar. I really am lazy when it comes to layout.

Just one quick note, the video of the final (Mrs Mawoo versus my mate Rod) was made using my SPV E200 Smartphone. It's not the greates quality, but hey, it's a phone. What did you expect? Spielberg?

Just wanted to share. Feel free to tell me I look great in a hat and eyepatch.

Doh!

Don't you hate it when you do something so stoopid it makes you want to cry? That happened to me just this morning. Bugger.

Over the past couple of days I've been writing just a very quick easy app to batch resize a folderful of images. I wanted to get a bunch of pictures from a party (it was my birthday Saturday. Woo and Yay) and resize them to put online somewhere. SImple, I know. Yes, I could have donme them by hand. Yes, I could have downloaded one of a million free utilities to do the same thing, but hey, where's the fun in that?

Originally the plan was to do it this way:

  1. Load the image
  2. Create a new image (in GDI+) from the original image's GetThumbNailImage method
  3. Save that image
Simple huh? It's something I've done a few times for creating thumbnail images on the fly.

Turns out (and I didn't know this before) that if the image file already has a thumbnail associated to it, it just takes that image and resizes, rather than taking the original and resizing it. As a result, half of the images that were produced were horrible pixellated crap. Not good. So I spent a few hours trying some other stuff, looking for resize methods in all of the GDI+ objects, and a whole bunch of other stuff. I even toyed with writing my own resizing algorithm to do the job I wanted. I didn't go down that route, though.

No. The route I went down was very very very easy. I'm even ashamed to admit that I had spent so much time thinking about it and playing with so many different things to arrive at this point. No.

Turns out the Bitmap object has a very nice constructor (yes, a CONSTRUCTOR! Note emphasis. I really was being that dumb!) that does it all for you. It goes like this:

Dim x as new Bitmap(Original as Image, Width as Integer, Height as Integer)

Dammit! It really hurt to delete the whole bunch of code I'd written only to replace it with one line.

And the even worse part? I haven't even got round to putting together a nice HTML page to put them on yet, so wrapped up have I been with trying to sort out this resizing thing, so my birthday party's still not online yet. When I do it, though, I'll put up a link.

Just wanted to share my stupidity. I'm hoping I'm not the only person who's had experiences like this!

Friday, October 22, 2004

Strange...

I've been playing a bit with non-rectangular Windows forms (using a background image and transparency key), and have discovered some strange things.

The TransparencyKey property doesn't work
Well, this is a known issue. The TransparencyKey property doesn't work on systems where you've got your screen colour depth set to more than 24 bit. Bit of an oversight in my book, but there you go.

Quick google search cured that, though. The problem can be solved by putting the following lines of code in your form.initialize method:
Dim Img As Bitmap = Me.BackgroundImage
Img.MakeTransparent(Img.GetPixel(1, 1))
Me.BackgroundImage = Img
Me.TransparencyKey = Img.GetPixel(1, 1)


That works, but seems to have a bit of a strange side-effect.

If I add a control to the form, a ListBox, say, and set its BackColor to Black, that control becomes transparent too. Like properly transparent. I mean it looks like there's a hole in the form. Any other colour's fine, it's just black makes a hole in the form.

It only seems to happen on the form with the transparency key stuff going on. On standard forms, it doesn't happen. Black controls look just as you'd expect. Black.

It's kind of disconcerting, seeing a selected item (blue bar and everything) floating seemingly in space (well, floating with a bunch of code behind it.

If anyone can figure out why this is happening, let me know. I'm really quite interested.

Anyway, that's what I learnt this evening.

PS - Feel free not to tell me the answer if you do know. I just needed to remind myself of an interesting thing I need to read up about.

Aha!!!!

Before I start, you're going to have to bear something in mind. I live in the UK. Which means that I'm at least 12 months behind the rest of the world when it comes to technology.

I had one of those proper 'Aha!' moments last night over the .NET framework 2.0. I went to an MSDN talk last night, ostensibly about Visual Studio Express. I'm not really that interested in the express versions per se, but I wanted to have a bit of a look at what the implications were for Visual Studio Standard Edition. What would the effect be of adding an extra layer of products at the bottom of the product line (bottom in terms of features and functionality, I hasten to add, not bottom in terms of the people using them!) have on the previous bottom of the ladder product.

And it looks good (providing the price for Standard stays about the same). Smart device development looks like it's supported in VS Standard, which is something I really kinda like. And it looks to be all round goodness in a box.

That wasn't what got me excited, though.

What got me excited was ASP.NET 2.0. Although I'm going to have to have a deeper look into how they really work, some of the data access features of ASP.NET look to really rock. Being able to put data sources with (and this is the important bit) parameters bound to other controls on the page right in the code on the ASPX page looks really cool. I'm sure there are security issues there, which is why I'm going to have to have to have a deeper look into how it works, but on the face of it, for quickly banging together web forms apps it looks like a really good thing.

Snaplines in Windows forms got me really fired up as well. Although I've seen quicky demos on channel 9 and the like, I never really appreciated just how funky a feature this really was. It's fantastic. Being able to snap controls so they line up with any of a dozen reference points (The top of the control, baseline of the text, middle of the control etc.) is really quite good. I might be biased because I've been knocking some forms together in Access, where that kind of thing is really quite hard. And even harder to do quickly without losing your train of thought.

The code editing formatting options are also really good. The demo showed a load of the options available in c#, like where opening curly brackets start and end (on a new line, inline etc), and stuff like that. In ASP.NET as well, the days of VS reformatting your code every time you switch from design to code view and back are gone You want to have a block of text hard-up against the margin, you can have a block of text hard-up against the margin. It's all preserved for you. Nice.

Data Access thingys in windows forms are quite cool as well. In the quicky demo the guy showed us, he did essentially what the Data Forms Wizard does in VS 2003, but all with just pure drag and drop. Just pull a datagrid onto a form (if I remember rightly) set its data source and run the app. It automagically generates the code to populate the grid, and even gives you a navigation menustrip to boot. The whole thing took under a minute. Sweet.

And the best thing, the thing that'll have me running out to the shop to buy VS the day it comes out, the thing that'll stick in my mind, the thing that when people ask me 'So what's so cool about VS Express?' I'll tell them about... They gave us beer and Pizza! God I'm a cheap whore.

Just wanted to share.

P.S. Sadly not many links to documentation. There's not a great deal online yet.

Tuesday, October 19, 2004

Another stoopid test...

You are .dll You are dynamic. You are constantly in danger of bringing down the house, because you don't play well with others.
Apparently I'm a .DLL.


The next couple of weeks or so mihgt be a bit light on .NET stuff. And generally light overall. I might be working on an Access project for a little while.

Yeah yeah, I know. It's Access. Which is bad on more levels than I care to imagine, but such is life.

Just wanted to share.

Friday, October 15, 2004

Blogging on Demand #3

Okay, this isn't a technical search that brought someone to my blog, but I thought it's be quite an interesting thing to write about since it's something I have (I think) a fair degree of experience in. And often colleagues at work ask me about it.

Mostly, they ask 'Why?'

Learning VB.net (via Yahoo)

Well, it's nice and vague, and I guess it is the title of my blog, so why not write a bit about my experiences learning VB.

Know that you know nothing
This I learnt after about 2 minutes playing with Viual Studio. I came from programming VBA and (gasp!) Access, thinking, 'Hey, know how this stuff works. I can write code that talks across applications, I know what a Select Case does.' I learnt very very soon that I didn't know diddly. I could talk for hours about the differences between VBA and .NET, but I'm not going to. You could try looking here for some inspiration. The 2 things that struck me first were

  1. The .NET framework is huge. To paraphrase Douglas Adams "The .NET framework is big. Really big. You might think the MS Word object model is a bit overwhelming, but that's just peanuts compared to the .NET framework."
  2. working with objects in VB.NET is completely different to working with objects in VBA. Nicer, I'll grant you, but nonetheless very different.
Unless you're really forced very hard to produce something concrete, it's very difficult to pick it up and start typing away.

In fact, I'll go as far as to say that I was so clueless about VB.NET when I first picked it up that even the help docs were next to useless for me. I mean, MustInherit? What's that all about?

Quickly, though, you'll notice something quite nice, though.

The world wants to help you (for free!)
It's true. There are a million and one places to find out about .NET. ASP.NET, WindowsForms.NET, Microsoft, everyone. If you need to find something out, it's all there. The .NET community rules. Honestly.

I sometimes post entries about webcasts and other various resources online. I love 'em. The web is a beautiful, beautiful thing for learning. But...

You can't beat a good bit of study
Unfortunately here's the pisser. Although there is more free interactive, lecture-based AV stuff out there than I have time to watch, there's nothing like sitting down for a few hours and reading. Studying is something that just unfortunately won't go away. No matter how far we advance in presentation techgnology, styles and material, if you really want to learn about something, you've got to graft for it. I tried learning a bunch of stuff through fluffy online tutorials and stuff, but when it came down to it, I learnt far more and got a much deeper understanding of the subject though just solid reading. In a way I'm lucky. I get the tube for an hour in the morning and an hour in the evening. There's 2 hours every day to just read and read and read.

An oh my, there are some books out there.

I'mk not going to start reviewing books, I can't be bothered, and hey, it's my blog. I found the Unleashed series and the teach yourself ... in 21 Days from Sams really good introducions to .NET. Personally I tend to stay away from the 24 hours books, butthat's just me.

The Dummies series is quite cool right at the very very beginning. In fact, it was this book that first made me think 'What, you can get a computer to do ANYTHING YOU WANT? Cool.'

Write stuff
I generally dont like doing the tutorials in books. I tried it, but here's the scenario I usually find:

Picture the scene. I'm sitting at home in front of my computer, book on my lap doing a tutorial. I type what it says in th book, nodding sagely at every line, saying to myself, yep. yep. Uhuh. Understand that.

Run it. Get an exception, AND THEN (here's the important bit) what do I do? Cancel the Unhandled Exception Dialog box and scour my code checking it against the book looking for the typo. Useful? I think not.

Instead, I just read the stuff think of a similar, but not identical problem, and try to solve that. Or, think of a task loosely based on the book example, but incorporate into it something I already know. I always find that where I thought I know loads, I actually know diddly when I come to integrate something that isn't in the book into the code I'm writing. Might just be me, though.

Or, do something kind of unrealted, but using just one bit of the stuff in the book. My favourite aplication I wrote, the one I'm most proud of, and the one I tell my friends (well, if we're being honest here, friend...) about is ASP2WMP which I wrote to explore remoting a bit. I got tired with populating a datagrid with the Northwind Products table. So I did something completely unrelated, but using just one apect of what I'd read that day. In fact, ASP2WMP was developed in several stages as I learnt about more stuff from the book I was reading at the time.

Answer questions
When I was getting my head round ASP.NET, I started answering questions in the ASP.NET forums. Sometimes I'd play it safe and stick to what I was absolutely sure of, but sometimes I'd try and solve a problem I wasn't too sure of and then come out with an answer. They weren't always particularly bad answers, either.

I don't know about anyone else, but I am very very lazy. That's why I started programming. I figured 'I really can't be arsed with all this work. Why can't I get a computer to do it instead?'. Well, being lazy, I really can't be arsed making problems for myself. The downside? No problems, no solutions. So I tried solving some other people's problems instead. I find that once I explain something to someone, it makes it much easier or me to crystallise that knowledge in my head too.

I think that's about all I've got to say about how I'm learning VB.NET. This is all just based on my own experience, mind you.

Oh yes, just one quick note, there's nothing annoys forum types (not me, but I occasionally see some pretty terse replies) than people eho just can't be arsed looking. So before you start asking other people questions, make sure you've checked:
  • The Help Files
  • The MSDN Library
  • Google
  • The forum itself, to make sure nobody else has come up against the same thing before
Just wanted to share. Sorry it's such a huge beast of a post. If you've got this far, then my heartiest congratulations to you. And thanks.

Wednesday, October 13, 2004

Sharing the Love

"This fella has a nice web log with some good information and seems to be right up our alley"
Some people say the sweetest things. Right back atcha dude!

Just felt the need to share.