Windows Phone 7 App - Traffic Trips

by sunil ravulapalli /4. January 2011 18:15 /windows-phone /Comments (0)

I am getting my feet wet in application development for Windows Phone 7.
My first App accepted into Market Place is "Traffic Tips".

1. If you have a windows phone, search for "Traffic tips" in marketplace.

2. External websites: http://www.freewarepocketpc.net/wp7/download-traffic-tips.html

3. Review(Look for traffic Tips)
http://www.pocket-lint.com/news/37048/best-windows-phone-7-navigation-apps

4. If you have Zune try: http://social.zune.net/redirect?type=phoneApp&id=5d6d614c-bbf6-df11-9264-00237de2db9e

Bing maps rest api in windows phone 7

by sunil ravulapalli /25. October 2010 22:30 /windows-phone /Comments (1)

Get a Bing maps developer account here http://www.microsoft.com/maps/developers/web.aspx so that you can get your own Bing maps key.
If you want to get the route between two points, the code to call the web service looks like this:

 string bingUri
  ="http://dev.virtualearth.net/REST/V1/Routes?
  wp.0={0}&wp.1={1}&output=xml&key={2}&optimize={3}";
 
 string homeAddress;
 
 string workAddress;
 
 string fullUri;
 
 const string bingKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

 fullUri = String.Format(bingUri,homeAddress,workAddress,bingKey,"time" );
 
 WebClient proxy = new WebClient();
 
 proxy.OpenReadCompleted += 
     new OpenReadCompletedEventHandler(proxy_OpenReadCompleted);
 
 proxy.OpenReadAsync(new Uri(fullUri));

proxy_OpenReadCompleted looks like this: (The following code also extracts traffic information)

uction = instruction; this.warnings = warnings; } } public class Warning { public string severity; public string desc; public Warning(string severity, string desc) { this.severity = severity; this.desc = desc; } }

If you want to loop through the results use this model:

foreach (ItineraryItem itineraryItem in itineraryItems)
{
  foreach (Warning warning in itineraryItem.warnings)
  {
                  
  }
}

You can find more options for REST API here: http://msdn.microsoft.com/en-us/library/ff701722.aspx

Windows Phone 7 Silverlight: How to move an image

by sunil ravulapalli /30. March 2010 04:17 /windows-phone /Comments (0)

To do this you will need a Canvas in the "ContentGrid" in the MainPage.xaml. Also make sure you have ManipulationStarted, ManipulationDelta activated on the content grid as show below.

 

In MainPage.xaml.cs,

public partial class MainPage : PhoneApplicationPage
{
    Image img;
    double startingPositionOfImageX;
    double startingPositionOfImageY;


    public MainPage()
    {
        InitializeComponent();

        SupportedOrientations = SupportedPageOrientation.Portrait | 
                SupportedPageOrientation.Landscape;

        img = new Image();

        img.Name = "myimg";
        //Size the Image
        img.Height = 80;
        img.Width = 80;

        //Place it top left
        img.HorizontalAlignment = HorizontalAlignment.Left;
        img.VerticalAlignment = VerticalAlignment.Top;

        //Point at the physical file
        Uri uri = new Uri("1.JPG", UriKind.Relative);
        ImageSource imgsource = new 
        System.Windows.Media.Imaging.BitmapImage(uri);

        //Set image property
        img.SetValue(Image.SourceProperty, imgsource);
        img.SetValue(Canvas.TopProperty, 100.0);
        img.SetValue(Canvas.LeftProperty, 100.0);

        canvas1.Children.Add(img);
    }

    private void ContentGrid_ManipulationStarted(object sender, 
                                           ManipulationStartedEventArgs e)
    {
        if (e.OriginalSource == img)
        {
            startingPositionOfImageX = 
            Convert.ToDouble(img.GetValue(Canvas.LeftProperty));
             
            startingPositionOfImageY =
            Convert.ToDouble(img.GetValue(Canvas.TopProperty));
        }
    }

    private void ContentGrid_ManipulationDelta(object sender, 
                                         ManipulationDeltaEventArgs e)
    {
        if (e.OriginalSource == img)
        {
            img.SetValue(Canvas.LeftProperty, 
            e.CumulativeManipulation.Translation.X + startingPositionOfImageX);
                
            img.SetValue(Canvas.TopProperty,
            e.CumulativeManipulation.Translation.Y + startingPositionOfImageY);
        }
    }

}

Windows Phone 7 Silverlight: How to place an image at a co-ordinate

by sunil ravulapalli /30. March 2010 03:30 /windows-phone /Comments (0)

To do this you will need a Canvas in the "ContentGrid" in the MainPage.xaml.

 

In MainPage.xaml.cs, set co-ordinates using img.SetValue(Canvas.TopProperty, 100.0) and img.SetValue(Canvas.LeftProperty, 100.0);

public MainPage()
{
       InitializeComponent();

       SupportedOrientations = SupportedPageOrientation.Portrait |
       SupportedPageOrientation.Landscape;

       Image img = new Image();

       //Size the Image
       img.Height = 80;
       img.Width = 80;

       //Point at the physical file
       Uri uri = new Uri("1.JPG", UriKind.Relative);
       ImageSource imgsource = new
       System.Windows.Media.Imaging.BitmapImage(uri);

       //Set image property
       img.SetValue(Image.SourceProperty, imgsource);

       //Set co-ordinates
       img.SetValue(Canvas.TopProperty, 100.0);
       img.SetValue(Canvas.LeftProperty, 100.0);

       canvas1.Children.Add(img);
}

Windows Phone 7 Silverlight: How to Load an Image using C#

by sunil ravulapalli /18. March 2010 03:39 /windows-phone /Comments (0)
public MainPage()
       {
           InitializeComponent();

           SupportedOrientations = SupportedPageOrientation.Portrait |
               SupportedPageOrientation.Landscape;

           Image img = new Image();

           //Size the Image
           img.Height = 80;
           img.Width = 80;

           //Place it top left
           img.HorizontalAlignment = HorizontalAlignment.Left;
           img.VerticalAlignment = VerticalAlignment.Top;

           //Point at the physical file
           Uri uri = new Uri("1.JPG", UriKind.Relative);
           ImageSource imgsource = new System.Windows.Media.Imaging.BitmapImage(uri);
          
           //Set image property
           img.SetValue(Image.SourceProperty, imgsource);
          
           //Add it to the main grid
           ContentGrid.Children.Add(img);

       }

Find the MainPage() function in the MainPage.xaml.cs and paste the code. Make sure there is image file in the project folder. When the windows emulator loads the image stretches to the entire screen. That is why you need to specify the Height and Width. We also need to specify the Horizontal and Vertical alignments, otherwise the image will appear in the center of the screen.