Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WinForms sample #888

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/develop-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version:
7.0.x
8.0.x

- name: Build Meadow Foundation
run: dotnet build -c Release Meadow.Foundation/Source/Meadow.Foundation.sln
2 changes: 1 addition & 1 deletion .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version:
7.0.x
8.0.x

- name: Build Meadow Foundation
run: dotnet build -c Release Meadow.Foundation/Source/Meadow.Foundation.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Meadow;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;
using System.Windows.Forms;

namespace WinForms_Sample;

//<!=SNIP=>

public class MeadowApp : App<Meadow.Windows>
{
WinFormsDisplay? _display;
MicroGraphics _graphics = default!;

public override Task Initialize()
{
_display = new WinFormsDisplay(240, 320);

_graphics = new MicroGraphics(_display)
{
CurrentFont = new Font12x20(),
Stroke = 1
};

_ = Task.Run(() =>
{
Thread.Sleep(2000);

_graphics.Clear();

_graphics.DrawTriangle(10, 30, 50, 50, 10, 50, Color.Red);
_graphics.DrawRectangle(20, 45, 40, 20, Color.Yellow, false);
_graphics.DrawCircle(50, 50, 40, Color.Blue, false);
_graphics.DrawText(5, 5, "Meadow F7", Color.White);

_graphics.Show();
});

return Task.CompletedTask;
}

public override Task Run()
{
Application.Run(_display!);

return Task.CompletedTask;
}

public static async Task Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ApplicationConfiguration.Initialize();

await MeadowOS.Start(args);
}
}

//<!=SNOP=>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\..\Meadow.Core\Source\implementations\windows\Meadow.Windows\Meadow.Windows.csproj" />
<ProjectReference Include="..\..\Driver\Displays.WinForms.csproj" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions Source/Meadow.Foundation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amg8833_Sample", "Meadow.Fo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Displays.AsciiConsole", "Meadow.Foundation.Peripherals\Displays.AsciiConsole\Driver\Displays.AsciiConsole.csproj", "{27589062-708E-44CD-9DF4-0D16899265FE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{80EC3729-DB91-4F94-B11D-B611A214BA31}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms_Sample", "Meadow.Foundation.Peripherals\Displays.WinForms\Samples\WinForms_Sample\WinForms_Sample.csproj", "{A5734B07-64C0-4C93-9EB0-390B0B6A075C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -3493,6 +3497,10 @@ Global
{27589062-708E-44CD-9DF4-0D16899265FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27589062-708E-44CD-9DF4-0D16899265FE}.Release|Any CPU.Build.0 = Release|Any CPU
{27589062-708E-44CD-9DF4-0D16899265FE}.Release|Any CPU.Deploy.0 = Release|Any CPU
{A5734B07-64C0-4C93-9EB0-390B0B6A075C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5734B07-64C0-4C93-9EB0-390B0B6A075C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5734B07-64C0-4C93-9EB0-390B0B6A075C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5734B07-64C0-4C93-9EB0-390B0B6A075C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -4214,6 +4222,8 @@ Global
{2F20AD5B-5879-432B-B44F-8540DAEE5C43} = {40687DAC-F3EF-4F70-850A-0429B9586648}
{866EA918-39E3-4440-877C-70A3205A3D00} = {E608C8E7-1B76-4859-9AF9-C868B5C61994}
{27589062-708E-44CD-9DF4-0D16899265FE} = {E775FF9F-8AC5-4994-B45A-20B50E2B03E2}
{80EC3729-DB91-4F94-B11D-B611A214BA31} = {BBF136B7-361C-4FC2-AACA-6B6ED79BDCF1}
{A5734B07-64C0-4C93-9EB0-390B0B6A075C} = {80EC3729-DB91-4F94-B11D-B611A214BA31}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AF7CA16F-8C38-4546-87A2-5DAAF58A1520}
Expand Down
Loading