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 0000000..2c1339d Binary files /dev/null and b/Icarus/Resources/EgtDialog/Folder.png differ diff --git a/Icarus/Resources/EgtDialog/New.png b/Icarus/Resources/EgtDialog/New.png new file mode 100644 index 0000000..b618597 Binary files /dev/null and b/Icarus/Resources/EgtDialog/New.png differ diff --git a/Icarus/Resources/EgtDialog/Restore.png b/Icarus/Resources/EgtDialog/Restore.png new file mode 100644 index 0000000..dd24cf1 Binary files /dev/null and b/Icarus/Resources/EgtDialog/Restore.png differ 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