Skip to content

Commit

Permalink
Improve smoothness when refreshing the listings
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleex255 committed Nov 23, 2017
1 parent 3ed5766 commit f9b11ee
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions PolicyPlus/Main.vb
Expand Up @@ -85,8 +85,12 @@ Public Class Main
End Sub
Sub UpdateCategoryListing()
' Update the right pane to include the current category's children
Dim topItemIndex As Integer?
If PoliciesList.TopItem IsNot Nothing Then topItemIndex = PoliciesList.TopItem.Index
Dim inSameCategory As Boolean = False
PoliciesList.Items.Clear()
If CurrentCategory IsNot Nothing Then
If CurrentSetting IsNot Nothing AndAlso CurrentSetting.Category Is CurrentCategory Then inSameCategory = True
If CurrentCategory.Parent IsNot Nothing Then ' Add the parent
Dim listItem = PoliciesList.Items.Add("Up: " & CurrentCategory.Parent.DisplayName)
listItem.Tag = CurrentCategory.Parent
Expand All @@ -104,7 +108,15 @@ Public Class Main
listItem.ImageIndex = GetImageIndexForSetting(policy)
listItem.SubItems.Add(GetPolicyState(policy))
listItem.SubItems.Add(GetPolicyCommentText(policy))
If policy Is CurrentSetting Then ' Keep the current policy selected
listItem.Selected = True
listItem.Focused = True
listItem.EnsureVisible()
End If
Next
If topItemIndex.HasValue And inSameCategory Then ' Minimize the list view's jumping around when refreshing
If PoliciesList.Items.Count > topItemIndex.Value Then PoliciesList.TopItem = PoliciesList.Items(topItemIndex.Value)
End If
If CategoriesTree.SelectedNode Is Nothing OrElse CategoriesTree.SelectedNode.Tag IsNot CurrentCategory Then ' Update the tree view
CategoriesTree.SelectedNode = CategoryNodes(CurrentCategory)
End If
Expand Down Expand Up @@ -259,7 +271,10 @@ Public Class Main
End Function
Sub ShowSettingEditor(Policy As PolicyPlusPolicy, Section As AdmxPolicySection)
' Show the Edit Policy Setting dialog for a policy and reload if changes were made
If EditSetting.PresentDialog(Policy, Section, AdmxWorkspace, CompPolicySource, UserPolicySource, CompPolicyLoader, UserPolicyLoader, CompComments, UserComments) = DialogResult.OK Then UpdateCategoryListing()
If EditSetting.PresentDialog(Policy, Section, AdmxWorkspace, CompPolicySource, UserPolicySource, CompPolicyLoader, UserPolicyLoader, CompComments, UserComments) = DialogResult.OK Then
' Keep the selection where it is if possible
If ShouldShowCategory(CurrentCategory) Then UpdateCategoryListing() Else MoveToVisibleCategoryAndReload()
End If
End Sub
Sub ClearSelections()
CurrentSetting = Nothing
Expand Down Expand Up @@ -651,7 +666,7 @@ Public Class Main
If ImportSpol.ShowDialog() = DialogResult.OK Then
Dim spol = ImportSpol.Spol
Dim fails = spol.ApplyAll(AdmxWorkspace, UserPolicySource, CompPolicySource)
UpdateCategoryListing()
MoveToVisibleCategoryAndReload()
If fails = 0 Then
MsgBox("Semantic Policy successfully applied.", MsgBoxStyle.Information)
Else
Expand All @@ -674,7 +689,7 @@ Public Class Main
If OpenSection.PresentDialog(True, True) = DialogResult.OK Then
Dim section = If(OpenSection.SelectedSection = AdmxPolicySection.User, UserPolicySource, CompPolicySource)
pol.Apply(section)
UpdateCategoryListing()
MoveToVisibleCategoryAndReload()
MsgBox("POL import successful.", MsgBoxStyle.Information)
End If
End If
Expand Down

0 comments on commit f9b11ee

Please sign in to comment.