Welcome Guest!
 VB.NET Helper
 Previous Message All Messages Next Message 
VB .NET Helper Newsletter  Rod Stephens
 Sep 23, 2011 10:59 PDT 

Lots of interesting stuff popping out of Microsoft lately.

    Announcing Visual Studio 11 Developer Preview
    Jason Zander's Weblog
    
http://blogs.msdn.com/b/jasonz/archive/2011/09/14/announcing-visual-studio-11-developer-preview.aspx


    Visual Studio 11 Developer Preview (MSDN subscribers only)
    http://msdn.microsoft.com/en-US/vstudio/hh127353

    .NET Framework 4.5 Developer Preview
    http://msdn.microsoft.com/en-us/netframework/hh403373

    What's New in Visual Studio 11 Developer Preview
    http://msdn.microsoft.com/en-us/library/bb386063%28VS.110%29.aspx

    What's New for Visual Basic in Visual Studio 11 Developer Preview
    http://msdn.microsoft.com/en-us/library/we86c8x2%28v=VS.110%29.aspx

See the articles in this newsletter for the details I've found so far.
The bottom line seems to be:
-----
Just for fun

Scientists recently discovered a planet orbiting a binary star system.
That brought me to this link:

http://www.space.com/12961-10-real-alien-worlds-star-wars-planets.html
-----
WPF Programmer's Reference
http://www.vb-helper.com/wpf_prog_ref.htm

Go beyond what you thought possible in user interface development

Windows Presentation Foundation (WPF) enables you to build effective and
unique graphical user interfaces. However, it takes a steep learning
curve to master the exceptions and shortcuts that are built into WPF.
This reference provides you with a solid foundation of fundamental WPF
concepts so you can start building attractive, dynamic, and interactive
applications quickly and easily. As the book progresses, topics
gradually become more advanced, and you'll discover how to use WPF to
build applications that run in more environments, on more hardware,
using more graphical tools, and providing a more engaging visual
experience than is normally possible with Windows Forms.
-----
Have a great week and thanks for subscribing!

Rod
RodSte-@vb-helper.com

Twitter feeds:
    VBHelper
    CSharpHelper
==========
==========

    VB.NET Contents:
1. New HowTo: Make an owner-drawn ListView control that draws server
status information in Visual Basic .NET
2. New HowTo: Measure distances on a map with a scale in Visual Basic
.NET

    Both Contents:
3. Summary of what's new in Visual Basic, Visual Studio, and Windows 8
4. What's new in Visual Basic 2011
5. What's new in Visual Studio 2011
6. What's new in .NET Framework 4.5
==========
++++++++++
      <VB.NET>
++++++++++
==========
1. New HowTo: Make an owner-drawn ListView control that draws server
status information in Visual Basic .NET
http://www.vb-helper.com/howto_net_owner_draw_listview.html
http://www.vb-helper.com/HowTo/howto_net_owner_draw_listview.zip

Picture at http://www.vb-helper.com/howto_net_ownerdraw_listview.png.

Normally a ListVeiw displays textual data but you can change that
behavior to make it display anything you can draw. This example draws
images and colored circles to show the status of its entries.

The approach is to set the ListView's OwnerDraw property to True and
then make items and subitems as placeholders in the control. Then code
then catches the ListView's DrawColumnHeader, DrawItem, and DrawSubItem
event handlers and draws the items appropriately.

The only really non-obvious issue is that the DrawSubItem event handler
that is called to draw the details view executes for every subitem in
each row including the item itself. That means the DrawItem event
handler should not draw the item because it will be taken care of by the
DrawSubItem event handler.

The basic ideas aren't too complicated but you do need to do a fair
amount of drawing so this is a fairly long example.

The program uses the following ServerStatus class to hold information
about each server.

Public Class ServerStatus
    Public ServerName As String
    Public Logo As Image
    Public StatusColor As Color

    Public Sub New(ByVal new_ServerName As String, ByVal new_Logo As
Image, ByVal new_StatusColor As Color)
        ServerName = new_ServerName
        Logo = new_Logo
        StatusColor = new_StatusColor
    End Sub
End Class

This class holds a server's name, a picture representing the server, and
a color indicating its status.

When the program loads, it creates the ListView controls' data as shown
in the following code.

' Make some data.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
    Dim list_views() As ListView = {lvwList, lvwSmallIcon, lvwLargeIcon,
lvwTile, lvwDetails}

    For Each lvw As ListView In list_views
        AddItem(lvw, "Butterfly", My.Resources.Butterfly, Color.Green)
        AddItem(lvw, "Guppy", My.Resources.Fish, Color.Red)
        AddItem(lvw, "Peggy", My.Resources.Peggy, Color.Yellow)
    Next lvw
End Sub

' Make a server status item.
Private Sub AddItem(ByVal lvw As ListView, ByVal server As String, ByVal
logo As Image, ByVal status As Color)
    ' Make the item.
    Dim item As New ListViewItem(server)

    ' Save the ServeStatus item in the Tag property.
    Dim server_status As New ServerStatus(server, logo, status)
    item.Tag = server_status
    item.SubItems(0).Name = "Server"

    ' Add subitems so they can draw.
    item.SubItems.Add("Logo")
    item.SubItems.Add("Status")

    ' Add the item to the ListView.
    lvw.Items.Add(item)
End Sub

The form's Load event handler calls AddItem to add items to the ListView
controls. AddItem makes a ListViewItem object and adds it to a ListView.
It sets the item's Tag property to a ServerStatus object so the program
can late get information about each item.

The following code shows the DrawColumnHeader event handler.

' Just draw the column's text.
Private Sub lvw_DrawColumnHeader(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.DrawListViewColumnHeaderEventArgs) Handles
lvwTile.DrawColumnHeader, lvwSmallIcon.DrawColumnHeader,
lvwList.DrawColumnHeader, lvwLargeIcon.DrawColumnHeader,
lvwDetails.DrawColumnHeader
    Using string_format As New StringFormat()
        string_format.Alignment = StringAlignment.Center
        string_format.LineAlignment = StringAlignment.Center

        Dim text As String = lvwList.Columns(e.ColumnIndex).Text
        Select Case e.ColumnIndex
            Case 0
                e.Graphics.DrawString(text, lvwList.Font, Brushes.Black,
e.Bounds)
            Case 1
                e.Graphics.DrawString(text, lvwList.Font, Brushes.Blue,
e.Bounds)
            Case 2
                e.Graphics.DrawString(text, lvwList.Font, Brushes.Green,
e.Bounds)
        End Select
    End Using
End Sub

In this example, the DrawColumnHeader event handler is fairly simple. It
just draws each column's text within the indicated bounds. It gets the
text from the ListView's column text set at design time.

The following code shows the DrawItem event handler.

' Draw the item. In this case, the server's logo.
Private Sub lvw_DrawItem(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DrawListViewItemEventArgs) Handles
lvwTile.DrawItem, lvwSmallIcon.DrawItem, lvwList.DrawItem,
lvwLargeIcon.DrawItem, lvwDetails.DrawItem
    ' Draw Details view items in the DrawSubItem event handler.
    Dim lvw As ListView = e.Item.ListView
    If (lvw.View = View.Details) Then Return

    ' Get the ListView item and the ServerStatus object.
    Dim item As ListViewItem = e.Item
    Dim server_status As ServerStatus = DirectCast(item.Tag,
ServerStatus)

    ' Clear.
    e.DrawBackground()

    ' Draw a status indicator.
    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
    Dim rect As New Rectangle( _
        e.Bounds.Left + 1, e.Bounds.Top + 1, _
        e.Bounds.Height - 2, e.Bounds.Height - 2)
    Using br As New SolidBrush(server_status.StatusColor)
        e.Graphics.FillEllipse(br, rect)
    End Using
    e.Graphics.DrawEllipse(Pens.Black, rect)
    Dim left As Integer = rect.Right + 2

    ' See how much we must scale it.
    Dim scale As Single = e.Bounds.Height /
