Wednesday, December 31, 2008

drag’n drop files into richtext boxes (so it’s actually useful)

There’s a ton of howto’s out there showing people how to do the drag and drop into a richtext box.  But recently I had a job that required me not to drag the contents from one part of the form to the other but to actually drag a file (or files) into a RichTextbox control – and process them.

Which… if you’ve never tried this before drops the file as an icon you can click on and open.  Not really imageuseful if you’re trying to process files.  It’s kind of annoying that even after a bit of Googling you’ll get a lot of links that let you drag the text or images or all kinds of stuff from one part of the form – to another part of the form. 

Which is fine if that’s what you need.  But what I needed was to be able to grab several files – of either text or xml – and then process them and display the output. 

Since I can’t share my work code – here’s the training wheels version of the code for you. image As you can see we process the XML and display it.  It also does text so … this is fairly close to the final version – which hopefully I’ll take some time and cleanse it from any confidential use info that may be in it and share.  In the mean time – here’s the actual guts of the code that makes it work.

 

Since I’m reallllly running behind – that’s all I can get out this week  - but hopefully it’ll be of use to someone out there.  As you can see – I’m calling the richtextbox dragenter event and customizing it.  The first thing I do is hunt for the dataformats.filedrop type off the event handleer – this allows me to grab the filename and – load it appropriately into the richtextbox.

Anyway… to all out there – here’s the code – have an AWESOME New Year… and I’ll be back on line to annoy all as soon as I can.

 

Imports System
Imports System.Drawing
Imports System.Data
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
Imports System.Xml
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'This call is required by the Windows Form Designer.
RichTextBox1.AllowDrop = True
End Sub

Private Sub
richTextBox1_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles RichTextBox1.DragEnter

Try
If
e.Data.GetDataPresent(DataFormats.FileDrop) Then
' Put all file names into a string array
'in case the user grabbed more than one file.
Dim files As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())
Try
'Now we break it down - we only want text files, xml or xsd files
'so we trap for that if it's not one of those - we ignore it.
If files(0).Contains(".txt") Then
Dim
f_stream As IO.StreamReader = FileIO.FileSystem.OpenTextFileReader(files(0))
RichTextBox1.Text = f_stream.ReadToEnd()
'Just for fun we show the name of the file and link it
llblFileName.Text = files(0).ToString

f_stream.Close()
ElseIf files(0).Contains(".xml") Then
Dim
filename As String = files(0)
Dim reader As New XmlTextReader(files(0))
llblFileName.Text = files(0).ToString
reader.MoveToContent()
'Loop through the XML and display it in the richtextbox
Do While reader.Read
RichTextBox1.AppendText(reader.ReadContentAsString)
Loop
reader.Close()
End If
Catch
ex As Exception
MessageBox.Show(ex.Message)
Return
End Try
End If
Catch
ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub
llblFileName_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles llblFileName.LinkClicked
System.Diagnostics.Process.Start(llblFileName.Text)
End Sub
End Class

Monday, December 22, 2008

Fighting Tigers in Burma…

is something I’ve never done.  Never really planned to do it either.  In fact, it’s not even on my long range to do list.  Like so many bizarre things you’re pretty sure are never going to happen – it is however – something that I am prepared to do if I am ever dropped accidentally into the back jungles of Burma with a 10 lb honey cured ham locked around my neck. 

Let’s face it no one plans for something like that.  Just like most people don’t plan on losing their jobs until it happens.  Money’s tight and we keep hearing that there are no jobs.  Read Mini-Microsoft’s latest rumors that Microsoft is going to lay off… Or you can read the same story in – frankly dozens, maybe even hundreds of web journals out there.  We’re all going to lose our jobs.  No one is hiring.  And we should all expect to have it take up to 3 years or more before we can find work where and how we once did.

In fact if you read the dishrags you’ll put your chances of financial survival right up there with fighting tigers naked in the jungles of Burma.  But that’s not reality.

I won’t say things aren’t serious – or that there aren’t going to be some serious “resource actions” at places like Microsoft – or IBM or a hundred other places out there.

But the Job Market isn’t as dead as people claim.  It’s not great like it was – but it’s also not the dead zone everyone is making out.  Don’t believe me?  Here…

Dice… 963 new jobs in the last 7 days.

image

Now, I know that in my area – Hotjobs has 81 new jobs.  And … Monsters got around 120 or more.  And I still get between 3-9 emails a week about jobs.  Many of which I can’t take due to NDAs or certain companies bizarre rules about not being able to work there for over 365 days in a row – that’s weird – but there are still jobs there for someone. 

Over the last 10 years I’ve never gone more than a month or so without being able to get a job.  Is it because I’m just … sooooo cool?  No.  It’s because I learned a long time ago that just because a job isn’t perfect it’s still a job. At the end of the day you don’t have to take it home with you, and even if it’s not “your dream job” like the ads say – it still pays bills.

So pay your bills and find something better.  The bottom line is that – it’s all about survival.  Just like fighting tigers.  You do what you need to do and you learn new skills if you need to so that you can survive.

No, you’re not going to find a dream job in this economy.  But you may – if you’re careful – find something that keeps you going until you do.  Survival isn’t about surviving better than others – it’s about surviving to better your own circumstances, so that your life it’s about survival.  So that it’s not waking up to a fear of your life – as you know it – suddenly vanishing. 

