Skip to content

Commit

Permalink
fixes issue #220 - order services on detail screen. also sorts identi…
Browse files Browse the repository at this point in the history
…tes on 'main' screen
  • Loading branch information
dovholuknf committed Nov 20, 2020
1 parent ad9a5df commit 62e1c04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
21 changes: 8 additions & 13 deletions DesktopEdge/IdentityDetails.xaml.cs
Original file line number Diff line number Diff line change
@@ -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 {
/// <summary>
/// Interaction logic for IdentityDetails.xaml
/// </summary>
public partial class IdentityDetails:UserControl {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

private bool _isAttached = true;
public delegate void Forgot(ZitiIdentity forgotten);
Expand Down Expand Up @@ -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);
}
Expand Down
11 changes: 7 additions & 4 deletions DesktopEdge/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 62e1c04

Please sign in to comment.