Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/NETworkManager.Profiles/GroupViewInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class GroupViewInfo

public GroupViewInfo()
{

}

public GroupViewInfo(GroupViewName name, Canvas icon)
Expand Down
31 changes: 17 additions & 14 deletions Source/NETworkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ public string Search
var sourceInfos = sourceCollection as ApplicationInfo[] ?? sourceCollection.ToArray();
var filteredInfos = filteredCollection as ApplicationInfo[] ?? filteredCollection.ToArray();

if (_filterLastCount == null)
_filterLastCount = sourceInfos.Length;
_filterLastCount ??= sourceInfos.Length;

SelectedApplication = _filterLastCount > filteredInfos.Length ? filteredInfos.FirstOrDefault() : sourceInfos.FirstOrDefault(x => x.Name == _filterLastViewName);

Expand Down Expand Up @@ -1016,21 +1015,23 @@ private void EventSystem_RedirectDataToApplicationEvent(object sender, EventArgs
}
#endregion

#region Settings
#region Settings
private void OpenSettings()
{
// Init settings view
{
OnApplicationViewHide(SelectedApplication.Name);

if (_settingsView == null)
{
_settingsView = new SettingsView(SelectedApplication.Name);
_settingsView = new SettingsView();
ContentControlSettings.Content = _settingsView;
}
else // Change view
else
{
_settingsView.ChangeSettingsView(SelectedApplication.Name);
_settingsView.Refresh();
_settingsView.OnViewVisible();
}

_settingsView.ChangeSettingsView(SelectedApplication.Name);

// Show the view (this will hide other content)
ShowSettingsView = true;
}
Expand All @@ -1044,6 +1045,8 @@ private void CloseSettings()
{
ShowSettingsView = false;

_settingsView.OnViewHide();

// Change HotKeys
if (SettingsManager.HotKeysChanged)
{
Expand Down Expand Up @@ -1072,9 +1075,9 @@ private void LoadProfiles()
SelectedProfileFile = ProfileFiles.SourceCollection.Cast<ProfileFileInfo>().FirstOrDefault(x => x.Name == SettingsManager.Current.Profiles_LastSelected);
SelectedProfileFile ??= ProfileFiles.SourceCollection.Cast<ProfileFileInfo>().FirstOrDefault();
}

private async Task LoadProfile(ProfileFileInfo info, bool showWrongPassword = false)
{
{
if (info.IsEncrypted && !info.IsPasswordValid)
{
IsProfileFileLocked = true;
Expand Down Expand Up @@ -1129,7 +1132,7 @@ private async Task SwitchProfile(ProfileFileInfo info)
catch (System.Security.Cryptography.CryptographicException)
{
// Wrong password, try again...
LoadProfile(info, true);
LoadProfile(info, true);
}
catch
{
Expand Down Expand Up @@ -1527,8 +1530,8 @@ private void ConfigureDNS()

foreach (var dnsServer in SettingsManager.Current.Network_CustomDNSServer.Split(";"))
{
dnsServers.Add((dnsServer, 53));
}
dnsServers.Add((dnsServer, 53));
}

dnsSettings.UseCustomDNSServers = true;
dnsSettings.DNSServers = dnsServers;
Expand Down
3 changes: 3 additions & 0 deletions Source/NETworkManager/Resources/Styles/ListBoxStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

<Style x:Key="ProfileListBox" TargetType="{x:Type ListBox}" BasedOn="{StaticResource DefaultListBox}">
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<!-- Performance problem with large ListBox/view?
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
</Trigger>
</Style.Triggers>
-->
</Style>

</ResourceDictionary>
10 changes: 5 additions & 5 deletions Source/NETworkManager/Resources/Styles/RectangleStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray3}" />
<Setter Property="OpacityMask">
<Setter.Value>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=InformationVariant}"/>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=InformationOutline}"/>
</Setter.Value>
</Setter>
<Setter Property="ToolTipService.InitialShowDelay" Value="0" />
Expand All @@ -33,10 +33,10 @@
<Style.Resources>
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource DefaultToolTip}" />
</Style.Resources>
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray3}" />
<Setter Property="Fill" Value="Orange" />
<Setter Property="OpacityMask">
<Setter.Value>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=Alert}"/>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=AlertOutline}"/>
</Setter.Value>
</Setter>
<Setter Property="ToolTipService.InitialShowDelay" Value="0" />
Expand All @@ -47,10 +47,10 @@
<Style.Resources>
<Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource DefaultToolTip}" />
</Style.Resources>
<Setter Property="Fill" Value="{DynamicResource MahApps.Brushes.Gray3}" />
<Setter Property="Fill" Value="Red" />
<Setter Property="OpacityMask">
<Setter.Value>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=AlertCircle}"/>
<VisualBrush Stretch="Uniform" Visual="{iconPacks:Material Kind=AlertOctagonOutline}"/>
</Setter.Value>
</Setter>
<Setter Property="ToolTipService.InitialShowDelay" Value="0" />
Expand Down
121 changes: 62 additions & 59 deletions Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,21 @@ public bool HeaderContextMenuIsOpen
}
#region Profiles