CSng(server_status.Logo.Height)

    ' Scale and position the image.
    e.Graphics.ScaleTransform(scale, scale)
    e.Graphics.TranslateTransform( _
        left, _
        e.Bounds.Top + (e.Bounds.Height - server_status.Logo.Height *
scale) / 2, _
        System.Drawing.Drawing2D.MatrixOrder.Append)

    ' Draw the image.
    e.Graphics.DrawImage(server_status.Logo, 0, 0)

    ' Draw the focus rectangle if appropriate.
    e.Graphics.ResetTransform()
    e.DrawFocusRectangle()
End Sub

If this is the ListView's details view, the code simply exits because
the details view is drawn by the DrawSubItem event handler.

If this is not the details view, the code gets the item's corresponding
ServerStatus object from the item's Tag property.

Next the code clears the item's background. It makes a Rectangle in the
left of the area where the item should be drawn that is as wide as it is
tall and draws a status indicator circle there.

The code then calculates the scale at which it should draw the server's
logo image to fit the available area nicely. It next draws the image to
the right of the status circle.

The event handler finishes by calling DrawFocusRectangle to draw a focus
rectangle around the item if it has the focus. (The first item in the
top left ListView has the focus in the picture shown above.)

That's all the code needed to draw the item unless the ListView is
displaying the detail view. The following DrawSubItem event handler
produces all of the graphics for the detail view.

' Draw subitems for Detail view.
Private Sub lvw_DrawSubItem(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DrawListViewSubItemEventArgs) Handles
lvwTile.DrawSubItem, lvwSmallIcon.DrawSubItem, lvwList.DrawSubItem,
lvwLargeIcon.DrawSubItem, lvwDetails.DrawSubItem
    ' Get the ListView item and the ServerStatus object.
    Dim item As ListViewItem = e.Item
    Dim server_status As ServerStatus = DirectCast(item.Tag,
ServerStatus)

    ' Draw.
    Select Case e.ColumnIndex
        Case 0
            ' Draw the server's name.
            e.Graphics.DrawString(server_status.ServerName, _
                lvwList.Font, Brushes.Black, e.Bounds)
        Case 1
            ' Draw the server's logo.
            Dim scale As Single = e.Bounds.Height /
CSng(server_status.Logo.Height)
            e.Graphics.ScaleTransform(scale, scale)
            e.Graphics.TranslateTransform( _
                e.Bounds.Left, _
                e.Bounds.Top + (e.Bounds.Height -
server_status.Logo.Height * scale) / 2, _
                MatrixOrder.Append)
            e.Graphics.DrawImage(server_status.Logo, 0, 0)
        Case 2
            ' Draw the server's status.
            Dim rect As New Rectangle( _
                e.Bounds.Left + 1, e.Bounds.Top + 1, _
                e.Bounds.Width - 2, e.Bounds.Height - 2)
            Using br As New SolidBrush(server_status.StatusColor)
                e.Graphics.FillRectangle(br, rect)
            End Using
            Dim pen_color As Color = Color.FromArgb(255, _
                255 - server_status.StatusColor.R, _
                255 - server_status.StatusColor.G, _
                255 - server_status.StatusColor.B)
            Using br As New SolidBrush(pen_color)
                Using string_format As New StringFormat()
                    string_format.Alignment = StringAlignment.Center
                    string_format.LineAlignment = StringAlignment.Center
                    Using the_font As New Font(lvwList.Font,
FontStyle.Bold)
                        
e.Graphics.DrawString(server_status.StatusColor.Name, _
                            Font, br, e.Bounds, string_format)
                    End Using
                End Using
            End Using
    End Select

    ' Draw the focus rectangle if appropriate.
    e.Graphics.ResetTransform()
    Dim lvw As ListView = e.Item.ListView
    If (lvw.FullRowSelect) Then
        e.DrawFocusRectangle(e.Item.Bounds)
    ElseIf (e.SubItem.Name = "Server") Then
        e.DrawFocusRectangle(e.Bounds)
    End If
End Sub

