diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 76d8be2..82816b7 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -237,6 +237,8 @@ Module ConstIni Public Const K_OTHERREFTABX As String = "OtherRefTabX" Public Const K_OTHERREFTABY As String = "OtherRefTabY" Public Const K_OTHERREFTABPOS As String = "OtherRefTabPos" + Public Const K_REFTAB As String = "RefTab" + Public Const K_CURRENTREFTAB As String = "CurrRefTab" Public Const S_RAWMOVE As String = "RawMove" diff --git a/RawPhoto/OtherRefTabWD.xaml b/RawPhoto/OtherRefTabWD.xaml index c0e1502..d5d61ae 100644 --- a/RawPhoto/OtherRefTabWD.xaml +++ b/RawPhoto/OtherRefTabWD.xaml @@ -4,7 +4,7 @@ xmlns:EgtWPFLib="clr-namespace:EgtWPFLib;assembly=EgtWPFLib" FontFamily="{DynamicResource OmagCut_Font}" ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" Background="Transparent" - Title="ModifStartEndWD" Height="250" Width="320" ShowInTaskbar="False"> + Title="ModifStartEndWD" Height="350" Width="320" ShowInTaskbar="False"> @@ -28,14 +28,30 @@ + + + - - - + + + + + + + + + + + @@ -44,17 +60,17 @@ - - - - - + diff --git a/RawPhoto/OtherRefTabWD.xaml.vb b/RawPhoto/OtherRefTabWD.xaml.vb index a2a8f51..ca3d78c 100644 --- a/RawPhoto/OtherRefTabWD.xaml.vb +++ b/RawPhoto/OtherRefTabWD.xaml.vb @@ -1,4 +1,5 @@ Imports System.IO +Imports System.Reflection Imports EgtUILib Imports EgtWPFLib @@ -12,9 +13,14 @@ Public Class OtherRefTabWD Private m_dPrevOffsetX As Double = 0 Private m_dPrevOffsetY As Double = 0 + Private m_bModifX As Boolean = False + Private m_bModifY As Boolean = False + Private m_SelIndex As Integer = 0 - Sub New(Owner As Window, PosX As String, PosY As String, OffsetX As Double, OffsetY As Double, OtherRefMode As Integer) + Private m_SelRef As Integer = 0 + + Sub New(Owner As Window, PosX As String, PosY As String, OffsetX As Double, OffsetY As Double, OtherRefMode As Integer, SelRef As Integer) Me.Owner = Owner ' La chiamata è richiesta dalla finestra di progettazione. InitializeComponent() @@ -25,6 +31,7 @@ Public Class OtherRefTabWD m_dPrevOffsetX = OffsetX m_dPrevOffsetY = OffsetY m_SelIndex = OtherRefMode + m_SelRef = SelRef End Sub Private Sub OtherRrefTabWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized @@ -36,8 +43,11 @@ Public Class OtherRefTabWD RefRawTxbl.Text = "Raw reference" RefTabXTxbl.Text = "Position X" RefTabYTxbl.Text = "Position Y" - RefTabModeCmBx.ItemsSource = m_RawPartPage.m_OtherRefTabList - RefTabModeCmBx.SelectedIndex = m_RawPartPage.m_OtherRefTabPos + SelRefTxbl.Text = "Sel reference" + RefTabOrientationCmBx.ItemsSource = m_RawPartPage.m_OtherRefTabOrientationList + RefTabOrientationCmBx.SelectedIndex = m_RawPartPage.m_OtherRefTabPos + RefTabCmBx.ItemsSource = m_RawPartPage.m_OtherRefTabList + RefTabCmBx.SelectedIndex = m_RawPartPage.m_CurrRefTab End Sub Private Sub OtherRrefTabWD_Load(sender As Object, e As EventArgs) Handles Me.Loaded @@ -45,9 +55,44 @@ Public Class OtherRefTabWD RefTabYTxBx.Text = m_sPosY End Sub - Private Sub RefTabModeCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles RefTabModeCmBx.SelectionChanged - m_RawPartPage.m_OtherRefTabPos = RefTabModeCmBx.SelectedIndex - WritePrivateProfileString(S_RAWPART, K_OTHERREFTABPOS, m_RawPartPage.m_OtherRefTabPos.ToString, m_MainWindow.GetIniFile()) + Private Sub RefTabCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles RefTabCmBx.SelectionChanged + If m_bModifX Or m_bModifY Then + Dim SaveCurrToolWnd = New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 2), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL) + Select Case SaveCurrToolWnd.m_nPressedBtn + Case 0 ' Annulla + ' annullo l'operazione di cambio indice + RefTabCmBx.SelectedIndex = m_RawPartPage.m_CurrRefTab + Return + Case 1 ' Si + ' salvo i valori modificati + UpdateCurrOffset() + ' recupero l'oggetto precedentemente selezionato e lo aggiorno (per evitare di rileggere il file ini) + Dim temp_RefTab As ReferenceTable = m_RawPartPage.m_OtherRefTabList(m_RawPartPage.m_CurrRefTab) + temp_RefTab.dOffsetX = m_RawPartPage.m_OtherRefTabX + temp_RefTab.dOffsetY = m_RawPartPage.m_OtherRefTabY + temp_RefTab.nPos = m_RawPartPage.m_OtherRefTabPos + Case 2 ' No + ' Non salvo e vado oltre + m_bModifX = False + m_bModifY = False + End Select + End If + ' recupero l'oggetto selezionato + Dim local_RefTab As ReferenceTable = m_RawPartPage.m_OtherRefTabList(RefTabCmBx.SelectedIndex) + m_RawPartPage.m_CurrRefTab = RefTabCmBx.SelectedIndex + ' Imposto gli Offset del riferimento selezionato + RefTabXTxBx.Text = LenToString(local_RefTab.dOffsetX, 2) + m_RawPartPage.m_OtherRefTabX = local_RefTab.dOffsetX + RefTabYTxBx.Text = LenToString(local_RefTab.dOffsetY, 2) + m_RawPartPage.m_OtherRefTabY = local_RefTab.dOffsetY + ' Aggiorno la posizine del grezzo + m_RawPartPage.RefTabModeChange() + m_bModifX = False + m_bModifY = False + End Sub + + Private Sub RefTabOrientationCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles RefTabOrientationCmBx.SelectionChanged + m_RawPartPage.m_OtherRefTabPos = RefTabOrientationCmBx.SelectedIndex m_RawPartPage.RefTabModeChange() End Sub @@ -66,6 +111,7 @@ Public Class OtherRefTabWD ' errore, posizione fuori dalla tavola End If m_RawPartPage.m_OtherRefTabX = dX + m_bModifX = True m_RawPartPage.RefTabModeChange() End If End Sub @@ -85,24 +131,99 @@ Public Class OtherRefTabWD ' errore, posizione fuori dalla tavola End If m_RawPartPage.m_OtherRefTabY = dY + m_bModifY = True m_RawPartPage.RefTabModeChange() End If End Sub Private Sub OkBtn_Click() Handles OkBtn.Click - WritePrivateProfileString(S_RAWPART, K_OTHERREFTABX, DoubleToString(RefTabXTxBx.Text, 2), m_MainWindow.GetIniFile()) - WritePrivateProfileString(S_RAWPART, K_OTHERREFTABY, DoubleToString(RefTabYTxBx.Text, 2), m_MainWindow.GetIniFile()) - WritePrivateProfileString(S_RAWPART, K_OTHERREFTABPOS, m_RawPartPage.m_OtherRefTabPos.ToString, m_MainWindow.GetIniFile()) + WritePrivateProfileString(S_RAWPART, K_CURRENTREFTAB, m_RawPartPage.m_CurrRefTab.ToString, m_MainWindow.GetIniFile()) + ' Aggiorno il valore del riferimento correntemente modificato + UpdateCurrOffset() + m_RawPartPage.RefTabModeChange() Me.Close() End Sub + Private Sub UpdateCurrOffset() + Dim sKeyMsg As String = K_REFTAB & m_RawPartPage.m_CurrRefTab.ToString + Dim sValMsg As String = DoubleToString(m_RawPartPage.m_OtherRefTabX, 2) & "," & DoubleToString(m_RawPartPage.m_OtherRefTabY, 2) & "," & m_RawPartPage.m_OtherRefTabPos.ToString + WritePrivateProfileString(S_RAWPART, sKeyMsg, sValMsg, m_MainWindow.GetIniFile()) + End Sub + Private Sub ExitBtn_Click() Handles ExitBtn.Click - ' riposiziono l'origine - m_RawPartPage.m_OtherRefTabX = m_sPosX - m_RawPartPage.m_OtherRefTabY = m_sPosY - ' ripristino il valore della combobox - m_RawPartPage.m_OtherRefTabPos = m_SelIndex + ' Recupero la prima selezione eseguita + m_RawPartPage.m_CurrRefTab = m_SelRef + Dim temp_RefTab As ReferenceTable = m_RawPartPage.m_OtherRefTabList(m_RawPartPage.m_CurrRefTab) + ' aggiorno i valori + m_RawPartPage.m_OtherRefTabX = temp_RefTab.dOffsetX + m_RawPartPage.m_OtherRefTabY = temp_RefTab.dOffsetY + m_RawPartPage.m_OtherRefTabPos = temp_RefTab.nPos m_RawPartPage.RefTabModeChange() End Sub End Class + +Public Class ReferenceTable + + Private m_dOffsetX As Double + Private m_dOffsetY As Double + Private m_nPos As RawPartPageUC.OTHERREFMODE = RawPartPageUC.OTHERREFMODE.BL + Private m_nIndexRef As Integer = 0 + + Public Property dOffsetX As Double + Get + Return m_dOffsetX + End Get + Set(value As Double) + m_dOffsetX = value + End Set + End Property + + Public Property dOffsetY As Double + Get + Return m_dOffsetY + End Get + Set(value As Double) + m_dOffsetY = value + End Set + End Property + + Public Property nPos As Integer + Get + Return m_nPos + End Get + Set(value As Integer) + m_nPos = value + End Set + End Property + + Public Property nIndexRef As Integer + Get + Return m_nIndexRef + End Get + Set(value As Integer) + m_nIndexRef = value + End Set + End Property + + Public ReadOnly Property Name As String + Get + Return "REF_" & m_nIndexRef.ToString() + End Get + End Property + + Public ReadOnly bOk As Boolean = True + + Sub New(sStringFromIni As String, IndexRef As Integer) + Dim sItems() As String = sStringFromIni.Split(","c) + If sItems.Count = 3 Then + bOk = bOk And StringToLen(sItems(0), m_dOffsetX) + bOk = bOk And StringToLen(sItems(1), m_dOffsetY) + bOk = bOk And StringToInt(sItems(2), m_nPos) + m_nIndexRef = IndexRef + Else + bOk = False + End If + End Sub + +End Class \ No newline at end of file diff --git a/RawPhoto/RawPartPageUC.xaml.vb b/RawPhoto/RawPartPageUC.xaml.vb index 3956bc5..8f1a7f9 100644 --- a/RawPhoto/RawPartPageUC.xaml.vb +++ b/RawPhoto/RawPartPageUC.xaml.vb @@ -1,4 +1,5 @@ Imports System.IO +Imports System.Reflection Imports EgtUILib Imports EgtWPFLib @@ -92,10 +93,12 @@ Public Class RawPartPageUC ' Riferimento grezzo Private m_bEnableOtherRefTab As Boolean = False Private m_bOtherRefTab As Boolean - Public m_OtherRefTabX As Double = 0 - Public m_OtherRefTabY As Double = 0 - Public m_OtherRefTabList(3) As String - Public m_OtherRefTabPos As Integer = 0 + Public m_OtherRefTabX As Double = 0 ' offset riferimento corrente + Public m_OtherRefTabY As Double = 0 ' offset riferimento corrente + Public m_OtherRefTabPos As Integer = 0 ' poisizione riferimento (Bottom-Left, ..) + Public m_OtherRefTabOrientationList(3) As String ' oriemtazione riferiemnto + Public m_OtherRefTabList As New List(Of ReferenceTable) ' lista dei riferiemneti configurata nel programma + Public m_CurrRefTab As Integer = 1 ' inidice del riferimento della lista corrente Private m_nOtherRefTabLay As Integer = GDB_ID.NULL Private m_OtherRefTabPoint As Point3d @@ -126,7 +129,7 @@ Public Class RawPartPageUC FROM_SAW = 7 End Enum - Private Enum OTHERREFMODE As Integer + Friend Enum OTHERREFMODE As Integer BL = 0 BR = 1 TR = 2 @@ -182,10 +185,10 @@ Public Class RawPartPageUC RawModeCmBx.ItemsSource = m_RawModeList ' Creo la lista dei riferimenti tavola - m_OtherRefTabList(OTHERREFMODE.BL) = "Bottom left" - m_OtherRefTabList(OTHERREFMODE.BR) = "Bottom right" - m_OtherRefTabList(OTHERREFMODE.TR) = "Top right" - m_OtherRefTabList(OTHERREFMODE.TL) = "Top left" + m_OtherRefTabOrientationList(OTHERREFMODE.BL) = "Bottom left" + m_OtherRefTabOrientationList(OTHERREFMODE.BR) = "Bottom right" + m_OtherRefTabOrientationList(OTHERREFMODE.TR) = "Top right" + m_OtherRefTabOrientationList(OTHERREFMODE.TL) = "Top left" ' lista per selezione RawModeDamaged m_RawModeDamagedList(0) = EgtMsg(MSG_RAWPARTPAGEUC + 2) 'Per Punti @@ -400,9 +403,36 @@ Public Class RawPartPageUC OtherRefTabBtn.Visibility = Visibility.Visible End If m_bOtherRefTab = (GetPrivateProfileInt(S_RAWPART, K_OTHERREFTAB, 0, m_MainWindow.GetIniFile()) <> 0) - m_OtherRefTabX = GetPrivateProfileDouble(S_RAWPART, K_OTHERREFTABX, 0, m_MainWindow.GetIniFile()) - m_OtherRefTabY = GetPrivateProfileDouble(S_RAWPART, K_OTHERREFTABY, 0, m_MainWindow.GetIniFile()) - m_OtherRefTabPos = GetPrivateProfileInt(S_RAWPART, K_OTHERREFTABPOS, 0, m_MainWindow.GetIniFile()) + ' Recupero il riferimento attivo + m_CurrRefTab = GetPrivateProfileInt(S_RAWPART, K_CURRENTREFTAB, 0, m_MainWindow.GetIniFile()) + ' carico l'elenco dei riferimenti da usare + LoadRefTabList() + ' Solo se non esiste una lista allora leggo i valori + If m_OtherRefTabList.Count = 0 Then + ' Versione precedente 2.7c# DEPRECABILE + Dim Off_X As Double = -1000 + Dim Off_Y As Double = -1000 + Dim Pos_Ind As Integer = -1 + Off_X = GetPrivateProfileDouble(S_RAWPART, K_OTHERREFTABX, -1000, m_MainWindow.GetIniFile()) + Off_Y = GetPrivateProfileDouble(S_RAWPART, K_OTHERREFTABY, -1000, m_MainWindow.GetIniFile()) + Pos_Ind = GetPrivateProfileInt(S_RAWPART, K_OTHERREFTABPOS, -1, m_MainWindow.GetIniFile()) + If Off_X <> -1000 And Off_Y <> -1000 And Pos_Ind <> -1 Then + Dim Local_Text As String = DoubleToString(Off_X, 2) & "," & DoubleToString(Off_Y, 2) & "," & Pos_Ind.ToString + Dim local_NewRef As New ReferenceTable(Local_Text, 0) + If local_NewRef.bOk Then + m_OtherRefTabList.Add(local_NewRef) + m_CurrRefTab = 0 + ' Carico i valori + m_OtherRefTabX = m_OtherRefTabList(m_CurrRefTab).dOffsetX + m_OtherRefTabY = m_OtherRefTabList(m_CurrRefTab).dOffsetY + m_OtherRefTabPos = m_OtherRefTabList(m_CurrRefTab).nPos + ' Creo la nuova configurazione da usare + Dim sKeyMsg As String = K_REFTAB & m_CurrRefTab.ToString + Dim sValMsg As String = DoubleToString(m_OtherRefTabX, 2) & "," & DoubleToString(m_OtherRefTabY, 2) & "," & m_OtherRefTabPos.ToString + WritePrivateProfileString(S_RAWPART, sKeyMsg, sValMsg, m_MainWindow.GetIniFile()) + End If + End If + End If ' RefTabPosCmbx.SelectedIndex = m_OtherRefTabPos OtherRefTabChBx.IsChecked = m_bOtherRefTab ' se riferimento tavola differente da quello atteso @@ -421,6 +451,29 @@ Public Class RawPartPageUC ' EgtDraw() End Sub + Private Sub LoadRefTabList() + m_OtherRefTabList.Clear() + Dim sRefTab As String = String.Empty + Dim nIndex As Integer = 0 + While GetPrivateProfileString(S_RAWPART, K_REFTAB & nIndex.ToString, "", sRefTab, m_MainWindow.GetIniFile()) > 0 + Dim local_NewRef As New ReferenceTable(sRefTab, nIndex) + If local_NewRef.bOk Then + m_OtherRefTabList.Add(local_NewRef) + nIndex += 1 + Else + EgtOutLog("ERROR in reading RefTab" & nIndex.ToString & " is not correctly defined in file OmagCUT.ini, any other reference will not loaded") + Exit While + End If + End While + ' Assegno il riferimento corrente + If m_CurrRefTab < m_OtherRefTabList.Count Then + m_OtherRefTabX = m_OtherRefTabList(m_CurrRefTab).dOffsetX + m_OtherRefTabY = m_OtherRefTabList(m_CurrRefTab).dOffsetY + m_OtherRefTabPos = m_OtherRefTabList(m_CurrRefTab).nPos + End If + + End Sub + Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseDownScene ' Verifico di essere il gestore attivo If Not m_bActive Then Return @@ -2369,8 +2422,10 @@ Public Class RawPartPageUC End Sub Private Sub OtherRefTabBtn_Click(sender As Object, e As EventArgs) Handles OtherRefTabBtn.Click + ' Aggiorno la lista dei riferimenti + LoadRefTabList() ' apro la finestra per gestire il riferimento - Dim OthWD As New OtherRefTabWD(m_MainWindow, LenToString(m_OtherRefTabX, 2), LenToString(m_OtherRefTabY, 2), m_RawOffsX, m_RawOffsY, m_OtherRefTabPos) + Dim OthWD As New OtherRefTabWD(m_MainWindow, LenToString(m_OtherRefTabX, 2), LenToString(m_OtherRefTabY, 2), m_RawOffsX, m_RawOffsY, m_OtherRefTabPos, m_CurrRefTab) OthWD.ShowDialog() End Sub