mobile ads

Friday, 11 October 2013

NavigationCommands Members 1

NavigationCommands.BrowseBack

Browseback property gets the value that represents the BrowseBack command

Key Gestures     -    ALT+LEFT
UI Text             -    Back

This command indicates the intention to navigate back to the previous page in the journal.
Frame and Navigation window implement support for responding to the BrowseBack, although you are not required to use it; in many cases the implementation in response to that command is the responsibility of the application writer.

Example
<MenuItem
  Command="NavigationCommands.BrowseBack"
  CommandTarget="{Binding ElementName=frame}" />
...

<Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" />

NavigationCommands.BrowseForward 

BrowseForward property gets the value that represents the BrowseForward command

Key Gestures     -    ALT+RIGHT
UI Text             -    Forward

This command indicates the intention to navigate forward to the nextpage in the journal.
Frame and Navigation window implement support for responding to the BrowseForward, although you are not required to use it; in many cases the implementation in response to that command is the responsibility of the application writer.

Example
  <MenuItem Command="NavigationCommands.BrowseForward" CommandTarget="{Binding ElementName=frame}" />
 ...
 <Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" />

NavigationCommands.BrowseHome


BrowseHome property gets the value that represents the BrowseHome command

Key Gestures     -    ALT+Home
UI Text             -    Home 

This command indicates the intention to navigate home.
There is no implementation for responding to the BrowseHome command on any given WPF class. As such, you need to provide an appropriate implementation, which is shown in the example.

XAML
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
 x:Class="SDKSample.BrowseHome"> 
..
   
<MenuItem Command="NavigationCommands.BrowseHome"> 
 <MenuItem.CommandBindings> 

<CommandBinding Command="NavigationCommands.BrowseHome" CanExecute="navigationCommandBrowseHome_CanExecute" Executed="navigationCommandBrowseHome_Executed" />  
</MenuItem.CommandBindings>  
</MenuItem> ... <Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" /> 
... 
</Window> 

 C# 

using System.Windows; // Window  
 using System.Windows.Input; // CanExecuteRoutedEventArgs, ExecutedRoutedEventArgs  namespace SDKSample 
{ 
 public partial class BrowseHome : Window 
{ 
public BrowseHome()
 {
 InitializeComponent();
 }
 void navigationCommandBrowseHome_CanExecute(object sender, CanExecuteRoutedEventArgs e) 
{
 // Can always navigate home e.CanExecute = true;
 }
 void navigationCommandBrowseHome_Executed(object target, ExecutedRoutedEventArgs e) 
{
 // Implement custom BrowseHome handling code 
}
 }
 }

 NavigationCommands.BrowseStop


BrowseStop property gets the value that represents the BrowseStop command

Key Gestures     -    ALT+Esc
UI Text             -   Stop
This command indicates the intention to stop the browser loading.
Frame and NavigationWindow implement support for responding to the BrowseStop command, although you are not required to use it; in many cases the implementation in response to that command is the responsibility of the application writer.

Example
<MenuItem
  Command="NavigationCommands.BrowseStop"
  CommandTarget="{Binding ElementName=frame}" />
 
<Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" />


NavigationCommands.DecreaseZoom


DecreaseZoom property gets the value that represents the DecreaseZoom command

Key Gestures     -   N/A
UI Text             -   Decrease Zoom
This command indicates the intention to decrease the zoom.
DocumentViewer, FlowDocumentReader, FlowDocumentScrollViewer, and FlowDocumentPageViewer implement support for responding to the DecreaseZoom command, although you are not required to use it; in many cases the implementation in response to that command is the responsibility of the application writer.

Example 


<MenuItem
  Command="NavigationCommands.DecreaseZoom"
  CommandTarget="{Binding ElementName=flowDocumentPageViewer}" />

...

<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus
 nec erat. Nam sollicitudin imperdiet mi. Sed rutrum. Morbi vel nunc. Donec 
imperdiet. Morbi hendrerit leo. Maecenas imperdiet. Curabitur viverra tempor nisi.
 Phasellus vitae augue sit amet neque venenatis elementum. Proin posuere lobortis
 quam. Curabitur et neque. Donec ac sem vitae libero pharetra luctus. Fusce purus.
 Nulla vehicula, leo commodo dictum lobortis, odio augue accumsan ante, id dictum
 nisi libero quis diam. Nam augue erat, malesuada eu, tincidunt eu, dictum ut,
 ante. In vel magna vel ligula faucibus lobortis. Praesent a felis non mi
 fringilla vulputate. Integer quis tellus cursus elit tincidunt vehicula.
 Morbi commodo sem eu eros. Vestibulum ante ipsum primis in faucibus orci
 luctus et ultrices posuere cubilia Curae;
    </Paragraph>
