DCSIMG
March 2008 - Posts - Alex Golesh's Blog About Silverlight Development

March 2008 - Posts

Where am I?

If you developing games using XNA game studio, many times you need to know where your code is running - on PC or on Xbox 360 hardware... Unfortunately, there is no any out-of-the box functionality provided by XNA Framework to check platform, but here is the solution: XBox 360 the only device, which supports special 3rd mode for Pixel & Shaders version 3 on its Shader profile and this could be checked out.

Here is the sample code:

   1: bool isXbox = false;
   2:  
   3: //Lets get graphics device for current game
   4: GraphicsDeviceManager graphics;
   5: graphics = new GraphicsDeviceManager(this);
   6: GraphicsDevice graphics = graphics.GraphicsDevice;
   7:  
   8: //Once we have graphics device, we could check its capabilities
   9: if (graphics.GraphicsDeviceCapabilities.MaxPixelShaderProfile == ShaderProfile.XPS_3_0 ||
  10:     graphics.GraphicsDeviceCapabilities.MaxPixelShaderProfile == ShaderProfile.XVS_3_0)
  11:     //XBox 360 is the only device, which will support this ShaderProfiles
  12:     isXbox = true;
  13:  
  14: //Rest of your game code goes here....

 

Want to know more about XNA game development? See me at TechEd 08, developing XBox 360 game on stage - DEV335: Game Development Using Microsoft’s Latest Technologies

 

sign_speaker2Enjoy,

Alex

Mystery Error

Today I've decided to change my regular Internet radio application, and try something new... I've got myself some free Internet Radio Player with recording ability and A LOT of radio station presets, but when tried to switch on Israelis "100 FM", got this very cute error:

image

I was very confused, what is so mysterious in connection fails... That's make a classical example of confusing user message.

Morale: Don't inform your users about mysterious errors :)

 

sign_speaker1

 

 

 

Enjoy,

Alex

Posted by Alex Golesh | with no comments

Silverlight 2 & CreateSilverlight()

Current Silverlight 2 Beta by default doesn't using silverlight.js/CreateSilverlight() functionality we used to add Silverlight in Alpha version, but Silverlight directly created on page as object:

   1: <div id="silverlightControlHost">
   2:        <object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%">
   3:            <param name="source" value="SilverlightApplication4.xap"/>
   4:            <param name="onerror" value="onSilverlightError" />
   5:            <param name="background" value="white" />
   6:            
   7:            <a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;">
   8:                 <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
   9:            </a>
  10:        </object>
  11:        <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
  12:    </div>

What to do, when we want to control more precisely the object creation, fine tune some properties or use single point of creation for multiple Silverlight components in single page?

Well, the good news, that silverlight.js is still exists (could be found in Silverlight SDK directory "%ProgramFiles%\Microsoft SDKs\Silverlight\v2.0\Tools"), and could be used to create our own createSilverlight() functions... Here is my example of such a function:

   1: //Parameters:
   2: //src - source xap file
   3: //elm - host element Id
   4: //width, height - control width/height (could be in %)
   5: //htmlAccess - allow control to interact with HTML. Values "true", "false"
   6: //windowLess - is control windowless. Values "true", "false"
   7: function createSilverlight(controlId, src, elm, width, height, htmlAccess, windowLess)
   8: {
   9:         Silverlight.createObjectEx({
  10:                 source: src,
  11:                 parentElement: elm,
  12:                 id: controlId,
  13:                 properties: {
  14:                         width: width,
  15:                         height: height,
  16:                         version: "2.0",
  17:                         enableHtmlAccess: htmlAccess,
  18:                         isWindowless: windowLess
  19:                 },
  20:                 events: { }
  21:         });
  22:         // Give the keyboard focus to the Silverlight control by default
  23:         document.body.onload = function()
  24:         {
  25:                 var silverlightControl = document.getElementById(controlId);
  26:                 if (silverlightControl)
  27:                         silverlightControl.focus();
  28:         }
  29: }

More information could be found here.

sign_speaker2

Enjoy,

Alex

MIX08 - Day3

Well.... Its the last day of MIX08...

First lecture on "Bringing Data to life in WPF" by Anson Tsao was very pathetic. He described binding mechanisms for dummies... For someone, who develops WPF this lecture was one big waste of time.

The session on Web Analytics with Silverlight by Michael Scherotter was good, but for me not enough technical.

Last one I have on this MIX was "Working with Data and Web Services in Silverlight 2" by Eugene Osovetsky. The session was very interesting with nice demos, code samples, etc.

All sessions could be watched online here.

Next MIX09 announced yesterday on keynote session. It will take a place at same place (Venetian Hotel, Las Vegas) at March 18th-20th 2009! Be there - it worth it!

Enjoy,

Alex

MIX08 - Day 2

Well, second day was nice with a lot of interesting lectures and second keynote from Steve Ballmers. I've attended on at Rob Releya's "Whats new in WPF 3.5" and Karen Corby's "Creating Rich, Dynamic UI  with Silverlight 2". Karen did a very good presentation, and was focused on creating reusable component methods in Silverlight 2, many code, samples, etc.. Rod did brief overview on upcoming service release for .Net 3.5 with a lot of demos,  but what I've personally missed is code behind them :(

Keynote was like any keynote - nothing special...

 

Will update at Day 3.

 

Enjoy,

Alex

MIX08 - Day 1

SANY0006Well, day 1 is over... It was very interesting day. I've started (like majority of attendees) on Keynote, being presented by Roy Ozzie, Scott Guthrie and Dean Hachamovitch.

It was very big excitement on announcing Silverlight 2 Beta1 and IE8 Beta. Lots of great demos and showcases by partners (AOE mail, Hard Rock Cafe with Deep Zoom, WeatherBug with Silverlight mobile for Nokia platform ), etc.

 SANY0019

So, here are the major release downloads:

  • Silverlight 2 runtime (download
  • Silverlight Tools for VS2008 (download
  • Microsoft Expression Studio 2 Beta (download) SANY0009
  • Microsoft Silverlight 2 SDK Beta 1 (download)
  • Microsoft Silverlight 2 SDK Beta 1 Documentation (download)
  • Source Code and Unit Tests for Silverlight 2 Beta 1 Controls (download)
  • Microsoft Expression Blend 2.5 March 2008 Preview (download)
  • Expression Web 2 Beta (download)
  • IE8 Beta (download)

After keynotes, I was on very good lecture about UI usability, and creating efficient UX by Gil Hupert-Graff and Yochay Kiriaty.

Last session I had (2 parts) was on building rich Internet applications using Silverlight 2 by Joe Stegman (1st part) and Mike Harsh (2nd part). There was a lot of useful (and not so useful) examples, of what Silverlight can do now, and how Internet developing is merging with "old-school" WPF developing.

Last, but not least, I've had a great party time at TAO nightclub :)

TAO1 TAO2

 

Will back tomorrow with more updates

 

Enjoy,

Alex