Friday 27 January 2012

Overview of Windows Presentation Foundation

Windows Presentation Foundation, also known as WPF, is the next-generation graphics platform on which both Windows- and web-based applications can be built to run on Windows Vista, the latest evolutionary release of the Windows operating system.

Windows Presentation Foundation (WPF)—The graphical subsystem for all things related to
the UI

Windows Communication Foundation (WCF)—The messaging subsystem of .NET
Framework 3.0, securing program communication through a single API

Windows Workflow Foundation (WF)—Provides workflow services for applications built to
run on Windows

In today’s world, developing a Windows application may require the use of any number of different technologies, ranging from GDI/GDI+ for 2D graphics, UI services (User32 or WinForms)
WPF was designed as a single model for application development, providing seamless integration between such services within an application. Similar constructs can be used for developing storyboard animation, data bound forms, and 3D models.

Declarative Programming
WPF introduces a new XML-based language to represent UI and user interaction, known as XAML (eXtensible Application Markup Language—pronounced “zammel”). Similar to Macromedia’s MXML specification, within XAML elements from the UI are represented as XML tags. Thus, XAML allows applications to dynamically parse and manipulate UI elements at either compile-time or runtime, providing a flexible model for UI composition.


Architecture

the general underlying architecture of WPF, with each major component detailed in
the sections that follow.

description
Element System
The element system represents the surface of WPF with which developers will interact. Contained within the element system are the core components making up the UI, such as styles, layout, controls, binding, and text layout.
 Visual System
The visual system is the subsystem through which applications access the core presentation services available through WPF. This subsystem examines the components within an application (labels, buttons, text, 2D and 3D graphics, animations) and will communicate with the underlying composition system (via the message transport) to generate the rendered result to the screen.
Font System
The font system was completely rewritten for WPF to provide a superior font and text engine over that of the systems previously available in Windows. The two font engines available in Windows today, GDI and Uniscribe, have significant drawbacks that do not make them suitable for WPF.
Input/Event System
The input/event system in WPF introduces significant advancements for input and user interaction over that of previous systems available in Windows, such as Win32. Messages evoked by Win32 for devicebased user input, such as WM_* messages, provide a verbose mechanism for input and lack enhanced support for modern devices, such as a stylus.
Property System
The property system is integral to core data-related functions within WPF. It comprises the following three main components:
Message Transport System
The message transport service is a key component of the WPF architecture that ties the visual system to the composition system. As mentioned previously, the visual system provides a managed interface through which all other managed subsystems within WPF provide instructions on what elements need to be represented on the screen. Although the visual system provides this hook, it doesn’t perform the work itself; rather, it offloads such tasks to the composition system.

Thursday 26 January 2012

contextmenu strip when right click on datagridviwe


Display contextmenu strip when right click on datagridviwe

 
The following code is for display contextmenu strip when user click on datagridviwe row right click.
It’s very simple to implement.
  1. ·         The following screen shot of contextmenu strip.
  2. ·         When user right click on datagridviwe row that time the strip display and when user click on delete the id of row is display.
  3. ·         You may write code for delete and whatever functionality you write there.
  4. ·         To add contextmenu strip selet toolbox and click on contextmenu strip and add it.
  5. ·         You not need to do any changes in property of contextmenu strip.
  6. just add menu in 

Dim _SelectionId As Integer = 0
    Private Sub DGListData_MouseDown(ByVal sender As Object, ByVal e As _
  System.Windows.Forms.MouseEventArgs) Handles DGListData.MouseDown
        For Each row In DGListData.Rows
            row.selected = False
        Next
        ' Load context menu on right mouse click
        Dim hitTestInfo As DataGridView.HitTestInfo
        If e.Button = Windows.Forms.MouseButtons.Right Then
            hitTestInfo = DGListData.HitTest(e.X, e.Y)
            'Set location of new point for display ContextMenuStrip1
            Dim x As New Point(Windows.Forms.Cursor.Position.X, _ 
Windows.Forms.Cursor.Position.Y)
            DGListData.Rows(hitTestInfo.RowIndex).Selected = True
            'display ContextMenuStrip1 with new locaition.
            Me.ContextMenuStrip1.Show(x)
            'fetch select row's first colunm value.
            _SelectionId = DGListData.Item(0, DGListData.SelectedRows.Item(0).Index).Value
        End If
    End Sub

    Private Sub DeleteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DeleteToolStripMenuItem.Click
        MsgBox(_SelectionId)
    End Sub

Using of My.Settings in vb.net




Use of settings in vb.net
Windows Forms applications require data that is needed for running the application. Most of the time you don't want to include this data in the code or you will have to recompile your application each time you make a change. If your application uses a Web service or a database, you probably want to store the URL or the connection string in a separate file so that you can change them easily. If your application stores the window layout and other UI customization, then you want to store this information separately for each user.

When you use settings that time the all settings are in app.config file and it’s code look’s like
  <userSettings>
        <BillPrinting.My.MySettings>
            <setting name="PVer" serializeAs="String">
                <value>150</value>
            </setting>
            <setting name="PHor" serializeAs="String">
                <value>170</value>
            </setting>
            <setting name="BackColor" serializeAs="String">
                <value>White</value>
            </setting>
            <setting name="SpaceTwo" serializeAs="String">
                <value>440</value>
            </setting>
            <setting name="printername" serializeAs="String">
                <value>0</value>
            </setting>
            <setting name="FPSmall" serializeAs="String">
                <value>Courier New, 9.75pt</value>
            </setting>
            <setting name="FPDark" serializeAs="String">
                <value>Arial, 14.25pt, style=Bold</value>
            </setting>
            <setting name="FPDate" serializeAs="String">
                <value>Courier New, 11.25pt</value>
            </setting>
        </BillPrinting.My.MySettings>
    </userSettings>

If the setting names scope is user than run time you change these value. And it the scope is application than you can not change these value.
In image thes example of set setting property.
Example image

Exmplae of access the mysetting value in code
Private Sub BillSetting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            TxtPver.Text = My.Settings.PVer
            TxtHoriP.Text = My.Settings.PHor
            TxtSpace.Text = My.Settings.SpaceTwo
            Me.BackColor = My.Settings.BackColor
        Catch ex As Exception

        End Try
    End Sub

For change the value of property(If scope is user than only change else it not change).
Try
            Dim x As DialogResult = FontDialog1.ShowDialog()
            If x = Windows.Forms.DialogResult.OK Then
                Try
                    My.Settings.FPSmall = FontDialog1.Font
                Catch ex As Exception

                End Try
            End If
        Catch ex As Exception
            MsgBox("These Font Are Not Suported", MsgBoxStyle.Information, "")
        End Try