Skip to content

Commit

Permalink
Add new example showing a Menu control.
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
simplexidev committed Jul 8, 2018
1 parent f73cd35 commit 4a80ea5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LibUISharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibUISharp.Demos.SimpleWind
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibUISharp.Demos.Histogram", "demos\LibUISharp.Demos.Histogram\LibUISharp.Demos.Histogram.csproj", "{E5DC1587-E591-48BE-BB83-A0DA7A8BFA99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibUISharp.Demos.SimpleWindowWithMenu", "demos\LibUISharp.Demos.SimpleWindowWithMenu\LibUISharp.Demos.SimpleWindowWithMenu.csproj", "{3930D1F8-F9FA-48A0-8759-C1B45728F924}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +35,10 @@ Global
{E5DC1587-E591-48BE-BB83-A0DA7A8BFA99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5DC1587-E591-48BE-BB83-A0DA7A8BFA99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5DC1587-E591-48BE-BB83-A0DA7A8BFA99}.Release|Any CPU.Build.0 = Release|Any CPU
{3930D1F8-F9FA-48A0-8759-C1B45728F924}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3930D1F8-F9FA-48A0-8759-C1B45728F924}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3930D1F8-F9FA-48A0-8759-C1B45728F924}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3930D1F8-F9FA-48A0-8759-C1B45728F924}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
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>
42 changes: 42 additions & 0 deletions demos/LibUISharp.Demos.SimpleWindowWithMenu/Program.cs
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;
}
}
}

0 comments on commit 4a80ea5

Please sign in to comment.