Coding4Fun Toolkit in .NET

Introduction

 
Visual Studio has already given us many controls, yet we need more for an even better UI. They must however be easy to implement.
 
So, in this article, we try to get into the Codeing4fun tool kit.
 
Coding4Fun Toolkit
 
Without wasting any time, open a tab with this: http://coding4fun.codeplex.com/ and click on the "download" button.
 
When you extract the Zip file, you will get three folders, Windows Store, Windows Phone 8, and Windows Phone7.
 
Because of my platform issue, I will show you the toolkit on Visual Studio 2010 with Windows Phone 7.1 SDK.
 
So, the first question you might have is, what does Codeing4fun actually have for me?
 
So, my answer would be ease and comfort.
 
From now, you can easily implement a few harsh tasks on your Windows Phone.
 
In codeing4 Fun you have:
  • About Prompt
  • Input Prompt
  • Progress Bar
  • Messageprompt
  • wordprompt
  • ToastPrompt
Background
 
You just need a Windows Phone 7 or above SDK on your Visual Studio.
 
And start your Windows Phone project.
 
Procedures
 
Without a DLL file, you can’t do anything in your project.
 
So, add the "Codeing4Fun.Tookit.Controls.dll" to your project.
 
Coding4Fun Toolkit
Note:
Add a "using Codeing4fun.Tookit.Controls" to the C# file, or add the following in XAML:
  1. xmlns:Controls="clr-namespace:  
  2. Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls" 
About Prompt
 
Coding4Fun Toolkit
 
In simple words, it is a small canvas that pops up when your event raises it.
 
Let’s get inside it.
 
Since we already have the codeing4fun(.dll) reference in our project.
  1. private void button1_Click(object sender, RoutedEventArgs e) {  
  2.     // About Prompt: Raised by the button 1  
  3.     AboutPrompt about = new AboutPrompt();  
  4.     //Set the Property of AboutPrompt  
  5.     about.Title = "C# Corner";  
  6.     about.Footer = "http://c-sharpcorner.com";  
  7.     about.VersionNumber = "v1.0";  
  8.     about.FontSize = 20;  
  9.     about.VerticalAlignment = VerticalAlignment.Center;  
  10.     about.Body = new TextBlock { Text = "This is My First About Prompt", TextWrapping = TextWrapping.Wrap };  
  11.     about.Background = new SolidColorBrush(Colors.Red);  
  12.     about.Foreground = new SolidColorBrush(Colors.Green);  
  13.     about.Completed += new EventHandler < PopUpEventArgs < object, PopUpResult >> (about_Completed);  
  14.     about.Show();  
  15. }  
  16. void about_Completed(object sender, PopUpEventArgs < object, PopUpResult > e) {  
  17.     // This will be MAIN part of AboutPrompt  
Explanation
 
First, we have created an object of AboutPrompt, and then we set corresponding values to the fields of the AboutPrompt class.
 
Major Fields are:
  • Title
  • Body
  • FooterVersionNumber
  • InputScope
InputPrompt
 
Coding4Fun Toolkit
 
It looks similar to the earlier prompt with a little TextBox inside it.
 
You can use this when you want single user input.
 
What will be the code for this?
 
Here it is:
  1. InputPrompt input = new InputPrompt();  
  2. private void button2_Click(object sender, RoutedEventArgs e) {  
  3.     // Input Prompt  
  4.     input.Title = "This is my Input Prompt Title";  
  5.     input.Message = "What make You a Intresting Guy ;)";  
  6.     input.InputScope = new InputScope { Names = { new InputScopeName() { NameValue = InputScopeNameValue.Number } } };  
  7.     input.Completed += new EventHandler < PopUpEventArgs < string, PopUpResult >> (input_Completed);  
  8.     input.Show();  
  9. }  
  10. void input_Completed(object sender, PopUpEventArgs < string, PopUpResult > e) {  
  11.     if (input.Value != null) {  
  12.         MessageBox.Show("You Have Entred This : " + input.Value);  
  13.     }  
  14. }  
Explanation
 
We have done the same in a previous one, except for an InputScope property.
 
And, you can check your user input using code inside the Event method.
 
Like we have a small check-up for User Input as in the following:
  1. if (input.Value!=null)  
  2. {  
  3.       MessageBox.Show("You Have Entred This : " + input.Value);  
Message Prompt
 
Coding4Fun Toolkit
 
A message box with a title Text, Body Message, and two buttons (at least one will be there). You can use it with your own needs.
 
The code will look like this:
  1. private void button3_Click(object sender, RoutedEventArgs e) {  
  2.     //Message Proompt Button  
  3.     MessagePrompt message = new MessagePrompt();  
  4.     Message.Title = "This is My Title";  
  5.     message.Message = " What are You looking for !!";  
  6.     message.IsCancelVisible = true//false, to make it One Button Message Box  
  7.     message.Completed += new EventHandler < PopUpEventArgs < string, PopUpResult >> (message_Completed);  
  8.     message.Show();  
  9. }  
  10. void message_Completed(object sender, PopUpEventArgs < string, PopUpResult > e) {  
  11.     // Do whatever  
wordInputPrompt
 
Coding4Fun Toolkit
 
Looks the same as an Input Prompt except with a small change in the type of the text input (in other words masked text).
 
So, the code will be:
  1. private void button4_Click(object sender, RoutedEventArgs e) {  
  2.     // word prompt  
  3.     wordInputPrompt = new wordInputPrompt();  
  4.     .Title = "This is my word Prompt";  
  5.     .Message = "Plese Give Us Your Secret word";  
  6.     .Completed += new EventHandler < PopUpEventArgs < string, PopUpResult >> (_Completed);  
  7.     .Show();  
  8. }  
  9. void _Completed(object sender, PopUpEventArgs < string, PopUpResult > e) {  
  10.     // Put Your Code Here to prcess Your word  
ToastPrompt
 
This is similar to the Toast notification that we have in general. But now, we can do this easily.
 
Coding4Fun Toolkit
 
Or, you may have this if you don’t use an image.
 
Coding4Fun Toolkit
  1. private void button5_Click(object sender, RoutedEventArgs e) {  
  2.     // Toast Prompt  
  3.     ToastPrompt toast = new ToastPrompt();  
  4.     toast.Title = "Notification";  
  5.     toast.Message = "You have Some Facebook Message Pending";  
  6.     //toast.ImageSource = new BitmapImage(new Uri("/Laptop.png",UriKind.Relative));  
  7.     toast.TextWrapping = TextWrapping.Wrap;  
  8.     toast.Show();  
ProgressOverlay
 
Coding4Fun Toolkit
  1. private void button6_Click(object sender, RoutedEventArgs e) {  
  2.     //Progess Overlay  
  3.     ProgressOverlay progress = new ProgressOverlay();  
  4.     progress.Content = "Loading...";  
  5.     progress.IsEnabled = true;  

Conclusion

 
For any further reference, you can log into http://coding4fun.codeplex.com/documentation.
 
I have enclosed a small solution file with the demo from this article.