...

  </FlowDocument>
</FlowDocumentPageViewer>


NavigationCommands.IncreaseZoom


IncreaseZoom property gets the value that represents the IncreaseZoom command

Key Gestures     -   N/A
UI Text             -   Increase Zoom
This command indicates the intention to increase the zoom.
DocumentViewer, FlowDocumentReader, FlowDocumentScrollViewer, and FlowDocumentPageViewer implement support for responding to the IncreaseZoom command, although you are not required to use it; in many cases the implementation in response to that command is the responsibility of the application writer.

Example 


<MenuItem
  Command="NavigationCommands.IncreaseZoom"
  CommandTarget="{Binding ElementName=flowDocumentPageViewer}" />

...

<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus 
nec erat. Nam sollicitudin imperdiet mi. Sed rutrum. Morbi vel nunc. Donec 
imperdiet. Morbi hendrerit leo. Maecenas imperdiet. Curabitur viverra tempor 
nisi. Phasellus vitae augue sit amet neque venenatis elementum. Proin posuere
 lobortis quam. Curabitur et neque. Donec ac sem vitae libero pharetra luctus.
 Fusce purus. Nulla vehicula, leo commodo dictum lobortis, odio augue accumsan
 ante, id dictum nisi libero quis diam. Nam augue erat, malesuada eu, tincidunt 
eu, dictum ut, ante. In vel magna vel ligula faucibus lobortis. Praesent a felis
 non mi fringilla vulputate. Integer quis tellus cursus elit tincidunt vehicula.
 Morbi commodo sem eu eros. Vestibulum ante ipsum primis in faucibus orci luctus
 et ultrices posuere cubilia Curae;
    </Paragraph>
...

  </FlowDocument>
</FlowDocumentPageViewer>


NavigationCommands.GoToPage


GoToPage property gets the value that represents the Go To Page command

Key Gestures     -   N/A
UI Text             -   Go To Page

This command indicates the intention to change the zoom.
DocumentViewer and FlowDocumentPageViewer implement support for responding to the GoToPage command.
Example
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
  <TextBox Name="pageNumberTextBox">1</TextBox>
  <Button
    Command="NavigationCommands.GoToPage"
    CommandTarget="{Binding ElementName=flowDocumentPageViewer}"
    CommandParameter="{Binding ElementName=pageNumberTextBox,Path=Text}">Go To Page</Button>
</StackPanel>
...

<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus
 nec erat. Nam sollicitudin imperdiet mi. Sed rutrum. Morbi vel nunc. Donec 
imperdiet. Morbi hendrerit leo. Maecenas imperdiet. Curabitur viverra tempor
 nisi. Phasellus vitae augue sit amet neque venenatis elementum. Proin posuere
 lobortis quam. Curabitur et neque. Donec ac sem vitae libero pharetra luctus.
 Fusce purus. Nulla vehicula, leo commodo dictum lobortis, odio augue accumsan
 ante, id dictum nisi libero quis diam. Nam augue erat, malesuada eu, tincidunt
 eu, dictum ut, ante. In vel magna vel ligula faucibus lobortis. Praesent a felis
 non mi fringilla vulputate. Integer quis tellus cursus elit tincidunt vehicula. 
Morbi commodo sem eu eros. Vestibulum ante ipsum primis in faucibus orci luctus e
t ultrices posuere cubilia Curae;
    </Paragraph>
...

  </FlowDocument>
</FlowDocumentPageViewer>

NavigationCommands Class

Provides a standard set of navigation related commands.

The NavigationCommands type expose the following members
  • BrowseBack
  • BrowseForward
  • BrowseHome
  • BrowseStop
  • DecreaseZoom
  • IncreaseZoom
  • Favorites
  • GoToPage
  • FirstPage
  • NextPage
  • LastPage
  • PreviousPage
  • NavigationJournal
  • Refresh
  • Search
  • Zoom
The NavigationCommands class exposes a standard set of navigation-related commands, including browser and document navigation. 


For example and further explanation Click here 

Simple way to encrypt and decrypt querystring

