From 6dcaf822a64078ee3879a152e8b06aeecebcfb13 Mon Sep 17 00:00:00 2001 From: Demetrio Cassarino Date: Fri, 21 Jul 2023 16:40:53 +0200 Subject: [PATCH] Creazione finestra di dialogo e aggiornamento rettangoli colore del ColorPicker --- Icarus/EgtColorPicker/EgtColorPickerV.xaml.vb | 84 +- Icarus/EgtColorPicker/EgtColorPickerVM.vb | 31 +- .../EgtManageFileDialogV.xaml | 450 +++++++++ .../EgtManageFileDialogV.xaml.vb | 88 ++ .../EgtManageFileDialogVM.vb | 893 ++++++++++++++++++ Icarus/Icarus.vbproj | 17 + Icarus/ProjManager/ProjManagerVM.vb | 22 +- Icarus/Resources/EgtDialog/Folder.png | Bin 0 -> 1292 bytes Icarus/Resources/EgtDialog/New.png | Bin 0 -> 374 bytes Icarus/Resources/EgtDialog/Restore.png | Bin 0 -> 254 bytes Icarus/SceneHost/MySceneHostVM.vb | 28 +- 11 files changed, 1554 insertions(+), 59 deletions(-) create mode 100644 Icarus/EgtManageFileDialog/EgtManageFileDialogV.xaml create mode 100644 Icarus/EgtManageFileDialog/EgtManageFileDialogV.xaml.vb create mode 100644 Icarus/EgtManageFileDialog/EgtManageFileDialogVM.vb create mode 100644 Icarus/Resources/EgtDialog/Folder.png create mode 100644 Icarus/Resources/EgtDialog/New.png create mode 100644 Icarus/Resources/EgtDialog/Restore.png diff --git a/Icarus/EgtColorPicker/EgtColorPickerV.xaml.vb b/Icarus/EgtColorPicker/EgtColorPickerV.xaml.vb index 1a71587..899a397 100644 --- a/Icarus/EgtColorPicker/EgtColorPickerV.xaml.vb +++ b/Icarus/EgtColorPicker/EgtColorPickerV.xaml.vb @@ -225,54 +225,54 @@ Public Class EgtColorPickerV - ''' - ''' Converte il colore selezionato da HLS ( tonalità, luminosità, saturazione) in RGB - ''' - ''' Tonalità del colore selezionato espressa in double - ''' Luminosità del colore selezionato espressa in double - ''' Saturazione del colore selezionato espressa in double - ''' Colore Rosso restituito dalla funzione espresso in intero - ''' Colore Verde restituito dalla funzione espresso in intero - ''' Colore Blu restituito dalla funzione espresso in intero - Private Shared Sub HlsToRgb(ByVal h As Double, ByVal l As Double, ByVal s As Double, ByRef r As Integer, ByRef g As Integer, ByRef b As Integer) - Dim p2 As Double + '''' + '''' Converte il colore selezionato da HLS ( tonalità, luminosità, saturazione) in RGB + '''' + '''' Tonalità del colore selezionato espressa in double + '''' Luminosità del colore selezionato espressa in double + '''' Saturazione del colore selezionato espressa in double + '''' Colore Rosso restituito dalla funzione espresso in intero + '''' Colore Verde restituito dalla funzione espresso in intero + '''' Colore Blu restituito dalla funzione espresso in intero + 'Private Shared Sub HlsToRgb(ByVal h As Double, ByVal l As Double, ByVal s As Double, ByRef r As Integer, ByRef g As Integer, ByRef b As Integer) + ' Dim p2 As Double - If l <= 0.5 Then - p2 = l * (1 + s) - Else - p2 = l + s - l * s - End If + ' If l <= 0.5 Then + ' p2 = l * (1 + s) + ' Else + ' p2 = l + s - l * s + ' End If - Dim p1 As Double = 2 * l - p2 - Dim double_r, double_g, double_b As Double + ' Dim p1 As Double = 2 * l - p2 + ' Dim double_r, double_g, double_b As Double - If s = 0 Then - double_r = l - double_g = l - double_b = l - Else - double_r = QqhToRgb(p1, p2, h + 120) - double_g = QqhToRgb(p1, p2, h) - double_b = QqhToRgb(p1, p2, h - 120) - End If + ' If s = 0 Then + ' double_r = l + ' double_g = l + ' double_b = l + ' Else + ' double_r = QqhToRgb(p1, p2, h + 120) + ' double_g = QqhToRgb(p1, p2, h) + ' double_b = QqhToRgb(p1, p2, h - 120) + ' End If - r = CInt((double_r * 255.0)) - g = CInt((double_g * 255.0)) - b = CInt((double_b * 255.0)) - End Sub + ' r = CInt((double_r * 255.0)) + ' g = CInt((double_g * 255.0)) + ' b = CInt((double_b * 255.0)) + 'End Sub - Private Shared Function QqhToRgb(ByVal q1 As Double, ByVal q2 As Double, ByVal hue As Double) As Double - If hue > 360 Then - hue -= 360 - ElseIf hue < 0 Then - hue += 360 - End If + 'Private Shared Function QqhToRgb(ByVal q1 As Double, ByVal q2 As Double, ByVal hue As Double) As Double + ' If hue > 360 Then + ' hue -= 360 + ' ElseIf hue < 0 Then + ' hue += 360 + ' End If - If hue < 60 Then Return q1 + (q2 - q1) * hue / 60 - If hue < 180 Then Return q2 - If hue < 240 Then Return q1 + (q2 - q1) * (240 - hue) / 60 - Return q1 - End Function + ' If hue < 60 Then Return q1 + (q2 - q1) * hue / 60 + ' If hue < 180 Then Return q2 + ' If hue < 240 Then Return q1 + (q2 - q1) * (240 - hue) / 60 + ' Return q1 + 'End Function ''' ''' Apre una finestra EgtColorPicker diff --git a/Icarus/EgtColorPicker/EgtColorPickerVM.vb b/Icarus/EgtColorPicker/EgtColorPickerVM.vb index 1c113fb..988a53b 100644 --- a/Icarus/EgtColorPicker/EgtColorPickerVM.vb +++ b/Icarus/EgtColorPicker/EgtColorPickerVM.vb @@ -1,7 +1,6 @@ Imports System.Windows.Forms -Imports EgtWPFLib5 Imports EgtUILib -Imports System.Reflection +Imports EgtWPFLib5 Public Class EgtColorPickerVM Inherits VMBase @@ -223,10 +222,11 @@ Public Class EgtColorPickerVM Set(value As String) If StringToDouble(value, m_Red) And (m_Red >= 0 AndAlso m_Red <= 255) Then UpdateRed(m_Red) - m_Red = value + 'm_Red = value m_Fill = New SolidColorBrush(Color.FromRgb(m_Red, m_Green, m_Blue)) SetCurrColorFill(m_Fill.Color) NotifyPropertyChanged(NameOf(Fill)) + NotifyPropertyChanged(NameOf(Red)) Else NotifyPropertyChanged(NameOf(Red)) End If @@ -244,8 +244,7 @@ Public Class EgtColorPickerVM Return DoubleToString(RgbColor.G, 0) End Get Set(value As String) - If StringToDouble(value, m_Green) And (m_Red >= 0 AndAlso m_Red <= 255) And - (m_Green >= 0 AndAlso m_Green <= 255) And (m_Blue >= 0 AndAlso m_Blue <= 255) Then + If StringToDouble(value, m_Green) And (m_Green >= 0 AndAlso m_Green <= 255) Then UpdateGreen(value) m_Green = value m_Fill = New SolidColorBrush(Color.FromRgb(m_Red, m_Green, m_Blue)) @@ -268,8 +267,7 @@ Public Class EgtColorPickerVM Return DoubleToString(RgbColor.B, 0) End Get Set(value As String) - If StringToDouble(value, m_Blue) And (m_Red >= 0 AndAlso m_Red <= 255) And - (m_Green >= 0 AndAlso m_Green <= 255) And (m_Blue >= 0 AndAlso m_Blue <= 255) Then + If StringToDouble(value, m_Blue) And (m_Blue >= 0 AndAlso m_Blue <= 255) Then UpdateBlue(value) m_Blue = value m_Fill = New SolidColorBrush(Color.FromRgb(m_Red, m_Green, m_Blue)) @@ -521,11 +519,13 @@ Public Class EgtColorPickerVM Dim RGBColor As Color = HSLColor.HslToRgb(m_HSLColor) Dim h, s, l As Double HSLColor.RgbToHsl(Color.FromRgb(value, RGBColor.G, RGBColor.B), h, s, l) + SetRed(value) m_HSLColor.SetHue(h) m_HSLColor.SetSaturation(s) m_HSLColor.SetLightness(l) NotifyPropertyChanged(NameOf(CurrColor)) SetLightnessColor() + UpdateHue() UpdateSaturation() UpdateLightness() NotifyPropertyChanged(NameOf(Red)) @@ -542,6 +542,7 @@ Public Class EgtColorPickerVM m_HSLColor.SetLightness(l) NotifyPropertyChanged(NameOf(CurrColor)) SetLightnessColor() + UpdateHue() UpdateSaturation() UpdateLightness() NotifyPropertyChanged(NameOf(Red)) @@ -559,6 +560,7 @@ Public Class EgtColorPickerVM m_HSLColor.SetLightness(l) NotifyPropertyChanged(NameOf(CurrColor)) SetLightnessColor() + UpdateHue() UpdateSaturation() UpdateLightness() NotifyPropertyChanged(NameOf(Red)) @@ -823,17 +825,22 @@ Public Class HSLColor Dim dRPrimo As Double = r / 255 Dim dGPrimo As Double = g / 255 Dim dBPrimo As Double = b / 255 - Dim CMax As Double = Math.Max(Math.Max(dRPrimo, dGPrimo), dBPrimo) - Dim CMin As Double = Math.Min(Math.Min(dRPrimo, dGPrimo), dBPrimo) + Dim CMax As Double = Math.Max(dRPrimo, Math.Max(dGPrimo, dBPrimo)) + Dim CMin As Double = Math.Min(dRPrimo, Math.Min(dGPrimo, dBPrimo)) Dim Delta As Double = CMax - CMin If Delta = 0 Then h = 0 ElseIf CMax = dRPrimo Then - h = 60 * (((dGPrimo - dBPrimo) / Delta) Mod 6) + Dim hMod = (((dGPrimo - dBPrimo) / Delta) Mod 6) + If hMod < 0 Then + h = 60 * (hMod + 6) + Else + h = 60 * hMod + End If ElseIf CMax = dGPrimo Then - h = 60 * (((dBPrimo - dRPrimo) / Delta) + 2) + h = 60 * ((dBPrimo - dRPrimo) / Delta + 2) ElseIf CMax = dBPrimo Then - h = 60 * (((dRPrimo - dGPrimo) / Delta) + 4) + h = 60 * ((dRPrimo - dGPrimo) / Delta + 4) End If l = (CMax + CMin) / 2 diff --git a/Icarus/EgtManageFileDialog/EgtManageFileDialogV.xaml b/Icarus/EgtManageFileDialog/EgtManageFileDialogV.xaml new file mode 100644 index 0000000..080e0ae --- /dev/null +++ b/Icarus/EgtManageFileDialog/EgtManageFileDialogV.xaml @@ -0,0 +1,450 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Public Sub NewProjectCmd() NewProject(True) + 'Dim x As New OpenFileDialog() + 'x.ShowDialog() + + Dim sDir As String = "C:\EgtData\Test3dPrinting" + Dim od As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With { + .Title = "Open", + .Filter = "Icarus project(*.icrs)|*.icrs" & + "|New geometry EgalTech(*.nge)|*.nge", + .FileName = "New.icrs", + .FilterIndex = 1, + .InitialDirectory = sDir} + od.ShowDialog() + Dim sFilePath As String = od.FileName + + 'Dim save As New EgtSaveDialogV(Application.Current.MainWindow, New EgtSaveDialogVM()) With { + ' .Title = "Save", + ' .Filter = "Icarus project(*.icrs)|*.icrs", + ' .FileName = "New.icrs", + ' .InitialDirectory = sDir} + 'save.ShowDialog() + 'Dim sFilePath As String = save.FileName End Sub Friend Sub NewProject(bDialog As Boolean) diff --git a/Icarus/Resources/EgtDialog/Folder.png b/Icarus/Resources/EgtDialog/Folder.png new file mode 100644 index 0000000000000000000000000000000000000000..2c1339d04ed24a4dbbe8aeecdde99b279336a84f GIT binary patch literal 1292 zcmV+n1@roeP)H7$(J1j1ltl0mh9(YV}ujem zuqFUiOlCOXF?a-UBv>qtKn_C=$kEBh!a>S=0%Zab7K6v41ZpUTm;|AY>-&TkfIbna zt7?5!0BCvx;;bqhLX2RE@Hheyo)&~0hKM?yI3fa;fJZQZ4Gs-4t{MXgR=Ozzt-#`% z9;kW*Pnzoi!P5m)33!U+&YvP=N)`o-r2Z1I7y`yxB&70U9fBgZPV2q`48P0U0E0)R zZQj!+F)f{W@=tuc>mAjRYMKLegn-3hQ8o~0DNWHif18eIn5&N;W`T(6dX(LzOZ1*S z!!zyeqn$tofD}F8Fu0_QSzI7Lbp_e?JT*Ms#B5m)0B3%n_uLF$sbWRMn5+r}MNuq@ zo1P+Hnna#_gmIKAfu8j+J~T!&Jju;3uJWt3)PY>u2RuTQm0t}vHBB@INWFv(T|kb! z&M1NHl{y8dsF$XlY zPRK4NOCwBER085bO}009nL=@%{=p*CKpCj7`bG5Fn{srt#6AG6riv5AdV}lfKy4xI z5iBBgLlP-2ZiK=^WFSg2C2Z`*Bnj^4LHheHak^Ba1kA5Cjzv`wkqGDj+ThNlyGsf{ zH7mQis)n@yNEQyq`jKYMCRytPR__0r-3M^50sIXfKPV$j2v|t~0000>fE=rpRC(t{) z0zlVYX>ba9KNnXZ>Xoev(uOyNHC`sWp783Vxn)nv&WbO zA0@#%8&eGqXl^7%Z(q$@4lniSNon&n)TxW- zjKtbD`bR}ydS}mV8vJXU(camd8{GGt`l`+q<~4D(@qLzrE2nVQ?R6o2_SCMtn#h_0 z2KnhCQd~rei%4-1DJ~+#MWnch6c>@=5=uQ2KaZ6^{2b0B&ZnA~a{mG4c##Ew7Z`C! Uy$xW$X8-^I07*qoM6N<$f-jhw0{{R3 literal 0 HcmV?d00001 diff --git a/Icarus/Resources/EgtDialog/Restore.png b/Icarus/Resources/EgtDialog/Restore.png new file mode 100644 index 0000000000000000000000000000000000000000..dd24cf127a3d9e9957614daf49da9d22d08febfd GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^q9Dw{1|(OCFP#RYI14-?iy0WWg+Q3`(%rg0K*0^3 zE{-7t}$|!u*Hzgq&c8a#G(~hyoYl8#cy{X7 zoj;4%QtT9++0{N8D;$zmpWoPcupz|RTuD7g!{K=|gUt;NDX!C19_#+hpB>*~I`zPT yj6NquVKx6Zza4y?g*(m!vK$mx=_er}!EnaY!1I*WeGj1989ZJ6T-G@yGywqYV_04Q literal 0 HcmV?d00001 diff --git a/Icarus/SceneHost/MySceneHostVM.vb b/Icarus/SceneHost/MySceneHostVM.vb index a09dfcf..6cc15ff 100644 --- a/Icarus/SceneHost/MySceneHostVM.vb +++ b/Icarus/SceneHost/MySceneHostVM.vb @@ -263,7 +263,14 @@ Public Class MySceneHostVM If Not String.IsNullOrWhiteSpace(sDir) Then sDir = Path.GetDirectoryName(sDir) End If - Dim OpenFileDialog As New Windows.Forms.OpenFileDialog With { + 'Dim OpenFileDialog As New Windows.Forms.OpenFileDialog With { + ' .Title = "Open", + ' .Filter = "Icarus project(*.icrs)|*.icrs" & + ' "|New geometry EgalTech(*.nge)|*.nge", + ' .FilterIndex = 1, + ' .InitialDirectory = sDir + '} + Dim OpenFileDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With { .Title = "Open", .Filter = "Icarus project(*.icrs)|*.icrs" & "|New geometry EgalTech(*.nge)|*.nge", @@ -313,12 +320,25 @@ Public Class MySceneHostVM If String.IsNullOrWhiteSpace(sFile) Then sFile = "New.icrs" ' Eventuale sistemazione estensione sFile = IO.Path.ChangeExtension(sFile, "icrs") + Dim sDir As String = MainController.GetCurrFile() + If String.IsNullOrWhiteSpace(sDir) Then + GetMainPrivateProfileString(S_MRUFILES, K_FILE & 1, "", sDir) + End If + If Not String.IsNullOrWhiteSpace(sDir) Then + sDir = Path.GetDirectoryName(sDir) + End If ' Assegnazione nome file con dialogo - Dim SaveFileDialog As New Windows.Forms.SaveFileDialog With { + 'Dim SaveFileDialog As New Windows.Forms.SaveFileDialog With { + ' .Title = "Save", + ' .Filter = "Icarus Project(*.icrs)|*.icrs", + ' .FileName = sFile, + ' .InitialDirectory = IO.Path.GetDirectoryName(sFile) + '} + Dim SaveFileDialog As New EgtManageFileDialogV(Application.Current.MainWindow, New EgtManageFileDialogVM()) With { .Title = "Save", - .Filter = "Icarus Project(*.icrs)|*.icrs", + .Filter = "Icarus project(*.icrs)|*.icrs", .FileName = sFile, - .InitialDirectory = IO.Path.GetDirectoryName(sFile) + .InitialDirectory = sDir } If SaveFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then Dim sFileName As String = SaveFileDialog.FileName