-
-
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.
- Loading branch information
Showing
26 changed files
with
732 additions
and
64 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class ButtonHandler : WinUIControl<muc.Button, Button, Button.ICallback>, Button.IHandler | ||
{ | ||
muc.TextBlock _textBlock; | ||
public Image Image { get; set; } | ||
public ButtonImagePosition ImagePosition { get; set; } | ||
public Size MinimumSize { get; set; } | ||
|
||
public string Text | ||
{ | ||
get => _textBlock.Text; | ||
set => _textBlock.Text = value; | ||
} | ||
|
||
protected override muc.Button CreateControl() => new muc.Button(); | ||
|
||
protected override void Initialize() | ||
{ | ||
base.Initialize(); | ||
_textBlock = new muc.TextBlock(); | ||
Control.Content = _textBlock; | ||
Control.Click += Control_Click; | ||
} | ||
|
||
private void Control_Click(object sender, mux.RoutedEventArgs e) | ||
{ | ||
Callback.OnClick(Widget, EventArgs.Empty); | ||
} | ||
|
||
public override void AttachEvent(string id) | ||
{ | ||
switch (id) | ||
{ | ||
default: | ||
base.AttachEvent(id); | ||
break; | ||
} | ||
} | ||
} |
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,34 @@ | ||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class CheckBoxHandler : WinUIControl<muc.CheckBox, CheckBox, CheckBox.ICallback>, CheckBox.IHandler | ||
{ | ||
public string Text | ||
{ | ||
get => Control.Content as string; | ||
set => Control.Content = value; | ||
} | ||
public bool? Checked | ||
{ | ||
get => Control.IsChecked; | ||
set => Control.IsChecked = value; | ||
} | ||
public bool ThreeState | ||
{ | ||
get => Control.IsThreeState; | ||
set => Control.IsThreeState = value; | ||
} | ||
|
||
protected override muc.CheckBox CreateControl() => new(); | ||
|
||
protected override void Initialize() | ||
{ | ||
base.Initialize(); | ||
Control.Checked += Control_Checked; | ||
} | ||
|
||
private void Control_Checked(object sender, mux.RoutedEventArgs e) | ||
{ | ||
Callback.OnCheckedChanged(Widget, EventArgs.Empty); | ||
} | ||
|
||
} |
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,39 @@ | ||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class DropDownHandler : WinUIControl<muc.ComboBox, DropDown, DropDown.ICallback>, DropDown.IHandler | ||
{ | ||
public bool ShowBorder { get; set; } | ||
IEnumerable<object> _store; | ||
public IEnumerable<object> DataStore | ||
{ | ||
get => _store; | ||
set | ||
{ | ||
_store = value; | ||
var source = _store; | ||
if (_store is not INotifyCollectionChanged) | ||
source = new ObservableCollection<object>(_store); | ||
Control.ItemsSource = source; | ||
} | ||
} | ||
public int SelectedIndex | ||
{ | ||
get => Control.SelectedIndex; | ||
set => Control.SelectedIndex = value; | ||
} | ||
public IIndirectBinding<string> ItemTextBinding { get; set; } | ||
public IIndirectBinding<string> ItemKeyBinding { get; set; } | ||
|
||
protected override muc.ComboBox CreateControl() => new(); | ||
protected override void Initialize() | ||
{ | ||
base.Initialize(); | ||
Control.SelectionChanged += Control_SelectionChanged; | ||
} | ||
|
||
private void Control_SelectionChanged(object sender, muc.SelectionChangedEventArgs e) | ||
{ | ||
Callback.OnSelectedIndexChanged(Widget, EventArgs.Empty); | ||
} | ||
|
||
} |
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,40 @@ | ||
|
||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class ListBoxHandler : WinUIControl<muc.ListView, ListBox, ListBox.ICallback>, ListBox.IHandler | ||
{ | ||
IEnumerable<object> _store; | ||
public IEnumerable<object> DataStore | ||
{ | ||
get => _store; | ||
set | ||
{ | ||
_store = value; | ||
var source = _store; | ||
if (_store is not INotifyCollectionChanged) | ||
source = new ObservableCollection<object>(_store); | ||
Control.ItemsSource = source; | ||
} | ||
} | ||
public int SelectedIndex | ||
{ | ||
get => Control.SelectedIndex; | ||
set => Control.SelectedIndex = value; | ||
} | ||
public IIndirectBinding<string> ItemTextBinding { get; set; } | ||
public IIndirectBinding<string> ItemKeyBinding { get; set; } | ||
public ContextMenu ContextMenu { get; set; } | ||
|
||
protected override muc.ListView CreateControl() => new(); | ||
|
||
protected override void Initialize() | ||
{ | ||
base.Initialize(); | ||
Control.SelectionChanged += Control_SelectionChanged; | ||
} | ||
|
||
private void Control_SelectionChanged(object sender, muc.SelectionChangedEventArgs e) | ||
{ | ||
Callback.OnSelectedIndexChanged(Widget, EventArgs.Empty); | ||
} | ||
} |
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,26 @@ | ||
|
||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class PanelHandler : WinUIContainer<muc.Border, Panel, Panel.ICallback>, Panel.IHandler | ||
{ | ||
Control _content; | ||
public Control Content | ||
{ | ||
get => _content; | ||
set | ||
{ | ||
if (_content != value) | ||
{ | ||
_content = value; | ||
Control.Child = value.ToNative(); | ||
} | ||
} | ||
} | ||
|
||
public Padding Padding { get; set; } | ||
public Size MinimumSize { get; set; } | ||
public ContextMenu ContextMenu { get; set; } | ||
public override mux.FrameworkElement ContainerControl => Control; | ||
|
||
protected override muc.Border CreateControl() => new(); | ||
} |
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,43 @@ | ||
|
||
|
||
namespace Eto.WinUI.Forms.Controls; | ||
|
||
public class ScrollableHandler : WinUIContainer<muc.ScrollView, Scrollable, Scrollable.ICallback>, Scrollable.IHandler | ||
{ | ||
Control _content; | ||
public Control Content | ||
{ | ||
get => _content; | ||
set | ||
{ | ||
if (_content != value) | ||
{ | ||
_content = value; | ||
Control.Content = value.ToNative(); | ||
} | ||
} | ||
} | ||
|
||
public Padding Padding { get; set; } | ||
public Size MinimumSize { get; set; } | ||
public ContextMenu ContextMenu { get; set; } | ||
|
||
protected override muc.ScrollView CreateControl() => new(); | ||
|
||
public void UpdateScrollSizes() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override mux.FrameworkElement ContainerControl => Control; | ||
|
||
public Point ScrollPosition { get; set; } | ||
public Size ScrollSize { get; set; } | ||
public BorderType Border { get; set; } | ||
public Rectangle VisibleRect { get; } | ||
public bool ExpandContentWidth { get; set; } | ||
public bool ExpandContentHeight { get; set; } | ||
public float MinimumZoom { get; set; } | ||
public float MaximumZoom { get; set; } | ||
public float Zoom { 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,52 @@ | ||
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 => (int)Control.OpenPaneLength; | ||
set => Control.OpenPaneLength = value; | ||
} | ||
|
||
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 => Widget.Controls; | ||
|
||
protected override muc.SplitView CreateControl() => new muc.SplitView | ||
{ | ||
DisplayMode = muc.SplitViewDisplayMode.Inline, | ||
IsPaneOpen = true | ||
}; | ||
} |
Oops, something went wrong.