From 5bf6b4acd4fcdd2a0b16f19f195214410e97af01 Mon Sep 17 00:00:00 2001 From: NicolaP Date: Mon, 21 Nov 2022 20:17:04 +0100 Subject: [PATCH] Inizio gestione cambio configurazione --- Constants/ConstIni.vb | 1 + OptionsWindow/OptionModule.vb | 91 +++++++++++++++++++++++++++++++ OptionsWindow/OptionsV.xaml | 53 +++++++++++++++++- OptionsWindow/OptionsViewModel.vb | 83 +++++++++++++++++++++++++++- RegexFunction.vb | 2 +- 5 files changed, 227 insertions(+), 3 deletions(-) diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 03c7b23..2207590 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -90,6 +90,7 @@ Module ConstIni Public Const K_MYPROJECTDIR As String = "ProjectDirectory" Public Const K_TEMPLATEDIR As String = "TemplateDirectory" Public Const K_MACHINDIR As String = "MachinDirectory" + Public Const K_MTABLE As String = "MTable" Public Const S_REPORT As String = "Report" Public Const K_REPORTDIR As String = "ReportDirectory" diff --git a/OptionsWindow/OptionModule.vb b/OptionsWindow/OptionModule.vb index 1b55165..fdbf6d3 100644 --- a/OptionsWindow/OptionModule.vb +++ b/OptionsWindow/OptionModule.vb @@ -11,6 +11,10 @@ Friend Module OptionModule Friend m_LanguageList As New ObservableCollection(Of Language) Friend m_SelectedLanguage As Language + ' Elenco delle MTable disponibili nella configurazione corrente + Friend m_MTableList As New ObservableCollection(Of MTable) + Friend m_SelectedMTable As MTable + Friend m_OptionLauncherList As New List(Of String) Friend m_SelectedOptionLauncher As Integer = 0 Friend m_bLauncherOpenOnce As Boolean = False @@ -391,6 +395,10 @@ Friend Module OptionModule DefaultGetMmUnits(ConstCompo.S_GENERALINI, ConstCompo.K_MMUNITSINI, IsMM) m_IsMM = IsMM + If GetCurrentMTableList() Then + ' abilito la modifica della MTbale solo se Debug superioere a 5 + End If + Dim Width As String = String.Empty DefaultGetPrivateProfileString(S_SIZE_INI, K_WIDTH_INI, "32", Width) Utility.ConvertCompoConfig(Width, 500) @@ -1000,6 +1008,59 @@ Friend Module OptionModule End If End Function + Public Function GetCurrentMTableList() As Boolean + If String.IsNullOrEmpty(IniFile.m_sDoorsDirPath) Then Return False + m_MTableList.Clear() + Dim sMTableDir As String = IniFile.m_sDoorsDirPath & "\MTables" + Dim Items As String() = Directory.GetFiles(sMTableDir) + ' recupero i file che hanno estemsione *.mtl + For Each MTableFile As String In Items + If MTableFile.EndsWith(".mtl") Then + Dim sName As String = Path.GetFileNameWithoutExtension(MTableFile).ToLower + Dim sPath As String = MTableFile + Dim bIsValid As Boolean = True + Dim ExcludeList As List(Of String) = GetExludeList() + For Each ExcludedItem As String In ExcludeList + If sName.ToLower.Contains(ExcludedItem) Then + bIsValid = False + Exit For + End If + Next + If bIsValid Then + sName = Path.GetFileNameWithoutExtension(MTableFile) + Dim LocalMTable As New MTable(sName.Trim, sPath.Trim) + m_MTableList.Add(LocalMTable) + End If + End If + Next + If m_MTableList.Count < 1 Then Return False + ' leggo il nome della MTable attiva + Dim sSelectedMTable As String = String.Empty + Dim nbSelected As Boolean = False + If GetMainPrivateProfileString(S_DOORS, K_MTABLE, "", sSelectedMTable) <> 0 Then + For Each ItemFile As MTable In m_MTableList + If ItemFile.FilePath.ToLower = sSelectedMTable.Trim.ToLower Then + m_SelectedMTable = ItemFile + nbSelected = True + Exit For + End If + Next + End If + If Not nbSelected Then m_SelectedMTable = m_MTableList(0) + Return True + End Function + + Private Function GetExludeList() As List(Of String) + Dim LocalList As New List(Of String) + Dim sVal As String = String.Empty + GetMainPrivateProfileString(S_DOORS, "Exclude", "", sVal) + Dim sItems As String() = sVal.Split(","c) + For Each Item As String In sItems + LocalList.Add(Item.Trim) + Next + Return LocalList + End Function + End Module ' Classe che identifica una lingua del programma con nome e path del file dei messaggi @@ -1032,3 +1093,33 @@ Public Class Language End Sub End Class + +Public Class MTable + + Private m_sName As String + Private m_sFilePath As String + + Public Property Name As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + Public Property FilePath As String + Get + Return m_sFilePath + End Get + Set(value As String) + m_sFilePath = value + End Set + End Property + + Sub New(sName As String, sFilePath As String) + Me.Name = sName + Me.FilePath = sFilePath + End Sub + +End Class diff --git a/OptionsWindow/OptionsV.xaml b/OptionsWindow/OptionsV.xaml index 8836193..14bc313 100644 --- a/OptionsWindow/OptionsV.xaml +++ b/OptionsWindow/OptionsV.xaml @@ -5,12 +5,14 @@ Title="{Binding Title}" Icon="/Resources/EgtDOOR.ico" TitleBarBrush="{StaticResource EgaltechBlue1}" BorderBrush="{StaticResource EgaltechBlue1}" - WindowStyle="None" ResizeMode="NoResize" TitleBarHeight="30" IsResizable="False" + WindowStyle="None" ResizeMode="NoResize" TitleBarHeight="30" + IsResizable="True" IsMovable="True" IsMinimizable="False" WindowStartupLocation="CenterScreen" ShowInTaskbar="False" CloseCommand="{Binding CloseOptionsCommand,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"> + @@ -253,6 +255,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +