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
17 changes: 9 additions & 8 deletions App/Dialogs/ConnectDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terminal.Gui;
using Opcilloscope.Utilities;
using Opcilloscope.App.Themes;
using Opcilloscope.OpcUa;
using AppThemeManager = Opcilloscope.App.Themes.ThemeManager;
Expand Down Expand Up @@ -174,7 +175,7 @@ public ConnectDialog(
if (ValidateInput())
{
_confirmed = true;
Application.RequestStop();
TerminalUi.RequestStop();
}
};

Expand All @@ -188,7 +189,7 @@ public ConnectDialog(
cancelButton.Accepting += (_, _) =>
{
_confirmed = false;
Application.RequestStop();
TerminalUi.RequestStop();
};

Add(endpointLabel, protocolLabel, _endpointField,
Expand All @@ -206,7 +207,7 @@ private bool ValidateInput()

if (string.IsNullOrEmpty(serverAddress))
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Please enter a server address", "OK");
TerminalUi.ErrorQuery("Error", "Please enter a server address", "OK");
return false;
}

Expand All @@ -215,20 +216,20 @@ private bool ValidateInput()
var uri = new Uri(EndpointUrl);
if (string.IsNullOrEmpty(uri.Host))
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Invalid host in server address", "OK");
TerminalUi.ErrorQuery("Error", "Invalid host in server address", "OK");
return false;
}
}
catch
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Invalid server address format", "OK");
TerminalUi.ErrorQuery("Error", "Invalid server address format", "OK");
return false;
}

var interval = _publishIntervalField.Value;
if (interval < 100 || interval > 10000)
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Publishing interval must be between 100 and 10000 ms", "OK");
TerminalUi.ErrorQuery("Error", "Publishing interval must be between 100 and 10000 ms", "OK");
return false;
}

Expand All @@ -237,15 +238,15 @@ private bool ValidateInput()
var username = _usernameField.Text?.Trim() ?? string.Empty;
if (string.IsNullOrEmpty(username))
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Please enter a username", "OK");
TerminalUi.ErrorQuery("Error", "Please enter a username", "OK");
_usernameField.SetFocus();
return false;
}

var password = _passwordField.Text ?? string.Empty;
if (string.IsNullOrEmpty(password))
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Please enter a password", "OK");
TerminalUi.ErrorQuery("Error", "Please enter a password", "OK");
_passwordField.SetFocus();
return false;
}
Expand Down
11 changes: 9 additions & 2 deletions App/Dialogs/HelpDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terminal.Gui;
using Opcilloscope.Utilities;
using Opcilloscope.App.Keybindings;
using Opcilloscope.App.Themes;
using ThemeManager = Opcilloscope.App.Themes.ThemeManager;
Expand Down Expand Up @@ -27,7 +28,12 @@ public HelpDialog(KeybindingManager keybindingManager)
SetScheme(theme.MainColorScheme);
BorderStyle = theme.EmphasizedBorderStyle;

// Create content view with the help text
// Create content view with the help text.
// TextView is obsolete in Terminal.Gui 2.4.5, superseded by EditorView from
// the separate gui-cs/Editor package. A read-only scrolling text pane is all
// that's needed here, so keep TextView rather than take on a new dependency;
// revisit if/when EditorView ships in the Terminal.Gui package itself.
#pragma warning disable CS0618 // TextView is obsolete (replacement lives in gui-cs/Editor)
var contentView = new TextView
{
X = 1,
Expand All @@ -44,6 +50,7 @@ public HelpDialog(KeybindingManager keybindingManager)
HotFocus = new Attribute(theme.Foreground, theme.Background),
Disabled = new Attribute(theme.MutedText, theme.Background)
});
#pragma warning restore CS0618

contentView.Text = GenerateHelpFromBindings(keybindingManager);

Expand Down Expand Up @@ -121,7 +128,7 @@ private static string GenerateHelpFromBindings(KeybindingManager manager)

