Scott Hanselman

Building your own Arcade Cabinet for Geeks - Part 3 - Control Panel

June 05, 2009 Comment on this post [4] Posted in Arcade
Sponsored By

This is the third part of a multi-part series I'm going to do about assembling an Arcade Cabinet for my house. This series has two disclaimers:

Software Disclaimer 1: There's all sorts of legal issues around emulating arcade games. This series of posts has nothing to do with that. I do own some original arcade boards, but if you want to emulate arcade games with MAME (Multiple Arcade Machine Emulator), you can search the 'tubes. What I'm doing here is putting a computer in a pretty box.

Hardware Disclaimer 2: Many folks that build arcade cabinets have a purist view of how these things should be done. They will prefer original Arcade CRT monitors and more expensive, higher quality parts. I am more of a pragmatist. I also have no idea what I'm doing, so I've also got ignorance on my side.

This part, the Control Panel, truly kicked our collective butts. We were rockin', working occasional evenings and making progress until we got here. This took probably 3 weeks (a day here and there, wait, a day here and there) and was a huge hassle. In retrospect, we know what we could do to make it easier on ourselves, but you live and learn.

Custom or Stock

Arcade Purists will say you should design your control panel custom, to suit your needs. You can visit a site like Happs Controls and buy the buttons and sticks and trackballs and what not, all to your specs. You can then buy a PCB Board that will let you map your buttons to keyboard strokes. Ultimarc has one called the I-PAC that seems to be the standard. If you like wiring and customization, this could be a good choice for you.

Buttons and Sticks the Easy Way

However, on this project I was really trying to find a balance, and stay cheap and pragmatic but with an eye on quality. So I decided to do a combination. I bought the Tankstick from X-Arcade with the plan to take it apart and install it into the original control panel that came with my arcade cabinet shell.

image IMG_0100

You can see from the picture on the right that I attempted to make a trackball fit, but ended up sending it back. It just was too large.

Instead, I took part the X-Arcade stick and used its wood top as a template for my stock steel control panel. I took a piece of Plexiglas and made a template out of it. Unfortunately this kind of acrylic is very hard to drill and I cracked two before I gave up. More on the plastic later.

 IMG_0116 IMG_0110

Cutting and Cutting and Cutting

Then, John and I transferred our button layout to the original steel panel with a Sharpie Pen. We got a bit-metal "hole saw," is is apparently what you call a big drill bit. It's a 29mm hole, which is standard for arcade controls. We had 19 to drill.

IMG_0125 IMG_0126

The drill bit lasted exactly 1 and 1/2 holes before it burned up. After the fact we learned that there are specific RPMs (speeds) that you should drill steel and we were drilling WAY to fast. I bought another drill bit and we got through a few more, but the drill press we were using wasn't strong enough to hold on to the bit. I wouldn't want to try this with a hand-held drill.

At this point, I had a choice. Spend more money on a drill and/or more bits, or enlist the help of a professional. I went to a local "machine shop" and told them to do their best.

IMG_0151IMG_0154 

They thought what I was doing was pretty funny, but they sure nailed it. The result was laughed at on Twitter, but it looked great to us.

IMG_0152 IMG_0178

It looks funny, like there's too many holes because there are too many! There were a few holes underneath the vinyl. Apparently the Video Trivia game had been ANOTHER game before! However, none of the holes were positioned in any way that would compromise the structure of the steel. Notice the Player 1 button in a new hold intersecting with an old hole. No problems.

Cost: US$100 (hired a pro)
Cost So Far: US$231

Now, we need to make a sandwich. First steel, then new vinyl art, then an acrylic/Plexiglas layer.

The Sandwich

We thought we'd need a piece of wood to stabilize the whole panel and give the buttons something to hold on to, but we underestimated how strong the steel was. Even though we added piece of wood underneath, we ended up abandoning it as a waste of time.

IMG_0180 IMG_0177

However, drilling all those holes in the wood wasn't a waste. We used the filler pieces of holes to fill up the holes that we didn't need. We put them in the holes and used an orbit sander. This provided a smoother surface for the vinyl to lie on.