public ICollectionView Profiles { get; }
public ICollectionView _profiles;
public ICollectionView Profiles
{
get => _profiles;
set
{
if (value == _profiles)
return;

_profiles = value;
OnPropertyChanged();
}
}

private ProfileInfo _selectedProfile = new ProfileInfo();
private ProfileInfo _selectedProfile = new();
public ProfileInfo SelectedProfile
{
get => _selectedProfile;
Expand All @@ -178,7 +190,9 @@ public string Search

_search = value;

StartDelayedSearch();
// Start searching...
IsSearching = true;
_searchDispatcherTimer.Start();

OnPropertyChanged();
}
Expand Down Expand Up @@ -287,32 +301,8 @@ public AWSSessionManagerHostViewModel(IDialogCoordinator instance)

TabItems = new ObservableCollection<DragablzTabItem>();

Profiles = new CollectionViewSource { Source = ProfileManager.Groups.SelectMany(x => x.Profiles) }.View;
Profiles.GroupDescriptions.Add(new PropertyGroupDescription(nameof(ProfileInfo.Group)));
Profiles.SortDescriptions.Add(new SortDescription(nameof(ProfileInfo.Group), ListSortDirection.Ascending));
Profiles.SortDescriptions.Add(new SortDescription(nameof(ProfileInfo.Name), ListSortDirection.Ascending));
Profiles.Filter = o =>
{
if (o is not ProfileInfo info)
return false;

if (string.IsNullOrEmpty(Search))
return info.AWSSessionManager_Enabled;

var search = Search.Trim();

// Search by: Tag=xxx (exact match, ignore case)

//if (search.StartsWith(ProfileManager.TagIdentifier, StringComparison.OrdinalIgnoreCase))
// return !string.IsNullOrEmpty(info.Tags) && info.AWSSessionManager_Enabled && info.Tags.Replace(" ", "").Split(';').Any(str => search.Substring(ProfileManager.TagIdentifier.Length, search.Length - ProfileManager.TagIdentifier.Length).Equals(str, StringComparison.OrdinalIgnoreCase));
//

// Search by: Name, AWSSessionManager_Host
return info.AWSSessionManager_Enabled && (info.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1 || info.AWSSessionManager_InstanceID.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1);
};

// This will select the first entry as selected item...
SelectedProfile = Profiles.SourceCollection.Cast<ProfileInfo>().Where(x => x.AWSSessionManager_Enabled).OrderBy(x => x.Group).ThenBy(x => x.Name).FirstOrDefault();
// Profiles
SetProfilesView();

ProfileManager.OnProfilesUpdated += ProfileManager_OnProfilesUpdated;

Expand Down Expand Up @@ -833,31 +823,7 @@ private static void AddRegionToHistory(string region)

SettingsManager.Current.AWSSessionManager_RegionHistory = new ObservableCollection<string>(ListHelper.Modify(SettingsManager.Current.AWSSessionManager_RegionHistory.ToList(), region, SettingsManager.Current.General_HistoryListEntries));
}

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 @@ -917,15 +883,48 @@ public void OnProfileLoaded()
SyncAllInstanceIDsFromAWS();
}

private void SetProfilesView(ProfileInfo profile = null)
{
Profiles = new CollectionViewSource { Source = ProfileManager.Groups.SelectMany(x => x.Profiles).Where(x => x.AWSSessionManager_Enabled).OrderBy(x => x.Group).ThenBy(x => x.Name) }.View;

Profiles.GroupDescriptions.Add(new PropertyGroupDescription(nameof(ProfileInfo.Group)));

Profiles.Filter = o =>
{
if (o is not ProfileInfo info)
return false;

if (string.IsNullOrEmpty(Search))
return true;

var search = Search.Trim();

// Search by: Tag=xxx (exact match, ignore case)
/*
if (search.StartsWith(ProfileManager.TagIdentifier, StringComparison.OrdinalIgnoreCase))
return !string.IsNullOrEmpty(info.Tags) && info.PingMonitor_Enabled && info.Tags.Replace(" ", "").Split(';').Any(str => search.Substring(ProfileManager.TagIdentifier.Length, search.Length - ProfileManager.TagIdentifier.Length).Equals(str, StringComparison.OrdinalIgnoreCase));
*/

// Search by: Name, AWSSessionManager_InstanceID
return info.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1 || info.AWSSessionManager_InstanceID.IndexOf(search, StringComparison.OrdinalIgnoreCase) > -1;
};

// Set specific profile or first if null
SelectedProfile = null;

if (profile != null)
SelectedProfile = Profiles.Cast<ProfileInfo>().FirstOrDefault(x => x.Equals(profile)) ??
Profiles.Cast<ProfileInfo>().FirstOrDefault();
else
SelectedProfile = Profiles.Cast<ProfileInfo>().FirstOrDefault();
}

public void RefreshProfiles()
{
if (!_isViewActive)
return;

Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate
{
Profiles.Refresh();
}));
SetProfilesView(SelectedProfile);
}

public void OnProfileDialogOpen()
Expand Down Expand Up @@ -988,7 +987,11 @@ private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e)

private void SearchDispatcherTimer_Tick(object sender, EventArgs e)
{
StopDelayedSearch();
_searchDispatcherTimer.Stop();

RefreshProfiles();

IsSearching = false;
}
#endregion
}
Loading