Skip to content

Commit

Permalink
merged !!! woot.
Browse files Browse the repository at this point in the history
  • Loading branch information
tig committed Mar 20, 2023
2 parents 10971ec + f269fd7 commit 7919764
Show file tree
Hide file tree
Showing 156 changed files with 2,612 additions and 1,833 deletions.
2 changes: 1 addition & 1 deletion Example/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ExampleWindow ()
};

// When login button is clicked display a message popup
btnLogin.Clicked += () => {
btnLogin.Clicked += (s,e) => {
if (usernameText.Text == "admin" && passwordText.Text == "password") {
MessageBox.Query ("Logging In", "Login Successful", "Ok");
Application.RequestStop ();
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public class ExampleWindow : Window {
};

// When login button is clicked display a message popup
btnLogin.Clicked += () => {
btnLogin.Clicked += (s,e) => {
if (usernameText.Text == "admin" && passwordText.Text == "password") {
MessageBox.Query ("Logging In", "Login Successful", "Ok");
Application.RequestStop ();
Expand Down
21 changes: 4 additions & 17 deletions Terminal.Gui/Configuration/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,6 @@ internal static Stream ToStream ()
return stream;
}

/// <summary>
/// Event arguments for the <see cref="ConfigurationManager"/> events.
/// </summary>
public class ConfigurationManagerEventArgs : EventArgs {

/// <summary>
/// Initializes a new instance of <see cref="ConfigurationManagerEventArgs"/>
/// </summary>
public ConfigurationManagerEventArgs ()
{
}
}

/// <summary>
/// Gets or sets whether the <see cref="ConfigurationManager"/> should throw an exception if it encounters
/// an error on deserialization. If <see langword="false"/> (the default), the error is logged and printed to the
Expand Down Expand Up @@ -353,14 +340,14 @@ private static void ClearJsonErrors ()
public static void OnUpdated ()
{
Debug.WriteLine ($"ConfigurationManager.OnApplied()");
Updated?.Invoke (new ConfigurationManagerEventArgs ());
Updated?.Invoke (null, new ConfigurationManagerEventArgs ());
}

/// <summary>
/// Event fired when the configuration has been updated from a configuration source.
/// application.
/// </summary>
public static event Action<ConfigurationManagerEventArgs>? Updated;
public static event EventHandler<ConfigurationManagerEventArgs>? Updated;

/// <summary>
/// Resets the state of <see cref="ConfigurationManager"/>. Should be called whenever a new app session
Expand Down Expand Up @@ -440,14 +427,14 @@ public static void Apply ()
public static void OnApplied ()
{
Debug.WriteLine ($"ConfigurationManager.OnApplied()");
Applied?.Invoke (new ConfigurationManagerEventArgs ());
Applied?.Invoke (null, new ConfigurationManagerEventArgs ());
}

/// <summary>
/// Event fired when an updated configuration has been applied to the
/// application.
/// </summary>
public static event Action<ConfigurationManagerEventArgs>? Applied;
public static event EventHandler<ConfigurationManagerEventArgs>? Applied;

/// <summary>
/// Name of the running application. By default this property is set to the application's assembly name.
Expand Down
36 changes: 36 additions & 0 deletions Terminal.Gui/Configuration/ConfigurationManagerEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;

#nullable enable

namespace Terminal.Gui.Configuration {
/// <summary>
/// Event arguments for the <see cref="ConfigurationManager"/> events.
/// </summary>
public class ConfigurationManagerEventArgs : EventArgs {

/// <summary>
/// Initializes a new instance of <see cref="ConfigurationManagerEventArgs"/>
/// </summary>
public ConfigurationManagerEventArgs ()
{
}
}

/// <summary>
/// Event arguments for the <see cref="ConfigurationManager.ThemeManager"/> events.
/// </summary>
public class ThemeManagerEventArgs : EventArgs {
/// <summary>
/// The name of the new active theme..
/// </summary>
public string NewTheme { get; set; } = string.Empty;

/// <summary>
/// Initializes a new instance of <see cref="ThemeManagerEventArgs"/>
/// </summary>
public ThemeManagerEventArgs (string newTheme)
{
NewTheme = newTheme;
}
}
}
24 changes: 3 additions & 21 deletions Terminal.Gui/Configuration/ThemeScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ internal override bool Apply ()
/// }
/// }
/// </code></example>
public class ThemeManager : IDictionary<string, ThemeScope> {
public partial class ThemeManager : IDictionary<string, ThemeScope> {
private static readonly ThemeManager _instance = new ThemeManager ();
static ThemeManager () { } // Make sure it's truly lazy
private ThemeManager () { } // Prevent instantiation outside
Expand Down Expand Up @@ -152,38 +152,20 @@ public string Theme {
}
}

/// <summary>
/// Event arguments for the <see cref="ThemeManager"/> events.
/// </summary>
public class ThemeManagerEventArgs : EventArgs {
/// <summary>
/// The name of the new active theme..
/// </summary>
public string NewTheme { get; set; } = string.Empty;

/// <summary>
/// Initializes a new instance of <see cref="ThemeManagerEventArgs"/>
/// </summary>
public ThemeManagerEventArgs (string newTheme)
{
NewTheme = newTheme;
}
}

/// <summary>
/// Called when the selected theme has changed. Fires the <see cref="ThemeChanged"/> event.
/// </summary>
internal void OnThemeChanged (string theme)
{
Debug.WriteLine ($"Themes.OnThemeChanged({theme}) -> {Theme}");
ThemeChanged?.Invoke (new ThemeManagerEventArgs (theme));
ThemeChanged?.Invoke (this, new ThemeManagerEventArgs (theme));
}

/// <summary>
/// Event fired he selected theme has changed.
/// application.
/// </summary>
public event Action<ThemeManagerEventArgs>? ThemeChanged;
public event EventHandler<ThemeManagerEventArgs>? ThemeChanged;

/// <summary>
/// Holds the <see cref="ThemeScope"/> definitions.
Expand Down
10 changes: 5 additions & 5 deletions Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandle

mLoop.ProcessInput = (e) => ProcessInput (e);

mLoop.WinChanged = (e) => {
ChangeWin (e);
mLoop.WinChanged = (s,e) => {
ChangeWin (e.Size);
};
}

Expand Down Expand Up @@ -1868,8 +1868,8 @@ internal class WindowsMainLoop : IMainLoopDriver {
/// <summary>
/// Invoked when the window is changed.
/// </summary>
public Action<Size> WinChanged;

public EventHandler<SizeChangedEventArgs> WinChanged;
public WindowsMainLoop (ConsoleDriver consoleDriver = null)
{
this.consoleDriver = consoleDriver ?? throw new ArgumentNullException ("Console driver instance must be provided.");
Expand Down Expand Up @@ -1991,7 +1991,7 @@ void IMainLoopDriver.MainIteration ()
}
if (winChanged) {
winChanged = false;
WinChanged?.Invoke (windowSize);
WinChanged?.Invoke (this, new SizeChangedEventArgs(windowSize));
}
}
}
Expand Down
Loading

0 comments on commit 7919764

Please sign in to comment.