Tuesday, February 26, 2013

IValueConverter incompatible, Pain level 3

Win8 seems to randomly break IValueConverter by making the last parameter a string instead of CultureInfo!  I haven’t found the correct way to fix this, but at least this compiles Win8 and WP8:

public class BooleanConverter<T> : IValueConverter
{
    public BooleanConverter(T trueValue, T falseValue)
    {
        True = trueValue;
        False = falseValue;
    }
 
    public T True { get; set; }
    public T False { get; set; }
 
    public virtual object Convert(object value, Type targetType, object parameter, string language)
    {
        return value is bool && ((bool)value) ? True : False;
    }
 
    public virtual object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        return value is T && EqualityComparer<T>.Default.Equals((T)value, True);
    }
 
#if !WINFX_CORE
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return Convert(value, targetType, parameter, "");
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return ConvertBack(value, targetType, parameter, "");
    }
#endif
}

Platform fragmentation, Pain level 7

Sure, any platform over time will begin to fragment, but Microsoft seems hell bent on ensuring minimal portability of source code across their recent platforms. Whereas 1992 source code written for Win32 can be recompiled and run without modification throughout the intervening years, the same cannot be said of code written for Silverlight, WPF, WP7 and now Win8 and WP8.  

The half life of supported development platforms has fallen precipitously.  Silverlight, dead.  WPF ailing, WP7 obsolete, and the newcomers Win8 and WP8 proclaiming themselves the new shining path going forward. 

But developers are now gunshy and looking elsewhere, having learned through painful experience that Microsoft seems unable to commit to a coherent, long term development strategy.  Presumably this is an outcome of the org chart from the last decade:

One would have hoped that C# and the painfully verbose XAML would form the foundation of the future, but then COM and  C++ were confusingly resurrected, and we’re all invited to enjoy sprinkle our code with pointy hats:

 task<IVectorView<StorageFile^>^>(picker->PickMultipleFilesAsync())