Encrypt code:


string data="query string";
     string encodedData = String.Empty;
       try
       {
           byte[] data_byte = Encoding.UTF8.GetBytes(data);
           encodedData = HttpUtility.UrlEncode(Convert.ToBase64String(data_byte));
        }
        catch (Exception exception)
        {
           //Log exception
        }
        return encodedData;
 
 
 
Decrypt code

string data="encoded data";
        string decodedData = String.Empty;
        try
        {
             byte[] data_byte = Convert.FromBase64String(HttpUtiltity.UrlDecode(data));
             decodedData = Encoding.UTF8.GetString(data_byte);
        }
        catch (Exception exception)
        {
             //Log exception
         }
         return decodedData;
 

Thursday, 10 October 2013

Difference between Int.Parse(), Convert.ToInt() and Int.TryParse()

Int32.parse(string)

Int32.Parse (string s) method converts the string representation of a number to its 32-bit signed integer equivalent. When s is a null reference, it will throw ArgumentNullException. If s is other than integer value, it will throw FormatException. When s represents a number less than MinValue or greater than MaxValue, it will throw OverflowException. 

 Convert.ToInt32(string)

Convert.ToInt32(string s) method converts the specified string representation of 32-bit signed integer equivalent. This calls in turn Int32.Parse () method. When s is a null reference, it will return 0 rather than throw ArgumentNullException. If s is other than integer value, it will throw FormatException. When s represents a number less than MinValue or greater than MaxValue, it will throw OverflowException. 

 Int32.TryParse(string, out int)

Int32.Parse(string, out int) method converts the specified string representation of 32-bit signed integer equivalent to out variable, and returns true if it is parsed successfully, false otherwise. This method is available in C# 2.0. When s is a null reference, it will return 0 rather than throw ArgumentNullException. If s is other than an integer value, the out variable will have 0 rather than FormatException. When s represents a number less than MinValue or greater than MaxValue, the out variable will have 0 rather than OverflowException.

  Convert.ToInt32 is better than Int32.Parse since it returns 0 rather than an exception. But again, according to the requirement, this can be used. TryParse will be the best since it always handles exceptions by itself. 

 

 

.Net Class Library

The .NET Framework class library is a collection of reusable types that tightly integrate with the common language runtime. The class library is object oriented, providing types from which your own managed code can derive functionality. This not only makes the .NET Framework types easy to use, but also reduces the time associated with learning new features of the .NET Framework. In addition, third-party components can integrate seamlessly with classes in the .NET Framework.
For example, the .NET Framework collection classes implement a set of interfaces that you can use to develop your own collection classes. Your collection classes will blend seamlessly with the classes in the .NET Framework.
As you would expect from an object-oriented class library, the .NET Framework types enable you to accomplish a range of common programming tasks, including tasks such as string management, data collection, database connectivity, and file access. In addition to these common tasks, the class library includes types that support a variety of specialized development scenarios. For example, you can use the .NET Framework to develop the following types of applications and services:

  • Console applications. 
  • Windows GUI applications (Windows Forms).
  • Windows Presentation Foundation (WPF) applications. 
  • ASP.NET applications. 
  • Windows services. 
  • Service-oriented applications using Windows Communication Foundation (WCF). 
  • Workflow-enabled applications using Windows Workflow Foundation (WF).
For example, the Windows Forms classes are a comprehensive set of reusable types that vastly simplify Windows GUI development. If you write an ASP.NET Web Form application, you can use the Web Forms classes.


The .NET Framework includes classes, interfaces, and value types that expedite and optimize the development process and provide access to system functionality. To facilitate interoperability between languages, most .NET Framework types are CLS-compliant and can therefore be used from any programming language whose compiler conforms to the common language specification (CLS).
The .NET Framework types are the foundation on which .NET applications, components, and controls are built. The .NET Framework includes types that perform the following functions:
  • Represent base data types and exceptions.
  • Encapsulate data structures.
  • Perform I/O.
  • Access information about loaded types.
  • Invoke .NET Framework security checks.
  • Provide data access, rich client-side GUI, and server-controlled, client-side GUI.
The .NET Framework provides a rich set of interfaces, as well as abstract and concrete (non-abstract) classes. You can use the concrete classes as is or, in many cases, derive your own classes from them. To use the functionality of an interface, you can either create a class that implements the interface or derive a class from one of the .NET Framework classes that implements the interface.