Click here to Skip to main content
15,895,011 members
Articles / Desktop Programming / WPF

Introducing PresentationWindows

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
4 Nov 2012CPOL6 min read 18K   564   19  
PresentationWindows is a WPF class library that introduces three new types derived from the Window class, enabling many previously difficult to access features of windows.
Imports System.Windows
Imports System.Windows.Controls
Imports System.Runtime.CompilerServices


Public Module StaticMethods
    Public Function EqualsOperatorNothingSafe(left As Object, right As Object) As Boolean
        If IsNothing(left) And IsNothing(right) Then Return True
        If IsNothing(left) Xor IsNothing(right) Then Return False
        Return left = right
    End Function

    <Extension()>
    Friend Sub CopyFrom(toCollection As RowDefinitionCollection, fromCollection As GridLength())
        toCollection.Clear()
        For Each dfn As GridLength In fromCollection
            Dim actualDfn As RowDefinition = New RowDefinition()
            actualDfn.Height = dfn
            toCollection.Add(actualDfn)
        Next
    End Sub

    <Extension()>
    Friend Sub CopyFrom(toCollection As ColumnDefinitionCollection, fromCollection As GridLength())
        toCollection.Clear()
        For Each dfn As GridLength In fromCollection
            Dim actualDfn As ColumnDefinition = New ColumnDefinition()
            actualDfn.Width = dfn
            toCollection.Add(actualDfn)
        Next
    End Sub

    Public Function GetGridLengths(rows As RowDefinitionCollection) As GridLength()
        Dim result As List(Of GridLength)
        result = New List(Of GridLength)
        For Each row As RowDefinition In rows
            result.Add(row.Height)
        Next
        Return result.ToArray()
    End Function

    Public Function GetGridLengths(rows As ColumnDefinitionCollection) As GridLength()
        Dim result As List(Of GridLength)
        result = New List(Of GridLength)
        For Each row As ColumnDefinition In rows
            result.Add(row.Width)
        Next
        Return result.ToArray()
    End Function
End Module

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions