This commit is contained in:
SchreiberM
2016-10-14 13:27:47 +02:00
parent 4548dc3abc
commit 353f161c57
30 changed files with 1400 additions and 607 deletions

View File

@@ -68,56 +68,67 @@ Public Class ClassBackgroundHelper
End Function
Private Sub GenerateBackgroundImage()
Dim gvInfo As GridViewInfo = TryCast(_grid.GetViewInfo(), GridViewInfo)
Dim _processedImage As New Bitmap(gvInfo.ViewRects.Client.Width + 1, gvInfo.ViewRects.Client.Height + 1)
Using g As Graphics = Graphics.FromImage(_processedImage)
Dim p As Point = CalculateImageLocation(_originalImage.Width, _originalImage.Height, gvInfo, _pictureAlignment)
Dim transparentImage As Bitmap = SetImgageOpacity(_originalImage, 0.5)
g.DrawImage(transparentImage, p)
g.Save()
End Using
_grid.GridControl.BackgroundImage = _processedImage
Try
Dim gvInfo As GridViewInfo = TryCast(_grid.GetViewInfo(), GridViewInfo)
Dim _processedImage As New Bitmap(gvInfo.ViewRects.Client.Width + 1, gvInfo.ViewRects.Client.Height + 1)
Using g As Graphics = Graphics.FromImage(_processedImage)
Dim p As Point = CalculateImageLocation(_originalImage.Width, _originalImage.Height, gvInfo, _pictureAlignment)
Dim transparentImage As Bitmap = SetImgageOpacity(_originalImage, 0.5)
g.DrawImage(transparentImage, p)
g.Save()
End Using
_grid.GridControl.BackgroundImage = _processedImage
Catch ex As Exception
ClassLogger.Add("Unexpected Error in GenerateBackgroundImage: " & ex.Message)
End Try
End Sub
Private Function CalculateImageLocation(imageWidth As Integer, imageHeight As Integer, gvInfo As GridViewInfo, alignment As ContentAlignment) As Point
Dim location As Point = Point.Empty
Dim rect As Rectangle = gvInfo.ViewRects.Rows
Dim indicatorWidth As Integer = gvInfo.ViewRects.IndicatorWidth
Dim vScrollSize As Integer = If(gvInfo.VScrollBarPresence = ScrollBarPresence.Visible, 20, 0)
Dim hSctollSize As Integer = If(gvInfo.HScrollBarPresence = ScrollBarPresence.Visible, 20, 0)
Try
Dim location As Point = Point.Empty
Dim rect As Rectangle = gvInfo.ViewRects.Rows
Dim indicatorWidth As Integer = gvInfo.ViewRects.IndicatorWidth
Dim vScrollSize As Integer = If(gvInfo.VScrollBarPresence = ScrollBarPresence.Visible, 20, 0)
Dim hSctollSize As Integer = If(gvInfo.HScrollBarPresence = ScrollBarPresence.Visible, 20, 0)
Select Case alignment
Case ContentAlignment.BottomCenter
location.Offset((rect.Width / 2) - (imageWidth / 2), rect.Bottom - imageHeight - hSctollSize)
Exit Select
Case ContentAlignment.BottomLeft
location.Offset(indicatorWidth, rect.Bottom - imageHeight - hSctollSize)
Exit Select
Case ContentAlignment.BottomRight
location.Offset(rect.Right - imageWidth - vScrollSize, rect.Bottom - imageHeight - hSctollSize)
Exit Select
Case ContentAlignment.MiddleCenter
location.Offset((rect.Width / 2) - (imageWidth / 2), (rect.Height / 2) - (imageHeight / 2))
Exit Select
Case ContentAlignment.MiddleLeft
location.Offset(indicatorWidth, (rect.Height / 2) - (imageHeight / 2))
Exit Select
Case ContentAlignment.MiddleRight
location.Offset(rect.Width - imageWidth - vScrollSize, (rect.Height / 2) - (imageHeight / 2))
Exit Select
Case ContentAlignment.TopCenter
location.Offset((rect.Width / 2) - (imageWidth / 2), rect.Top)
Exit Select
Case ContentAlignment.TopLeft
location.Offset(indicatorWidth, rect.Top)
Exit Select
Case ContentAlignment.TopRight
location.Offset(rect.Right - imageWidth - vScrollSize, rect.Top)
Exit Select
Case Else
Exit Select
End Select
Return location
Select Case alignment
Case ContentAlignment.BottomCenter
location.Offset((rect.Width / 2) - (imageWidth / 2), rect.Bottom - imageHeight - hSctollSize)
Exit Select
Case ContentAlignment.BottomLeft
location.Offset(indicatorWidth, rect.Bottom - imageHeight - hSctollSize)
Exit Select
Case ContentAlignment.BottomRight
location.Offset(rect.Right - imageWidth - vScrollSize, rect.Bottom - imageHeight - hSctollSize)
Exit Select
Case ContentAlignment.MiddleCenter
location.Offset((rect.Width / 2) - (imageWidth / 2), (rect.Height / 2) - (imageHeight / 2))
Exit Select
Case ContentAlignment.MiddleLeft
location.Offset(indicatorWidth, (rect.Height / 2) - (imageHeight / 2))
Exit Select
Case ContentAlignment.MiddleRight
location.Offset(rect.Width - imageWidth - vScrollSize, (rect.Height / 2) - (imageHeight / 2))
Exit Select
Case ContentAlignment.TopCenter
location.Offset((rect.Width / 2) - (imageWidth / 2), rect.Top)
Exit Select
Case ContentAlignment.TopLeft
location.Offset(indicatorWidth, rect.Top)
Exit Select
Case ContentAlignment.TopRight
location.Offset(rect.Right - imageWidth - vScrollSize, rect.Top)
Exit Select
Case Else
Exit Select
End Select
Return location
Catch ex As Exception
ClassLogger.Add("Unexpected Error in CalculateImageLocation: " & ex.Message)
Return Nothing
End Try
End Function
Private Sub InitializingBlendingComponent()