-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new example showing a Menu control.
Fixes #25
- Loading branch information
1 parent
f73cd35
commit 4a80ea5
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
demos/LibUISharp.Demos.SimpleWindowWithMenu/LibUISharp.Demos.SimpleWindowWithMenu.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\source\LibUISharp\LibUISharp.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using LibUISharp; | ||
using LibUISharp.Drawing; | ||
|
||
namespace LibUISharpDemos.SimpleWindowWithMenu | ||
{ | ||
internal class Program | ||
{ | ||
// This MUST be static, or dotnet itself will crash. | ||
private static Menu menu; | ||
|
||
public static void Main() | ||
{ | ||
// Initialize application. | ||
Application app = new Application(); | ||
|
||
// Create the menu and it's items. | ||
menu = new Menu("Demo"); | ||
|
||
// The next line unfourtunately doesn't work, but it's not possible since we need a Window reference. | ||
// menu.AddAboutItem(click => Window.ShowMessageBox(w, "Demo", "Demo")); | ||
|
||
menu.AddAboutItem(); | ||
menu.AddSeparator(); | ||
menu.AddQuitItem(); | ||
|
||
// Initialize the window. | ||
Window w = new MainWindow(); | ||
app.Run(w); | ||
} | ||
} | ||
|
||
public class MainWindow : Window | ||
{ | ||
// You MUST specify the hasMenu parameter of the base Window class to have a visible menu at the top of the Window. | ||
public MainWindow() : base("LibUISharp Control Gallery", new Size(640, 480), true) => InitializeComponent(); | ||
|
||
protected sealed override void InitializeComponent() | ||
{ | ||
IsMargined = true; | ||
} | ||
} | ||
} |