PictureCollection pc = new MediaLibrary().Pictures;
foreach (Picture item in pc)
{
MessageBox.Show(item.Name);
}
PictureCollection pc = new MediaLibrary().Pictures;
foreach (Picture item in pc)
{
MessageBox.Show(item.Name);
}
In this article we are discussing about UriMapping concept in Windows Phone 7. As your application grows you will probably have to use folders and perhaps subfolders in order to keep the project structure easy to follow.
The navigation system within a Windows Phone 7 application allows you to use UriMapping to convert a short URI into the full path of the XAML page within your project. UriMapping is a mechanism; that allows us to implement developer friendly navigation between Windows Phone 7 applications.
What is UriMapping?
UriMapping is an alias of physical path of views in WP7 project, which allows developer to mapped entire views using UriMapper class object. It helps developer to modify the project structure and without making any changes in the navigation code.
To developer friendly term, Uri-Mapping mechanism is used to hide the actual (physical of a file path) navigation structure of application and it also provides easy way to pass data through parameters to the pages by using query string between one page to another page.
Let’s take an example for the same; in this case we have created three xaml pages like (Facebook.xaml, PramValues.xaml, Twitter.xaml).
In this project structure we have one UI directory to keep all views. See below picture.
There are some basic steps to achieve this functionality in the project.
Step-1: Create an instance of UriMapper class object in App.xaml.cs class and add URI mapping items in Constructor for the Application object. And now add UriMapper object to PhoneApplicationFrame’s object RootFrame’s property UriMapper. See below code snippet for the same.
public App(){// Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException;
// Standard Silverlight initializationInitializeComponent();
// Phone-specific initializationInitializePhoneApplication();
// URI Mapping var appNavigationMapper = new UriMapper();appNavigationMapper.UriMappings.Add(CreateUriMapping("Facebook","/UIs/Facebook.xaml"));
appNavigationMapper.UriMappings.Add(CreateUriMapping("Twitter", "/UIs/Twitter.xaml"));
appNavigationMapper.UriMappings.Add(CreateUriMapping("About/{value}/{value1}", "/UIs/PramValues.xaml?id={value}&name={value1}"));
RootFrame.UriMapper = appNavigationMapper;
// Show graphics profiling information while debugging.if (System.Diagnostics.Debugger.IsAttached){// Display the current frame rate counters.Application.Current.Host.Settings.EnableFrameRateCounter = true;// Show the areas of the app that are being redrawn in each frame.//Application.Current.Host.Settings.EnableRedrawRegions = true;// Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay.//Application.Current.Host.Settings.EnableCacheVisualization = true;// Disable the application idle detection by setting the UserIdleDetectionMode property of the// application's PhoneApplicationService object to Disabled.// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run// and consume battery power when the user is not using the phone.PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}
}
Step-2: Now we are developing UI (user interface) for accessing the particular UI using UriMapping mechanism. In this example I have added three buttons for like Twitter, Facebook and Param(s) to call the specific UI with an action of appropriate command button. Here is UI design with xaml code.
<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="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/><TextBlock x:Name="PageTitle" Text="Uri Mapper" 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"><Button Content="Twitter" Height="72" HorizontalAlignment="Left" Margin="40,68,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" Background="#FFEB3636"></Button><Button Content="Facebook" Height="72" HorizontalAlignment="Left" Margin="240,209,0,0" Name="button2" VerticalAlignment="Top" Width="160" Click="button2_Click" Background="#FFEB3636"></Button><Button Content="Param(s)" Height="72" HorizontalAlignment="Left" Margin="42,365,0,0" Name="button3" VerticalAlignment="Top" Width="160" Click="button3_Click" Background="#FFEB3636" /></Grid></Grid>
Step-3: At the end we will call the URI mapping using NavigationService.Navigate() method. In this example I have created a generic method for calling specific UI call by specific alias of UriMapping name as we mentioned in the App.xaml.cs class constructor. See below code snippet.
private void DoNavigate(string NavigatePageName){this.NavigationService.Navigate(new Uri(NavigatePageName, UriKind.Relative));}private void button1_Click(object sender, RoutedEventArgs e){DoNavigate("Twitter");}private void button2_Click(object sender, RoutedEventArgs e){DoNavigate("Facebook");}private void button3_Click(object sender, RoutedEventArgs e){DoNavigate("About/2/pavan"); // With two parameters}
The Following code shows an example of Uri mapping process. When user pass “About/2/pavan” it will be navigated to relative address “/About/2/pavan” which is a fake address. That fake address is mapped by “About/{value}/{value1}” to “/UIs/PramValues.xaml?id={value}&name={value1}”
How to get Query string values in Navigated Page.
Using NavigationContext is used to retrieve the specific value about the passing by the parameters. See below code for the same.
void PramValues_Loaded(object sender, RoutedEventArgs e){// Method - 1textBlock1.Text = string.Format("Id= {0}", NavigationContext.QueryString["id"]);textBlock2.Text = string.Format("Name= {0}",NavigationContext.QueryString["name"]);// Method - 2var values = NavigationContext.QueryString.ToArray();foreach (var item in values){System.Diagnostics.Debug.WriteLine("Key : " + item.Key + " " + "Value : " + item.Value);}}
Step-4: Press F5 to execute the application.
~ Happy Coding ![]()
In order to finalize the SharePoint multilingual sessions BIWUG ( the Belux Information Worker User Group) – www.biwug.be has a special evening planned.
This session will cover level 400 topics on SharePoint 2010 Variations. The following topics will be covered: concepts and internals of variations (page vs. site variations), concepts and internals of configuration, variation Timer Jobs internals, different flavors of variations (automatic, manual, different site templates, same site templates, …), the “famous relationships list”, stsadm and PowerShell commands which assist variations, changes between 2007 and 2010.
Demos will be performed while some coding aspects will be covered. It will be shown how variations can be used for other purposes than just implementing multilingual solutions
Pascal Benois is a SharePoint Premier Field Engineer at Microsoft.
He is into SharePoint technologies from the early days and has a strong focus on custom applications, ECM and multilingual deployments.
Date: 21/12/2011 at 18:00, you are welcome at 17:30
Location: Microsoft Belgium offices
Registration link: http://biwug2112-estwhdr.eventbrite.co.uk/
When trying to install SharePoint Server 2010 Language Packs on top of Windows 7 you might receive the following error – “Setup is enable to proceed due to the following errors: this product requires Windows Server 2008 Service Pack 2 …” – to work around this you can use the same procedure with the language pack installation files as the one outlined for the normal SharePoint installation on Windows 7 – a great walkthrough is Setting up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7 or Windows Server 2008. Listed below are the exact steps
Copy the language pack installation files to a folder on your computer where you are installing SharePoint and doing your development
Extract the installation files by opening a Command Prompt window, and then typing the following command at the directory location of the folder where you copied the installation files in the previous step.
For SharePoint Server 2010 -c:\SharePointFiles\ServerLanguagePack.exe /extract:c:\LangPack
Using a text editor such as Notepad, open the installation configuration file, config.xml, located in the following path: c:\LangPack\files\Setup\config.xml and add <Setting Id="AllowWindowsClientInstall" Value="True"/> inside the <configuration> tag
Proceed with the installation using the normal way of working
To see the correct ApplicationBar icons in the DatePicker and TimePicker, you will need to create a folder in the root of your project called "Toolkit.Content" and put the icons in there. The toolkit provides the necessary icons, but you have to copy them from the PhoneToolkitSample project. They must be named "ApplicationBar.Cancel.png" and "ApplicationBar.Check.png" and the build action must be "Content"!
Source: WP7 DatePicker and TimePicker in depth | API and Customization
Doing a SharePoint project in a multilingual environment can be tricky. In this BIWUG session we will focus on how the new MUI (Multilingual User Interface) allows for multilingual collaboration scenarios. We will show you how MUI and the SharePoint variations framework relate to each other. Next to showing the out of the box features we will do a deep dive for developers explaining how to use the MUI framework in SharePoint custom solutions. The session will wrap up with some best practices and pitfalls as well as a round the table discussion to exchange ideas.
Hope to see you there.
Agenda:
18:00-18:30 – Welcome and snacks
18:30-19:30 – SharePoint MUI – Part I (Speakers: Andy Van Steenbergen & Joris Poelmans)
19:30-19:45 – Break
19:45:20:45 – SharePoint MUI – Part II (Speakers: Andy Van Steenbergen & Joris Poelmans)
20:45 – … SharePint!
I recently found an interesting discussion about the SharePoint pie – to pie or not to pie? Most of you have probably use the image depicted below in presentations to potential customers – but is that such a good idea?
Here are some of my ideas about this:
Please leave a comment with your idea about this or fill in this poll
Module 8 – Sandboxed solutions
Module 9 – SharePoint Web Services
Module 10: LINQ and REST
Module 11: Building webparts
In this article, I am going to describe how to make a call in windows phone 7 using managed API.
Objective of this article to make a call programmatically, sometimes application has specific requirement to make a phone call from application; in that scenario we can take the leverage of Microsoft managed API Microsoft.Phone.Tasks (namespace) allows to access PhoneCallTask API to make a call in windows phone.
Basically PhoneCallTask API allows an application to launch the Phone application. Use this to allow users to make a phone call from your application.
Let’s take an example to make a phone call from application. Add a Button to the default XAML which is gifted by MS Visual Studio when you start a new Windows Phone 7 Silverlight application. See the below xaml here.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"><Button Content="Phone Call" Height="82" HorizontalAlignment="Left" Margin="140,234,0,0" Name="btnCall" VerticalAlignment="Top" Width="auto" Click="btnCall_Click" /></Grid>
XAML will generate the UI (user interface) that look like see below screen.
Now initialize the PhoneCallTask task object in the constructor of page, to avoid the memory overhead so I initialized in the constructor.
PhoneCallTask phoneTask = null;// Constructorpublic MainPage(){InitializeComponent();phoneTask = new PhoneCallTask();}
The PhoneCallTask class contains two core properties like DisplayName, PhoneNumber and one show method, which allows us to shows the phone application. To make an actual call though the application.
Now double click the button control and click event handler got added to button control object. In the button click event set the display name and phone number which you want to make a call. And calls a *Show()* method of phone task object. See below mentioned code snippet.
private void btnCall_Click(object sender, RoutedEventArgs e){phoneTask.DisplayName = "Pavan Pareta";phoneTask.PhoneNumber = "+911234567890"; // put your desired phone number herephoneTask.Show();}
Now the application is get ready to execute. When the user clicks on the button, phone dial will appear the phone user has to click the on *call* button then only we can make a call.
See blow screenshots
Download source code here.
Thank you for your time.
BIWUG is announcing another session about SharePoint on Thursday October 27th 2011 in the Microsoft Belgium offices.
Agenda
18:00-19:00 Welcome with snacks
19:00-19:15 Introduction
19:15-20:15 SharePoint Governance (Speaker Patrick Sledz): Stop thinking about features features features when talking about governance.
When designing governance for a SharePoint implementation, a lot (not to say all) energy and words go out to technical stuff, SLA's and not to the things that define the business value. And the business value is not only a perfect technically tuned and performant SharePoint farm (if that even exists).
20:15-20:30 Break
20:30-21:00 The past, present and the future of BIWUG
During a seemingly quiet period, a lot has been going on behind the scenes. The result of all this secrecy will be revealed in the second part of the evening.
21:00-21:30 SharePint!
Of course there is also an opportunity to network, socialize and discuss the matter explained the previous hours... therefore SharePint!
Location: Microsoft Belgium Corporate Village - Bayreuth Building, Leonardo Da Vincilaan 3, 1935 Zaventem
Registration is now opened on the BIWUG site www.biwug.be
How to use cloud-based Microsoft Translator Service in windows phone 7 to translate text to speech.
In this article I am going to explain how we can take the leverage of cloud to solve the problem for Text to Speech translation. It’s pretty simple to archive such kind of functionality in windows phone 7 using Bing API. Here I will show how we can retrieve a list of languages supported by Microsoft Translator for the Speech API and speak the user’s input text.
First of all we must obtain a valid Bing API AppID, lets follow the below steps.
Step -1 Open below mentioned url to register your application. And follow the instructions to obtain a valid Bing API AppID.
Step-2 Enter required information and obtain a valid Bing API AppID.
Once you register your application now we will be moving ahead with the windows phone 7 application developments and invoke the cloud service.
Step-3 Create a windows phone 7 application project.
Step-4 To add web reference of the Microsoft Translator Service, we need to add a service reference to Windows Phone project. Right - click the Windows Phone Project in solution explorer, and choose Add Service Reference. Please see below pictures for the same.
http://api.microsofttranslator.com/V2/Soap.svc
Step-5 Now adds a panorama page to windows phone 7 project.
Step-6 creates a UI as per application requirement see below xaml code snippet. Here I have added three panorama items.
<Grid x:Name="LayoutRoot">
<controls:Panorama Title="text to speech" Name="panoSpeech" Foreground="Blue" FontFamily="Comic Sans MS">
<!--Panorama item one-->
<controls:PanoramaItem Header="Language(s)" Foreground="Plum" FontFamily="DengXian" FontSize="72">
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>
<DataTemplate x:Key="LanguageTemplate">
<TextBlock Foreground="White" Margin="0,0,0,0" Text="{Binding Name}" />
</DataTemplate>
</StackPanel.Resources>
<ListBox HorizontalAlignment="Left" ItemTemplate="{StaticResource LanguageTemplate}" Margin="20,10,0,20" Name="ListLanguages" Width="441">
</ListBox>
</StackPanel>
</controls:PanoramaItem>
<!--Panorama item two-->
<controls:PanoramaItem Header="Speech" Foreground="Yellow">
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
<TextBox Name="TextToSpeachText" Text="This Pavan Pareta, Microsoft Most Value able proffesional. He has written an application for windows phone 7" TextWrapping="Wrap" Height="350" />
<Button Content="S p e a k" Height="90" Margin="0,30,0,0" Name="btnSpeak" Width="338" Click="btnSpeak_Click" />
</StackPanel>
</controls:PanoramaItem>
<!--Panorama item three-->
<controls:PanoramaItem Header="Speak" Foreground="Violet">
<StackPanel Orientation="Vertical">
<Image Height="auto" Name="image1" Stretch="None" Width="auto" Margin="50 60 80 0" Source="/speak.jpg" />
</StackPanel>
</controls:PanoramaItem>
</controls:Panorama>
</Grid>
Step-7 Fist Panorama item used to develop for retrieving supported speech languages. To retrieve the supported language we need to call web service method “GetLanguagesForSpeakAsync”. The GetLanguagesForSpeak method only returns the language codes, for example, en for English and fr for French etc. see blow UI and code snippet.
GetLanguagesForSpeakAsync takes two methods like AppID and object.
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
try
{
FrameworkDispatcher.Update();
var objTranslator = new ServiceReference1.LanguageServiceClient();
objTranslator.GetLanguagesForSpeakCompleted += new EventHandler<GetLanguagesForSpeakCompletedEventArgs>(translator_GetLanguagesForSpeakCompleted);
objTranslator.GetLanguagesForSpeakAsync(AppId, objTranslator);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void translator_GetLanguagesForSpeakCompleted(object sender, GetLanguagesForSpeakCompletedEventArgs e)
{
var objTranslator = e.UserState as ServiceReference1.LanguageServiceClient;
objTranslator.GetLanguageNamesCompleted += new EventHandler<GetLanguageNamesCompletedEventArgs>(translator_GetLanguageNamesCompleted);
objTranslator.GetLanguageNamesAsync(AppId, "en", e.Result, e.Result);
}
void translator_GetLanguageNamesCompleted(object sender, GetLanguageNamesCompletedEventArgs e)
{
var codes = e.UserState as ObservableCollection<string>;
var names = e.Result;
var languagesData = (from code in codes
let cindex = codes.IndexOf(code)
from name in names
let nindex = names.IndexOf(name)
where cindex == nindex
select new TranslatorLanguage()
{
Name = name,
Code = code
}).ToArray();
this.Dispatcher.BeginInvoke(() =>
{
this.ListLanguages.ItemsSource = languagesData;
});
}
Step-8 Second Panorama item used to develop for speak text using SpeakAsync method takes four string parameters like AppId, SpeechText, SpeechLanguage, format. See below UI and code snippet.
private void btnSpeak_Click(object sender, RoutedEventArgs e)
{
var languageCode = "en";
var language = this.ListLanguages.SelectedItem as TranslatorLanguage;
if (language != null)
{
languageCode = language.Code;
}
var objTranslator = new ServiceReference1.LanguageServiceClient();
objTranslator.SpeakCompleted += translator_SpeakCompleted;
objTranslator.SpeakAsync(AppId, this.TextToSpeachText.Text, languageCode, "audio/wav");
panoSpeech.DefaultItem = panoSpeech.Items[(int)2];
}
void translator_SpeakCompleted(object sender, ServiceReference1.SpeakCompletedEventArgs e)
{
var client = new WebClient();
client.OpenReadCompleted += ((s, args) =>
{
SoundEffect se = SoundEffect.FromStream(args.Result);
se.Play();
});
client.OpenReadAsync(new Uri(e.Result));
}
Step-9 Now builds the application and executes it.
Thank you for your time.