private void OnThemeChanged(AppTheme theme)
{
Application.Invoke(() =>
UiThread.Run(() =>
{
SetScheme(theme.MainColorScheme);
BorderStyle = theme.EmphasizedBorderStyle;
Expand Down
9 changes: 5 additions & 4 deletions App/Dialogs/OpenConfigDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terminal.Gui;
using Opcilloscope.Utilities;
using Opcilloscope.App.Themes;
using Opcilloscope.Configuration;
using AppThemeManager = Opcilloscope.App.Themes.ThemeManager;
Expand Down Expand Up @@ -90,7 +91,7 @@ public OpenConfigDialog()
cancelButton.Accepting += (_, _) =>
{
_confirmed = false;
Application.RequestStop();
TerminalUi.RequestStop();
};

Add(_directoryLabel, _fileListView, openButton, browseButton, cancelButton);
Expand Down Expand Up @@ -121,7 +122,7 @@ private void Confirm()
{
SelectedFilePath = _files[_fileListView.SelectedItem!.Value].FullName;
_confirmed = true;
Application.RequestStop();
TerminalUi.RequestStop();
}
}

Expand All @@ -139,13 +140,13 @@ private void OnBrowse(object? sender, CommandEventArgs e)
Path = ConfigurationService.GetDefaultConfigDirectory()
};

Application.Run(dialog);
TerminalUi.RunModal(dialog);

if (!dialog.Canceled && dialog.Path != null)
{
SelectedFilePath = dialog.Path.ToString()!;
_confirmed = true;
Application.RequestStop();
TerminalUi.RequestStop();
}
}
}
5 changes: 3 additions & 2 deletions App/Dialogs/PasswordPromptDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terminal.Gui;
using Opcilloscope.Utilities;
using Opcilloscope.App.Themes;
using AppThemeManager = Opcilloscope.App.Themes.ThemeManager;

Expand Down Expand Up @@ -61,7 +62,7 @@ public PasswordPromptDialog(string username, string endpoint)
okButton.Accepting += (_, _) =>
{
_confirmed = true;
Application.RequestStop();
TerminalUi.RequestStop();
};

var cancelButton = new Button
Expand All @@ -74,7 +75,7 @@ public PasswordPromptDialog(string username, string endpoint)
cancelButton.Accepting += (_, _) =>
{
_confirmed = false;
Application.RequestStop();
TerminalUi.RequestStop();
};

Add(promptLabel, endpointLabel, _passwordField, okButton, cancelButton);
Expand Down
17 changes: 9 additions & 8 deletions App/Dialogs/SaveConfigDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terminal.Gui;
using Opcilloscope.Utilities;
using Opcilloscope.App.Themes;
using Opcilloscope.Configuration;
using AppThemeManager = Opcilloscope.App.Themes.ThemeManager;
Expand Down Expand Up @@ -161,7 +162,7 @@ private void OnBrowseDirectory(object? sender, CommandEventArgs e)
// We'll let user navigate to any directory and extract the directory path
};

Application.Run(dialog);
TerminalUi.RunModal(dialog);

if (!dialog.Canceled && dialog.Path != null)
{
Expand Down Expand Up @@ -198,13 +199,13 @@ private void OnSave(object? sender, CommandEventArgs e)
return;

_confirmed = true;
Application.RequestStop();
TerminalUi.RequestStop();
}

private void OnCancel(object? sender, CommandEventArgs e)
{
_confirmed = false;
Application.RequestStop();
TerminalUi.RequestStop();
}

private bool ValidateSave()
Expand All @@ -213,23 +214,23 @@ private bool ValidateSave()
var filename = _currentFilename.Trim();
if (string.IsNullOrEmpty(filename))
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Please enter a filename", "OK");
TerminalUi.ErrorQuery("Error", "Please enter a filename", "OK");
return false;
}

// Check for invalid characters in filename
var invalidChars = Path.GetInvalidFileNameChars();
if (filename.IndexOfAny(invalidChars) >= 0)
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Filename contains invalid characters", "OK");
TerminalUi.ErrorQuery("Error", "Filename contains invalid characters", "OK");
return false;
}

// Validate directory
var directory = _currentDirectory.Trim();
if (string.IsNullOrEmpty(directory))
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Please specify a directory", "OK");
TerminalUi.ErrorQuery("Error", "Please specify a directory", "OK");
return false;
}

Expand All @@ -243,15 +244,15 @@ private bool ValidateSave()
}
catch (Exception ex)
{
MessageBox.ErrorQuery(Application.Instance, "Error", $"Cannot create directory: {ex.Message}", "OK");
TerminalUi.ErrorQuery("Error", $"Cannot create directory: {ex.Message}", "OK");
return false;
}