Back to the Plexiglas. I tried to drill a bunch and just couldn't get it right. We'd do a bunch of holes and it would crack. After the fact, we learned there are specially designed drill bits for drilling holes in this kind of acrylic. Again, hindsight is 20/20, but live and learn.

Again, to a pro. I called a local plastics shop and they said if I gave them a Corel Draw file that was accurate to a 1/2 mm that they could cut it with freakin' lasers.

IMG_0333 corel

Awesome. Since I love lasers, all the better. I downloaded the Corel Draw 30-day trial and got to work with a small ruler. I measured the heck out of my stuff, praying I wouldn't be off by a millimeter and have things not line up. Here's the EPS and Corel Draw files if you want them.

Cost: US$75 (hired a pro)
Cost So Far: US$306

Turns out I nailed it. I was off by less than a half millimeter in a few spots, but nothing that we couldn't work around with a small hobby razor blade.

I'll talk about Art in Part 5, but I have to mention it here as it's part of the sandwich. We ordered art from Scott at Mame Marquees and were thrilled with the results.

IMG_0290 IMG_0179

With the vinyl applied to the cut steel, I used the hobby knife to cut the holes for joysticks and buttons.

Wiring, Joysticks and Buttons

Next, John and I took the X-Gaming Arcade Stick apart on his counter. We labeled each button so we could put it back together in the SAME way inside our control panel. We also took a LOT of high-res photos as a reference.

IMG_0101 IMG_0294

The picture on the left is the inside of the X-Gaming stick as we purchased it. The right side is the buttons, controller board and joysticks. Note there are a few buttons that don't go in the control panel like the side flippers, programming switch and learn button.

Here's the complete control panel sitting on John's kitchen counter.

IMG_0293

Cost: US$0 (John is nice to me, and free.)
Cost So Far: US$306

At this point we have the exact guts of an X-gaming Arcade Stick inside our stock control panel. The controller for the thing includes a PS/2 port, so as long as my computer has a PS/2 port (or I get an X-Gaming USB or Xbox adapter, etc) then it'll just look like a keyboard to the system.

Next Up: Sound and Lights

  1. Cabinet and Power
  2. Monitor and Mounting
  3. Control Panel
  4. Sound and Lights
  5. Paint and Art
  6. Computer Hardware and Software
  7. Success and Conclusion

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

MSDN Updates - and RFC for you

June 05, 2009 Comment on this post [61] Posted in Microsoft | MSDN
Sponsored By

There's a bunch of stuff going on over at MSDN. They're making some cool changes and aren't afraid to break a few eggs to make an omelet. I used to think that MSDN was this static, non-moving thing, but I've been meeting with a bunch of folks on the various sub-teams and I'm seeing a resurgence of agility. (MSDN, agile?! Madness! No, seriously.) Soma blogged recently about some of the changes.

Here's some of the stuff that's been going on lately at MSDN, as well as a Request for Comments (RFC) from me.

Alternate MSDN Views

I blogged while back about alternate views for MSDN, including a Low-Bandwith (loband) view. MSDN includes the Home Page (of course), the MSDN Library, Downloads, Community and Forums. The library experience (LEX) team has updated the loband view as well as the new  dev10ide view. They're aiming for sub-1-second load times, small page weight and they are reading all the feedback

MSDN Forums in ASP.NET MVC

image The MSDN Forums have been updated and are now written in ASP.NET MVC. This, along with other changes has made the forums markup much smaller and the site much snappier. This forum upgrade went out to all MSDN/TechNet forums, including the Windows 7 Forums and Windows Client Development Forums.

The Forums are also more answer-focused now, kind of like StackOverflow. You can see how many questions remain unanswered, mark questions answered, and browse by tag. There's also filters like "hascode" to show only Q&A with code, or you can show only "helpful" answers, or just proposed, but not accepted answers.

The Forum Reading view has been updated with AJAXy goodness, so you can expand threads without leaving the page.

Other tweaks to MSDN include, the MSDN Community Center that includes not just blogs, but also tweets, delicious links, Technorati results and Diggs.

What would a new MSDN look like?

Chris Sells told me once:

"If you're not getting in trouble at least twice a year, you're not doing your job."

This statement really changed the way I thought about my job. It's good to push the envelope.

I was in an MSDN redesign meeting and they were brainstorming on some potential designs. I said, hey, let's go crazy here and try some way-out-there-MSDN designs. A bunch of emails have been thrown around and since they never explicitly said "don't blog this," I figured, why not ask you guys, then take the feedback/comments you give directly to them.

This is just brainstorming, to be sure, VERY early on for a potential redesign. I picked a few comps that the designer was working on that were in the same vein, but different in purpose.

First, here's a concept design for a a would-be MSDN Home Page. There's two goals here, and a visual refresh is just one of them. The other is to change the user experience to make it easier to find things. To make it easy to find things you need, but also have enough active content to have "serendipity" moments when you see something you wouldn't ordinarily.

There's a community visualizer at the middle there. It'd be an active widget and clicking on the left site would get you real-time results with recent activity, most popular items, etc from all over the network.

The Developer Centers are called out on the left-side to get you to the top areas in one-click. I pushed them to get you from the MSDN Home page to mostly anywhere in one click, two tops. For example, downloads has the most likely download links. At the bottom, you can get to other sites within the network.

MSDN_LOCH_HOME

Perhaps a lighter frame?

lightframe

Darker? Notice the "channel bar" at the top in gray.

MSDN_SHOE_HOME_D

Perhaps a compromise?

MSDN_TRAM_HOME

 

This potential home page is as a result of me saying, do the opposite of what we'd ordinarily do. Is the MSDN Home page too visually busy? Make it simpler. How simple can it get, and if it gets simple, does it still provide value?

MSDN_NORD_HOME

Perhaps without the blue frame? Even simpler?

MSDN_HM_NORD_5

Please offer your opinions and comments here. MSDN is your site and if you have an opinion, make it heard and I'll pass them out to my bosses. How should the site look? How do you want to use it? What do you think of these designs? What works and what doesn't?

If me leaking designs like this is helpful, tell me here and I'll use them as character references at my Court Martial. All the better if you find it helpful, then I'll have good reason to share even more, even earlier in the process.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Building your own Arcade Cabinet for Geeks - Part 2 - The Monitor

June 05, 2009 Comment on this post [6] Posted in Arcade
Sponsored By

This is the second part of a multi-part series I'm going to do about assembling an Arcade Cabinet for my house. This series has two disclaimers:

Software Disclaimer 1: There's all sorts of legal issues around emulating arcade games. This series of posts has nothing to do with that. I do own some original arcade boards, but if you want to emulate arcade games with MAME (Multiple Arcade Machine Emulator), you can search the 'tubes. What I'm doing here is putting a computer in a pretty box.

Hardware Disclaimer 2: Many folks that build arcade cabinets have a purist view of how these things should be done. They will prefer original Arcade CRT monitors and more expensive, higher quality parts. I am more of a pragmatist. I also have no idea what I'm doing, so I've also got ignorance on my side.

Picking a Monitor

image If you ask a purist, the ONLY monitor on to get for your home arcade is the Wells Gardener 27" Flat Screen Arcade CRT Monitor. There are others, and there are special video cards that run at the appropriate 15kHz that these monitors like. This particular monitor I've linked to has VGA support, however and will do 70Hz and 800x600. However, it's also about 80-95lbs.

Not only are these heavy, but they are a hassle to mount, they are heavy (did I mention that?) and depending on which one you get, they can be a little dangerous if you touch the wrong stuff.

True, you will get the "genuine" arcade look. Also, you can't argue with 27", size matters.

IMG_0070For me, however, I used a Dell 2003FP LCD Monitor. You may laugh, but it's clear, high-res, it's fantastically light, and I'm sure at some point, there will be some software to make my LCD as crappy and blurry and ghosty as a real arcade monitor.

Remember, I don't just want to play Donkey Kong, I also want to play Far Cry and Doom, so I am totally happy with a high-res LCD. The only trouble is finding a 4:3 LCD. I happened to have an extra, but you may need to look in the classifieds or on Craigslist.

Another option is to use a 24" 16:9 LCD and cover it with a bezel, or frame. You'll likely already need a bezel around your screen, so cropping the sides isn't a big deal for me. If my 4:3 LCD dies one day, I'll replace it with a 16:9 and crop it and I suspect no one will notice.

