-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2652 from cwensley/curtis/winui
Initial basic WinUI 3 platform
- Loading branch information
Showing
35 changed files
with
2,794 additions
and
9 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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"microsoft.net.sdk.macos": "12.3.2372" | ||
"microsoft.net.sdk.macos": "14.0.8478" | ||
} |
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
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,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> |
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,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; | ||
} | ||
} |
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,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; } | ||
} | ||
} |
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,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(); | ||
} | ||
} |
Oops, something went wrong.