From c458f1cd1db282aa731d673d063202d3635127a0 Mon Sep 17 00:00:00 2001 From: Andy <88590076+AAndyProgram@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:34:53 +0300 Subject: [PATCH] 2023.12.26.0 SiteEditorForm: sort controls only if some of them have numbers UserCreatorForm: reset site options for new user only; add host reset when changing account for created user PropertyValueHost: add 'UpdateMember' function SettingsHost: add 'DefaultInstanceChanged' function to update properties when setting default instance SettingsHostCollection: update properties when setting default instance --- SCrawler/API/Base/UserDataBase.vb | 2 +- SCrawler/Editors/SiteEditorForm.vb | 2 +- SCrawler/Editors/UserCreatorForm.vb | 3 ++- SCrawler/MainFrameObjects.vb | 4 ++-- .../Hosts/PropertyValueHost.vb | 23 +++++++++++++++---- .../PluginsEnvironment/Hosts/SettingsHost.vb | 3 +++ .../Hosts/SettingsHostCollection.vb | 2 +- 7 files changed, 28 insertions(+), 11 deletions(-) diff --git a/SCrawler/API/Base/UserDataBase.vb b/SCrawler/API/Base/UserDataBase.vb index c6d06d5..eae3aab 100644 --- a/SCrawler/API/Base/UserDataBase.vb +++ b/SCrawler/API/Base/UserDataBase.vb @@ -205,7 +205,7 @@ Namespace API.Base If Not h Is Nothing Then _HostKey = h.Key End Set End Property - Private Sub ResetHost() + Friend Sub ResetHost() _HostObtained = False End Sub Friend Property HostStatic As Boolean = False Implements IUserData.HostStatic diff --git a/SCrawler/Editors/SiteEditorForm.vb b/SCrawler/Editors/SiteEditorForm.vb index 5bbbaba..1197869 100644 --- a/SCrawler/Editors/SiteEditorForm.vb +++ b/SCrawler/Editors/SiteEditorForm.vb @@ -213,7 +213,7 @@ Namespace Editors Dim loAdded As Boolean = False Dim pArr() As Boolean If .PropList.Exists(Function(p) If(p.Options?.IsAuth, False)) Then pArr = {True, False} Else pArr = {False} - .PropList.Sort() + If .PropList.Exists(Function(p) p.ControlNumber >= 0) Then .PropList.Sort() For Each pAuth As Boolean In pArr For Each prop As PropertyValueHost In .PropList If Not prop.Options Is Nothing Then diff --git a/SCrawler/Editors/UserCreatorForm.vb b/SCrawler/Editors/UserCreatorForm.vb index d4fbd2d..91762ef 100644 --- a/SCrawler/Editors/UserCreatorForm.vb +++ b/SCrawler/Editors/UserCreatorForm.vb @@ -430,6 +430,7 @@ Namespace Editors If Not UserInstance Is Nothing Then With DirectCast(UserInstance, UserDataBase) .User = User + .ResetHost() Dim setFriendly As Boolean = True If FriendlyNameIsSiteName Then If Not FriendlyNameChanged Then @@ -590,7 +591,7 @@ CloseForm: End Sub Private _AccountsRefilling As Boolean = False Private Sub CMB_ACCOUNT_ActionSelectedItemChanged(ByVal Sender As Object, ByVal e As EventArgs, ByVal Item As ListViewItem) Handles CMB_ACCOUNT.ActionSelectedItemChanged - If Not _AccountsRefilling Then SetParamsBySite(False) + If Not _AccountsRefilling And UserInstance Is Nothing Then SetParamsBySite(False) End Sub Private Sub CH_TEMP_CheckedChanged(sender As Object, e As EventArgs) Handles CH_TEMP.CheckedChanged If CH_TEMP.Checked Then CH_FAV.Checked = False : CH_READY_FOR_DOWN.Checked = False diff --git a/SCrawler/MainFrameObjects.vb b/SCrawler/MainFrameObjects.vb index 242e17f..13d300a 100644 --- a/SCrawler/MainFrameObjects.vb +++ b/SCrawler/MainFrameObjects.vb @@ -21,8 +21,8 @@ Friend Class MainFrameObjects : Implements INotificator PauseButtons = New DownloadObjects.AutoDownloaderPauseButtons(DownloadObjects.AutoDownloaderPauseButtons.ButtonsPlace.MainFrame) ProgramLogInitialize() With ProgramLog - AddHandler ProgramLog.TextAdded, AddressOf ProgramLog_TextAdded - AddHandler ProgramLog.TextCleared, AddressOf ProgramLog_TextCleared + AddHandler .TextAdded, AddressOf ProgramLog_TextAdded + AddHandler .TextCleared, AddressOf ProgramLog_TextCleared End With End Sub #Region "Users" diff --git a/SCrawler/PluginsEnvironment/Hosts/PropertyValueHost.vb b/SCrawler/PluginsEnvironment/Hosts/PropertyValueHost.vb index 27da12b..4a78799 100644 --- a/SCrawler/PluginsEnvironment/Hosts/PropertyValueHost.vb +++ b/SCrawler/PluginsEnvironment/Hosts/PropertyValueHost.vb @@ -23,6 +23,7 @@ Namespace Plugin.Hosts Private ReadOnly Keeper As SettingsHost Protected Source As Object 'ReadOnly Protected Member As MemberInfo + Private ReadOnly MemberRef As MemberInfo Friend ReadOnly Options As PropertyOption Friend Overridable ReadOnly Property Name As String Protected _Type As Type @@ -41,7 +42,7 @@ Namespace Plugin.Hosts #End Region #Region "Control" Friend Property Control As Control - Protected ControlNumber As Integer = -1 + Friend Property ControlNumber As Integer = -1 Friend ReadOnly Property ControlHeight As Integer Get If Not Control Is Nothing Then @@ -245,13 +246,12 @@ Namespace Plugin.Hosts Me.Keeper = Keeper Source = PropertySource Name = Member.Name + MemberRef = Member ControlNumber = If(Member.GetCustomAttribute(Of ControlNumber)()?.PropertyNumber, -1) If DirectCast(Member, PropertyInfo).PropertyType Is GetType(PropertyValue) Then - ExternalValue = DirectCast(DirectCast(Member, PropertyInfo).GetValue(Source), PropertyValue) - _Value = ExternalValue.Value - AddHandler ExternalValue.ValueChanged, AddressOf ExternalValueChanged + UpdateMember() Options = Member.GetCustomAttribute(Of PropertyOption)() IsTaskCounter = Not Member.GetCustomAttribute(Of TaskCounter)() Is Nothing _XmlName = If(Member.GetCustomAttribute(Of PXML)()?.ElementName, String.Empty) @@ -274,9 +274,22 @@ Namespace Plugin.Hosts Next End If End Sub + Friend Sub UpdateMember() + If Not ExternalValue Is Nothing Then + Try : RemoveHandler ExternalValue.ValueChanged, AddressOf ExternalValueChanged : Catch : End Try + End If + _ExternalValue = DirectCast(DirectCast(MemberRef, PropertyInfo).GetValue(Source), PropertyValue) + _Value = ExternalValue.Value + AddHandler ExternalValue.ValueChanged, AddressOf ExternalValueChanged + End Sub #End Region #Region "Value" - Protected ReadOnly Property ExternalValue As PropertyValue + Private _ExternalValue As PropertyValue = Nothing + Private ReadOnly Property ExternalValue As PropertyValue + Get + Return _ExternalValue + End Get + End Property Friend ReadOnly Property XValue As IXMLValue Protected _Value As Object Friend Overloads Property Value As Object Implements IPropertyValue.Value diff --git a/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb b/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb index f013bc5..d0a99f5 100644 --- a/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb +++ b/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb @@ -143,6 +143,9 @@ Namespace Plugin.Hosts End Set End Property Friend ReadOnly Property [Default] As Boolean + Friend Sub DefaultInstanceChanged() + If PropList.Count > 0 Then PropList.ForEach(Sub(p) p.UpdateMember()) + End Sub Friend ReadOnly Property IsSeparatedTasks As Boolean = False Friend ReadOnly Property IsSavedPostsCompatible As Boolean = False Private ReadOnly _TaskCountDefined As Integer? = Nothing diff --git a/SCrawler/PluginsEnvironment/Hosts/SettingsHostCollection.vb b/SCrawler/PluginsEnvironment/Hosts/SettingsHostCollection.vb index 27229db..a9dee00 100644 --- a/SCrawler/PluginsEnvironment/Hosts/SettingsHostCollection.vb +++ b/SCrawler/PluginsEnvironment/Hosts/SettingsHostCollection.vb @@ -122,7 +122,7 @@ Namespace Plugin.Hosts AddHandler Host.OkClick, AddressOf Hosts_OkClick AddHandler Host.Deleted, AddressOf Hosts_Deleted AddHandler Host.CloneClick, AddressOf Hosts_CloneClick - If Host.Index > 0 Then Host.Source.DefaultInstance = [Default].Source + If Host.Index > 0 Then Host.Source.DefaultInstance = [Default].Source : Host.DefaultInstanceChanged() End Sub Private Sub Hosts_OkClick(ByVal Obj As SettingsHost) If Obj.Index = -1 Then