This code starts by getting the item corresponding to the subitem that
it should draw. It then gets the ServerStatus object corresponding to
that item.

Next the code uses a switch statement to see which of the item's columns
it should draw. Depending on which column this is, the code draws:

    - The server's name
    - The server's logo
    - The server's status inside a colored box

The event handler finishes by calling DrawFocusRectangle to draw a focus
rectangle around the item if it has the focus. If the ListView control's
FullRowSelect property is true, the control passes DrawFocusRectangle
the bounds of the item so it draws the rectangle around the whole row.
If FullRowSelect is false, it only calls DrawFocusRectangle if the code
is drawing the server's name so the box appears only around the name.
(Change FullRowSelect to false at design time to see this.)
==========
2. New HowTo: Measure distances on a map with a scale in Visual Basic
.NET
http://www.vb-helper.com/howto_net_measure_map.html
http://www.vb-helper.com/HowTo/howto_net_measure_map.zip

Picture at http://www.vb-helper.com/howto_net_measure_map.png.

Recently I wanted to know how far a lap around my local park was. If you
look at Google Maps, you can find maps of just about anywhere with the
scale shown on them. This application lets you load such a map,
calibrate by using the scale, and then measure distances on the map in
various units.

This is a fairly involved example. Most of the pieces are relatively
simple but there are a lot of details such as how to parse a distance
string such as "1.5 miles."

