Having trouble with Form.AcceptButton?

Recent explorations of WPF have caused me to revisit things I used to avoid in .NET. I’ve spent a lot of time over the past week or so working with the TableLayoutPanel and FlowLayoutPanel, and I never really realized how much I dislike the designer for some nitpicky alignment things. I made a relatively complicated application to test myself, and though there’s some lingering issues in Windows Forms 2.0 it looks like WPF solves most of them.

The big thing that has been bugging me is I made a dialog to edit program settings, and when I added the “OK” and “Cancel” buttons I set the form’s AcceptButton and CancelButton properties appropriately. However, when I tried the form out, I found that the cancel button worked perfectly but the OK button did nothing. I decided that perhaps I had left something out of my layout logic, so I started a new project and used the designer to set up a simple dialog with a text box and the two buttons; this dialog worked so I figured I’d done something wrong. I decided I’d just make the button’s click event set DialogResult and left the issue alone.

Then today, someone on the VB .NET forum I frequent posted a problem with the AcceptButton property that was exactly opposite of mine: they didn’t want the button to respond to the Enter key or close the dialog. I decided that the answer to his question was probably pertinent to mine, so I revisited the example. This time, I managed to do something in the designer that caused the OK button to not work properly. I was mystified, so I asked the guy on the forums to post some of his code so I could try to figure out what was different. The answer turns out to be a combination of the Button class’s DialogResult property and an oversight on the part of Microsoft.

I wrote a test program to examine the DialogResult property before and after assigning buttons to a form’s AcceptButton and CancelButton properties. CancelButton worked exactly as I expected and changed the button’s DialogResult property to DialogResult.Cancel. However, AcceptButton did not alter the button’s DialogResult property at all. I double-checked this in Reflector and found that the property set method for AcceptButton doesn’t do anything at all with the button’s DialogResult property.

So if you are having trouble with getting the OK button of a dialog to work, and the only step you are taking is to set the form’s AcceptButton property, be sure to always manually set the button’s DialogResult property. AcceptButton‘s property set method does call UpdateDefaultButton, a protected method of Form with no default implementation. It’s possible you could override this method and add the line:

this.AcceptButton.DialogResult = DialogResult.OK

However, since it’s a protected method that is used by the default implementations of the Form class it’s probably a bad idea to assume this will always work. In particular, if they swap the order of the lines of code it will fail. Perhaps you could override the AcceptButton property and call the base implementation, but that’s still kind of icky. I have not tested this in .NET versions later than 2.0, but I doubt it has been fixed.

A week with the Zune

A week or so ago I got my Zune, and wrote a bit about its software and some of the issues I had with it.  This time around I want to discuss the hardware.

First, I’m not a very hardcore user of mp3 players.  I bought this unit because it was a good deal from woot.com and I wanted something that could hold my collection.  I haven’t used the video features of the Zune much yet because honestly I haven’t found a use for that feature.

The first real problem I stumbled upon with the Zune is a common problem with mp3 players: since Apple patented their clickwheel there is no clickwheel on the Zune, and I am convinced the clickwheel is the perfect input method for an mp3 player.  What the Zune does have is the standard “clickwheel emulator”.  It is a small circular button with another button in its center; 4-way navigation is facilitated by the outer button and menu choices are selected by the inner button.  There is a “go back” button and a “pause/play” button on either side of the clickwheel emulator.  The size of the center button makes navigation feel a little clumsy sometimes, but I haven’t had any serious problems with it so far.

The Zune UI is quite usable compared to the PC software . For music, you have the usual plethora of browsing options such as by playlist, artist, and album.  Scrolling through large lists is made easier by a neat feature they added: when you are moving pages at a time a large letter is displayed behind the list to indicate the first letter of the artist or album you have reached (depending on which browse option you are using).  For randomly playing a playlist, I find the Zune quite satisfactory.  The shuffle algorithm seems a little less random than I want, but I’m going to give it a few more weeks before I think it’s completely off.

There’s a radio feature on the Zune and I think that’s kind of neat, though I’ve never listened to it other than to just test it out.  Reception seems pretty good.  The picture browser is horribly crippled by the limited browse options of “folder name when it was on your PC” and “date of creation”; if you take pictures frequently, save a lot of random pictures, or have lots of different image folders the Zune is practically useless for making nice slideshows of favorite images.

There’s also a wireless community feature, where you can send songs to other Zune users and download songs from their Zunes.  Unfortunately I haven’t managed to find another Zune owner yet to test it out, but I’m sure I’d be frustrated with the “3 plays or 3 days” DRM that is placed on songs transferred this way.

In short:
Playing mp3s: Awesome
Viewing Videos: I don’t care
Listening to the radio: OK I guess
Viewing Pictures: Needs work

Hosting Review: Fuitadnet.com

