Thursday, August 29, 2013

Shrinking an image in iOS with Xamarin.iOS and C#

Images taken with the camera are rather large in the iPhone.  How do you shrink them down?  I need to shrink them because I am going to send them to a web service and I want to spend as little time as possible in the upload process.  While I am not sure that this is the best code, it seems to be working for me.  I want to put this out for sharing and if you have a suggestion on how to make it better, please let me know.
                UIImage img = UIImage.FromFile (fileName);
                var width = img.Size.Width;
                var height = img.Size.Height;
                var newWidth = defaultImageWidth;
                var newHeigth = height * newWidth / width; // I always hope I get this scaling thing right. #crossedfingers
                UIGraphics.BeginImageContext (new SizeF (newWidth, newHeigth));
                img.Draw (new RectangleF (0, 0, newWidth, newHeigth));
                img = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext ();
  

HTML5 Threading with Web Workers and Data Storage with IndexedDB - MSDN Article

In a previous article, I looked at the HTML5
Note: The APIs for HTML5 vary slightly across different versions of browsers and different implementations. Because HTML5 is still in the recommendation phase at the W3C, you should think of it as a draft at this point. Because these APIs may change before they become a final standard, I cover only the version of HTML5 implemented in Internet Explorer 10. Every opportunity will be made to test the code across other browsers to verify that it works.
Url: http://msdn.microsoft.com/en-us/magazine/dn423698.as

Wednesday, August 28, 2013

Video and History support in HTML5 with Internet Explorer 10 - Article on MSDN

Who hasn’t started looking at the mobile Web and HTML5—features like the viewport, new HTML5 controls, geolocation and many others that are part of smartphones, tablets and advanced browsers? With these features, developers have started to provide users with fairly common, new input controls; jQuery Mobile features; location and mapping; and much more. In this article, I describe two features that you might not be familiar with: the
Url:  http://msdn.microsoft.com/en-us/magazine/dn423697.aspx

Sunday, August 25, 2013

Tech After Dark - Mobile Web Development - August 27-29

In the busy world of development, you barely have time to learn something new because you’re so busy dealing with the technology you’ve already got. Wouldn’t it be great to take control of your learning? But when? Your days are already spoken for.
Mobile development is a hot item. Customers are buying iPhones, iPads, Android devices, and many other mobile computing devices at an ever increasing record pace. Devices based on iOS and Android are nearly 80 percent of the marketplace. RIM continues to be dominant in the business area across the world. Nokia's growth with Windows Phone will grow on a worldwide basis.
At the same time, clearly web development is a tremendous driver of applications, both on the public Internet and on private networks. How can developers target these various mobile platforms with web technologies? Developers can write web applications that take advantage of each mobile platform, but that is a lot of work.
Into this space, the jQuery Mobile framework was developed. This eLearning series will provide an overview of mobile web development with jQuery Mobile, a detailed look at what the jQuery Mobile framework provides for us, how we can customize jQuery Mobile, and how we can use jQuery Mobile inside of ASP.NET.

Wednesday, August 21, 2013

UIRefreshControl Timeout with Xamarin.iOS

The UIRefreshControl doesn't have a timeout mechanism built into it.  Once the refresh begins, the control will display that a refresh is occurring until the .EndRefreshing() method is called.  Because we are in a mobile environment, the data may never come back.  We don't want to display the UIRefreshControl forever.  Solving this problem is actually pretty simple.  Setup a timer and when the timer runs, call .EndRefreshing().  Here is some code I used for this:
nstRefresh = NSTimer.CreateScheduledTimer( new TimeSpan(0,0,20), delegate{
BeginInvokeOnMainThread(delegate{
if( uir.Refreshing )
{    
       uir.EndRefreshing();
}
});
nstRefresh = null;
});
 
I hope that this helps 

Tuesday, August 20, 2013

Using the UIRefreshControl with the UICollectionView in Xamarin.iOS

If you have used Twitter on an iPhone, you are familiar with the concept of pull to refresh.  When you work with a UITableViewController, there is a .Refresh property that can be used to assign  a Refresh Control to.  A UICollectionViewcontroller has many similarities.  Unfortunately, the .RefreshControl property is not one of them.  How in the heck are you supposed to provide the same functionality in the UICollectionViewController?  It is actually rather simple, but not documented by Apple.  I found this on Stack Overflow and translated it to Xamarin.iOS.  The steps are:
  1. Create the UIRefreshControl just like you would with the UITableViewController.  Set properties on the UIRefreshControl just like you have previously.
  2. Add the UIRefreshControl as a subview on the UICollectionViewController's .CollectionView. 
There you go, now pull down in your UICollectionView in the UI and boom, there you have what you want.