mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* touching publish.yml * Moved Examples into ./Examples * Moved Benchmarks into ./Tests * Moved Benchmarks into ./Tests * Moved UICatalog into ./Examples * Moved UICatalog into ./Examples 2 * Moved tests into ./Tests * Updated nuget
This commit is contained in:
4
Examples/FSharpExample/.editorconfig
Normal file
4
Examples/FSharpExample/.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
[*.fs]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
tab_width = 4
|
||||
19
Examples/FSharpExample/FSharpExample.fsproj
Normal file
19
Examples/FSharpExample/FSharpExample.fsproj
Normal file
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AssemblyVersion>1.6.2.0</AssemblyVersion>
|
||||
<FileVersion>1.6.2.0</FileVersion>
|
||||
<InformationalVersion>1.6.2+Branch.main.Sha.b6eeb6321685af474ffc17b1390ff1d4894a90c5</InformationalVersion>
|
||||
<Version>1.6.2</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Update="FSharp.Core" Version="8.0.300" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
31
Examples/FSharpExample/FSharpExample.sln
Normal file
31
Examples/FSharpExample/FSharpExample.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30011.22
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpExample", "FSharpExample.fsproj", "{6E4DF691-FA5F-4D7C-8DBC-8656103C5CB1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Terminal.Gui", "..\Terminal.Gui\Terminal.Gui.csproj", "{FA48E777-1308-489D-95A0-89DE46B65A93}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6E4DF691-FA5F-4D7C-8DBC-8656103C5CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6E4DF691-FA5F-4D7C-8DBC-8656103C5CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6E4DF691-FA5F-4D7C-8DBC-8656103C5CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6E4DF691-FA5F-4D7C-8DBC-8656103C5CB1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA48E777-1308-489D-95A0-89DE46B65A93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA48E777-1308-489D-95A0-89DE46B65A93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA48E777-1308-489D-95A0-89DE46B65A93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA48E777-1308-489D-95A0-89DE46B65A93}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A023D2E3-EF0F-4986-8E6C-323F967788B7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
48
Examples/FSharpExample/Program.fs
Normal file
48
Examples/FSharpExample/Program.fs
Normal file
@@ -0,0 +1,48 @@
|
||||
open Terminal.Gui
|
||||
|
||||
type ExampleWindow() as this =
|
||||
inherit Window()
|
||||
|
||||
do
|
||||
this.Title <- sprintf "Example App (%O to quit)" Application.QuitKey
|
||||
|
||||
// Create input components and labels
|
||||
let usernameLabel = new Label(Text = "Username:")
|
||||
|
||||
let userNameText = new TextField(X = Pos.Right(usernameLabel) + Pos.op_Implicit(1), Width = Dim.Fill())
|
||||
|
||||
let passwordLabel = new Label(Text = "Password:", X = Pos.Left(usernameLabel), Y = Pos.Bottom(usernameLabel) + Pos.op_Implicit(1))
|
||||
|
||||
let passwordText = new TextField(Secret = true, X = Pos.Left(userNameText), Y = Pos.Top(passwordLabel), Width = Dim.Fill())
|
||||
|
||||
// Create login button
|
||||
let btnLogin = new Button(Text = "Login", Y = Pos.Bottom(passwordLabel) + Pos.op_Implicit(1), X = Pos.Center(), IsDefault = true)
|
||||
|
||||
// When login button is clicked display a message popup
|
||||
btnLogin.Accepting.Add(fun _ ->
|
||||
if userNameText.Text = "admin" && passwordText.Text = "password" then
|
||||
MessageBox.Query("Logging In", "Login Successful", "Ok") |> ignore
|
||||
ExampleWindow.UserName <- userNameText.Text.ToString()
|
||||
Application.RequestStop()
|
||||
else
|
||||
MessageBox.ErrorQuery("Logging In", "Incorrect username or password", "Ok") |> ignore
|
||||
)
|
||||
|
||||
// Add the views to the Window
|
||||
this.Add(usernameLabel, userNameText, passwordLabel, passwordText, btnLogin)
|
||||
|
||||
static member val UserName = "" with get, set
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
Application.Init()
|
||||
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.
|
||||
printfn "Username: %s" ExampleWindow.UserName
|
||||
|
||||
0 // return an integer exit code
|
||||
Reference in New Issue
Block a user