630527ca60
- Allineate lavorazioni con EgtCAM5. - Correzione uso caratteri speciali in SaveFileDialog. - Aggiunte funzioni WinPos che scrivono su ini non principale.
95 lines
3.8 KiB
VB.net
95 lines
3.8 KiB
VB.net
'----------------------------------------------------------------------------
|
|
' EgalTech 2017-2017
|
|
'----------------------------------------------------------------------------
|
|
' File : WinPos.vb Data : 08.04.17 Versione : 1.8d1
|
|
' Contenuto : Classe WinPos per gestione posizione e dimensioni finestra.
|
|
'
|
|
'
|
|
'
|
|
' Modifiche : 08.04.17 ES Creazione modulo.
|
|
'
|
|
'
|
|
'----------------------------------------------------------------------------
|
|
|
|
Public Module WinPosition
|
|
|
|
Public Class WinPos
|
|
' Membri
|
|
Public nFlag As Integer
|
|
Public nLeft As Integer
|
|
Public nTop As Integer
|
|
Public nWidth As Integer
|
|
Public nHeight As Integer
|
|
|
|
Public Sub ToWindow(Window As Window)
|
|
' Verifico che il punto in alto a sinistra stia nello schermo
|
|
Dim PtTL = New System.Drawing.Point(nLeft, nTop)
|
|
Dim s As System.Windows.Forms.Screen = System.Windows.Forms.Screen.FromPoint(PtTL)
|
|
If Not s.Bounds.Contains(PtTL) Then Return
|
|
' Imposto posizione e dimensioni
|
|
Window.WindowStartupLocation = WindowStartupLocation.Manual
|
|
Window.Top = nTop
|
|
Window.Left = nLeft
|
|
Window.Height = nHeight
|
|
Window.Width = nWidth
|
|
Window.WindowState = If(nFlag = 1, WindowState.Maximized, WindowState.Normal)
|
|
End Sub
|
|
|
|
Public Sub FromWindow(Window As Window)
|
|
nTop = CInt(Window.Top)
|
|
nLeft = CInt(Window.Left)
|
|
nHeight = CInt(Window.Height)
|
|
nWidth = CInt(Window.Width)
|
|
nFlag = If(Window.WindowState = WindowState.Maximized, 1, 0)
|
|
If Window.WindowState = WindowState.Maximized Then
|
|
nHeight = CInt(Window.RestoreBounds.Height)
|
|
nWidth = CInt(Window.RestoreBounds.Width)
|
|
End If
|
|
End Sub
|
|
|
|
Public Overloads Function FromIni(sSection As String, sKey As String) As Boolean
|
|
Return GetMainPrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight)
|
|
End Function
|
|
|
|
Public Overloads Function FromIni(sSection As String, sKey As String, IpFileName As String) As Boolean
|
|
Return EgtUILib.GetPrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight, IpFileName)
|
|
End Function
|
|
|
|
Public Overloads Function ToIni(sSection As String, sKey As String) As Boolean
|
|
Return WriteMainPrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight)
|
|
End Function
|
|
|
|
Public Overloads Function ToIni(sSection As String, sKey As String, IpFileName As String) As Boolean
|
|
Return EgtUILib.WritePrivateProfileWinPos(sSection, sKey, nFlag, nLeft, nTop, nWidth, nHeight, IpFileName)
|
|
End Function
|
|
|
|
End Class
|
|
|
|
Public Function WinPosFromIniToWindow(sSection As String, sKey As String, Window As Window) As Boolean
|
|
Dim WinPos As New WinPos
|
|
If Not WinPos.FromIni(sSection, sKey) Then Return False
|
|
WinPos.ToWindow(Window)
|
|
Return True
|
|
End Function
|
|
|
|
Public Function WinPosFromIniToWindow(sSection As String, sKey As String, Window As Window, IpFileName As String) As Boolean
|
|
Dim WinPos As New WinPos
|
|
If Not WinPos.FromIni(sSection, sKey, IpFileName) Then Return False
|
|
WinPos.ToWindow(Window)
|
|
Return True
|
|
End Function
|
|
|
|
Public Function WinPosFromWindowToIni(Window As Window, sSection As String, sKey As String) As Boolean
|
|
Dim WinPos As New WinPos
|
|
WinPos.FromWindow(Window)
|
|
Return WinPos.ToIni(sSection, sKey)
|
|
End Function
|
|
|
|
Public Function WinPosFromWindowToIni(Window As Window, sSection As String, sKey As String, IpFileName As String) As Boolean
|
|
Dim WinPos As New WinPos
|
|
WinPos.FromWindow(Window)
|
|
Return WinPos.ToIni(sSection, sKey, IpFileName)
|
|
End Function
|
|
|
|
End Module
|