Centering a WPF Window in an Outlook 2013 Add-in

I recently came upon the need to show a WPF window in an Outlook add-in, preferably centered on the Outlook window (WindowStartupLocation = CenterInParent).  Easy enough, but without setting Window.Owner, it will appear in an uncontrolled location when calling ShowDialog().

Setting Window.Owner is where things get a little tricky.

Searching online produced a few variations of the theme of using the WindowInteropHelper class in combination with the win32 FindWindow API with the window caption discovered via Reflection.  Yuck.  Surely there’s a better way.

Enter System.Process.  One of the properties of the System.Process class is MainWindowHandle, which Microsoft states:

The main window is the window opened by the process that currently has the focus (the TopLevel form).

Sounds like exactly what I’m looking for.  A quick call to Process.GetCurrentProcess() and we’ve got everything we need.  The final code to show the WPF window is:

Simple as that!

 

Kindle Voyage

Yesterday I received my new Kindle Voyage.

Kindle Voyage

I’ve been a first-gen Paperwhite user since shortly after it was released and I have been nothing but pleased with it.  It was miles ahead of the other Kindles we in the household have owned.

The Voyage is another big step forward.  I was expecting an improvement, obviously, why else would I have upgraded?  What I was not expecting was how much of an improvement it is over that first Paperwhite.

The Screen

And what a beautiful screen it is!  Ultimately, the higher resolution screen is what caused me to pull the trigger on the upgrade.  The Voyage is sitting at 300ppi compared to the predecessor’s 212.  This, combined with the much improved screen contrast, makes the screen look like a printed magazine page.  Incredibly crisp and easy to read.  Texted seemed to get a little fuzzy on the smallest font and line sizes on the Paperwhite – not so with the Voyage.

The Voyage comes with a glass screen, something new to Kindles.  I was afraid this would hurt readability due to glare, but with their technology you can’t even tell there is glass on it when you aren’t touching it.  Nicely done.

The Light

Until upgrading, I didn’t realize the faults of the Paperwhite’s screen.  It lit up, making night reading pleasant.  End of story.

Well, the Voyage’s light can get much brighter (adding to that great contrast) and is distributed so much more evenly across the screen that the Paperwhite’s screen looks rather ugly to me now.

The Speed

I didn’t think I cared too much about the processor speed on my Kindle.  Until I fired up this one, that is.  Menus are very responsive, so much so that I’m actually browsing around the Kindle Store and Goodreads on it now.  Overall navigation is much improved by this.

PagePress

No more moving your hands to swipe/tap the screen to go to the next page!  You still can if you want, but they’ve added pressure-sensitive areas to the screen’s bezel for page navigation.  My only minor complaint is that I wish these glowed just a tiny bit for reading in the dark – at least on my first night I found it a little difficult to locate where to press.

Origami Case

The Amazon-recommended case is called the Origami case, named so due to how the case’s cover can fold up and function as a Kindle stand.  I’ll be honest, I thought it was just a gimmick when I ordered it, but I’ve already found myself folding it up to read hands-free.  The other nice surprise is that the entire case is magnetic: the folds are held magnetically; the cover closes magnetically; and the entire case holds onto the Kindle magnetically.

Overall, a fantastic device and well worth the upgrade.

Ugh: Windows 8, Metro and Desktop

First I’ll say that every PC I use these days is running Windows 8.1.  That’s my home desktop, laptop, Surface RT, and work PC.

Windows 8 is actually very good on the tablet form factor.  It’s fine on PCs if you’re wanting to stick to the new Metro style apps.

But it’s horrible when mixing desktop and Metro apps.  This seems to be compounded further when you’re running a multiple monitor rig.  Since many people complain about Windows 8 in general without offering specifics, I thought I would.

IE Stops Streaming

So here I am doing some work in Visual Studio or Lightroom. I’d like to stream something to listen to and watch, so I fire up Internet Explorer (Metro).  I dock it on the side of a monitor and get back to work.  Everything’s going just fine, I can glance over and catch a peek. It’s really nice.

Until I need to launch another app, that is.  So I hit the Start button to bring up the Start Screen and BAM.  Audio and video pause.  I suspect it’s because MS didn’t add background audio capabilities to IE, but still… it’s EXTREMELY jarring and frustrating.

Metro Apps Disappear

Many times, it’s happening right now actually, I’ll have a couple Metro apps docked but will still be working on the desktop.  As soon as the desktop app gets focus, some (or all) of the docked apps disappear and leave the start screen background color.  That’s it.  So now I just have a gaping hole of blue. If I click on that hole, the Metro app re-appears.  Give focus back to the desktop app and it disappears once again.

I don’t think it’s a driver issue, but then again I’m running all NVidia displays.  Anyone else experience this?

What’s Going to Happen?

When I want to open or close a Metro app, what happens next feels non-deterministic.  I can never guess where an app will open, what will replace the screen when it closes, etc..  On my Surface, my resolution doesn’t support 3 simultaneous running Metro apps, so I get prompted about which to replace. On my desktops, the new app starts full-screen and I have to move it somewhere.  The result is before launching an app I have to pause and recall which machine I’m on so I can prepare for what will happen (or if I should launch it to begin with given the screen/resolution limitations).

Sometimes after closing and app, I expect the Start Screen to re-appear, but it’ll just be replaced with a blank canvas, forcing me to hit the Start button (keyboard or lower left hotspot) to bring the Start Screen back.

And why, oh why, if I’m on the desktop and launch a Metro app am I not taken back to the desktop if I dock that app somewhere? After docking it somewhere, I’m taken back to the Start screen.  I just noticed this happens regardless of the starting point (Desktop or other Metro app).  Don’t make me remember what I was in before launching the new app, just take me right back there.  It’s ridiculous.

Did I Mention Multiple Monitors is just Weird?

Over the course of writing this, I have a situation where I have the desktop showing on one half of my left monitor and one half of the right monitor (full-screen metro app in between).  You can drag a window “behind” the metro apps, to the other sides.  It’s just really strange and unnatural feeling.

What am I Missing?

So these are my main gripes, coming from someone who uses Windows 8 daily and in multiple form factors.  Hopefully more is done to fix these in upcoming releases, but I’m not holding my breath.

Anyone have any other specific complaints?