-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WinUI: Add Button/Splitter and fill out properties of Label
- Loading branch information
Showing
9 changed files
with
207 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class ButtonHandler : WinUIControl<muc.Button, Button, Button.ICallback>, Button.IHandler | ||
{ | ||
public Image Image { get; set; } | ||
public ButtonImagePosition ImagePosition { get; set; } | ||
public Size MinimumSize { get; set; } | ||
|
||
public string Text | ||
{ | ||
get => Control.Content as string; | ||
set => Control.Content = value; | ||
} | ||
|
||
public Color TextColor | ||
{ | ||
get => Control.Foreground.ToEtoColor(); | ||
set => Control.Foreground = value.ToWinUIBrush(); | ||
} | ||
|
||
public Font Font { get; set; } | ||
|
||
protected override muc.Button CreateControl() => new muc.Button(); | ||
|
||
} |
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,20 +1,51 @@ | ||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
namespace Eto.WinUI.Forms.Controls | ||
public class LabelHandler : WinUIFrameworkElement<muc.TextBlock, Label, Label.ICallback>, Label.IHandler | ||
{ | ||
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 => Control.TextAlignment.ToEto(); | ||
set => Control.TextAlignment = value.ToWinUI(); | ||
} | ||
|
||
public VerticalAlignment VerticalAlignment | ||
{ | ||
public override mux.FrameworkElement ContainerControl => Control; | ||
protected override muc.TextBlock CreateControl() => new muc.TextBlock(); | ||
get => Control.VerticalAlignment.ToEto(); | ||
set => Control.VerticalAlignment = value.ToWinUI(); | ||
} | ||
|
||
public TextAlignment TextAlignment { get; set; } | ||
public VerticalAlignment VerticalAlignment { get; set; } | ||
public WrapMode Wrap { get; set; } | ||
public string Text | ||
public WrapMode Wrap | ||
{ | ||
get => Control.TextWrapping.ToEto(); | ||
set => Control.TextWrapping = value.ToWinUI(); | ||
} | ||
public string Text | ||
{ | ||
get => Control.Text; | ||
set => Control.Text = value; | ||
} | ||
public Color TextColor | ||
{ | ||
get => Control.Foreground.ToEtoColor(); | ||
set => Control.Foreground = value.ToWinUIBrush(); | ||
} | ||
|
||
public Font Font { get; set; } | ||
|
||
public override void AttachEvent(string id) | ||
{ | ||
switch (id) | ||
{ | ||
get => Control.Text; | ||
set => Control.Text = value; | ||
case TextControl.TextChangedEvent: | ||
// do nothing, label doesn't get updated by the user | ||
break; | ||
|
||
default: | ||
base.AttachEvent(id); | ||
break; | ||
} | ||
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,56 @@ | ||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class SplitterHandler : WinUIControl<muc.SplitView, Splitter, Splitter.ICallback>, Splitter.IHandler | ||
{ | ||
Control _panel1; | ||
Control _panel2; | ||
public Orientation Orientation { get; set; } | ||
public SplitterFixedPanel FixedPanel { get; set; } | ||
public int Position { get; set; } | ||
public double RelativePosition { get; set; } | ||
public int SplitterWidth { get; set; } | ||
public Control Panel1 | ||
{ | ||
get => _panel1; | ||
set | ||
{ | ||
if (_panel1 == value) | ||
return; | ||
_panel1 = value; | ||
Control.Pane = value.ToNative(); | ||
} | ||
} | ||
public Control Panel2 | ||
{ | ||
get => _panel2; | ||
set | ||
{ | ||
if (_panel2 == value) | ||
return; | ||
|
||
_panel2 = value; | ||
Control.Content = value.ToNative(); | ||
} | ||
} | ||
public int Panel1MinimumSize { get; set; } | ||
public int Panel2MinimumSize { get; set; } | ||
public Size ClientSize { get; set; } | ||
public bool RecurseToChildren => true; | ||
|
||
public override IEnumerable<Control> VisualControls | ||
{ | ||
get | ||
{ | ||
yield return _panel1; | ||
yield return _panel2; | ||
} | ||
} | ||
|
||
protected override muc.SplitView CreateControl() => new(); | ||
|
||
protected override void Initialize() | ||
{ | ||
base.Initialize(); | ||
Control.DisplayMode = muc.SplitViewDisplayMode.Inline; | ||
} | ||
} |
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 Microsoft.UI.Xaml; | ||
|
||
namespace Eto.WinUI.Forms; | ||
|
||
public abstract class WinUIControl<TControl, TWidget, TCallback> : WinUIFrameworkElement<TControl, TWidget, TCallback>, Control.IHandler | ||
where TControl : muc.Control | ||
where TWidget : Control | ||
where TCallback : Control.ICallback | ||
{ | ||
public override FrameworkElement ContainerControl => Control; | ||
public override Color BackgroundColor | ||
{ | ||
get => Control.Background.ToEtoColor(); | ||
set => Control.Background = value.ToWinUIBrush(); | ||
} | ||
} |
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