HttpUtility.UrlEncode in Windows Phone 7?

Silverlight has the Uri.EscapeUriString and Uri.EscapeDataString which can be used to URL-encode portions of a URI such as query strings and path components and such. Even in the desktop framework, you should never take a dependency on System.Web.dll just for HttpUtility, although many developers still do it. This is bad for 3 reasons. The assembly … Read more

Write once deploy on Windows Mobile 6, Windows Phone 7, Android and iPhone? [closed]

If you’re happy to re-use business logic and write device specific user interfaces (more work, but better user experience on each device) you could consider the various Mono frameworks. Writing the core business logic as a class library, then writing specific user interfaces using MonoTouch, MonoDroid and Windows using .NET Framework you’ll have a cross … Read more

Saving Bitmap as PNG on WP7

You’re attempting to convert the JPEG memory stream into PNG. That will make it corrupt – you should save the Bitmap directly to PNG. I haven’t tried this particular task with the imagetools library, but if you see John Papa’s blog, it looks like you need to call the ToImage extension method on your WriteableBitmap … Read more

How to zoom in and zoom out Images in WP7?

Perhaps the most expedient approach would be to include the Silverlight for Windows Phone Toolkit. This contains a GestureService that will help with pinch and rotate touch gestures. You could apply it to an image like this:- <Image Source=”someSourceUrl” RenderTransformOrigin=”0.5, 0.5″ CacheMode=”BitmapCache”> <Image.RenderTransform> <CompositeTransform x:Name=”transform” /> </Image.RenderTransform> <toolkit:GestureService.GestureListener> <toolkit:GestureListener PinchStarted=”OnPinchStarted” PinchDelta=”OnPinchDelta” /> </toolkit:GestureService.GestureListener> </Image> Then … Read more

How to use credentials in HttpClient in c#?

I had the exact same problem myself. It seems the HttpClient just disregards the credentials set in the HttpClientHandler. The following shall work however: using System.Net.Http.Headers; // For AuthenticationHeaderValue const string uri = “https://example.com/path?params=1”; using (var client = new HttpClient()) { var byteArray = Encoding.ASCII.GetBytes(“MyUSER:MyPASS”); var header = new AuthenticationHeaderValue( “Basic”, Convert.ToBase64String(byteArray)); client.DefaultRequestHeaders.Authorization = header; … Read more

Getting GPS coordinates on Windows phone 7

Here’s a simple example: GeoCoordinateWatcher watcher; watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default) { MovementThreshold = 20 }; watcher.PositionChanged += this.watcher_PositionChanged; watcher.StatusChanged += this.watcher_StatusChanged; watcher.Start(); private void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e) { switch (e.Status) { case GeoPositionStatus.Disabled: // location is unsupported on this device break; case GeoPositionStatus.NoData: // data unavailable break; } } private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> … Read more