.then([this, uri] (IVectorView<StorageFile^>^ files)
 

Or we can learn the joys of non-typesafe code by switching to javascript and CSS for coding our Win8 UI (but not WP8!).

Since C#, javascript, and C++ and associated controls and libraries aren’t compatible for developing applications across Win8 and WP8, the future for Windows developers will be one of continued pain. 

…none of the crazy you get from too much choice.

Windows 8 and Windows Phone 8 Pain Log

I’ve been a Windows developer for just about forever, and since my pain threshold has just been exceeded attempting to port existing code to these new platforms, I’ve decided to share my agonies as a form of therapy.

Each item will have an associated numeric Pain value of  1 to 10, with 10 being extreme, out of one’s mind pain.

This should be fun!

Friday, February 10, 2012

Google Video Chat disables other capture applications

Since I recently stumbled back into video capture work for a client, I thought I should bring to light an annoyance with Google Video Chat that caused several moments of consternation.

Google Video Chat installs fake Direct Show video capture drivers (Google Camera Adapter 0 and Google Camera Adapter 1). Although these drivers are registered with DirectShow as functioning capture devices in the category CLSID_VideoInputDeviceCategory they are in fact not available to applications other than Google Video Chat and return errors when they are instantiated using normal DirectShow conventions. Since many programs (including the one I’m in the process of writing!) weren't written to handle the case of a registered , but non-functioning capture device, they fail in various ways, not to mention the general confusion of having a bunch of non-functioning entries in device selection lists within the program.

Since this problem has been known for over a year now but has not been corrected, should one assume that we are witnessing an attempt by Google to undermine the functionality of alternative video capture applications for their own benefit? Evil or not evil, you decide!

The simple fix which would be trivial for Google to implement is to not register the Google Camera Adapter in the CLSID_VideoInputDeviceCategory category.

References:

DirectShow App Mess: Google Video Chat vs. Skype
http://alax.info/blog/1233#more-1233

Hardware/Software issues
http://luizgustavo.wordpress.com/2011/07/30/hardware-and-software-issues/

Google camera adapter causing problems with other programs
https://groups.google.com/a/googleproductforums.com/forum/#!searchin/chat/%22google$20camera$20adapter%22/chat/MygYu9bo_hw/xfCcgy1p2zMJ

GOOGLE CHAT CAMERA BLOCKS MY REGULAR CAMERA
https://groups.google.com/a/googleproductforums.com/forum/#!searchin/chat/"google$20camera$20adapter"/chat/mIXdZWBGOKw/oewf2rIZ1TQJ

Google Camera Adapter shows up as a source when it is not
http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.directx.video/2009-10/msg00026.html

How to uninstall "Google Camera Adapter 0" and "Google Camera Adapter 1"?
https://groups.google.com/a/googleproductforums.com/forum/#!searchin/chat/"google$20camera$20adapter"/chat/5C-JcQjQA7Y/TcHusD0iX3sJ

Tuesday, November 25, 2008

Silverlight 2.0 and facebook

I decided to figure out how easy it would be to embed DeepZoom within facebook as an application.  After wasting most of the day learning to configure IIS7 applications for debugging and downloading and installing toolkits and starter kits, I finally figured out that all this rigmarole is unnecessary if you don’t need to access the facebook API and just want to embed your Silverlight app.

If you have a working Silverlight 2.0 application working within an .aspx page and you want to embed it into facebook, all you really need to do is add a few lines to your web.config file and then set up the facebook application to reference your existing web site.

The lines to be added to web.config are:

<appSettings>
      <add key="APIKey" value="GetThisFromTheFacebookAppConfigPage"/>
      <add key="Secret" value="GetThisFromTheFacebookAppConfigPage"/>
      <add key="Callback" value=”http://www.deepzoom.com/default.aspx/>
      <add key="Suffix" value="MyIFrameApp"/>
      <add key="TemplateID1" value="20889707566"/>
      <add key="TemplateID2" value="20889902566"/>
</appSettings>

(I have no idea what the last 3 lines do either.)

The facebook app needs to be setup with using an IFrame and needs to have the Callback URL and Canvas URL set according to the instructions here.

If you want to go to the next step and actually access the facebook API, then you’ll need to follow the lengthy instructions at:

Facebook application development in ASP.NET

How to Build Facebook Applications with Silverlight 2 RTW – Part 1 of 2

How to Build Facebook Applications with Silverlight 2 RTW – Part 2 of 2

Tuesday, November 18, 2008

Embedding DeepZoom in FaceBook

It turns out it’s pretty simple to embed a Silverlight control in a FaceBook page.  Here’s the result.  Visit http://apps.facebook.com/nauticalcharts/ to see DeepZoom live.

image

Saturday, June 7, 2008

Moving to Silverlight 2.0 Beta 2 from Silverlight 2.0 Beta 1

Always a willing masochist guinea pig to help uncover the latest round of Microsoft bugs and features, I upgraded to Silverlight Beta 2 the day it became available.  Here is a link to the files you need to install.  I uninstalled Beta 1 components first but others reported no problems upgrading over the Beta 1 bits.

Below is a running list of what needed to be updated on www.deepzoom.com, and here's the official change list.

Updating www.deepzoom.com to B2

  1. Switch to the B2 mime type in your .aspx or .htm file.  Below, the "silverlight-2-b1" has changed to "silverlight-2-b2", and don't forget to change the Installer URL to "LinkID=115261" so your clients will download B2 instead of B1.
       1: <div style="height: 100%; width: 100%;">
       2:     <object type="application/x-silverlight-2-b2" width="100%" height="100%">
       3:         <param name="source" value="ClientBin/DeepZoom.FullScreen.xap" />
       4:         <param name="onerror" value="onSilverlightError" />
       5:         <param name="background" value="white" />
       6:         <div id="no-sl" class="install-badge">
       7:             <img alt="Puget Sound" src="images/SeattleArea.gif" />
       8:             <a href="http://go.microsoft.com/fwlink/?LinkID=115261" 
       9:                 style="position: absolute;
      10:                 text-decoration: none; left: 260px; top: 150px;">
      11:                 <img alt="Get Microsoft Silverlight" 
      12:                     src="http://go.microsoft.com/fwlink/?LinkId=108181"
      13:                     style="border-style: solid; padding: 10px; 
      14:                     background: white;" /></a>
      15:         </div>
      16:     </object>
      17: </div>
  2. Toss out all your B1 Deep Zoom content and create it anew in Deep Zoom Composer B2.  I had problems opening old Composer projects, so I don't know if upgrades are supposed to be supported.  The image metadata is now stored as XML file instead of binary, and the per layer detail from the old format seems to be gone completely.  Here's a sample of the new format:
       1: <?xml version="1.0" encoding="UTF-8" ?> 
       2: <Image TileSize="256" Overlap="1" Format="png" 
       3:     xmlns="http://schemas.microsoft.com/deepzoom/2008">
       4:     <Size Width="14718" Height="14334" /> 
       5:     <DisplayRects>
       6:         <DisplayRect MinLevel="0" MaxLevel="14">
       7:             <Rect X="0" Y="0" Width="14718" Height="14334" /> 
       8:         </DisplayRect>
       9:     </DisplayRects>
      10: </Image>
    This also breaks my Deep Zoom analyzer program, DeepZoomAnalyze.exe, and I'll be working on an update for this problem.
  3. Setting the source for a MultiZoomImage has changed.  Note that DeepZoomImageTileSource is in System.Windows.Media.dll, so add a reference to it:
    using System.Windows.Media;
       1: msi.Source = new DeepZoomImageTileSource(new System.Uri("images/info.dzi"));
       2: // Or
       3: msi.Source = new YourMultiScaleTileSourceOverride();
    Notice that you can now provide your own Tile source provider, which opens up a slew of new possibilities for the use of MultiScaleImage.
  4. Tooltips have changed completely.  Throw away your code and start over.
  5. Update silverlight.js.

And that's about it.  Except for regenerating all of the content, it took about two hours to figure out the changes.  None of the mouse or scroll or zoom logic needed to change which was a great relief.

Deep Zoom Composer Problems and Feature Requests

  1. Uploading a 78MB Tiff file which worked fine in Beta 1 fails to load in Beta 2.  The file opens fine in Photoshop and Paint so I don't think it's a corruption issue.  No error is given at the completion of a long import, but the resulting image is 1x1 pixels.
  2. Importing to Deep Zoom Composer has become painfully slow.
  3. Feature request:  Provide an option when bringing images onto the composer canvas to not scale the images to some random default value.  I need to have the relative scale of multiple images preserved, but it looks like Composer finds the largest image dimension for all images, and then scales all subsequent images to this value.  While this might be the generally desired behavior, there's another large class of applications in which autoscaling is the wrong choice.
  4. Feature request:  Let me assign a transparency value to an image so I can align images which overlap others.

VS2008 problems

  1. For a while, every time I touched a XAML page in VS2008, it reported an exception but then completed my request anyway.  But this problem seems to have disappeared after a restart or two, this seems to have gone away.