Files
OmagVIEW/OptionsPageUC.xaml.vb
2021-08-30 15:15:39 +02:00

132 lines
6.0 KiB
VB.net

Imports EgtUILib
Imports System.IO
Public Class OptionsPageUC
Dim m_MainWindow As MainWindow = Application.Current.MainWindow
Private UnitsList() As String = {"inch", "mm"}
Private ViewRotsList() As String = {"0", "90", "180", "270"}
Private ThemesList() As String = {"Classic", "Dark"}
Sub New(Owner As Window)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.Owner = Owner
Me.Top = Owner.Top + (Owner.Height / 2 - Me.Height / 2)
Me.Left = Owner.Left + (Owner.Width / 2 - Me.Width / 2)
Me.ShowDialog()
End Sub
Private Sub OptionsPageUC_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
' Associazione della lista linguaggi alla combobox
LanguageCmBx.ItemsSource = m_MainWindow.m_LanguagesList
' Associazione della lista unità di misura alla combobox
UnitsOfMeasureCmBx.ItemsSource = UnitsList
' Associazione della lista rotazioni alla combobox
ViewRotCmBx.ItemsSource = ViewRotsList
' Associazione della lista temi alla combobox
ThemesCmBx.ItemsSource = ThemesList
' Imposto la lingua corrente
LanguageCmBx.SelectedItem = m_MainWindow.m_CurrLanguage
' Imposto l'unità di misura corrente
UnitsOfMeasureCmBx.SelectedIndex = If(EgtUiUnitsAreMM(), 1, 0)
' Imposto la rotazione corrente
ViewRotCmBx.SelectedIndex = m_MainWindow.m_nTopViewRotStep
' Imposto il tema corrente
ThemesCmBx.SelectedIndex = m_MainWindow.m_CurrTheme
AddHandler BrowseBtn.Click, AddressOf Me.BrowseBtn_OnClick
AddHandler BrowseArrowBtn.Click, AddressOf Me.BrowseArrowBtn_OnClick
' Messaggi
OptTitle.Text = EgtMsg(MSG_OMAGCUT + 6) ' OPZIONI
LanguageGpBx.Header = EgtMsg(MSG_OPTIONSPAGEUC + 1) ' Lingua
LanguageMsgTxBl.Text = EgtMsg(MSG_OPTIONSPAGEUC + 2) ' La nuova lingua diventerà corr...
UnitsOfMeasureGpBx.Header = EgtMsg(MSG_OPTIONSPAGEUC + 3) ' Unità di misura
ViewRotGpBx.Header = EgtMsg(MSG_OPTIONSPAGEUC + 4) ' Rotazione vista
ThemesGpBx.Header = EgtMsg(MSG_OPTIONSPAGEUC + 25) ' Tema
LabelGpBx.Header = EgtMsg(92056) ' Etichetta
LabelTxt.Text = m_MainWindow.m_TemplateFilePrinter
LabelArrowGpBx.Header = EgtMsg(92057) ' Etichetta Freccia
LabelArrowTxt.Text = m_MainWindow.m_TemplateFileArrowPrinter
End Sub
Private Sub LanguageCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles LanguageCmBx.SelectionChanged
m_MainWindow.m_CurrLanguage = LanguageCmBx.SelectedItem
WritePrivateProfileString(S_GENERAL, K_MESSAGES, m_MainWindow.m_CurrLanguage.LanguageName, m_MainWindow.GetIniFile())
End Sub
Private Sub UnitsOfMeasureCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles UnitsOfMeasureCmBx.SelectionChanged
Dim bMM As Boolean = (UnitsOfMeasureCmBx.SelectedIndex <> 0)
EgtSetUiUnits(bMM)
WritePrivateProfileString(S_GENERAL, K_MMUNITS, If(bMM, 1, 0), m_MainWindow.GetIniFile())
End Sub
Private Sub ViewRotCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles ViewRotCmBx.SelectionChanged
m_MainWindow.m_nTopViewRotStep = ViewRotCmBx.SelectedIndex
WritePrivateProfileString(S_SCENE, K_TOPVIEWROTSTEP, m_MainWindow.m_nTopViewRotStep.ToString(), m_MainWindow.GetIniFile())
' aggiorno visualizzazione
EgtSetGenericView(0, (m_MainWindow.m_nTopViewRotStep - 1) * 90)
EgtZoom(ZM.ALL)
End Sub
Private Sub ThemesCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles ThemesCmBx.SelectionChanged
'Dim app As Application = Application.Current
If (ThemesCmBx.SelectedIndex = 0) Then
' app.ChangeTheme(New Uri("/OmagVIEW;component/OmagVIEWDictionary.xaml", UriKind.Relative))
' WritePrivateProfileString(S_GENERAL, K_THEME, 0, m_MainWindow.GetIniFile())
m_MainWindow.m_CurrTheme = 0
End If
If (ThemesCmBx.SelectedIndex = 1) Then
'app.ChangeTheme(New Uri("/OmagView;component/OmagViewDarkDictionary.xaml", UriKind.Relative))
'Application.Current.Resources("GroupBox_CornerRadius") = 3
'Application.Current.Resources("Button_CornerRadius") = 3
'Application.Current.Resources("EmptyBorder_CornerRadius") = New CornerRadius(3)
'WritePrivateProfileString(S_GENERAL, K_THEME, 1, m_MainWindow.GetIniFile())
m_MainWindow.m_CurrTheme = 1
End If
End Sub
' distinguo il direttorio di ricerca a seconda del file selezionato
Private Sub BrowseBtn_OnClick()
Browse(m_MainWindow.m_TemplateFilePrinter, K_TEMPLATE)
LabelTxt.Text = m_MainWindow.m_TemplateFilePrinter
End Sub
Private Sub BrowseArrowBtn_OnClick()
Browse(m_MainWindow.m_TemplateFileArrowPrinter, K_TEMPLATE_ARROW)
LabelArrowTxt.Text = m_MainWindow.m_TemplateFileArrowPrinter
End Sub
Private Sub Browse(ByRef sFileName As String, sKey As String)
'recupero il nome del direttorio
Dim CurrDirectory As String = Path.GetDirectoryName(sFileName)
' Apro la finestra di dialogo aperta direttamente sulla cartella cercata
Dim OpenFileDialog As New Microsoft.Win32.OpenFileDialog() With {
.InitialDirectory = CurrDirectory
}
OpenFileDialog.Filter = "prn files (*.prn)|*.prn"
If OpenFileDialog.ShowDialog() <> True Then
' se la risposta è diversa da OK esce
Else
' carico l'indirizzo del template che voglio aprire
sFileName = OpenFileDialog.FileName
' salvo il nome del nuovo file template in uso
WritePrivateProfileString(S_PRINTER, sKey, sFileName, m_MainWindow.GetIniFile())
End If
End Sub
End Class