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

Initial basic WinUI 3 platform #2652

Merged
merged 4 commits into from
Jun 27, 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
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: [ published ]

env:
DotNetVersion: "7.0.116"
DotNetVersion: "8.0.106"
BuildConfiguration: "Release"
BuildParameters: "build/Build.proj /v:Minimal /consoleLoggerParameters:NoSummary /p:Configuration=Release /p:BuildVersion=${{ github.run_id }} /p:BuildBranch=${{ github.ref }}"

Expand All @@ -28,6 +28,9 @@ jobs:
with:
dotnet-version: ${{ env.DotNetVersion }}

- name: Create global.json
run: echo '{"sdk":{"version":"${{ env.DotNetVersion }}"}}' > global.json

- name: Build
run: dotnet build ${{ env.BuildParameters }} /p:Platform=Windows /t:Build /bl:artifacts/log/Build.Windows.binlog

Expand Down Expand Up @@ -72,7 +75,7 @@ jobs:
with:
dotnet-version: ${{ env.DotNetVersion }}

- name: Create global.json for the version we are using
- name: Create global.json
run: del global.json || echo '{"sdk":{"version":"${{ env.DotNetVersion }}"}}' > global.json

- name: Install macos workload
Expand Down
2 changes: 1 addition & 1 deletion dotnet-workloads.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"microsoft.net.sdk.macos": "12.3.2372"
"microsoft.net.sdk.macos": "14.0.8478"
}
2 changes: 1 addition & 1 deletion src/Eto.Mac/Eto.macOS.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework Condition="$(TargetFrameworkOverride) == ''">net6.0-macos10.15</TargetFramework>
<TargetFramework Condition="$(TargetFrameworkOverride) == ''">net7.0-macos10.15</TargetFramework>
<TargetFramework Condition="$(TargetFrameworkOverride) != ''">$(TargetFrameworkOverride)</TargetFramework>
<RootNamespace>Eto.Mac</RootNamespace>
<DefineConstants>$(DefineConstants);OSX;DESKTOP;UNIFIED;MACOS_NET;USE_CFSTRING</DefineConstants>
Expand Down
31 changes: 31 additions & 0 deletions src/Eto.WinUI/Eto.WinUI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>Eto.WinUI</RootNamespace>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<WindowsPackageType>None</WindowsPackageType>
<PackageId>Eto.Platform.WinUI</PackageId>
</PropertyGroup>

<ItemGroup>
<Using Include="Microsoft.UI.Xaml" Alias="mux" />
<Using Include="Microsoft.UI.Xaml.Media" Alias="muxm" />
<Using Include="Microsoft.UI.Dispatching" Alias="mud" />
<Using Include="Microsoft.UI.Xaml.Controls" Alias="muc" />
<Using Include="Windows.Foundation" Alias="sw" />
<Using Include="Windows.Foundation" Alias="wf" />
<Using Include="Windows.UI" Alias="wu" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240428000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Eto\Eto.csproj" />
</ItemGroup>
</Project>
84 changes: 84 additions & 0 deletions src/Eto.WinUI/Forms/ApplicationHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
namespace Eto.WinUI.Forms;

public class ApplicationHandler : WidgetHandler<mux.Application, Application, Application.ICallback>, Application.IHandler
{
mud.DispatcherQueue _dispatcher;
Thread _mainThread;

public bool QuitIsSupported => true;
public Keys CommonModifier => Keys.Control;
public Keys AlternateModifier => Keys.Alt;
public string BadgeLabel { get; set; }
public bool IsActive { get; }

public ApplicationHandler()
{
Control = mux.Application.Current;
}

public void AsyncInvoke(Action action)
{
_dispatcher.TryEnqueue(new mud.DispatcherQueueHandler(action));
}

public void Attach(object context)
{
Control = context as mux.Application;
}

protected override void Initialize()
{
base.Initialize();
_dispatcher = mud.DispatcherQueue.GetForCurrentThread();
_mainThread = Thread.CurrentThread;
}

public void Invoke(Action action)
{

if (_dispatcher == null || Thread.CurrentThread == _mainThread)
action();
else
{
var mre = new ManualResetEvent(false);
_dispatcher.TryEnqueue(() =>
{
action();
mre.Set();
});
mre.WaitOne();
}
}

public void OnMainFormChanged()
{
//mux.Application.Current..MainWindow = Widget.MainForm.ToNative();
}

public void Open(string url)
{
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}

public void Quit()
{
Control.Exit();
}

public void Restart()
{
}

public void Run()
{
Callback.OnInitialized(Widget, EventArgs.Empty);
}

public void RunIteration()
{
//var frame = new DispatcherFrame();
//Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame);
//Dispatcher.PushFrame(frame);
//WpfFrameworkElementHelper.ShouldCaptureMouse = false;
}
}
20 changes: 20 additions & 0 deletions src/Eto.WinUI/Forms/Controls/LabelHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

namespace Eto.WinUI.Forms.Controls
{
public class LabelHandler : WinUIFrameworkElement<muc.TextBlock, Label, Label.ICallback>, Label.IHandler
{
public override mux.FrameworkElement ContainerControl => Control;
protected override muc.TextBlock CreateControl() => new muc.TextBlock();

public TextAlignment TextAlignment { get; set; }
public VerticalAlignment VerticalAlignment { get; set; }
public WrapMode Wrap { get; set; }
public string Text
{
get => Control.Text;
set => Control.Text = value;
}
public Color TextColor { get; set; }
public Font Font { get; set; }
}
}
17 changes: 17 additions & 0 deletions src/Eto.WinUI/Forms/FormHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using mui = Microsoft.UI.Xaml;

namespace Eto.WinUI.Forms;

public class FormHandler : WinUIWindow<mui.Window, Form, Form.ICallback>, Form.IHandler
{
protected override mui.Window CreateControl() => new mui.Window();

public bool ShowActivated { get; set; }
public bool CanFocus { get; set; }

public void Show()
{
//Control.CoreWindow.Di = Windows.UI.Core.CoreWindowActivationMode.ActivatedNotForeground;
Control.Activate();
}
}
Loading
Loading