Cost: US$0 (I had one)
Cost So Far: US$131

Mounting

While my arcade cabinet came with a large broken (well, I broke it) monitor with burn-in, I needed to change the layout to make my LCD work. You can see there's a hole for dropping a CRT in and having the end of the CRT hang down into the middle of the box.

One of the benefits of using an LCD is the standard VESA mount on the back of the monitor. John and I pulled this old wood frame out, and took a piece of plywood and mounted the VESA bracket from the monitor's original pedestal (that we took apart), then put the whole thing back in. Now I can mount any VESA LCD in the system on this centered mount.

IMG_0072IMG_0087 IMG_0083

We then cut a semi-circle at the bottom to make room for both the video cables and the future control panel wires.

Notice also the angle of the monitor. Most older arcade cabinets didn't mount the monitor at a vertical angle or even close to vertical. Instead, since your head will be down while playing, they put the monitor nearer the horizontal.

We'll put a black framed bezel around the monitor in the "art" portion of the project.

IMG_0090 IMG_0091 IMG_0092

Then as seen in the third picture, we added a piece of frosted glass. At this point I'm playing solitaire as a test. I purchased an X-Arcade Dual Tankstick a while back (a year or more) and again, just for a test, I set it in the void.

IMG_0093

To be clear, to finish here would be the height of cheesy, so this is just a test. Unfortunately this point is where a lot of home arcade kits stop, but not us. However, confirming you are on the right track is a good motivator to continue.

Next Up: Control Panel

  1. Cabinet and Power
  2. Monitor and Mounting
  3. Control Panel
  4. Sound and Lights
  5. Paint and Art
  6. Computer Hardware and Software
  7. Success and Conclusion

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Building your own Arcade Cabinet for Geeks - Part 1 - The Cabinet

June 05, 2009 Comment on this post [7] Posted in Arcade
Sponsored By

This is the first part of a multi-part series I'm going to do about assembling an Arcade Cabinet for my house. This series has two disclaimers:

Software Disclaimer 1: There's all sorts of legal issues around emulating arcade games. This series of posts has nothing to do with that. I do own some original arcade boards, but if you want to emulate arcade games with MAME (Multiple Arcade Machine Emulator), you can search the 'tubes. What I'm doing here is putting a computer in a pretty box.

Hardware Disclaimer 2: Many folks that build arcade cabinets have a purist view of how these things should be done. They will prefer original Arcade CRT monitors and more expensive, higher quality parts. I am more of a pragmatist. I also have no idea what I'm doing, so I've also got ignorance on my side.

The Point

I have always wanted an Arcade at home. I spent hours wasting nickels, then quarters, then nickels again, at the local arcade. Who wouldn't want one in their house? Well, our spouses, but that's another post.

First step, build or buy? How to start the "Hanselcade?"

The Goal

I decided a few things early on from talking to folks (and you should decide for yourself, also):

  • I wasn't going to build my own cabinet from scratch. I have no wood-working skills, and I was concerned it wouldn't feel "stock" - like a real cabinet. It would look like a wood box with joysticks taped to it, like some that I've seen.
  • I am cheap. One can spend thousands and purchase a complete super-custom cabinet, but that's a little over the top for me. 
  • I wasn't going to build the greatest/largest/most versatile cabinet. I like the look of a single-purpose normal size cabinet, so I decided against any controls other than joysticks. No trackball, spinners, etc.
  • I may want to put an XBox, PS2/3, or other things in the cabinet also. Again, my goal was "a computer in an arcade box" that can play not just arcade games, but also Doom, or whatever. You can buy boards that have some large number of games already installed as well.

The Cabinet

You can build your own Arcade Cabinet using Cabinet Plans and your own wood. There's a lot of free plans and pay plan on the web. Personally, I find most of these plans to be to large and too tall. You have to ask yourself if you want a 2-player or 4 player system. Most of the 4-player ones are VERY large. Additionally, the control panels for those can be extremely wide, especially if you are making a panel that includes not just joysticks, but also trackballs and spinners. You can also buy the kit and assemble it later.

