Skip to content

Commit

Permalink
Merge pull request #258 from BornToBeRoot/issue-227
Browse files Browse the repository at this point in the history
Improve profile search in views #227
  • Loading branch information
BornToBeRoot committed Jan 26, 2020
2 parents acf79ba + f6669ff commit 27f4e43
Show file tree
Hide file tree
Showing 34 changed files with 1,006 additions and 100 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Source/NETworkManager/Resources/Localization/Strings.resx
Expand Up @@ -2519,7 +2519,7 @@ URL: https://github.com/BornToBeRoot/NETworkManager/tree/master/Documentation</v
<value>LLDP / CDP</value>
</data>
<data name="RestartAsAdmin" xml:space="preserve">
<value>Restart as Admininistrator</value>
<value>Restart as Administrator</value>
</data>
<data name="NetworkPacketsCaptureAdminMessage" xml:space="preserve">
<value>To analyze network packets, the application must be started with elevated rights!</value>
Expand Down
52 changes: 51 additions & 1 deletion Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs
Expand Up @@ -12,13 +12,15 @@
using NETworkManager.Views;
using NETworkManager.Utilities;
using NETworkManager.Models.Profile;
using System.Windows.Threading;

namespace NETworkManager.ViewModels
{
public class DNSLookupHostViewModel : ViewModelBase, IProfileManager
{
#region Variables
private readonly IDialogCoordinator _dialogCoordinator;
private readonly DispatcherTimer _searchDispatcherTimer = new DispatcherTimer();

public IInterTabClient InterTabClient { get; }
public ObservableCollection<DragablzTabItem> TabItems { get; }
Expand Down Expand Up @@ -69,12 +71,26 @@ public string Search

_search = value;

RefreshProfiles();
StartDelayedSearch();

OnPropertyChanged();
}
}

private bool _isSearching;
public bool IsSearching
{
get => _isSearching;
set
{
if (value == _isSearching)
return;

_isSearching = value;
OnPropertyChanged();
}
}

private bool _canProfileWidthChange = true;
private double _tempProfileWidth;

Expand Down Expand Up @@ -161,6 +177,9 @@ public DNSLookupHostViewModel(IDialogCoordinator instance)
// This will select the first entry as selected item...
SelectedProfile = Profiles.SourceCollection.Cast<ProfileInfo>().Where(x => x.DNSLookup_Enabled).OrderBy(x => x.Group).ThenBy(x => x.Name).FirstOrDefault();

_searchDispatcherTimer.Interval = GlobalStaticConfiguration.SearchDispatcherTimerTimeSpan;
_searchDispatcherTimer.Tick += SearchDispatcherTimer_Tick;

LoadSettings();

_isLoading = false;
Expand Down Expand Up @@ -247,6 +266,30 @@ private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
#endregion

#region Methods
private void StartDelayedSearch()
{
if (!IsSearching)
{
IsSearching = true;

_searchDispatcherTimer.Start();
}
else
{
_searchDispatcherTimer.Stop();
_searchDispatcherTimer.Start();
}
}

private void StopDelayedSearch()
{
_searchDispatcherTimer.Stop();

RefreshProfiles();

IsSearching = false;
}

private void ResizeProfile(bool dueToChangedSize)
{
_canProfileWidthChange = false;
Expand Down Expand Up @@ -305,5 +348,12 @@ public void OnProfileDialogClose()

}
#endregion

#region Event
private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
{
StopDelayedSearch();
}
#endregion
}
}
54 changes: 52 additions & 2 deletions Source/NETworkManager/ViewModels/HTTPHeadersHostViewModel.cs
Expand Up @@ -12,14 +12,16 @@
using NETworkManager.Views;
using NETworkManager.Utilities;
using NETworkManager.Models.Profile;
using System.Windows.Threading;

namespace NETworkManager.ViewModels
{
public class HTTPHeadersHostViewModel : ViewModelBase, IProfileManager
{
#region Variables
private readonly IDialogCoordinator _dialogCoordinator;

private readonly DispatcherTimer _searchDispatcherTimer = new DispatcherTimer();

public IInterTabClient InterTabClient { get; }
public ObservableCollection<DragablzTabItem> TabItems { get; }

Expand Down Expand Up @@ -69,8 +71,22 @@ public string Search

_search = value;

RefreshProfiles();
StartDelayedSearch();

OnPropertyChanged();
}
}

