Friday, March 8, 2013

Country Information About Page

CountryInformation App gives Information about the country in the form of Capital, Currency, Currency code, Two letter ISO code, Three letter ISO code, Population, Area in KM.

Threading in C#.Net

Thread is an independent execution path, able to run simultaneously with the other threads.When you create  a c# client program the CLR automatically creates a single thread .i.e the "main" thread.
Example:

using System;
using System.Threading;

namespace threading
{
    class Program
    {
        static void Main()
        {
            Thread t = new Thread(display); //Creating a new thread.
            t.Start(); //starts the new thread
////// Simultaneously, do something on the main thread.
            for (int i = 0; i < 1000; i++)
            {
                //Thread.Sleep(1000);
                Console.Write("rayala"+"\t"); }
            Console.ReadKey();
        }
        public static void display()
        {
            for (int i = 0; i < 1000; i++)
            { //Thread.Sleep(2000);
                Console.Write("sagar"+"\t"); }
        }
    }
}
The above example prints the "rayala" and "sagar" simultaneously.i.e two threads running parallel.Do you want to see the execution of threads uncomment the lines Thread.Sleep(1000) and Thread.Sleep(2000) in the above code.

Out Keyword in C#.Net

Out is a keyword which is used in c#. Generally a method returns only one value to where the call to the method is made. Suppose we want to return more than one value from a method , it is not possible.If we want to return more than one value from a method we use out key word . Just place the out keyword before the declaration of parameters in the method.
 Example: public int add(out int a, out int b)
{
--------
--------
}
In the above example I declared a method add(). It has two parameters a , b of integer types. Now, when the call to this method is made , then this method returns two values of integer type.
Example:
using System;

namespace Out_Keyword
{
    class Program
    {
        static void Main()
        {
            int a, b;
            float f;
            double d;
            char c;
            string s;
            Display(out a, out b,out f,out d, out c, out s);
            Console.WriteLine(a+"\n"+b+"\n"+f+"\n"+d+"\n"+c+"\n"+s);
            Console.ReadKey();
        }
        public static void Display(out int a1,out int b1,out float f1,out double d1, out char c1,out string s1)
        {
            a1 = 5;
            b1 = 6;
            f1= 64.654783f;
            d1 = 875.339854721;
            c1 = 's';
            s1 = "sagar rayala";
     
        }
    }
}

In the above example I declared  method Display() with 6 parameters of int , float , double , char and string types.And I initialized the parameters with some values.
In the main() I declared  variables of same types declared in the Display().And I called the Display() with variables declared in the main (). The Display() returns values to the variables.


Monday, March 4, 2013

Privacy Policy of CountryInformation app

Country Information App does not collect or publish any personal information.If you would like to report any violations of this policy, please contact us at sagar@gmail.com.

Tuesday, February 26, 2013

HexaDecimal Color Codes

Black - #000000
Blue -   #0000ff
Brown - #a52a2a
Cyan -  #00ffff
DarkBlue - #0000a0
Fuchsia - #ff00ff
Green - #008000
Grey - #808080
LightBlue - #add8e6
Lime - #00ff00
Maroon - #800000
Olive - #808000
Orange - #ffa500
Purple - #800080
Red - #ff0000
Silver - #c0c0c0
White - #ffffff
Yellow - #ffff00

popup lightdismissal in windows store


Wrirte this code in Mainpage.xaml.
< Popup x : name = popup IsLightDismissEnabled = true >
< Popup . ChildTransitioins >
< TransitionCollection >
< PaneThemeTransition />
< /TransitionCollection >

<Border x : Name = PopupBorder Thickness = 6 Background = "#FF72A4EC"> < TextBlock x : Name = "tb" Text = "This is a popup with lightdismissal" />
 </Border>
< /Popup>  


Write this code  in Mainpage.xaml.cs.

if (!Popup.IsOpen)
                {
                    PopupBorder.Width = 658;
                    PopupBorder.Height = 100;
                    Popup.HorizontalOffset = Window.Current.Bounds.Width - 658 ;
                    Popup.VerticalOffset = 90;
                    Popup.IsOpen = true;

                }
              

                 
           
           
               
           
 


Friday, February 22, 2013

settingspane in windows store apps

OPen App.xaml.cs page and follow the below steps.

First thing you should do is to add callisto reference to your app or project references node and the namespaces shown below in bold and underlined.
Then you add two usercontrols to your project. In this code I named two usercontrols  as AboutUserControl and  PrivacyPolicyUserControl.
Then add the following code which highlighted in bold underlined.


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI;
using Windows.UI.ApplicationSettings;
using Callisto.Controls;

// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227

namespace CountryInformation
{
    /// Provides application-specific behavior to supplement the default Application class.
    sealed partial class App : Application
    {
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        ///
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }
        private Color _background = Color.FromArgb(255, 24, 0, 82); 
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        ///
        /// Details about the launch request and process.
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;


            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }

        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        ///
        /// The source of the suspend request.
        /// Details about the suspend request.

        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity
            deferral.Complete();
        }

        void OnCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)

        {


            // Add an About command

            var about = new SettingsCommand("about", "About", (handler) =>
            {

                var settings = new SettingsFlyout();

                settings.Content = new AboutUserControl();

                settings.HeaderBrush = new SolidColorBrush(_background);

                settings.Background = new SolidColorBrush(_background);

                settings.HeaderText = "About";

                settings.IsOpen = true;



            });

            args.Request.ApplicationCommands.Add(about);

            var privacypolicy = new SettingsCommand("privacypolicy", "Privacy Policy", (handler) =>
            {

                var settings = new SettingsFlyout();

                settings.Content = new PrivacyPolicyUserControl();

                settings.HeaderBrush = new SolidColorBrush(_background);

                settings.Background = new SolidColorBrush(_background);

                settings.HeaderText = "Privacy Policy";

                settings.IsOpen = true;



            });

            args.Request.ApplicationCommands.Add(privacypolicy);

            var accounts = new SettingsCommand("accounts", "Accounts", (handler) =>
            {

                var settings = new SettingsFlyout();

                settings.Content = new PrivacyPolicyUserControl();

                settings.HeaderBrush = new SolidColorBrush(_background);

                settings.Background = new SolidColorBrush(_background);

                settings.HeaderText = "Accounts";

                settings.IsOpen = true;



            });

            args.Request.ApplicationCommands.Add(accounts);

        }