Instead, I decided, along with my friend/helper on this project John Batdorf to start with a REAL antique (wow, I'm old) arcade cabinet, and strip it down. I would compare this decision to refurbishing an antique car, rather than building a kit car.

I spent a few weeks searching Craigslist for terms like "MAME" and "Arcade" and found a local guy who had a very old "Video Trivia" game I'd never heard of. Most importantly it didn't work. Always buy ones that don't work and you'll get them cheaper.

IMG_0034 IMG_0035

Cost: US$100
Cost So Far: US$100

It wasn't much to look at, but it was physically solid. It came with an old CRT, but I accidentally broke it (it hissed air at me) and recycled it. I wasn't planning on using a CRT anyway, as they are not only high-voltage, but also unspeakably heavy.

Aside: This is where I differ from many. While some like the CRT look and authentic feel, I think a high-res LCD is more versatile and soon there will be real-time filters that, if you like, will make your crisp LCD look like an old CRT.

IMG_0038Notice the control panel sitting diagonally in that picture .This is one of the reasons I picked this cabinet. The Video Trivia game had only 5 buttons. No joysticks. As such, the control panel was almost all hole-free steel. In fact, this control panel is as solid as any piece of metal I've ever seen. I planned on using this panel to host my joysticks.

The cabinet also had lot of wires inside that I could piggy back other things on like getting the coin doors working, lights, etc. It was structurally sound, had no bugs living it it, and I could visualize it painted and finished.

Sounds silly, but being able to take an antique and visualize it completed is a big part of picking the right one.

The image at right is of the Oregon State "Music and Amusement Device Tax Receipt." Basically a license to have these. It's from 1985. I don't need a license now, but I like the nostalgic feel of this, so I'm going to keep it.

The Power

IMG_0104I have seen lots of cabinets online created by people who actually know and understand electricity. They come up with a lot of cool and clever ways to mount switches in new places in the cabinet. Since we're putting a computer in there, there will be a power need for a few things.

My electrical skills are limited to amps, volts, ohms, positive and negative. Using these superpowers and a dude from Home Depot, I found this little gem.

It's a "Belkin Conserve" Energy Strip. In English, it's a power strip with a remote. Bam!

Cost: US$30
Cost So Far: US$130

This was perfect. I drilled a 3/8" hole in the cabinet and snipped the cable in two (while unplugged, ahem.) I put the cable through the hole and spliced the cable back together with some wire connector/splicer dealies I got at Radio Shack for a buck.

Cost: US$1
Cost So Far: US$131

Then using the wall mount on the Belkin, I mounted the power strip on the inside of the cabinet.

 IMG_0105 IMG_0106

The remote control uses a single battery and comes with a holster with sticky tape. That'll go on the top of the cabinet. This was the cheapest and most creative (and clever, I thought) way to make this a "single power button" cabinet.

IMG_0107IMG_0108

Then I temporarily shoved everything in there to see if it would fit. Probably should have done that first. ;)

Next Up: Mounting the Monitor

  1. Cabinet and Power
  2. Monitor and Mounting
  3. Control Panel
  4. Sound and Lights
  5. Paint and Art
  6. Computer Hardware and Software
  7. Success and Conclusion

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

How to Remove the .NET ClickOnce Firefox Extension

June 04, 2009 Comment on this post [10] Posted in Microsoft | Open Source
Sponsored By

.NET 3.5 SP1 enables a Firefox Extension that allows .NET applications on Firefox, but its Uninstall button is grayed out.  Since .NET 3.5 SP1 is on Windows Update and is rolling out to more users than ever before, a number of people have noticed this and are frustrated.

Why is the Uninstall button grayed out? What does this add-in do?

Short Version: Remove the .NET Firefox Extension

First: To uninstall completely, if you're running XP or Vista, here's an update that will make the .NET ClickOnce Extension/Addin easily uninstallable by adding on a per-user, rather than per-machine basis. This update will also go out on Windows Update if you prefer to wait. Alternatively, you can click Disable and it won't be loaded.

Longer Version: Some Background and Details

This addin allows users to launch .NET applications from Firefox. The primary issue is that the plugin is enabled at the machine level, rather than the user level. This has the benefit of enabling the Addin for all users, but it as the unfortunate side effect of making the "Uninstall" button grayed out which makes people feel that something sinister has happened or they've lost control.

