Senin, 23 Desember 2013

How to Launch setting page from Windows Phone 8 C# app

Introduction:

Windows Phone application is not allowed to modify some of the device’s settings directly.As a developer we can't access the phone functionality directly.And so alternative way  is "launch the settings screen " from the our app.However one of the most wanted functionality is added in "WindowsPhone 8 sdk" is "URI schemes" 

This topic lists the URI schemes that can be used to launch built-in apps. Many of the apps built into Windows Phone can be launched from your app by calling LaunchUriAsync(Uri), passing in a URI that uses the scheme associated with the app you want to launch. 


Source File at :WP8URISchemes

Note: URI schemes are not supported in windowsphone 7 sdk

By usign URI schemes we can easily launch "Airplane Mode Settings,Bluetooth Settings,email and accounts settings,Location Settings,Lock Screen settings,Battery Saver settings,Screen Rotation settings for Windows Phone 8 Update 3,Wi-Fi Settings...........etc and many more settings


For info you may visit WindowsPhone 8 URI schems


Please note following URI schemes are most useful in real time apps.


In your application, instead of asking the user to navigate to the Settings page, you can directly bring them to the page, programmatically.

To launch the various Settings pages, you can use the Launcher class with the LaunchUriAsync() method. As you are launching the pages asynchronously, you need to wrap these calls in a async method, like this:

1. Launch the Bluetooth Settings App using URI Scheme in Windows Phone 8

C#
Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-bluetooth:”));
 

2. Launch the AirplaneMode Settings App using URI Scheme in Windows Phone 8 

C#
Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-airplanemode:”));

 3. Launch the Cellular Settings App using URI Scheme in Windows Phone 8 

C#
Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-cellular:”));

 4. Launch the WiFi Settings App using URI Scheme in Windows Phone 8

C#
Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-wifi:”));

 5. Launch the Location Settings App using URI Scheme in Windows Phone 8

C#
Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-location:”));

 6. Launch the EmailandAccounts Settings App using URI Scheme in Windows Phone 8

C#
Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-emailandaccounts:”));

 7. Launch the Lock Settings App using URI Scheme in Windows Phone 8

C#
Windows.System.Launcher.LaunchUriAsync(new Uri(“ms-settings-lock:”));

 8. Sending Email using URI LaunchUriAsync in Windows Phone 8




C#

async private void Button_Click_1(object sender, RoutedEventArgs e) 
 

 
await Launcher.LaunchUriAsync(new Uri("mailto:awesomecoder@abundantcode.com")); 
 
}

9. Search for an App by Publisher in Windows Phone Store using URI Scheme from WP8 App




C#

// Function to Search for an App by publisher in Windows Phone Store using URI Scheme in Windows Phone 8 using C#. 
 
private async System.Threading.Tasks.Task SearchForAnApp() 
 

 
await Launcher.LaunchUriAsync(new Uri("zune:search?publisher=Abundantcode")); 
 
}




Windows Phone tutorials for beginners key points




This section is included for only windows phone beginners.However this article can covers following questions.Off course these key words are more helpful for getting more best results about this topic in search engines like google/bing/yahoo.. 





1. Launching the Location Settings App using URI Scheme in Windows Phone 8





2. How to Launch the Cellular Settings App using URI Scheme in Windows Phone 8?






3. Launching the Wifi Settings App using URI Scheme in Windows Phone 8






4. How to Search for an App in Windows Phone Store using URI Scheme from WP8 App?






5.Launch the Bluetooth Settings App using URI Scheme in Windows Phone 8





Related Posts:
  1. WindowsPhone 8 Custom URI Scheme:Launching other own apps from your app (C#-XAML)
Have a nice day by 

Kamis, 19 Desember 2013

Customizing windowsphone 8 calender control c#

Introduction

Firstly i would like to say very thanks to http://wpcontrols.codeplex.com/, here we can get calender control for windows phone,which is can support both windowsphone 7.1 and windowsphone 8 OS.I was really impressed by this open source custom control and i would like to say very thanks to making source code available in codeplex.It will be more helpful for developers to customize calender as per their requirement .By the way i want to share a few things about "How to customize this windowsphone calender control"


Building the Sample

We need to download source code of windowsphone calender control from http://wpcontrols.codeplex.com/.Here there is an option for  downloading source code which can support both windows phone 7.1 & windowsphone 8.
Description
However this article can explain the way of easily  customizing  the "WindowsPhone calender control" with our reuirements.Here iam going to explain about 
1)How to set background image to windowsphone calender
2)Customized Next and Previous month buttons for calender
3)webservice responce data binding to windowsphone calender
4)How to display events with specific date color
5)Screenshots
6)WindowsPhone calender gestures
So lets start start with simple steps to making our requiremnts

1)How to set background image to windowsphone calender

