-
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update for latest Eto/.NET 8 and get minimal example working
- Loading branch information
Showing
12 changed files
with
164 additions
and
23 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
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
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,6 +1,20 @@ | ||
|
||
namespace Eto.WinUI.Forms.Controls | ||
{ | ||
internal class LabelHandler : WinUIFrameworkElement<> | ||
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Eto.Drawing; | ||
using Eto.Drawing; | ||
using Eto.Forms; | ||
|
||
namespace Eto.WinUI.Forms | ||
|
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
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
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,90 @@ | ||
using Eto.WinUI.Forms; | ||
using Eto.WinUI.Forms.Controls; | ||
using System.Diagnostics.Metrics; | ||
|
||
namespace Eto.Forms | ||
{ | ||
public static class WinUIHelpers | ||
{ | ||
/// <summary> | ||
/// Gets the native Wpf framework element that contains the Eto.Forms control. | ||
/// </summary> | ||
/// <remarks> | ||
/// Note for some controls, this will not be the 'main' native control. | ||
/// For example, a GridView on OS X will return a NSScrollView instead of a NSTableView, since the table view | ||
/// itself does not scroll. | ||
/// | ||
/// When you intend on using the control inside an existing native application, set <paramref name="attach"/> to | ||
/// true so that it can prepare for attaching to the native application by sending OnPreLoad/Load/LoadComplete events. | ||
/// </remarks> | ||
/// <returns>The native control that can be used to add this control to an existing application.</returns> | ||
/// <param name="control">Control to get the native control for.</param> | ||
/// <param name="attach">If set to <c>true</c> the control is to be attached to an existing application, or <c>false</c> to get the native control directly.</param> | ||
public static mux.FrameworkElement ToNative(this Control control, bool attach = false) | ||
{ | ||
if (control?.Handler is not IWinUIFrameworkElement handler) | ||
return null; | ||
|
||
if (attach && !control.Loaded) | ||
{ | ||
control.AttachNative(); | ||
// handler.SetScale(false, false); | ||
} | ||
return handler.ContainerControl; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the native WPF window of the specified Eto window | ||
/// </summary> | ||
/// <param name="window">Eto window to get the native control for</param> | ||
/// <returns>The native WPF window object.</returns> | ||
public static mux.Window ToNative(this Window window) | ||
{ | ||
if (window == null) | ||
return null; | ||
return (window.Handler as IWinUIWindow)?.Control; | ||
} | ||
|
||
/// <summary> | ||
/// Wraps the specified <paramref name="nativeControl"/> to an Eto control that can be used directly in Eto.Forms code. | ||
/// </summary> | ||
/// <returns>The eto control wrapper around the native control.</returns> | ||
/// <param name="nativeControl">Native control to wrap.</param> | ||
public static Control ToEto(this mux.FrameworkElement nativeControl) | ||
{ | ||
if (nativeControl == null) | ||
return null; | ||
return new NativeControlHost(nativeControl); | ||
} | ||
|
||
/// <summary> | ||
/// Wraps the specified WPF <paramref name="window"/> in an Eto control so it can be used as a parent when showing dialogs, etc. | ||
/// </summary> | ||
/// <returns>The eto window wrapper around the native WPF window.</returns> | ||
/// <param name="window">WPF Window to wrap.</param> | ||
public static Window ToEtoWindow(this mux.Window window) | ||
{ | ||
if (window == null) | ||
return null; | ||
throw new NotImplementedException(); | ||
//return new Form(new NativeFormHandler(window)); | ||
} | ||
|
||
/// <summary> | ||
/// Wraps a native win32 window in an Eto control so it can be used as a parent when showing dialogs, etc. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is useful when your application is fully native and does not use WinForms or Wpf. | ||
/// </remarks> | ||
/// <returns>The eto window wrapper around the win32 window with the specified handle.</returns> | ||
/// <param name="windowHandle">Handle of the win32 window.</param> | ||
public static Window ToEtoWindow(IntPtr windowHandle) | ||
{ | ||
if (windowHandle == IntPtr.Zero) | ||
return null; | ||
throw new NotImplementedException(); | ||
//return new Form(new HwndFormHandler(windowHandle)); | ||
} | ||
|
||
} | ||
} |
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