There are other plugins that use this technique to enable themselves machine-wide, including Google Gears and Java, but I totally understand that some folks don't want certain Firefox Addins enabled.

image

image

This is a tricky situation, because you'll notice that many applications enable browser plugins in similar ways, including, but not limited to:

  • Java
  • VLC Player
  • Adobe Acrobat
  • QuickTime
  • Google Talk
  • iTunes
  • Hulu
  • Picasa

There are lots of other applications that include their own browser addins, many install this same way. Most of these addins are in the "Plugins" tab, rather than the Extensions tab, which might explain why fewer people freak out. 

My point here is that the "Extensions" tab is something that Firefox users, myself included, feel strongly about, while they think less about plugins. Extensions often affect UI and make Firefox personalizable, while Plugins usually enable system-level functionality. It's a subtle difference, but it's significant and important to remember. Extensions are personalization points for Firefox at the User level, and are thought of as such. Some addins (not ours) mark themselves as Hidden, which could be perceived as even more sinister.

Ultimately since many people requested .NET support for Firefox, and we wanted to give it to them, we made this feature. When .NET was updated, this feature was included.

The Future

Here's some more detail and some insight into what we're doing about it.

  • First, this is already fixed in Windows 7 RC. You can uninstall this addin, no problem.
  • Second, for XP and Vista, the update above makes this add-in per-user so it can be easily uninstalled like any other Firefox addin.
    • This update will go out on Windows Update automatically soon. That means. if you already have this add-in, the only visual difference for you will be that the uninstall button will be enabled and you can remove it if you like.
  • Going forward, for .NET 4, the team wants to host this plugin at https://addons.mozilla.org. If you want it you can go get it. If not, no worries. We're still checking on this.

All the Technical Details

In case you want to know the technical details, and in the interest of transparency, it's called "MicrosoftDotNetFrameworkAssistant.xpi." You can rename it to .zip and unzip it. It's got XUL and JavaScript inside - it's just a zip file. If you have made a Firefox add-on, this will look familiar. There's an options dialog, standard stuff, keeping track of two booleans as preferences:

var dotNetAssistantOptions = 
{
onAccept: function()
{
var prefs = this.getPrefs();

var autoLaunchChk = document.getElementById("autolaunch");
prefs.setBoolPref("clickonce.autolaunch", !autoLaunchChk.checked);

var allVersionsChk = document.getElementById("allversions");
prefs.setBoolPref("all_clr_versions_in_useragent", allVersionsChk.checked);

// Update the user-agent if preferences changed
checkCLRVersionString();
return true;
},

onLoad: function()
{
var prefs = this.getPrefs();

var autoLaunchChk = document.getElementById("autolaunch");
autoLaunchChk.checked = !prefs.getBoolPref("clickonce.autolaunch");

var allVersionsChk = document.getElementById("allversions");
allVersionsChk.checked = prefs.getBoolPref("all_clr_versions_in_useragent");
},

getPrefs: function()
{
return Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("microsoft.CLR.");
}
}

There's a contentType handler. This is the meat of it. We see if the mime/type being requested is "application/x-ms-application," indicating the user is trying to launch a .NET ClickOnce application. We then do some path stuff and launch our "sandbox" application that hosts these apps.

var clickOnce = {

dialog_onload: function()
{
// This is the function that would have been called had our overlay not stepped in.
dialog.initDialog();

if (this.isClickOnce())
{
this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("microsoft.CLR.clickonce.");

if (this.prefs.getBoolPref("autolaunch"))
{
this.launch_application();
}
else
{
var button = dialog.dialogElement("launchApplicationButton");
button.collapsed = false;
// If the user has both this addon and FFClickOnce installed show only our button
var ffClickOnceButton = dialog.dialogElement("FFClickOnce-runbutton");
if (ffClickOnceButton)
{
ffClickOnceButton.collapsed = true;
}

// Let the dialog know it must resize to accommodate the new button
dialog.mDialog.sizeToContent();
}
}
},


isClickOnce: function()
{
var mimeInfo = dialog.mLauncher.MIMEInfo;

// Checking the file extension may be second guessing the webserver
// but when 'prompt' is set the user will still have a save button.
if (mimeInfo.MIMEType == "application/x-ms-application" ||
mimeInfo.primaryExtension == "application")
{
return true;
}

return false;
},


launch_application: function()
{
this.execute(this.getPresentationHostLocation(), "-LaunchApplication " + dialog.mLauncher.source.spec);

dialog.mDialog.close();
},

getPresentationHostLocation: function()
{
var nsIProperties = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)

// Attempting to forward-proof this extension by testing for where PresentationHost
// will probably be for CLR 4
var phNewLoc64 = nsIProperties.get("WinD", Components.interfaces.nsILocalFile);
phNewLoc64.appendRelativePath("Microsoft.NET\\Framework64\\wpf\PresentationHost.exe");
if (phNewLoc64.exists())
{
return phNewLoc64;
}

var phNewLoc32 = nsIProperties.get("WinD", Components.interfaces.nsILocalFile);
phNewLoc32.appendRelativePath("Microsoft.NET\\Framework\\wpf\PresentationHost.exe");
if (phNewLoc32.exists())
{
return phNewLoc32;
}

// Fallback to the default location
var phOldLoc = nsIProperties.get("SysD", Components.interfaces.nsILocalFile);
phOldLoc.appendRelativePath("PresentationHost.exe");
return phOldLoc;
},

execute: function(exe, strArgs)
{
// exe should already be an nsILocalFile

// create an nsIProcess
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(exe);

// Run the process.
// If first param is true, calling thread will be blocked until
// called process terminates.
// Second and third params are used to pass command-line arguments
// to the process.
var args = strArgs.split(" ");
process.run(false, args, args.length);

}

}

There's also a UserAgent module that will optionally append the .NET CLR version to the UserAgent so that websites can detect and show content based on

// Check for updated .NET Framework install on browser startup
checkCLRVersionString();

function checkCLRVersionString()
{
var useragentExtrasPref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("general.useragent.extra.");

useragentExtrasPref.QueryInterface(Components.interfaces.nsIPrefBranch2);

// startup check the registry for the latest version of the CLR added to the IE user agent
var versions = getInstalledCLRVersions();

var addonPref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("microsoft.CLR.");
addonPref.QueryInterface(Components.interfaces.nsIPrefBranch2);
var allAddonsInAgent = addonPref.getBoolPref("all_clr_versions_in_useragent");
// Allow the user to configure whether they want all version of the CLR in their user agent
// or just the highest.
if (allAddonsInAgent)
{
var appendString = "(";
for (var i=0; i < versions.length; i++)
{
if (i != 0)
{
appendString += "; ";
}
var localVersion = versions[i];
appendString += ".NET " + localVersion[0] + " " + localVersion[1];
}
appendString += ")";

useragentExtrasPref.setCharPref("microsoftdotnet", appendString);
}
else
{
var latestVersion = versions[versions.length-1];
var appendString = "(.NET " + latestVersion[0] + " " + latestVersion[1] + ")";
useragentExtrasPref.setCharPref("microsoftdotnet", appendString);
}
}

function getInstalledCLRVersions()
{
var wrk = Components.classes["@mozilla.org/windows-registry-key;1"]
.createInstance(Components.interfaces.nsIWindowsRegKey);

// Enumerate though the CLR version strings that will be appended to the Internet Explorer user agent
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\5.0\\User Agent\\Post Platform",
wrk.ACCESS_READ);

var clrVersions = new Array();
for (var i=0; i < wrk.valueCount; i++)
{
var name = wrk.getValueName(i);
var matches = name.match("\.NET (CLR|Client) \(.*\)");
if (matches && matches.length > 1)
{
clrVersions.push([matches[1], matches[2]]);
}
}
wrk.close();

clrVersions.sort(function(left, right)
{
if (left[1] < right[1]) return -1;
if (left[1] > right[1]) return 1;
// if version numbers are equal, prefer full CLR over Client sku
if (left[0] == "Client" && right[0] == "CLR") return -1;
if (left[0] == "CLR" && right[0] == "Client") return 1;
return 0;
});
return clrVersions;
}

That's it. Hope this helps. I'll keep my ear to the ground if anything else comes up, so stay tuned.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.