Skip to content

Commit

Permalink
Reorg and add TableLayout to WinUI
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Jun 27, 2024
1 parent 15b4134 commit 549fd3a
Show file tree
Hide file tree
Showing 31 changed files with 1,991 additions and 616 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/Eto.WinUI/Eto.WinUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
<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>
Expand Down
134 changes: 66 additions & 68 deletions src/Eto.WinUI/Forms/ApplicationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,86 +1,84 @@
using Eto.Forms;
namespace Eto.WinUI.Forms
namespace Eto.WinUI.Forms;

public class ApplicationHandler : WidgetHandler<mux.Application, Application, Application.ICallback>, Application.IHandler
{
public class ApplicationHandler : WidgetHandler<mux.Application, Application, Application.ICallback>, Application.IHandler
{
mud.DispatcherQueue _dispatcher;
Thread _mainThread;
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 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 ApplicationHandler()
{
Control = mux.Application.Current;
}

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

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

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

public void Invoke(Action action)
{
public void Invoke(Action action)
{

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

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

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

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

public void Restart()
{
}
public void Restart()
{
}

public void Run()
{
Callback.OnInitialized(Widget, EventArgs.Empty);
}
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;
}
public void RunIteration()
{
//var frame = new DispatcherFrame();
//Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame);
//Dispatcher.PushFrame(frame);
//WpfFrameworkElementHelper.ShouldCaptureMouse = false;
}
}
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

0 comments on commit 549fd3a

Please sign in to comment.