One  ineresting of windowsphone calender is default with transferent background color.And so it is helpful more for developers to change bg colot of calender by put into grid background like this way,
XAML
<Grid x:Name="ContentPanel"  Grid.Row="1" Margin="12,0,12,101"
            <Grid.Background
                <ImageBrush Stretch="Fill" ImageSource="/shade_white (2).png"/> 
            </Grid.Background> 
            <Grid.RowDefinitions
                <RowDefinition Height="*"/> 
                <RowDefinition Height="Auto"/> 
            </Grid.RowDefinitions> 
            <!--ColorConverter="{StaticResource ColorConverter}"--> 
            <wpControls:Calendar Grid.Row="0" 
                x:Name="Cal"  
                ColorConverter="{StaticResource ColorConverter}" 
                MonthChanged="Cal_MonthChanged" 
                MonthChanging="Cal_MonthChanging" 
                SelectionChanged="Cal_SelectionChanged" 
                DateClicked="Cal_DateClicked" 
                EnableGestures="False" StartingDayOfWeek="Monday" Margin="0,0,0,109" 
                /> 
            <!--<wpControls:Calendar  
                x:Name="Cal"/>-->
 
            
 </Grid>

2)Customized Next and Previous month buttons for calender

One of the most important thing point of windowsphone is "Generic.xaml" page ,it is main head of every custom control in windowsphone ,or if you want to know more about "Generic.xaml" you may visit my favorite website is http://www.geekchamp.com/articles/creating-a-wp7-custom-control-in-7-steps
we can found this file under "WpControls=>Thems=>Generic.xaml" 
So,open that page and you may observed in this there is two buttons next/prev as names are x:Name="PreviousMonthButton" and x:Name="NextMonthButton" 
XAML
<Style TargetType="local:Calendar"
<Button  
                           Height="80" 
                            Width="80"  
                            Grid.Column="1" 
                            BorderThickness="0" 
                            x:Name="PreviousMonthButton"  
                            HorizontalAlignment="Right"  
                            VerticalAlignment="Center"  
                            Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ShowNavigationButtons, Converter={StaticResource BooleanToVisibilityConverter}}"
                            <Button.Background
                                <ImageBrush Stretch="Fill" ImageSource="/backwrd_1.PNG"/> 
                            </Button.Background> 
                        </Button> 
                        <Button  
                            Height="80" 
                            Width="80"  
                            Grid.Column="2"  
                            BorderThickness="0" 
                            x:Name="NextMonthButton"  
                            HorizontalAlignment="Right"  
                            VerticalAlignment="Center"  
                            Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ShowNavigationButtons, Converter={StaticResource BooleanToVisibilityConverter}}"
                            <Button.Background
                                <ImageBrush Stretch="Fill" ImageSource="/frwd_1.PNG"/> 
                            </Button.Background> 
                        </Button> 
</Setter>
3)Binding WebService responce data to windowsphone calender

Now days in most of requiremnt want to this feature in their apps,and so as developer we need to get responce data from webservice and finnaly need to map the list of events from calander.And it is little bit difficult to synchrounise webservice data with our calender,off cource wp calender makes it is as very simple by introducing the bellow class .However this is explaned more cleraly in next important heading.
C#
public class ColorConverter : IDateToBrushConverter 
    { 
}
4)How to display events with specific date color
 In step the 3 i had explaned about "ColorConverter.cs" class.It is more helpful for displaying events date with specific color broush ,here i was displayed the events with "yellow" color
Here iam statically taken the events on today dates of 2,11,21,30,so i hope you will check like this with webservice repsonce list of events data
Note:I just want giving the idea about changing the bg color of particular event date.
C#
using System; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Ink; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using WPControls; 
 
namespace WpControlsExample 

    public class ColorConverter : IDateToBrushConverter 
    { 
 
        public Brush Convert(DateTime dateTime, bool isSelected, Brush defaultValue, BrushType brushType) 
        { 
            if (brushType == BrushType.Background) 
            { 
                if (dateTime == new DateTime(DateTime.Today.Year, DateTime.Today.Month, 2) || dateTime == new DateTime(DateTime.Today.Year, DateTime.Today.Month, 11) || dateTime == new DateTime(DateTime.Today.Year, DateTime.Today.Month, 21) || dateTime == new DateTime(DateTime.Today.Year, DateTime.Today.Month, 30)) 
                { 
                    return new SolidColorBrush(Colors.Yellow); 
                } 
                else 
                { 
                    return defaultValue; 
                } 
            } 
            else 
            { 
                if (dateTime == new DateTime(DateTime.Today.Year, DateTime.Today.Month, 6)) 
                { 
                    return new SolidColorBrush(Colors.Cyan); 
                } 
                else 
                { 
                    return defaultValue; 
                } 
            } 
 
        } 
    } 

5)ScreenShots of customized windowsphone 8 calender

