5f26278bbb
- correzione a EgtCalculatorWD per valore di ritorno.
133 lines
4.7 KiB
VB.net
133 lines
4.7 KiB
VB.net
'----------------------------------------------------------------------------
|
|
' EgalTech 2014-2015
|
|
'----------------------------------------------------------------------------
|
|
' File : EgtCalculatorWD.xaml.vb Data : 19.01.16 Versione : 1
|
|
' Contenuto : Finestra che permette di aprire la calcolatrice senza la
|
|
' necessità di chiamarla da una TextBox.
|
|
'
|
|
' Creato da : Emmanuele Sassi
|
|
' Modificato da :
|
|
'
|
|
' Modifiche :
|
|
'
|
|
'----------------------------------------------------------------------------
|
|
|
|
Public Class EgtCalculatorWD
|
|
|
|
' Riferimento alla calcolatrice vera e propria
|
|
Private WithEvents m_Calculator As EgtWPFLib.EgtCalculator
|
|
|
|
' Parametri ricevuti
|
|
Private m_sTitle As String = String.Empty
|
|
Private m_dStartValue As Double = Nothing
|
|
Private m_Width As Double = 0
|
|
Private m_WidthType As WidthType = WidthType.NULL
|
|
|
|
' Parametro di ritorno
|
|
'Public Shadows DialogResult As Integer = 0
|
|
|
|
' Riferimento alla finestra in cui si trova la EgtTxBx
|
|
Private m_Owner As Window
|
|
|
|
Public ReadOnly Property dResult As Double
|
|
Get
|
|
Return m_Calculator.dResult
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(Owner As Window, dStartValue As Double, dWidth As Double, WidthType As WidthType, Top As Double, Left As Double, Optional sTitle As String = "")
|
|
|
|
'Inizializzazione dei membri della classe con i valori ricevuti
|
|
m_Owner = Owner
|
|
m_sTitle = sTitle
|
|
m_dStartValue = dStartValue
|
|
m_Width = dWidth
|
|
m_WidthType = WidthType
|
|
|
|
' Verifico che non ci sia una calcolatrice già aperta
|
|
If Not EgtCalculator.GetbIsActive Then
|
|
' This call is required by the designer.
|
|
InitializeComponent()
|
|
|
|
' Add any initialization after the InitializeComponent() call.
|
|
|
|
' Apro la finestra
|
|
Me.ShowDialog()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub EgtCalculatorWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
|
|
'Applico il FontFamily alla finestra
|
|
Dim EgtFontFamilyConverter As New FontFamilyConverter
|
|
Me.FontFamily = EgtFontFamilyConverter.ConvertFromString(InitializeEgtWPFLib.FontFamilyPath)
|
|
|
|
' Creo calcolatrice
|
|
m_Calculator = New EgtCalculator(m_Owner, m_dStartValue, m_Width, m_WidthType)
|
|
|
|
' Se è presente un titolo gli creo lo spazio nella calcolatrice
|
|
If m_sTitle <> String.Empty Then
|
|
'Dim HeaderRow2 As New RowDefinition
|
|
'HeaderRow2.Height = New GridLength(1.25, GridUnitType.Star)
|
|
m_Calculator.HeaderRow.Height = New GridLength(1.25, GridUnitType.Star)
|
|
'Dim TitleRow2 As New RowDefinition
|
|
'TitleRow2.Height = New GridLength(0.5, GridUnitType.Star)
|
|
m_Calculator.TitleRow.Height = New GridLength(0.5, GridUnitType.Star)
|
|
End If
|
|
|
|
' Posiziono la calcolatrice nella griglia
|
|
If m_sTitle <> String.Empty Then
|
|
m_Calculator.SetValue(Grid.RowProperty, 1)
|
|
End If
|
|
CalculatorWDGrid.Children.Add(m_Calculator)
|
|
|
|
' Se presente creo TextBlock per titolo
|
|
If m_sTitle <> String.Empty Then
|
|
Dim TitleTxBl As New TextBlock With {
|
|
.Text = m_sTitle,
|
|
.FontSize = m_Calculator.dFontSize,
|
|
.Margin = New Thickness(5, 0, 0, 0),
|
|
.HorizontalAlignment = Windows.HorizontalAlignment.Left,
|
|
.VerticalAlignment = Windows.VerticalAlignment.Center
|
|
}
|
|
TitleTxBl.SetValue(Grid.ColumnProperty, 1)
|
|
m_Calculator.TitleGrid.Children.Add(TitleTxBl)
|
|
End If
|
|
' Rendo tasti V e X modali
|
|
m_Calculator.VBtn.IsCancel = True
|
|
m_Calculator.XBtn.IsCancel = True
|
|
|
|
'Assegno le dimensioni della calcolatrice alla finestra
|
|
Me.Height = m_Calculator.Height
|
|
Me.Width = m_Calculator.Width
|
|
|
|
' Se il titolo è presente aumento l'altezza della finestra
|
|
If m_sTitle <> String.Empty Then
|
|
m_Calculator.Height += m_Calculator.Height / 5 * 0.5
|
|
Me.Height = m_Calculator.Height
|
|
End If
|
|
|
|
Me.Top = m_Owner.Top + (m_Owner.Height / 2) - (Me.Height / 2)
|
|
Me.Left = m_Owner.Left + (m_Owner.Width / 2) - (Me.Width / 2)
|
|
|
|
'Assegno la finestra come figlia della MainWindow
|
|
Me.Owner = m_Owner
|
|
|
|
End Sub
|
|
|
|
Private Sub EgtCalculatorWD_ContentRendered(sender As Object, e As EventArgs) Handles Me.ContentRendered
|
|
m_Calculator.ValueTxBx.Focus()
|
|
m_Calculator.ValueTxBx.SelectAll()
|
|
End Sub
|
|
|
|
Private Sub m_Calculator_EgtClosed(sender As Object, e As System.EventArgs) Handles m_Calculator.EgtClosed
|
|
If IsNothing(m_Calculator.bConfirmResult) Then
|
|
DialogResult = False
|
|
Else
|
|
DialogResult = m_Calculator.bConfirmResult
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|