Archive for August, 2007

Microsoft has provided some very good documentation on how to package fonts with WPF applications, and I’ve been following it in several different ways in different apps I’ve written. Recently I provided a feature in Posh Console which allows you to load the startup banner from an external file: StartupBanner.xaml.

Loading the banner from an external XAML file means that users can configure their own startup banner and make it look however they like, but it broke our default banner. The startup banner we’ve been using has a logo and some text which are all defined in pure XAML and uses several fonts which we had embedded in a FontLibrary.dll resource assembly. It worked great as long as the XAML was defined in the application, but as soon as we removed it to an external file and loaded it in using the XamlReader.Load method, the fonts all went to the fallback default fonts instead of our embedded ones.

Normally this might not be a big deal, but since our logo is based on the “Q” in a Quake-like font … it looks really lame without fonts. :D Apparently, when you load external XAML, it can’t use the Font Resource Library resources. At this point, I can’t seem to find anything to indicate why this is the case, but I suspect it has to do with the fact that the external, loaded XAML only has partial trust, and since the font is in an external assembly instead of embedded in the partial trust content, it can’t get to it. However, it might be simpler than that: it might just be that the base URI for the externally loaded XAML is an actual file location rather than one of the pack://,,,application/ type URIs, so the slightly odd font path doesn’t resolve.

In any case, I found a way around it, which is of course, why I’m writing all of this down. :) (more…)

So, I’ve been working on PoshConsole for awhile now, and with the help of some of the guys in #PowerShell@irc.freenode.net have been playing with trying to find ways to enhance output, like using ANSI escape sequences, and even creating an Out-WPF cmdlet which can output objects as databound WPF controls which look really good.

We have been trying to find a way to incorporate the colored and even bold/italic formatting in a way that would be compatible with the existing format-* cmdlets, and we’ve even looked at replacing out-default with a cmdlet that would be compatible with the default PowerShell host. But today I finally locked in on the import of this post on the PowerShell blog. It’s just not possible.

The format cmdlets (Format-List, Format-Custom, Format-Table, Format-Wide) output data in the form of undocumented .Net objects which are “subject to change without notice,” and are therefore basically useless. Of course, that means that if you want to replace Out-Default you have to not only replace the output, but you have to replace the formatting cmdlets, and of course the Update-FormatData cmdlet too — in fact, you have to either parse the largely undocumented format data files, or create some replacement for them to allow users to specify formatting for types you haven’t thought of…

All of this amounts to what many of you probably already knew: it’s a lot of work to create a complete PowerShell host, but it’s at least as much work to create a replacement PowerShell formatter.

Click for a teaser screenshot

This is actually a bit scary, because you can load sort-of … anything ;-) To prove it (you’re gonna love this … I should take a video, really, but it’s time for bed, so this will have to do): check this out Beat that! ;)

So yeah, I have this control written from an earlier project which creates a task list with live preview images. When I say “live previews” I mean actually live, like on the Vista Alt+Tab: if there’s a video playing, you can watch it in there (of course, it dies a horrible death on XP, but I have other code for that).

As a side note the TaskBar2.panel stuff is from the TINS release I made months ago, there’s several fun .panel files in there … but you have to load a bunch of the TINS assemblies first, I didn’t distinguish which ones, I just did:


cd C:\Users\Joel\Projects\TechDemos\TINS\bin\Release
ls *.dll,*.exe | % { [System.Reflection.Assembly]::LoadFrom($_) }
$Host.PrivateData.XamlUI.LoadXaml("C:\Users\Joel\Projects\TechDemos\TINS\bin\Release\Panels\TaskBar2.panel");

 

Of course, in .Net 3.5 the RichTextBox has the ability to go ContentEnabled="true" which should allow those things to be actual controls you can click to switch active task, right-click to get a task menu, etc (although I haven’t tried that yet). We might just have to upgrade ;-)

Anyway, it’s past time for bed, so I’ll preempt complaints about how this isn’t ready for release yet with this quote:

I don’t have to take this abuse from you; I’ve got hundreds of people waiting to abuse me. — Bill Murray, “Ghostbusters”

Well, it’s finally over. SCO v. Novell has been decided, and the court has concluded that Novell is the owner of the UNIX and UnixWare Copyrights, and that SCO is obligated to recognize Novell’s waiver of SCO’s claims against IBM and Sequent. So that’s pretty much a wrap, I’d say.

Even Groklaw actually passed on thanks to Novell on behalf of the entire FOSS community “for being willing to see this through.” Do you suppose this will make up for the fiasco with the Microsoft agreements? ;-)

So I was kind of bored today …
And it’s been a long time since I posted anything …

I’ve been hard at work … among other things I’ve made lots of progress on PoshConsole, and I’ve been playing with PowerShell a lot. If anyone knows anyone using Vista who still has UAC turned on, do them a favor:

1) Download a wav of Regis saying “Is that your final answer?”
2) Put it on their computer somewhere
3) Open up PowerShell (to the folder where you put the wav) and run this command:


Set-ItemProperty -path HKCU:\AppEvents\Schemes\Apps\.Default\WindowsUAC\.Current\ -name "(default)" $(Resolve-Path "FinalAnswer.wav")

 

:D Obviously you can do that in the “Sound” control panel too, it’s the last event under the “Windows” app, labelled “Windows User Account Control” ... now whenever Windows asks for permission to run something, they’ll get a bit of a chuckle out of it. Makes it more bearable. ;)