A long time ago (2003 if the records are right) I signed up for hosting under Fuitadnet. They had a pretty good deal at the time, I seem to remember it was about $5 for 3GB space and 25GB transfer. That was way more than I knew I’d ever use, based on the fact that none of my free hosting sites ever seemed to hit their quota, so I signed up. I had a couple of warnings from the people at Armageddon Games that the service and uptime were kind of flaky, but I figured for personal hosting the price was right and the risk was worth taking.

The first few years were no big deal; there were occasional downtimes and defacements, but generally I was satisfied because within a few hours of any major event there’d be a post about what happened in the forums. I don’t like losing service, but I do like it when the company reports the failures and is open about them.

The first real signs of trouble came a couple of years back, when I noticed that the only way to get their one-click image galleries running was to make several directories world-writable. I may just be ignorant of the way web servers worked, but I thought you were supposed to run php with a group that you could set so it could touch directories without having to set them world-writable. I mentioned this on the forums and I was told that I was on a misconfigured server and needed to request to be moved, so I filed a support ticket. The support guy was suspicious and asked me to try setting up the image gallery again, so I did, and demonstrated the problem. He told me there was definitely something wrong and they’d fix it. A week or so later he got back to me and said the gallery should work no problem.

The fix? The one-click install was changed to automatically make those directories world-writable. I’m pretty sure this isn’t the solution upon looking at the directory permissions on my new host, and I was quite agitated that Fuitadnet’s support had the nerve to claim they’d fix the problem, then silently do the poor workaround behind my back. I just sucked it up and lived with world-writable directories because I needed an image gallery up for a project I was doing.

That’s not why I quit Fuitadnet though; it was just some background to show I was a long-time customer and was generally pleased with the hosting. My experimental blog has an account with links to forum posts, but sadly Fuitadnet has deleted their forums. I didn’t predict this move so I didn’t archive the forums for permanent proof, but I will summarize without the forum links.

About a year ago, all users were notified of unavoidable price increases. This would cover increased costs and additionally Fuitadnet would increase their customer support staffing and introduce a new feature: daily backups. This was a great idea; the worst can sometimes happen and Fuitadnet promised that in the worst case a site could be up and running with a recent backup. I figured this was worth an extra $2/month so I didn’t bother researching any other hosting solutions.

Towards the end of July, the worst happened. My support tickets and forum posts show I noticed something was up around July 31, when I logged into FTP to upload a file and found nothing staring back at me. All of my data was gone. I looked to the forums, and noticed a thread started on the 28th from someone with similar problems. I filed a support ticket asking what was up, and I got a response the next day. Apparently, two disks in their RAID array had failed so they suffered a total data loss on a server. That’s understandable; sometimes it happens. I remembered the daily backups thing (and so did some forums posters) so I decided I’d just indicate in a forum post and in my open support ticket that I wanted to be restored. Some people started getting restores, but were reporting that they were as old as October. Around July 31st a post was made on the forums by the Fuitadnet president explaining the situation and he indicated that they would restore things to normal “as fast as possible”. A couple of days later, I made a post on the forums indicating that I was upset by the slow response to let the users know via the forums, pointing out that the forums were the first thing I checked for service outages. I also asked what the status of the daily backups were. The owner (Sharon)’s response was that the forums were of low priority to them and I should really go to their IRC channel for support.

That’s bull. I started researching new hosts that day. My support ticket requesting a restore was still open, and I would periodically poke my head into the forums and point out that people were paying for backups. On August 23rd I still had no information about a restoration, so I made the post in my experimental blog, taking care to link to forum posts to strengthen my points. Incidentally on August 24th the Fuitadnet forums disappeared. I guess it’s no real surprise since 2/3 of the posts were “Horrible service — never again!” and the like, but it struck me as the final indicator that I was dealing with a company that had no interests in me other than my monthly contribution.

As I said, I can take failure. I can even sympathize with a company that does a poor job at handling a catastrophe such as the loss of a disk array; it’s a rare event and even if you have a plan you don’t get to test that plan out often. I will not give my money to a company that will do its best to quiet unsatisfied customers by removing their ability to publicly discuss issues. By deleting the forums, Fuitadnet moved all support to the internal support ticket system or the IRC room, both controlled environments where they can severely limit how many people can see what is said. Sadly, the only evidence I have to back me up now is a screenshot of their “Why we are better” page. I noticed the first item on the page is their daily backup and figured I’d make sure someone had a record that they claimed this was a feature.

With backup using an image technology we are able to take a daily snapshot of your site. In another words if any damage caused to your data, whether from Virus, hackers or any other damaging factors, we are able to restore the data to the exact configuration it was the day before, like nothing happen.

It’s been two months now, and I have yet to see any kind of file restoration. I have a local backup of the web site, but sadly I did not have a backup of the SQL databases, and I don’t really feel like I should have since I was assured I was under the protection of daily backups.

Now I’m on Apis Networks, and though I’m a little concerned about the proprietary control panel I do like the idea. I hope I don’t have to move again because transferring the domain so I could actually change the nameservers was a pretty big hassle; Fuitadnet acted as a middleman and didn’t let me directly access the domain records, and I learned why that is a convenient but bad idea.