Click here to Skip to main content
13,146,315 members (45,535 online)
Click here to Skip to main content


50 bookmarked
Posted 1 Oct 2008

A Reflective and Translucent Glass Panel

, 1 Oct 2008
Component derived from Panel that acts like a window (glass)
Imports System.Drawing

Module Positionning

    Public Function GetImageDrawingPoint(ByVal ImageSize As Size, ByVal Alignment As ContentAlignment, ByVal ControlSize As Size) As Point
        Dim iHorizPosition As Integer = 0
        Dim iVertPosition As Integer = 0
        Select Case Alignment
            Case ContentAlignment.BottomCenter, ContentAlignment.MiddleCenter, ContentAlignment.TopCenter
                iHorizPosition = ControlSize.Width * 0.5 - ImageSize.Width * 0.5
            Case ContentAlignment.BottomLeft, ContentAlignment.MiddleLeft, ContentAlignment.TopLeft
                iHorizPosition = 2
            Case ContentAlignment.BottomRight, ContentAlignment.MiddleRight, ContentAlignment.TopRight
                iHorizPosition = ControlSize.Width - 2 - ImageSize.Width
        End Select
        Select Case Alignment
            Case ContentAlignment.BottomCenter, ContentAlignment.BottomLeft, ContentAlignment.BottomRight
                iVertPosition = ControlSize.Height - 2 - ImageSize.Height
            Case ContentAlignment.MiddleCenter, ContentAlignment.MiddleLeft, ContentAlignment.MiddleRight
                iVertPosition = ControlSize.Height * 0.5 - ImageSize.Height * 0.5
            Case ContentAlignment.TopCenter, ContentAlignment.TopLeft, ContentAlignment.TopRight
                iVertPosition = 2
        End Select
        Return New Point(iHorizPosition, iVertPosition)
    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.


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


About the Author

Nicolas Wälti
Software Developer (Senior)
Switzerland Switzerland
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170915.1 | Last Updated 1 Oct 2008
Article Copyright 2008 by Nicolas Wälti
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid