Skip to content

Commit

Permalink
Merge pull request #3582 from BDisp/v2_3574_self-contained-single-file
Browse files Browse the repository at this point in the history
Fixes #3574. Enabling trim mode breaks program at runtime (v2 only)
  • Loading branch information
tig authored Jul 12, 2024
2 parents 7dc12a4 + abdde3a commit f1fe7e7
Show file tree
Hide file tree
Showing 38 changed files with 521 additions and 517 deletions.
6 changes: 0 additions & 6 deletions Directory.Build.props

This file was deleted.

5 changes: 0 additions & 5 deletions Directory.Build.targets

This file was deleted.

41 changes: 21 additions & 20 deletions Example/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
using System;
using Terminal.Gui;

var app = Application.Run<ExampleWindow> ();

Console.WriteLine ($"Username: {app.UserNameText.Text}");

app.Dispose ();
Application.Run<ExampleWindow> ().Dispose ();

// Before the application exits, reset Terminal.Gui for clean shutdown
Application.Shutdown ();

// To see this output on the screen it must be done after shutdown,
// which restores the previous screen.
Console.WriteLine ($@"Username: {ExampleWindow.UserName}");

// Defines a top-level window with border and title
public class ExampleWindow : Window
{
public TextField UserNameText;
public static string UserName;

public ExampleWindow ()
{
Expand All @@ -27,7 +27,7 @@ public ExampleWindow ()
// Create input components and labels
var usernameLabel = new Label { Text = "Username:" };

UserNameText = new TextField
var userNameText = new TextField
{
// Position text field adjacent to the label
X = Pos.Right (usernameLabel) + 1,
Expand All @@ -46,7 +46,7 @@ public ExampleWindow ()
Secret = true,

// align with the text box above
X = Pos.Left (UserNameText),
X = Pos.Left (userNameText),
Y = Pos.Top (passwordLabel),
Width = Dim.Fill ()
};
Expand All @@ -64,19 +64,20 @@ public ExampleWindow ()

// When login button is clicked display a message popup
btnLogin.Accept += (s, e) =>
{
if (UserNameText.Text == "admin" && passwordText.Text == "password")
{
MessageBox.Query ("Logging In", "Login Successful", "Ok");
Application.RequestStop ();
}
else
{
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
};
{
if (userNameText.Text == "admin" && passwordText.Text == "password")
{
MessageBox.Query ("Logging In", "Login Successful", "Ok");
UserName = userNameText.Text;
Application.RequestStop ();
}
else
{
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
};

// Add the views to the Window
Add (usernameLabel, UserNameText, passwordLabel, passwordText, btnLogin);
Add (usernameLabel, userNameText, passwordLabel, passwordText, btnLogin);
}
}
3 changes: 3 additions & 0 deletions FSharpExample/FSharpExample.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="8.0.300" />
</ItemGroup>
</Project>
Loading

0 comments on commit f1fe7e7

Please sign in to comment.