5.1)Customized next/prev buttons

5.2)Customized  background image

5.3)Displaying events with yellow color 

6) windowsphone 8 calender gestures

However windowsphone calender provide gestures functionality.it is more helpful for user can flick on calender dates
6.1)Disable gesture from windowsphone calender
XAML

<wpControls:Calendar Grid.Row="0" 
                x:Name="Cal"  
                ColorConverter="{StaticResource ColorConverter}" 
                MonthChanged="Cal_MonthChanged" 
                MonthChanging="Cal_MonthChanging" 
                SelectionChanged="Cal_SelectionChanged" 
                DateClicked="Cal_DateClicked" 
                EnableGestures="False" StartingDayOfWeek="Monday" Margin="0,0,0,109" 
                />
6.2)Enabling gesture from windowsphone calender
XAML

<wpControls:Calendar Grid.Row="0" 
                x:Name="Cal"  
                ColorConverter="{StaticResource ColorConverter}" 
                MonthChanged="Cal_MonthChanged" 
                MonthChanging="Cal_MonthChanging" 
                SelectionChanged="Cal_SelectionChanged" 
                DateClicked="Cal_DateClicked" 
                EnableGestures="True" StartingDayOfWeek="Monday" Margin="0,0,0,109" 
                />

Source Code Files

You may get total knowledge of source file hierachy after downloading the source file what i had provided in this article.

More Information

Note: Don't be miss use of this code for security of mine,and i really thanks again to codeplex.com by sergey






Windows Phone tutorials for beginners key points




This section is included for only windows phone beginners.However this article can covers following questions.Off course these key words are more helpful for getting more best results about this topic in search engines like google/bing/yahoo.. 





1. How to customize calender control in windows phone 8 c#





2.How to display events dates in windowsphone calender






3.How to set background image to windowsphone calender






4. Previous and NextButton in windows phone 8 c#






5.WindowsPhone calender gestures enable/disable





Have a nice day by 

Selasa, 17 Desember 2013

Image loader in windows phone 8 ListBox

Introduction

Recently lot of queries has been asked which is regarding to image loader.In general there is a chance of requirement in windows phone  is need to set image loader when image getting from xaml feed or web service responce.Beacuse it will take some time to get our image from the web service and loaded completly.And so from the user point of view we need to put some progress bar or loader for image until it gets loaded completly.However finally i had come up with my best solution with custom progress overrellay.

Source File at :ImageLoderwp8c#

Building the Sample

In this sample i had added references for following
1)Reference to Coding4Fun.Phone.Controls.dll for  progress overellay  control 
2)We need add following custom user control progress overellay to our project. 

1.Creating custom user control for spinner in windows phone 

              (or)

 Creating custom loader in windows phone 8 xaml

XAML
<UserControl x:Class="WP7SoapRiaService.Spinner" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    d:DesignHeight="480" d:DesignWidth="480"
 
    <Canvas RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" Width="55" Height="55" HorizontalAlignment="Center" VerticalAlignment="Center" d:LayoutOverrides="Margin"
        <Canvas.RenderTransform
            <RotateTransform x:Name="SpinnerRotate" Angle="0" /> 
        </Canvas.RenderTransform> 
        <Canvas.Triggers
            <EventTrigger RoutedEvent="Canvas.Loaded"
                <BeginStoryboard
                    <Storyboard
                        <DoubleAnimation Storyboard.TargetName="SpinnerRotate"  
                            Storyboard.TargetProperty="(RotateTransform.Angle)"  
                            From="0" To="360" Duration="0:0:01"  
                            RepeatBehavior="Forever" /> 
                    </Storyboard> 
                </BeginStoryboard> 
            </EventTrigger> 
        </Canvas.Triggers> 
        <Ellipse Width="10" Height="10" Canvas.Left="10" Canvas.Top="3"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="1" Canvas.Top="13"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Top="26"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="6" Canvas.Top="37"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="17" Canvas.Top="44"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="29" Canvas.Top="44"  
            Stretch="Fill" Fill="#FFF0EAEA"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="40" Canvas.Top="36"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="45" Canvas.Top="24"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="42" Canvas.Top="12"  
            Stretch="Fill" Fill="#FFF0EAEA"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="35" Canvas.Top="3"  
            Stretch="Fill" Fill="Black"/> 
        <Ellipse Width="10" Height="10" Canvas.Left="23"  
            Stretch="Fill" Fill="Black" Canvas.Top="-1"/> 
    </Canvas> 
</UserControl> 
Description
Here to meet the requirement i was taken listbox with one image&progress over rellay control.I had putted same margin for image &progressrelay in data template of listbox control.And first i had placed progress bar and then image control,because progress bar will be visible until image will get imagepath completely.To do so when image has image path fully then it will overlaps the progressbar that's the tricy of my sample.

