Customization of WPWidgetLibrary


In only 12 days WPWidgetLibrary reach more that 800 page views and over 50 downloads. This is good start of the library since building HTML5 apps in Windows Phone is coming. We have also got several feedbacks and questions about the library, and we can say the WPWidgetLibrary is indeed solution for developing hybrid mobile applications for Windows Phone 7.
One of the question about WPWIdgetLibrary is how to customise some features. For example default library no support avi file format. For that reason we have opened Discussion section of the library and put some answers. Here is one of them Damir has posted:
WpWidgetLibrary installs HTML app by calling:

InstalHTMLContent(string htmlFolder, string[] htmlDirs) ;

where htmlFolder is the folder in solution which contains all required web files. In other words this is the root of web-application which will be executed from isolated storage. Because you are free to use any kind of extension like “myfile.tiff” the framework can either copy any file in your project or specific files. We decided to copy specific files only.
Here is how we do it:

protected virtual bool IsWebExtension(string ext)       {
bool res = false;
switch (ext.ToLower())
{
 case "htm":
 case "html":
 case "js":
 case "jpg":
 case "jpeg":
 case "png":
 case "css":
 res = true;
 break;
 }
return res;
}

If your HTML mobile app requires other file formats eg. “abc.avi”, just derive the WPWIdgetLibrary class and override this method like the following sample.

public class MyWPWidgetLibrary: WPWidgetLibrary{
protected override bool IsWebExtension(string ext){
bool res = false;
 switch (ext.ToLower())
 {
 case "avi":
 return true;
 //break;
 }
 return base.IsWebExtension(ext);
 }
}

Now WPWidgetLibrary supports custom avi files.
On similar way you can implement support of any file format you want.

In only 12 days WPWidgetLibrary reach more that 800 page views and over 50 downloads. This is good start of the library since building HTML5 apps in Windows Phone is coming. We have also got several feedbacks and questions about the library, and we can say the WPWidgetLibrary is indeed solution for developing hybrid mobile applications for Windows Phone 7.

One of the question about WPWIdgetLibrary is how to customise some features. For example default library no support avi file format. For that reason we have opened  Discussion section of the library and put some answers. Here is one of them Damir has posted:

WpWidgetLibrary installs HTML app by calling:


 InstalHTMLContent(string htmlFolder, string[] htmlDirs) ;

where htmlFolder is the folder in solution which contains all required web files. In other words this is the root of web-application which will be executed from isolated storage. Because you are free to use any kind of extension like “myfile.tiff” the framework can either copy any file in your project or specific files. We decided to copy specific files only.

Here is how we do it:


protected virtual bool IsWebExtension(string ext)       {
bool res = false;
switch (ext.ToLower())
{
 case "htm":
 case "html":
 case "js":
 case "jpg":
 case "jpeg":
 case "png":
 case "css":
 res = true;
break;
}
return res;
}

If your HTML mobile app requires other file formats eg. “abc.avi”, just derive the WPWIdgetLibrary class and override this method like the following sample.

public class MyWPWidgetLibrary: WPWidgetLibrary{
protected override bool IsWebExtension(string ext){
bool res = false;
switch (ext.ToLower())
{
 case "avi":
 return true;
 //break;
}
return base.IsWebExtension(ext);
}
}

Now WPWidgetLibrary supports custom avi files.

On similar way you can implement support of any file format you want.

About Bahrudin Hrnjica

PhD in Mechanical Engineering, Microsoft MVP for .NET. Likes .NET, Math, Mechanical Engineering, Evolutionary Algorithms, Blogging.

Posted on 29/10/2011, in .NET, Widget for WP7, Windows Phone 7 and tagged , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s