From 62e1c045118799e28ba4ed67e2f18c3bccae9ed5 Mon Sep 17 00:00:00 2001 From: dovholuknf <46322585+dovholuknf@users.noreply.github.com> Date: Fri, 20 Nov 2020 18:18:25 -0500 Subject: [PATCH] fixes issue #220 - order services on detail screen. also sorts identites on 'main' screen --- DesktopEdge/IdentityDetails.xaml.cs | 21 ++++++++------------- DesktopEdge/MainWindow.xaml.cs | 11 +++++++---- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/DesktopEdge/IdentityDetails.xaml.cs b/DesktopEdge/IdentityDetails.xaml.cs index 292c74827..e18d255f3 100644 --- a/DesktopEdge/IdentityDetails.xaml.cs +++ b/DesktopEdge/IdentityDetails.xaml.cs @@ -1,26 +1,20 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using ZitiDesktopEdge.Models; using ZitiDesktopEdge.ServiceClient; +using NLog; + namespace ZitiDesktopEdge { /// /// Interaction logic for IdentityDetails.xaml /// public partial class IdentityDetails:UserControl { + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private bool _isAttached = true; public delegate void Forgot(ZitiIdentity forgotten); @@ -89,11 +83,12 @@ public void UpdateView() { IdentityStatus.Value = _identity.IsEnabled ? "active" : "disabled"; ServiceList.Children.Clear(); if (_identity.Services.Count>0) { - for (int i = 0; i < _identity.Services.Count; i++) { + foreach(var zitiSvc in _identity.Services.OrderBy(s => s.Name.ToLower())) { + Logger.Debug("painting: " + zitiSvc.Name); ServiceInfo editor = new ServiceInfo(); - editor.Label = _identity.Services[i].Name; - editor.Value = _identity.Services[i].Url; - editor.Warning = _identity.Services[i].Warning; + editor.Label = zitiSvc.Name; + editor.Value = zitiSvc.Url; + editor.Warning = zitiSvc.Warning; editor.IsLocked = true; ServiceList.Children.Add(editor); } diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index 0840b9429..f5bd98df5 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -423,8 +423,11 @@ private void ServiceClient_OnServiceEvent(object sender, ServiceEvent e) { if (e.Action == "added") { ZitiService zs = new ZitiService(e.Service); var svc = found.Services.Find(s => s.Name == zs.Name); - if (svc == null) found.Services.Add(zs); - else Debug.WriteLine("the service named " + zs.Name + " is already accounted for on this identity."); + if (svc == null) { + found.Services.Add(zs); + } else { + Debug.WriteLine("the service named " + zs.Name + " is already accounted for on this identity."); + } } else { Debug.WriteLine("removing the service named: " + e.Service.Name); found.Services.RemoveAll(s => s.Name == e.Service.Name); @@ -539,11 +542,11 @@ private void SetNotifyIcon(string iconPrefix) { Application.Current.MainWindow.Icon = System.Windows.Media.Imaging.BitmapFrame.Create(iconUri); } - private void LoadIdentities(Boolean repaint) { + private void LoadIdentities(Boolean repaint) { IdList.Children.Clear(); IdList.Height = 0; IdList.MaxHeight = _maxHeight - 520; - ZitiIdentity[] ids = identities.ToArray(); + ZitiIdentity[] ids = identities.OrderBy(i => i.Name.ToLower()).ToArray(); double height = 490 + (ids.Length * 60); if (height > _maxHeight) height = _maxHeight; this.Height = height;