From 4f43e8656be49e5635c9c6c10110df34ee9f2984 Mon Sep 17 00:00:00 2001
From: Julien W <50249422+julien-wff@users.noreply.github.com>
Date: Thu, 21 Dec 2023 12:04:47 +0100
Subject: [PATCH] feat: make the connect button disappear if connected
---
EasyGUI/Controls/JobsHeader.xaml | 2 +-
EasyGUI/Controls/JobsHeader.xaml.cs | 21 ++++++++++++++++++++-
EasyGUI/MainWindow.xaml | 1 +
EasyGUI/MainWindow.xaml.cs | 1 +
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/EasyGUI/Controls/JobsHeader.xaml b/EasyGUI/Controls/JobsHeader.xaml
index 61bb077..fafb3c9 100644
--- a/EasyGUI/Controls/JobsHeader.xaml
+++ b/EasyGUI/Controls/JobsHeader.xaml
@@ -22,7 +22,7 @@
-
+
diff --git a/EasyGUI/Controls/JobsHeader.xaml.cs b/EasyGUI/Controls/JobsHeader.xaml.cs
index 3910b49..44cd178 100644
--- a/EasyGUI/Controls/JobsHeader.xaml.cs
+++ b/EasyGUI/Controls/JobsHeader.xaml.cs
@@ -51,6 +51,13 @@ public partial class JobsHeader : INotifyPropertyChanged
new PropertyMetadata(default(ObservableCollection))
);
+ private static readonly DependencyProperty IsRemoteProperty = DependencyProperty.Register(
+ nameof(IsRemote),
+ typeof(bool),
+ typeof(JobsHeader),
+ new PropertyMetadata(default(bool))
+ );
+
public JobsHeader()
{
InitializeComponent();
@@ -76,6 +83,16 @@ public ObservableCollection SelectedJobs
}
}
+ public bool IsRemote
+ {
+ get => (bool)GetValue(IsRemoteProperty);
+ set
+ {
+ SetValue(IsRemoteProperty, value);
+ OnPropertyChanged();
+ }
+ }
+
public event PropertyChangedEventHandler? PropertyChanged;
public event RoutedEventHandler CreateButtonClick
@@ -111,7 +128,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- if (propertyName == nameof(SelectedJobs))
+ if (propertyName is nameof(SelectedJobs) or nameof(IsRemote))
{
UpdateButtonsDisplay();
}
@@ -123,6 +140,8 @@ private void UpdateButtonsDisplay()
SelectedJobs.Count > 1 && SelectedJobs.All(j => j.State is JobState.End or JobState.Paused)
? Visibility.Visible
: Visibility.Collapsed;
+
+ ConnectButton.Visibility = IsRemote ? Visibility.Collapsed : Visibility.Visible;
}
private void ToggleButton_OnChecked(object sender, RoutedEventArgs e)
diff --git a/EasyGUI/MainWindow.xaml b/EasyGUI/MainWindow.xaml
index 6ba21b7..09f5076 100644
--- a/EasyGUI/MainWindow.xaml
+++ b/EasyGUI/MainWindow.xaml
@@ -12,6 +12,7 @@