There are reasons to be afraid, but losing your job isn’t a reason to be afraid.  It’s a reason to hone your skills – sharpen your abilities.  It’s a reason to become better at what you’ve been doing that you’ve ever been.  It’s a reason to learn not to be afraid, not to let yourself become depressed, not to lose track of your goals. 

Your goals.  Not the company you work for.  But yours.  It’s a reason to learn about what your goals are.  But it’s not a reason to panic.  It’s not a reason to be afraid.  There are jobs.

The economy is bad – but it’s not some nightmare.  Bad economies and job cuts are cycles.  If you hone those skills, keep your outlook positive, and you never stop trying to better yourself – you will always be able to find work.

That’s not me saying that – it’s my father.  Because of him I’ve kept that attitude and I’ve always kept myself in work.  If I didn’t have it – I’d find it.  It was his gift to me.  One that I have kept and that’s kept my family well. 

If I can give one gift to people – to friends who are approaching this Christmas season with trepidation, with stress, with fear.  It’s that you don’t have to be afraid.  It really will be all right, and hang in there.  We have the skills, the knowledge, the drive and the ambition to not just survive but thrive.  Because we – are the people – who do not ever want to fight tigers.  We have too much work surviving what is real – to give our time to fighting things and preparing for things that are not. 

Just a few thoughts.

Wednesday, December 10, 2008

We’re not dead yet…

Been a week or two since I updated so this is going to be quick before I lumber off to work.  The recession isn’t as bad as it might appear.  It’s bad – almost every IT company out there decided to put the breaks on a lot of hiring and dropped the expected wages they’re paying.  But the jobs are still there.  Nationally I just got a ping for over 35 IT Jobs that opened since December 10th – most are east coast related (NY, NH, NJ, FL) although there’s a surprising number from TX and IL that I really didn’t see coming.  Most of these are Dev and Engineering – but there’s a smattering of UI designer and PM type roles.

In the NW USA we’re still seeing a remarkable amount of stuff going on – although most is at MS still around 36 jobs posted through Dice and Careerbuilder since Dec 5th.  Once again – MS leads with Test positions and Dev positions, but has a nice nearly equal compliment of PM jobs.

Had someone ask me how to tell if companies are gearing up for work or completing projects based on job postings… here’s the tip:  If they need more PMs than they do Developers – they’re gearing up and there’s more work coming.  If they’ve got more Developer positions than PM and Test it generally means they aren’t planning they’re completing what they have on their plates.  This is often cyclical so don’t read a whole lot into it.

If you want a good idea of how to predict work in an economy – check comic books.  They’re a luxury item but they’re one that kids save up for – so if the kiddies have money for comics then mom & dad we can guesstimate if times are really tight.  If kids buy a lot of comics – then the allowance is healthy if they buy fewer – then the allowance is down.  As a result the comics industry has always been a good way to tell how hard hit families are in a financial crunch.  They’re one of those trail indicators you don’t think about but watching their wake tells you the size of the destructive forces applied to children.  Hate to be so cold blooded – but economics suck.

Warren Ellis sent off a ping saying the comics industry’s finally feeling the pinch – and his info seems to match up with mine.  It’s not that financially the industry’s gone south yet – tons of work being done and things are being bought – but the fear of the slow down is causing less work.  His recipe for digging out of holes in the comics industry is the same as mine – raise your game up a level or two. 

What every business from Film & Entertainment (Web especially) to  GM & FORD to Marvel Comics and Microsoft has had for the last decade has been an assumed captive market.  Raise your game and create better products or you’re going to get your corporate clocks cleaned by people willing to raise their game and give customers what they want. 

This isn’t the time to get conservative – this is the time to get creative.  To dig deep take some risks (not financially but creatively) and come up with great product.  Warren’s DOKTOR SLEEPLESS is a good example of a comic built and crafted for fans that’s selling in a market where others are slipping back.

Dr. Horrible (from Joss Whedon) is another example – built for fans it was what fans wanted.  It sold beyond well (waaay past expectations)  for no advertising, no budget, and not a lot of time.  But the quality was there and they created a product they knew their target audience would want.

These are the kinds of products that save companies and that’s the strategy needed to pull it out and win. 

That’s all for this week… back to slaving away…

Oh… and for those who haven’t seen it yet – did a new experiment with Vanishing Point in Photoshop and After Effects… it’s up on the web.  A 20 minute wonder here… but always fun to play.   The original here was a still photo of an alley – near canal street as I recall – a bit of adjustment, and wallah… 3D from flat using Vanishing Point in Photoshop to extract the planes for AE.

To belabor the theme of this week’s blog here … if you haven’t picked up a new skill this week you’re not raising your personal game up a notch.  Find something you haven’t done before – and go do it!  If you don’t someone else will.  If you do – you get to choose what it is you want to learn – what it is you want to do – and you’re a lot closer to doing what you want to do in life.  Remember … you can be a passenger or the guy driving the bus in your life.  Do you want to be the guy who gets to tell everyone where they’re going and when they can get off or do you want to be told?  The choice is up to you.