private bool _isSearching;
public bool IsSearching
{
get => _isSearching;
set
{
if (value == _isSearching)
return;

_isSearching = value;
OnPropertyChanged();
}
}
Expand Down Expand Up @@ -161,6 +177,9 @@ public HTTPHeadersHostViewModel(IDialogCoordinator instance)
// This will select the first entry as selected item...
SelectedProfile = Profiles.SourceCollection.Cast<ProfileInfo>().Where(x => x.HTTPHeaders_Enabled).OrderBy(x => x.Group).ThenBy(x => x.Name).FirstOrDefault();

_searchDispatcherTimer.Interval = GlobalStaticConfiguration.SearchDispatcherTimerTimeSpan;
_searchDispatcherTimer.Tick += SearchDispatcherTimer_Tick;

LoadSettings();

_isLoading = false;
Expand Down Expand Up @@ -245,6 +264,30 @@ private void ClearSearchAction()
#endregion

#region Methods
private void StartDelayedSearch()
{
if (!IsSearching)
{
IsSearching = true;

_searchDispatcherTimer.Start();
}
else
{
_searchDispatcherTimer.Stop();
_searchDispatcherTimer.Start();
}
}

private void StopDelayedSearch()
{
_searchDispatcherTimer.Stop();

RefreshProfiles();

IsSearching = false;
}

private void ResizeProfile(bool dueToChangedSize)
{
_canProfileWidthChange = false;
Expand Down Expand Up @@ -304,5 +347,12 @@ public void OnProfileDialogClose()

}
#endregion

#region Event
private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
{
StopDelayedSearch();
}
#endregion
}
}
57 changes: 54 additions & 3 deletions Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs
Expand Up @@ -12,13 +12,15 @@
using System.Windows;
using System.Linq;
using NETworkManager.Models.Profile;
using System.Windows.Threading;

namespace NETworkManager.ViewModels
{
public class IPScannerHostViewModel : ViewModelBase, IProfileManager
{
#region Variables
private readonly IDialogCoordinator _dialogCoordinator;
private readonly DispatcherTimer _searchDispatcherTimer = new DispatcherTimer();

public IInterTabClient InterTabClient { get; }
public ObservableCollection<DragablzTabItem> TabItems { get; }
Expand Down Expand Up @@ -69,11 +71,25 @@ public string Search

_search = value;

RefreshProfiles();
StartDelayedSearch();

OnPropertyChanged();
}
}

private bool _isSearching;
public bool IsSearching
{
get => _isSearching;
set
{
if (value == _isSearching)
return;

_isSearching = value;
OnPropertyChanged();
}
}

private bool _canProfileWidthChange = true;
private double _tempProfileWidth;
Expand Down Expand Up @@ -161,6 +177,9 @@ public IPScannerHostViewModel(IDialogCoordinator instance)
// This will select the first entry as selected item...
SelectedProfile = Profiles.SourceCollection.Cast<ProfileInfo>().Where(x => x.IPScanner_Enabled).OrderBy(x => x.Group).ThenBy(x => x.Name).FirstOrDefault();

_searchDispatcherTimer.Interval = GlobalStaticConfiguration.SearchDispatcherTimerTimeSpan;
_searchDispatcherTimer.Tick += SearchDispatcherTimer_Tick;

LoadSettings();

_isLoading = false;
Expand Down Expand Up @@ -247,6 +266,30 @@ private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
#endregion

#region Methods
private void StartDelayedSearch()
{
if (!IsSearching)
{
IsSearching = true;

_searchDispatcherTimer.Start();
}
else
{
_searchDispatcherTimer.Stop();
_searchDispatcherTimer.Start();
}
}

private void StopDelayedSearch()
{
_searchDispatcherTimer.Stop();

RefreshProfiles();

IsSearching = false;
}

private void ResizeProfile(bool dueToChangedSize)
{
_canProfileWidthChange = false;
Expand Down Expand Up @@ -294,12 +337,12 @@ public void OnViewHide()
{

}

public void RefreshProfiles()
{
Profiles.Refresh();
}

public void OnProfileDialogOpen()
{

Expand All @@ -309,6 +352,14 @@ public void OnProfileDialogClose()
{

}

#endregion

#region Event
private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
{
StopDelayedSearch();
}
#endregion
}
}

0 comments on commit 27f4e43

Please sign in to comment.