// Check if file exists and prompt for overwrite
var fullPath = FilePath;
if (File.Exists(fullPath))
{
var result = MessageBox.Query(Application.Instance, "Confirm Overwrite",
var result = TerminalUi.Query("Confirm Overwrite",
$"File '{Path.GetFileName(fullPath)}' already exists.\nDo you want to replace it?",
"Yes", "No");
if (result != 0) // "No" selected
Expand Down
12 changes: 6 additions & 6 deletions App/Dialogs/SaveRecordingDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public SaveRecordingDialog(string defaultDirectory, string defaultFilename)
if (ValidateAndSetPath())
{
_confirmed = true;
Application.RequestStop();
TerminalUi.RequestStop();
}
};

Expand All @@ -128,7 +128,7 @@ public SaveRecordingDialog(string defaultDirectory, string defaultFilename)
cancelButton.Accepting += (_, _) =>
{
_confirmed = false;
Application.RequestStop();
TerminalUi.RequestStop();
};

Add(directoryLabel, _directoryField, fileListLabel, _fileListView,
Expand Down Expand Up @@ -181,7 +181,7 @@ private void LoadDirectory(string directory)
}
catch (Exception ex)
{
MessageBox.ErrorQuery(Application.Instance, "Error", $"Cannot access directory:\n{ex.Message}", "OK");
TerminalUi.ErrorQuery("Error", $"Cannot access directory:\n{ex.Message}", "OK");
}
}

Expand Down Expand Up @@ -248,7 +248,7 @@ private bool ValidateAndSetPath()

if (string.IsNullOrEmpty(filename))
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Please enter a filename", "OK");
TerminalUi.ErrorQuery("Error", "Please enter a filename", "OK");
return false;
}

Expand All @@ -259,7 +259,7 @@ private bool ValidateAndSetPath()
var invalidChars = Path.GetInvalidFileNameChars();
if (filename.IndexOfAny(invalidChars) >= 0)
{
MessageBox.ErrorQuery(Application.Instance, "Error", "Filename contains invalid characters", "OK");
TerminalUi.ErrorQuery("Error", "Filename contains invalid characters", "OK");
return false;
}

Expand All @@ -268,7 +268,7 @@ private bool ValidateAndSetPath()
// Check if file already exists
if (File.Exists(fullPath))
{
var result = MessageBox.Query(Application.Instance, "Confirm Overwrite",
var result = TerminalUi.Query("Confirm Overwrite",
$"File already exists:\n{filename}\n\nOverwrite?",
"Yes", "No");
if (result != 0)
Expand Down
7 changes: 4 additions & 3 deletions App/Dialogs/ScopeDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Terminal.Gui;
using Opcilloscope.Utilities;
using Opcilloscope.App.Views;
using Opcilloscope.App.Themes;
using Opcilloscope.OpcUa;
Expand Down Expand Up @@ -63,7 +64,7 @@ public ScopeDialog(
Y = 0,
Text = $"{Theme.ButtonPrefix}CLOSE{Theme.ButtonSuffix}",
}.WithScheme(Theme.ButtonColorScheme);
_closeButton.Accepting += (_, _) => Application.RequestStop();
_closeButton.Accepting += (_, _) => TerminalUi.RequestStop();

buttonFrame.Add(_pauseButton, _closeButton);

Expand All @@ -88,7 +89,7 @@ private void OnPauseToggle(object? _, CommandEventArgs _1)

private void OnPauseStateChanged(bool isPaused)
{
Application.Invoke(() =>
UiThread.Run(() =>
{
_pauseButton.Text = isPaused
? $"{Theme.ButtonPrefix}RESUME{Theme.ButtonSuffix}"
Expand All @@ -98,7 +99,7 @@ private void OnPauseStateChanged(bool isPaused)

private void OnThemeChanged(AppTheme theme)
{
Application.Invoke(() =>
UiThread.Run(() =>
{
Title = $"{theme.TitleDecoration}[ SCOPE ]{theme.TitleDecoration}";
ThemeStyler.ApplyToDialog(this, theme);
Expand Down
8 changes: 4 additions & 4 deletions App/Dialogs/WriteValueDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,23 @@ public WriteValueDialog(NodeId nodeId, string nodeName, BuiltInType dataType, st
if (ValidateAndParse())
{
// Show confirmation dialog before writing
var confirmResult = MessageBox.Query(Application.Instance,
var confirmResult = TerminalUi.Query(
"Confirm Write",
$"Write '{_valueField.Text}' to {nodeName}?",
"Yes", "No");

if (confirmResult == 0) // Yes was selected
{
_confirmed = true;
Application.RequestStop();
TerminalUi.RequestStop();
}
}
};

cancelButton.Accepting += (_, _) =>
{
_confirmed = false;
Application.RequestStop();
TerminalUi.RequestStop();
};

// Add all controls
Expand Down Expand Up @@ -210,7 +210,7 @@ private bool ValidateAndParse()
// Check if write is supported for this data type
if (!OpcValueConverter.IsWriteSupported(_dataType))
{
MessageBox.ErrorQuery(Application.Instance, "Write Error", $"Write not supported for data type: {_dataType}", "OK");
TerminalUi.ErrorQuery("Write Error", $"Write not supported for data type: {_dataType}", "OK");
return false;
}

Expand Down
Loading
Loading