From 5cfc72be27681812199b9ba326f0b285d6d93906 Mon Sep 17 00:00:00 2001 From: Nicola Pievani Date: Fri, 17 Jan 2025 16:25:51 +0100 Subject: [PATCH] Gestione PNG/SVG da variabile MainWindow --- CadCuts/SelParkIndWD.xaml | 6 ++-- CadCuts/SelParkIndWD.xaml.vb | 54 +++++++++++++++++++-------------- DrawImport/DrawPageUC.xaml.vb | 37 ++++++++++++---------- DrawImport/ImportPageUC.xaml.vb | 39 ++++++++++++------------ MainWindow.xaml.vb | 2 ++ Project/ProjectMgrUC.xaml.vb | 13 +++++--- 6 files changed, 84 insertions(+), 67 deletions(-) diff --git a/CadCuts/SelParkIndWD.xaml b/CadCuts/SelParkIndWD.xaml index c30857a..170b047 100644 --- a/CadCuts/SelParkIndWD.xaml +++ b/CadCuts/SelParkIndWD.xaml @@ -68,9 +68,9 @@ - - - + + + diff --git a/CadCuts/SelParkIndWD.xaml.vb b/CadCuts/SelParkIndWD.xaml.vb index debb252..1fb287d 100644 --- a/CadCuts/SelParkIndWD.xaml.vb +++ b/CadCuts/SelParkIndWD.xaml.vb @@ -283,6 +283,8 @@ End Class Public Class ParkInd Implements INotifyPropertyChanged + Private m_VisbilityAllOff As Visibility = Visibility.Hidden + Private m_Ind As Integer Public Property Ind As Integer Get @@ -310,7 +312,7 @@ Public Class ParkInd End Get Set(value As String) m_Img = value - NotifyPropertyChanged("MyVisibility") + NotifyPropertyChanged("MyVisibilityImg") End Set End Property @@ -389,31 +391,31 @@ Public Class ParkInd End Get End Property - Public ReadOnly Property MyVisibility As Visibility + Public ReadOnly Property MyVisibilityTmg As Visibility Get Return If(Not System.IO.File.Exists(m_Img), Visibility.Collapsed, Visibility.Visible) End Get End Property + Public ReadOnly Property MyVisibilitySvg As Visibility + Get + Return If(Not System.IO.File.Exists(m_Svg), Visibility.Collapsed, Visibility.Visible) + End Get + End Property + Public ReadOnly Property TitleVisibility As Visibility Get - Return If(m_Ind = 999, Visibility.Collapsed, Visibility.Visible) + Return If(m_Ind = 999, m_VisbilityAllOff, Visibility.Visible) End Get End Property - Private m_LocalCanvas As MyCanvas - Public ReadOnly Property LocalCanvas As Canvas - Get - Return m_LocalCanvas.CurrCanvas - End Get - End Property + Private m_LocalMyCanvas As MyCanvas Public ReadOnly Property LocalMyCanvas As MyCanvas Get - Return m_LocalCanvas + Return m_LocalMyCanvas End Get End Property - Sub New(Ind As Integer, Name As String, Stat As Integer) m_Ind = Ind m_Name = Name @@ -421,28 +423,34 @@ Public Class ParkInd ' Costruisco il percorso immagine If m_Ind = 0 Then ' Se Ind=0 allora applico il default: C:\EgtData\OmagCUT\Resources\MachineButtonsImage\NewIcons - ' m_Img = DirectCast(Application.Current.MainWindow, MainWindow).GetResourcesDir() & "\MachineButtonsImage\NewIcons\Park_On.png" + m_Img = DirectCast(Application.Current.MainWindow, MainWindow).GetResourcesDir() & "\MachineButtonsImage\NewIcons\Park_On.png" m_Svg = DirectCast(Application.Current.MainWindow, MainWindow).GetResourcesDir() & "\MachineButtonsImage\NewIcons\Park_On.svg" ElseIf m_Ind = 999 Then ' Se Ind=0 allora applico il default: C:\EgtData\OmagCUT\Resources\MachineButtonsImage\NewIcons - ' m_Img = DirectCast(Application.Current.MainWindow, MainWindow).GetResourcesDir() & "\MachineButtonsImage\NewIcons\Park_Off.png" + m_Img = DirectCast(Application.Current.MainWindow, MainWindow).GetResourcesDir() & "\MachineButtonsImage\NewIcons\Park_Off.png" m_Svg = DirectCast(Application.Current.MainWindow, MainWindow).GetResourcesDir() & "\MachineButtonsImage\NewIcons\Park_Off.svg" Else - ' m_Img = SelParkIndWD.GetPathCurrProj() & m_Ind.ToString & ".png" + m_Img = SelParkIndWD.GetPathCurrProj() & m_Ind.ToString & ".png" m_Svg = SelParkIndWD.GetPathCurrProj() & m_Ind.ToString & ".svg" End If - m_LocalCanvas = New MyCanvas(120, 70) - If System.IO.File.Exists(m_Svg) Then - ReadMyXML(m_Svg, m_LocalCanvas) + If MainWindow.m_bShowSVGParkInd Then + Dim CanvWidth As Integer = 145 + Dim CanvHeight As Integer = CInt(CanvWidth / 1.4) + m_LocalMyCanvas = New MyCanvas(CanvWidth, CanvHeight) + If System.IO.File.Exists(m_Svg) Then + ReadMyXML(m_Svg, m_LocalMyCanvas) + m_Img = "" + End If + Else + m_Svg = "" End If ' Conto il numero di pezzi in Tavola CountPartInTable() ' Conto il numero di pezzi in parcheggio CountPartInPark() - ' Riassegno il nome del parcheggio - m_Name = "TAB:" & m_nPartInTable.ToString & " PRK:" & m_nPartInPark.ToString + End Sub ' Conta in numero di pezzi di questo parcheggio in Tavola @@ -476,7 +484,7 @@ Public Class ParkInd End Sub Private Sub UpdateEntInCanvas(nPartId, dOpacity) - If Not IsNothing(m_LocalCanvas) Then + If Not IsNothing(m_LocalMyCanvas) Then ' modifico il colore del pezzo nel SVG Dim nIdRegion As Integer = EgtGetFirstNameInGroup(nPartId, "Region") If nIdRegion <> GDB_ID.NULL Then @@ -489,12 +497,12 @@ Public Class ParkInd If nIdEnt <> GDB_ID.NULL Then Dim sName As String = "" EgtGetName(nIdEnt, sName) - Dim Idpath As MyPath = m_LocalCanvas.ListPath.Find(Function(x) x.id = sName) + Dim Idpath As MyPath = m_LocalMyCanvas.ListPath.Find(Function(x) x.id = sName) If Not IsNothing(Idpath) Then Idpath.fill_opacity = dOpacity - m_LocalCanvas.UpdateMyPath(Idpath) + m_LocalMyCanvas.UpdateMyPath(Idpath) Idpath.LoadPath() - NotifyPropertyChanged(NameOf(LocalCanvas)) + NotifyPropertyChanged(NameOf(LocalMyCanvas)) End If End If End If diff --git a/DrawImport/DrawPageUC.xaml.vb b/DrawImport/DrawPageUC.xaml.vb index 60b811f..34c879d 100644 --- a/DrawImport/DrawPageUC.xaml.vb +++ b/DrawImport/DrawPageUC.xaml.vb @@ -1175,22 +1175,6 @@ Public Class DrawPageUC ' Se errore esco If Not m_bDrawOk Then Return - ' Aggiorno la gestione dei parcheggi: spengo tutti i parcheggi tranne quello dei pezzi disegnati "0" - Dim ListParkInd As New List(Of ParkInd) - SelParkIndWD.LoadParkInd(ListParkInd) - For Each ItemParkInd As ParkInd In ListParkInd - If ItemParkInd.Ind = 0 Then - ItemParkInd.Status = GDB_ST.ON_ - Else - ItemParkInd.Status = GDB_ST.OFF - End If - Next - ' Aggiorno lo stato dei pezzi - For Each Item As ParkInd In ListParkInd - SelParkIndWD.SetStatusPartInParkInd(Item, False) - Next - - ' Nome pezzo Dim sPartName As String = PartNameTxBx.Text ' Leggo numero di pezzi da inserire @@ -1222,6 +1206,9 @@ Public Class DrawPageUC m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_DrawPageUC) m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_CurrentProjectPageUC) m_MainWindow.m_ActivePage = If(m_MainWindow.FrameCutBtn.IsChecked, MainWindow.Pages.FrameCut, MainWindow.Pages.CadCut) + ' Attivo il parcheggio dei pezzi Draw + ActivateParkIndZero() + Else m_SceneButtons.MeasureBtn.IsChecked = False DrawPage_Unloaded(sender, e) @@ -1256,6 +1243,24 @@ Public Class DrawPageUC m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_DrawPageUC) m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_CurrentProjectPageUC) m_MainWindow.m_ActivePage = If(m_MainWindow.FrameCutBtn.IsChecked, MainWindow.Pages.FrameCut, MainWindow.Pages.CadCut) + + End Sub + + Private Sub ActivateParkIndZero() + ' Aggiorno la gestione dei parcheggi: spengo tutti i parcheggi tranne quello dei pezzi disegnati "0" + Dim ListParkInd As New List(Of ParkInd) + SelParkIndWD.LoadParkInd(ListParkInd) + For Each ItemParkInd As ParkInd In ListParkInd + If ItemParkInd.Ind = 0 Then + ItemParkInd.Status = GDB_ST.ON_ + Else + ItemParkInd.Status = GDB_ST.OFF + End If + Next + ' Aggiorno lo stato dei pezzi + For Each Item As ParkInd In ListParkInd + SelParkIndWD.SetStatusPartInParkInd(Item, False) + Next End Sub Private Sub TrfDataBtn_Click(sender As Object, e As RoutedEventArgs) Handles TrfDataBtn.Click diff --git a/DrawImport/ImportPageUC.xaml.vb b/DrawImport/ImportPageUC.xaml.vb index d799257..29f55ee 100644 --- a/DrawImport/ImportPageUC.xaml.vb +++ b/DrawImport/ImportPageUC.xaml.vb @@ -914,8 +914,7 @@ Public Class ImportPageUC Dim dW As Integer = 120 Dim dH As Integer = 120 - Dim bPrintImgPNG As Boolean = False - If bPrintImgPNG Then + If Not MainWindow.m_bShowSVGParkInd Then Try ' Prendo l'immagine corrente per la stampa Dim colBackTopColor As Color3d = GetBackTopColor() @@ -952,26 +951,26 @@ Public Class ImportPageUC ' Rrror in executing print EgtOutLog(EgtMsg(50182)) End Try - End If - - ' Assegno dei nomi ai pezzi (Da controllare bene se funzione sempre)...riassegno i nomi dopo? - Dim nIdPart As Integer = EgtGetFirstPart() - Dim nIndex As Integer = 0 - While nIdPart <> GDB_ID.NULL - ' recupero il primo layer del part - Dim nIdLay As Integer = EgtGetFirstLayer(nIdPart) - While nIdLay <> GDB_ID.NULL - Dim nIdEnt As Integer = EgtGetFirstInGroup(nIdLay) - While nIdEnt <> GDB_ID.NULL - EgtSetName(nIdEnt, nIndex.ToString) - nIdEnt = EgtGetNext(nIdEnt) - nIndex = nIndex + 1 + Else + ' Assegno dei nomi ai pezzi (Da controllare bene se funzione sempre)...riassegno i nomi dopo? + Dim nIdPart As Integer = EgtGetFirstPart() + Dim nIndex As Integer = 0 + While nIdPart <> GDB_ID.NULL + ' recupero il primo layer del part + Dim nIdLay As Integer = EgtGetFirstLayer(nIdPart) + While nIdLay <> GDB_ID.NULL + Dim nIdEnt As Integer = EgtGetFirstInGroup(nIdLay) + While nIdEnt <> GDB_ID.NULL + EgtSetName(nIdEnt, nIndex.ToString) + nIdEnt = EgtGetNext(nIdEnt) + nIndex = nIndex + 1 + End While + nIdLay = EgtGetNextLayer(nIdLay) End While - nIdLay = EgtGetNextLayer(nIdLay) + nIdPart = EgtGetNextPart(nIdPart) End While - nIdPart = EgtGetNextPart(nIdPart) - End While - EgtExportSvg(GDB_ID.ROOT, SelParkIndWD.GetPathCurrProj() & NewParkInd.ToString & ".svg") + EgtExportSvg(GDB_ID.ROOT, SelParkIndWD.GetPathCurrProj() & NewParkInd.ToString & ".svg") + End If End Sub diff --git a/MainWindow.xaml.vb b/MainWindow.xaml.vb index cfe9c1d..4db4389 100644 --- a/MainWindow.xaml.vb +++ b/MainWindow.xaml.vb @@ -26,6 +26,8 @@ Class MainWindow ' Variabile che definisce l'avvio forzato in modalità FRAME Friend m_OnlyFrame As Boolean = False + Public Shared m_bShowSVGParkInd As Boolean = True + ' Dichiarazione delle Page UserControl Friend m_WorkInProgressPageUC As WorkInProgressPageUC Friend m_CurrentProjectPageUC As CurrentProjectPageUC diff --git a/Project/ProjectMgrUC.xaml.vb b/Project/ProjectMgrUC.xaml.vb index bd259d5..8b91603 100644 --- a/Project/ProjectMgrUC.xaml.vb +++ b/Project/ProjectMgrUC.xaml.vb @@ -115,11 +115,14 @@ Public Class ProjectMgrUC If ItemParkInd.Ind <> 0 And ItemParkInd.Ind <> 999 And ItemParkInd.nPartInPark > 0 Then Try Dim sNewFile As String = sNewFileName & ItemParkInd.Ind.ToString & Extension - 'If File.Exists(sNewFile) Then - ' File.Delete(sNewFile) - 'End If - 'File.Copy(If(Extension = ".svg", ItemParkInd.Svg, ItemParkInd.Img), sNewFile) - WriteMyXML(sNewFile, ItemParkInd.LocalMyCanvas) + If MainWindow.m_bShowSVGParkInd Then + WriteMyXML(sNewFile, ItemParkInd.LocalMyCanvas) + Else + If File.Exists(sNewFile) Then + File.Delete(sNewFile) + End If + File.Copy(If(Extension = ".svg", ItemParkInd.Svg, ItemParkInd.Img), sNewFile) + End If Catch ex As Exception EgtOutLog("Copia immagine " & If(Extension = ".svg", ItemParkInd.Svg, ItemParkInd.Img) & " di ParkInd non roiscita") End Try