XAML
<phone:PhoneApplicationPage  
    x:Class="ImageLoader.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    shell:SystemTray.IsVisible="True" xmlns:toolkit="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls" xmlns:spin="clr-namespace:WP7SoapRiaService"
 
    <!--LayoutRoot is the root grid where all page content is placed--> 
    <Grid x:Name="LayoutRoot" Background="Transparent"
        <Grid.RowDefinitions
            <RowDefinition Height="Auto"/> 
            <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 
 
        <!--TitlePanel contains the name of the application and page title--> 
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"
            <TextBlock x:Name="ApplicationTitle" Text="Image Loader" Style="{StaticResource PhoneTextNormalStyle}"/> 
            <TextBlock x:Name="PageTitle" Text="ListBox" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
        </StackPanel> 
 
        <!--ContentPanel - place additional content here--> 
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"
             
            <!--<Border BorderBrush="White"  BorderThickness="1" HorizontalAlignment="Left" Height="196" Margin="124,150,0,0" VerticalAlignment="Top" Width="222">--> 
                <ListBox Name="Listimg" 
                    <ListBox.ItemTemplate
                        <DataTemplate
                            <Grid  Width="150" Height="auto" Background="White"
                            <Grid.RowDefinitions
                                <RowDefinition Height="Auto"/> 
                                <RowDefinition Height="Auto"/> 
                                <RowDefinition Height="10"/> 
                            </Grid.RowDefinitions> 
                            <toolkit:ProgressOverlay Grid.Row="0" Height="100"  Background="White"   x:Name="PrgrsOverLay" 
                                    <toolkit:ProgressOverlay.Content
                                        <spin:Spinner Visibility="Visible"></spin:Spinner> 
                                    </toolkit:ProgressOverlay.Content> 
 
                                </toolkit:ProgressOverlay> 
                            <Image Grid.Row="0" Height="100"  Stretch="Fill" Source="{Binding Imageurl}"/> 
                            </Grid> 
                        </DataTemplate> 
                    </ListBox.ItemTemplate> 
                 
                </ListBox> 
            <!--</Border>--> 
            
        </Grid> 
    </Grid> 
  
</phone:PhoneApplicationPage>
                                             Fig:Image loader             Fig:Image loaded completed
C#
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
using Microsoft.Phone.Controls; 
 
namespace ImageLoader 

    public partial class MainPage : PhoneApplicationPage 
    { 
        // Constructor 
        public MainPage() 
        { 
            InitializeComponent(); 
            ImageFile IMF = new ImageFile(); 
            List<ImageFile> lst = new List<ImageFile>(); 
            lst.Add(new ImageFile() { Imageurl = "http://kareninthekitchen.files.wordpress.com/2012/04/strawberry-shortcake10.jpg?r=" + System.DateTime.Now }); 
            lst.Add(new ImageFile() { Imageurl = "http://kareninthekitchen.files.wordpress.com/2012/04/strawberry-shortcake10.jpg?r=" + System.DateTime.Now }); 
            lst.Add(new ImageFile() { Imageurl = "http://upload.wikimedia.org/wikipedia/en/1/14/Album_Nothing_Was_The_Same_cover.jpg?r=" + System.DateTime.Now }); 
            lst.Add(new ImageFile() { Imageurl = "http://upload.wikimedia.org/wikipedia/en/1/14/Album_Nothing_Was_The_Same_cover.jpg?r=" + System.DateTime.Now }); 
            lst.Add(new ImageFile() { Imageurl = "http://kareninthekitchen.files.wordpress.com/2012/04/strawberry-shortcake10.jpg?r=" + System.DateTime.Now }); 
           lst.Add(new ImageFile() { Imageurl = "http://kareninthekitchen.files.wordpress.com/2012/04/strawberry-shortcake10.jpg?r=" + System.DateTime.Now }); 
           lst.Add(new ImageFile() { Imageurl = "http://kareninthekitchen.files.wordpress.com/2012/04/strawberry-shortcake10.jpg?r=" + System.DateTime.Now }); 
            Listimg.ItemsSource = lst; //Binding listbox with images in windowsphone 8
            
        } 
    } 
    public class ImageFile 
    { 
        public string Imageurl 
        { 
            get
            set
        } 
    } 
}



Windows Phone tutorials for beginners key points




This section is included for only windows phone beginners.However this article can covers following questions.Off course these key words is more helpful for getting more best results about this topic in search engines like google/bing/yahoo.. 








1.ListBox image loader in windows phone 8 xaml,c#







2. Progress bar for image loading in windows phone 8





3. Image loader in windows phone 8






4.How to bind listbox images in windows phone 8 c# 






5.User Control in windows phone 8 c# ,xaml






6. How to create custom loader  from image in windows phone 8 c# ,xaml





Have a nice day by