2023.9.29.0

UserDataBind: fix labels, colors, script when adding a new user
UserCreatorForm: fix labels issue
This commit is contained in:
Andy
2023-09-29 16:24:43 +03:00
parent f4eb33d8da
commit 7f1ac6f512
2 changed files with 27 additions and 18 deletions

View File

@@ -291,7 +291,7 @@ Namespace API
End Property End Property
Friend Overrides Property ScriptUse As Boolean Friend Overrides Property ScriptUse As Boolean
Get Get
Return Count > 0 AndAlso Collections.Exists(Function(c) c.ScriptUse) Return Count > 0 AndAlso Collections.All(Function(c) c.ScriptUse)
End Get End Get
Set(ByVal u As Boolean) Set(ByVal u As Boolean)
If Count > 0 Then Collections.ForEach(Sub(ByVal c As IUserData) If Count > 0 Then Collections.ForEach(Sub(ByVal c As IUserData)
@@ -499,20 +499,20 @@ Namespace API
Friend Overloads Sub Add(ByVal _Item As IUserData) Implements ICollection(Of IUserData).Add Friend Overloads Sub Add(ByVal _Item As IUserData) Implements ICollection(Of IUserData).Add
With _Item With _Item
If .MoveFiles(CollectionName, CollectionPath) Then If .MoveFiles(CollectionName, CollectionPath) Then
If Not _Item.IsVirtual And DataMerging Then DirectCast(.Self, UserDataBase).MergeData() If Not .Self.IsVirtual And DataMerging Then DirectCast(.Self, UserDataBase).MergeData()
Collections.Add(_Item) ConsolidateLabels(.Self)
ConsolidateScripts(.Self)
ConsolidateColors(.Self)
Collections.Add(.Self)
With Collections.Last With Collections.Last
If Count > 1 Then
If _CollectionName.IsEmptyString Then _CollectionName = .CollectionName If _CollectionName.IsEmptyString Then _CollectionName = .CollectionName
.Temporary = Temporary .Temporary = Temporary
.Favorite = Favorite .Favorite = Favorite
.ReadyForDownload = ReadyForDownload .ReadyForDownload = ReadyForDownload
ConsolidateLabels(_Item) .UpdateUserInformation()
ConsolidateScripts()
ConsolidateColors(_Item) MainFrameObj.ImageHandler(.Self, False)
.UpdateUserInformation()
End If
MainFrameObj.ImageHandler(_Item, False)
AddRemoveBttDeleteHandler(.Self, True) AddRemoveBttDeleteHandler(.Self, True)
AddHandler .Self.UserUpdated, AddressOf User_OnUserUpdated AddHandler .Self.UserUpdated, AddressOf User_OnUserUpdated
End With End With
@@ -550,8 +550,12 @@ Namespace API
Private Sub ConsolidateLabels(ByVal Destination As UserDataBase) Private Sub ConsolidateLabels(ByVal Destination As UserDataBase)
UpdateLabels(If(Destination, Me), ListAddList(Nothing, Labels.ListWithRemove(SpecialLabels)), 1, True) UpdateLabels(If(Destination, Me), ListAddList(Nothing, Labels.ListWithRemove(SpecialLabels)), 1, True)
End Sub End Sub
Private Sub ConsolidateScripts() Private Sub ConsolidateScripts(ByVal Destination As UserDataBase)
If Count > 1 AndAlso ScriptUse Then Collections.ForEach(Sub(c) c.ScriptUse = True) If Count > 0 AndAlso ScriptUse Then
Dim __scriptData$ = Collections(0).ScriptData
Destination.ScriptUse = True
If Collections.All(Function(c) c.ScriptData = __scriptData) Then Destination.ScriptData = __scriptData
End If
End Sub End Sub
Private Sub ConsolidateColors(ByVal Destination As UserDataBase) Private Sub ConsolidateColors(ByVal Destination As UserDataBase)
If Count > 0 And Not Destination.ForeColor.HasValue And Not Destination.BackColor.HasValue Then If Count > 0 And Not Destination.ForeColor.HasValue And Not Destination.BackColor.HasValue Then

View File

@@ -120,6 +120,7 @@ Namespace Editors
Private SpecialPathHandler As PathMoverHandler = Nothing Private SpecialPathHandler As PathMoverHandler = Nothing
Friend ReadOnly Property UserLabels As List(Of String) Friend ReadOnly Property UserLabels As List(Of String)
Private LabelsIncludeSpecial As Boolean = False Private LabelsIncludeSpecial As Boolean = False
Private LabelsChanged As Boolean = False
#End Region #End Region
#Region "Initializers" #Region "Initializers"
''' <summary>Create new user</summary> ''' <summary>Create new user</summary>
@@ -327,6 +328,8 @@ Namespace Editors
FriendlyNameChanged = False FriendlyNameChanged = False
Catch ex As Exception Catch ex As Exception
MyDef.InvokeLoaderError(ex) MyDef.InvokeLoaderError(ex)
Finally
LabelsChanged = False
End Try End Try
End Sub End Sub
Private Sub UserCreatorForm_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown Private Sub UserCreatorForm_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
@@ -367,7 +370,7 @@ Namespace Editors
End If End If
End If End If
If Not .Labels.ListEquals(UserLabels) Then _ If LabelsChanged Then _
UserDataBase.UpdateLabels(.Self, UserLabels, 1, UserDataBase.UpdateLabels(.Self, UserLabels, 1,
Not DirectCast(.Self, UserDataBase).SpecialLabels.ListExists OrElse Not DirectCast(.Self, UserDataBase).SpecialLabels.ListExists OrElse
UserDataBase.UpdateLabelsKeepSpecial(1)) UserDataBase.UpdateLabelsKeepSpecial(1))
@@ -596,7 +599,7 @@ CloseForm:
Private Sub TXT_LABELS_ActionOnButtonClick(ByVal Sender As ActionButton, ByVal e As EventArgs) Handles TXT_LABELS.ActionOnButtonClick Private Sub TXT_LABELS_ActionOnButtonClick(ByVal Sender As ActionButton, ByVal e As EventArgs) Handles TXT_LABELS.ActionOnButtonClick
Select Case Sender.DefaultButton Select Case Sender.DefaultButton
Case ADB.Open : ChangeLabels() Case ADB.Open : ChangeLabels()
Case ADB.Clear : UserLabels.Clear() Case ADB.Clear : UserLabels.Clear() : LabelsChanged = True
Case ADB.Refresh : UpdateSpecificLabels(False) Case ADB.Refresh : UpdateSpecificLabels(False)
End Select End Select
End Sub End Sub
@@ -784,8 +787,10 @@ CloseForm:
Using fl As New LabelsForm(UserLabels) Using fl As New LabelsForm(UserLabels)
fl.ShowDialog() fl.ShowDialog()
If fl.DialogResult = DialogResult.OK Then If fl.DialogResult = DialogResult.OK Then
LabelsChanged = True
UserLabels.ListAddList(fl.LabelsList, LAP.NotContainsOnly, LAP.ClearBeforeAdd) UserLabels.ListAddList(fl.LabelsList, LAP.NotContainsOnly, LAP.ClearBeforeAdd)
If UserLabels.ListExists Then If UserLabels.ListExists Then
UserLabels.Sort()
TXT_LABELS.Text = UserLabels.ListToString TXT_LABELS.Text = UserLabels.ListToString
Else Else
TXT_LABELS.Clear() TXT_LABELS.Clear()