I wanted to use this program with a map from Google Maps but their terms
of use don't allow me to republish their maps so this example comes with
a cartoonish map of a park that I drew. (Probably no one would care but
there's no need to include one of their maps anyway.) To use a real
Google Map, find the area that you want to use and press Alt-PrntScrn to
capture a copy of your browser. Paste the result into Paint or some
other drawing program and edit the image to create the map you want.

The following code shows variables and types defined by the program.

' The loaded map image.
Private Map As Bitmap = Nothing

' Known units.
Private Enum Units
    Undefined
    Miles
    Yards
    Feet
    Kilometers
    Meters
End Enum

' Key map values.
Private ScaleDistanceInUnits As Double = -1
Private ScaleDistanceInPixels As Double = -1
Private CurrentUnit As Units = Units.Miles
Private CurrentDistance As Double = -1

The Units enumeration defines the units of measure that this program can
handle.

Use the File menu's Open command to open a map file. You can control the
program by using its combo box and two buttons.

The combo box lets you select one of the known units. If you pick one of
the choices, the following code executes.

' Set the desired units.
Private Sub btnUnits_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnYards.Click, btnMiles.Click,
btnMeters.Click, btnKilometers.Click, btnFeet.Click
    ' Find a factor to convert from the old units to meters.
    Dim conversion As Double = 1
    If (CurrentUnit = Units.Feet) Then
        conversion = 0.3048
    ElseIf (CurrentUnit = Units.Yards) Then
        conversion = 0.9144
    ElseIf (CurrentUnit = Units.Miles) Then
        conversion = 1609.344
    ElseIf (CurrentUnit = Units.Kilometers) Then
        conversion = 1000
    End If

    Dim menu_item As ToolStripMenuItem = DirectCast(sender,
ToolStripMenuItem)
    Select menu_item.Text
        Case "Miles"
            CurrentUnit = Units.Miles
        Case "Yards"
            CurrentUnit = Units.Yards
        Case "Feet"
            CurrentUnit = Units.Feet
        Case "Kilometers"
            CurrentUnit = Units.Kilometers
        Case "Meters"
            CurrentUnit = Units.Meters
    End Select
    btnUnits.Text = CurrentUnit.ToString()

    ' Find a factor to convert from meters to the new units.
    If (CurrentUnit = Units.Feet) Then
        conversion *= 3.28083
    ElseIf (CurrentUnit = Units.Yards) Then
        conversion *= 1.09361
    ElseIf (CurrentUnit = Units.Miles) Then
        conversion *= 0.000621
    ElseIf (CurrentUnit = Units.Kilometers) Then
        conversion *= 0.001
    End If

    ' Convert and display the values.
    ScaleDistanceInUnits *= conversion
    CurrentDistance *= conversion
    DisplayValues()
End Sub

The code checks the current units and makes a conversion factor to
convert from the current unit to meters. It then looks at the new choice
and multiplies on a conversion factor to convert from meters to the new
units. That avoids the need to have a table giving conversion factors
for every pair of old and new units.

When you click the Set Scale button, the following code executes.

' Reset the scale.
Private StartPoint, EndPoint As Point
Private Sub btnScale_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnScale.Click
    lblInstructions.Text = "Click and drag from the start and end point
of the map's scale bar."
    picMap.Cursor = Cursors.Cross

    AddHandler picMap.MouseDown, AddressOf Scale_MouseDown
End Sub
Private Sub Scale_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
    StartPoint = e.Location
    RemoveHandler picMap.MouseDown, AddressOf Scale_MouseDown
    AddHandler picMap.MouseMove, AddressOf Scale_MouseMove
    AddHandler picMap.MouseUp, AddressOf Scale_Mouseup
End Sub
Private Sub Scale_MouseMove(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
    EndPoint = e.Location
    DisplayScaleLine()
End Sub
Private Sub Scale_MouseUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
    RemoveHandler picMap.MouseMove, AddressOf Scale_MouseMove
    RemoveHandler picMap.MouseUp, AddressOf Scale_MouseUp
    picMap.Cursor = Cursors.Default
    lblInstructions.Text = ""

    ' Get the scale.
    Dim dlg As New ScaleDialog()
    If (dlg.ShowDialog() = DialogResult.OK) Then
        ' Get the distance on the screen.
        Dim dx As Integer = EndPoint.X - StartPoint.X
        Dim dy As Integer = EndPoint.Y - StartPoint.Y
        Dim dist As Double = Math.Sqrt(dx * dx + dy * dy)
        If (dist < 1) Then Return
        ScaleDistanceInPixels = dist

        ' Parse the distance.
        ParseDistanceString(dlg.txtScaleLength.Text, _
            ScaleDistanceInUnits, CurrentUnit)

        ' Display the units.
        btnUnits.Text = CurrentUnit.ToString()

        ' Display the scale and measured distance.
        CurrentDistance = -1
        DisplayValues()
    End If
End Sub

The button's Click event handler displays some instructions in the label
at the bottom of the form and then installs a MouseDown event handler.

The MouseDown event handler saves the mouse's current location in the
StartPoint variable. It then removes the MouseDown event handler and
installs MouseMove and MouseUp eventhandlers.

The MouseMove event handler saves the mouse's current position in the
EndPoint variable and calls the DisplayScaleLine method. That method
simply draws a copy of the map with a red line between StartPoint and
EndPoint so you can see where you are drawing.

The MouseUp event handler removes the MouseMove and MouseUp event
handlers. It then displays a small dialog where you can enter the
distance you selected as in "100 yards" or "1 kilometer." If you enter a
value and click OK, the code calculates the length you selected in
pixels. It also calls the ParseDistanceString method to determine what
distance you entered in the dialog. It finishes by displaying the units
you entered and the scale in units per pixel, and by clearing any
previous distance.

The following code shows how the ParseDistanceString method parses the
scale distance you enter in the dialog.

' Parse a distance string. Return the length in meters.
Private Sub ParseDistanceString(ByVal txt As String, ByRef distance As
Double, ByRef unit As Units)
    txt = txt.Trim()

    ' Find the longest substring that makes sense as a double.
    Dim i As Integer = DoublePrefixLength(txt)
    If (i <= 0) Then
        distance = -1
        unit = Units.Undefined
    Else
        ' Get the distance.
        distance = Double.Parse(txt.Substring(0, i))

        ' Get the unit.
        Dim unit_string As String = txt.Substring(i).Trim().ToLower()
        If (unit_string.StartsWith("mi")) Then
            unit = Units.Miles
        ElseIf (unit_string.StartsWith("y")) Then
            unit = Units.Yards
        ElseIf (unit_string.StartsWith("f")) Then
            unit = Units.Feet
        ElseIf (unit_string.StartsWith("'")) Then
            unit = Units.Feet
        ElseIf (unit_string.StartsWith("k")) Then
            unit = Units.Kilometers
        ElseIf (unit_string.StartsWith("m")) Then
            unit = Units.Meters
        Else
            unit = Units.Undefined
        End If
    End If
End Sub

This method calls the DoublePrefixLength method to see how many
characters at the beginning of the string should be interpreted as part
of the number. It extracts those characters to calculate the numeric
value. It then examines the beginning of the characters that follow to
see what unit you entered. For example, if the following text starts
with y, the unit is yards.

The following code shows the DoublePrefixLength method.

' Return the length of the longest prefix
' string that makes sense as a double.
Private Function DoublePrefixLength(ByVal txt As String) As Integer
    For i As Integer = 1 To txt.Length
        Dim test_string As String = txt.Substring(0, i)
        Dim test_value As Double
        If (Not Double.TryParse(test_string, test_value)) Then Return i
- 1
    Next i
    Return txt.Length
End Function

This code considers prefixes of the string of increasing lengths until
it finds one that it cannot parse as a double. For example, if you enter
"100yards," the program can parse the prefixes 1, 10, and 100 but it
cannot parse 100y so it concludes that the numeric part of the string
contains 3 characters.

The program uses the following code to let you measure a distance on the
map.

' Let the user draw something and calculate its length.
Private Sub btnDistance_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDistance.Click
    lblInstructions.Text = "Click and draw to define the path that you
want to measure."
    picMap.Cursor = Cursors.Cross

    DistancePoints = New List(Of Point)()
    AddHandler picMap.MouseDown, AddressOf Distance_MouseDown
End Sub

Private DistancePoints As List(Of Point)
Private Sub Distance_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
    DistancePoints.Add(e.Location)
    RemoveHandler picMap.MouseDown, AddressOf Distance_MouseDown
    AddHandler picMap.MouseMove, AddressOf Distance_MouseMove
    AddHandler picMap.MouseUp, AddressOf Distance_MouseUp
End Sub
Private Sub Distance_MouseMove(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
    DistancePoints.Add(e.Location)
    DisplayDistanceCurve()
End Sub
Private Sub Distance_MouseUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
    RemoveHandler picMap.MouseMove, AddressOf Distance_MouseMove
    RemoveHandler picMap.MouseUp, AddressOf Distance_MouseUp
    picMap.Cursor = Cursors.Default
    lblInstructions.Text = ""

    ' Measure the curve.
    Dim distance As Double = 0
    For i As Integer = 1 To DistancePoints.Count - 1
        Dim dx As Integer = DistancePoints(i).X - DistancePoints(i -
1).X
        Dim dy As Integer = DistancePoints(i).Y - DistancePoints(i -
1).Y
        distance += Math.Sqrt(dx * dx + dy * dy)
    Next i

    ' Convert into the proper units.
    CurrentDistance = distance * ScaleDistanceInUnits /
ScaleDistanceInPixels

    ' Display the result.
    DisplayValues()
End Sub

When you click the Measure button, the button's event handler displays
some instructions, creates a List(Of Point), and installs a MouseDown
event handler.

The MouseDown event handler adds the mouse's current location to the
point list, removes the MouseDown event handler, and installs MouseMove
and MouseUp event handlers.

The MouseMove event handler adds the mouse's current location to the
point list. It also calls the DisplayDistanceCurve method to show a copy
of the map with the distance drawn so far shown in red. Tha method is
fairly straightforward so it isn't shown here. Download the example to
see the details.

The MouseUp event handler removes the MouseMove and MouseUp event
handlers. It then loops through the points and adds up the distances
between successive points. It converts the distance from pixels to the
currently selected units and displays the results.

I haven't spent too much time on bug proofing this program so I wouldn't
be surprised if it shows some odd behavior. I'll leave it to you to
experiment with it.
==========
++++++++++
      <Both>
++++++++++
==========
3. Summary of what's new in Visual Basic, Visual Studio, and Windows 8

I have not spent nearly enough time with the new versions to be certain
about this, bit I think the bottom line seems to be:

- In Visual Basic, not much has changed.

- In Visual Studio, there are a few new windows and tools. Nothing that
will require extensive retraining.

- In Windows, big changes. Microsoft now favors "Metro-style"
applications. I think they basically want the computer to look like a
big Windows 7 Phone or iPad or something. You can switch to a classic
windows desktop but it seems like Microsoft is pushing for the Metro
style.

To make building Metro-style interfaces easier, the next release of
Visual Studio will include a bunch of templates that you can use as a
basis for creating applications. I think this will be pretty important
for us Windows developers.

This article caught my eye:

    Microsoft's Metro proves the PC is dead
    
http://www.zdnet.com/blog/perlow/microsofts-metro-proves-the-pc-is-dead/18705


Probably the most interesting part is the architectural picture at the
top, which is also discussed in greater detail here:

    Here's the one Microsoft Windows 8 slide that everyone wants to redo
    
http://www.zdnet.com/blog/microsoft/heres-the-one-microsoft-windows-8-slide-that-everyone-wants-to-redo/10736


That picture shows how Metro-style and desktop applications fit in
Windows 8. The two areas are noticeably separated vertically so there's
very little that they share except at the lowest levels (Windows kernel
services or core OS services).

Microsoft says everything will eventually transition from the blue
desktop area to the green Metro area and that lack of interaction
between the two in the picture makes this plausible.

Other pictures from the second article provide more information. It
seems like Microsoft is still pushing its notion that all developers
will move to WPF, and that this will happen in the Metro-style
environment in the future.

As usual, we�ll see how it plays out over the next year or so.
==========
4. What's new in Visual Basic 2011

Here are the key changes I've read about so far:
---
Async - A new way to run code asynchronously, although without starting
new threads.

Taking advantage of parallelism will be essential in the future for
getting the most out of multicore and multi-CPU systems. Unfortunately
parallel programming in general is difficult. Anything that makes it
easier is a good thing. What this does is allow a method to wait for
some other asynchronous call to complete before continuing, but at the
same time allowing the rest of the program to continue.

For example, suppose you write a DownloadFileAsync method (by convention
you now add Async to the end of the name) that downloads a big file from
the Internet. You mark the method Async. At some point it starts the
download call. You mark that statement with the Await keyword. When
execution reaches that point, the DownloadFileAsync method waits but
control is returned to the main program so it can continue executing.
When the download finishes, the DownloadFileAsync method continues
running after the Await statement.
---
Iterators - You can write an iterator that other code can loop through
by using a For Each loop.

The Yield statement makes the iterator return a value to the looping
code. For example, the following code defines an iterator that returns
the even numbers between 1 and 100.

    Private Iterator Function Evens1to100() As IEnumerable(Of Integer)
        For number As Integer = 1 To 100
            If number Mod 2 = 0 Then
                Yield number
            End If
        Next number
    End Function

The following code calls this iterator:

    For Each number As Integer In Evens1to100()
        Console.WriteLine(number)
    Next number
---
Call hierarchy IDE design time window - Lets you understand the code's
call graph better. It lets you display:

    - All calls to or from a method
    - All implementations of an interface
    - All overrides of an Overridable or MustOverride member
---
Global namespace keyword - Defines a namespace outside of your root
namespace.

This has always been an odd omission. If you want two programs to use
something that is in the same namespace, this lets you do it. For
example, suppose you define a Student class that you want multiple
projects to use. By using the Global namespace, you can declare a
namespace to hold the Students class that is outside of the namespaces
of the two projects.

Global also allows you to use system namespaces even if you have
"shadowed" them by defining one with the same name. For example, if you
make a namespace called "System" (which would be prestty confusing), you
can access the real system namespace by using Global.System.
==========
5. What's new in Visual Studio 2011

Here are the key changes I've read about so far:
---
From Jason Zander's blog
http://blogs.msdn.com/b/jasonz/archive/2011/09/14/announcing-visual-studio-11-developer-preview.aspx


"Visual Studio 11 provides an integrated development experience that
spans the entire lifecycle of software creation from architecture to
code creation, testing and beyond. This release adds support for Windows
8 and HTML 5, enabling you to target platforms across devices, services
and the cloud. Integration with Team Foundation Server enables the
entire team to collaborate throughout the development cycle to create
quality applications."

It's not clear what all that means in practical terms.
---
Code clone analysis

Jason's blog mentions this. It will look through your code for common
structure. You may be able to use that to refactor or to find code that
is similar to code in which you found a bug so you know where to look
for similar bugs.
---
Code review workflow with Team Explorer
---
Exploratory testing and enhanced unit testing
---
Backward compatibility

Really this means forward compatibility.

I've been complaining about this since Visual Basic 3.0. There's no
reason why you can't make software forward compatible. If you try to
open a VB 2011 project in VB 2010, it can work as long as the project
doesn't use any of the features that were introduced in VB 2011. We
finally have this, sort of.

If you edit a VB 2010 project in VB 2011, you can later open it again in
VB 2010 as long as you haven't used any new VB 2011 features.

It's not quite what I had in mind but it's a start.
---
Browse code in Solution Explorer
---
Pin frequently used files
---
Preview files by single-clicking them in Solution Explorer (without
opening them and cluttering up the IDE with extra windows)
---
Enhanced multi-monitor support
---
Quick search for IDE menu commands

For example, to find that missing window. Is it in the View menu? The
Debug menu? The View menu's Other Windows submenu?
---
Filter entries in Toolbox, Solution Explorer, Error List and other
windows

This is a feature that was already introduced in Expression Blend, IMHO
to overcome the terrible arrangement of items in the Properties window.
Items are ordered by categories that don't make intuitive sense so it's
very hard to find anything even if you know exactly what you're looking
for. Now if you can't find the HScrollBar control in a Toolbox
containing more than 50 controls, you can search for it.
---
Regular expressions in Find and Replace

This is very powerful but it will take some time to get good at it.
---
Simplified remote debugging
---
Collect IntelliTrace event data on computers that don't have Visual
Studio installed
---
New windows and features for parallel debugging
---
Concurrency Visualizer enhancements
---
TPL dataflow support
---
New image and texture editing tools. Includes support for compression
(PNG, JPG, TIFF), alpha transparency, and mipmaps.
---
3D modeling support

Inspect files in standard 3D model formats and add placeholder objects.
---
Edit HLSL programmable shaders
---
Create pixel shaders
---
DirectX graphics debugging tools
---
LocalDB engine

A lightweight SQL Server engine.
---
SQL Server node in Server Explorer
---
ASP.NET and Web development enhancements

I didn't look closely at these because I haven't done much of that
lately.
---
Sharepoint development enhancements

I didn't look closely at these either because I haven't done much of
that lately.
==========
6. What's new in .NET Framework 4.5

Here are the key changes I've read about so far:
---
Core New Features and Improvements
    - Add timeout limit for regular expressions
    - Define culture for an application domain
    - Console support for Unicode
    - Versioning for cultural string ordering and comparison data
---
.NET for Metro style apps
---
Web

I haven't looked closely at these. If you do a lot of this, you'll want
more detail than I can give you.
---
Networking

New programming interface for working with HTTP.
---
WPF

    - A new ribbon control. (Hasn't Microsoft realized how horrible the
ribbon is yet?)
    - New support for synchronous and asynchronous data validation.
    - New features for some classes.
    - Improved performance.
    - Data binding to static properties.
    - Repositioning data as values change.
---
WCF

I haven't looked closely at this.
---
WF

I haven't looked closely at this.
---
==========
Archives:
    http://www.topica.com/lists/VBHelper
    http://www.topica.com/lists/VB6Helper
    http://www.topica.com/lists/VBNetHelper

Twitter feeds:
    VBHelper
    CSharpHelper

Post questions at:
    http://www.topica.com/lists/VBHelperQA
	
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Developers
 Food & Drink
 Health & Fitness
 Internet
 Music
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Software
 Sports
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.