Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,75 +9,75 @@ namespace Maui.Controls.Sample;

public partial class AbsoluteLayoutOptionsPage : ContentPage
{
private AbsoluteLayoutViewModel _viewModel;
public AbsoluteLayoutOptionsPage(AbsoluteLayoutViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
}
private AbsoluteLayoutViewModel _viewModel;
public AbsoluteLayoutOptionsPage(AbsoluteLayoutViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
}

private void ApplyButton_Clicked(object sender, EventArgs e)
{
Navigation.PopAsync();
}
private void ApplyButton_Clicked(object sender, EventArgs e)
{
Navigation.PopAsync();
}

private void OnLayoutFlagCheckedChanged(object sender, CheckedChangedEventArgs e)
{
AbsoluteLayoutFlags flags = AbsoluteLayoutFlags.None;
private void OnLayoutFlagCheckedChanged(object sender, CheckedChangedEventArgs e)
{
AbsoluteLayoutFlags flags = AbsoluteLayoutFlags.None;

if (chkX.IsChecked)
flags |= AbsoluteLayoutFlags.XProportional;
if (chkY.IsChecked)
flags |= AbsoluteLayoutFlags.YProportional;
if (chkWidth.IsChecked)
flags |= AbsoluteLayoutFlags.WidthProportional;
if (chkHeight.IsChecked)
flags |= AbsoluteLayoutFlags.HeightProportional;
if (chkPosition.IsChecked)
flags |= AbsoluteLayoutFlags.PositionProportional;
if (chkSize.IsChecked)
flags |= AbsoluteLayoutFlags.SizeProportional;
if (chkAll.IsChecked)
flags |= AbsoluteLayoutFlags.All;
if (chkX.IsChecked)
flags |= AbsoluteLayoutFlags.XProportional;
if (chkY.IsChecked)
flags |= AbsoluteLayoutFlags.YProportional;
if (chkWidth.IsChecked)
flags |= AbsoluteLayoutFlags.WidthProportional;
if (chkHeight.IsChecked)
flags |= AbsoluteLayoutFlags.HeightProportional;
if (chkPosition.IsChecked)
flags |= AbsoluteLayoutFlags.PositionProportional;
if (chkSize.IsChecked)
flags |= AbsoluteLayoutFlags.SizeProportional;
if (chkAll.IsChecked)
flags |= AbsoluteLayoutFlags.All;

if (chkNone.IsChecked)
flags = AbsoluteLayoutFlags.None;
if (chkNone.IsChecked)
flags = AbsoluteLayoutFlags.None;

_viewModel.LayoutFlags = flags;
}
_viewModel.LayoutFlags = flags;
}

private void IsVisibleRadio_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if (!(sender is RadioButton rb) || !rb.IsChecked)
return;
_viewModel.IsVisible = rb.Content?.ToString() == "True";
}
private void IsVisibleRadio_CheckedChanged(object sender, CheckedChangedEventArgs e)
{
if (!(sender is RadioButton rb) || !rb.IsChecked)
return;
_viewModel.IsVisible = rb.Content?.ToString() == "True";
}

private void OnFlowDirectionChanged(object sender, EventArgs e)
{
_viewModel.FlowDirection = FlowDirectionLTR.IsChecked ? FlowDirection.LeftToRight : FlowDirection.RightToLeft;
}
private void OnBackgroundColorChanged(object sender, EventArgs e)
{
if (BindingContext is AbsoluteLayoutViewModel vm && sender is Button button && button.Text is string color)
{
switch (color)
{
case "Red":
vm.BackgroundColor = Colors.Red;
break;
case "Gray":
vm.BackgroundColor = Colors.Gray;
break;
case "LightYellow":
vm.BackgroundColor = Colors.LightYellow;
break;
default:
vm.BackgroundColor = Colors.White;
break;
}
}
}
private void OnFlowDirectionChanged(object sender, EventArgs e)
{
_viewModel.FlowDirection = FlowDirectionLTR.IsChecked ? FlowDirection.LeftToRight : FlowDirection.RightToLeft;
}

private void OnBackgroundColorChanged(object sender, EventArgs e)
{
if (BindingContext is AbsoluteLayoutViewModel vm && sender is Button button && button.Text is string color)
{
switch (color)
{
case "Red":
vm.BackgroundColor = Colors.Red;
break;
case "Gray":
vm.BackgroundColor = Colors.Gray;
break;
case "LightYellow":
vm.BackgroundColor = Colors.LightYellow;
break;
default:
vm.BackgroundColor = Colors.White;
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,85 @@ namespace Maui.Controls.Sample;

public class AbsoluteLayoutViewModel : INotifyPropertyChanged
{
double _x = 0, _y = 0;
double _width = AbsoluteLayout.AutoSize;
double _height = AbsoluteLayout.AutoSize;
private bool _isVisible = true;
private Color _backgroundColor = Colors.Lavender;
private FlowDirection _flowDirection = FlowDirection.LeftToRight;
AbsoluteLayoutFlags _layoutFlags = AbsoluteLayoutFlags.None;
public Rect Bounds => new Rect(X, Y, Width, Height);
double _x = 0, _y = 0;
double _width = AbsoluteLayout.AutoSize;
double _height = AbsoluteLayout.AutoSize;
private bool _isVisible = true;
private Color _backgroundColor = Colors.Lavender;
private FlowDirection _flowDirection = FlowDirection.LeftToRight;
AbsoluteLayoutFlags _layoutFlags = AbsoluteLayoutFlags.None;
public Rect Bounds => new Rect(X, Y, Width, Height);

public double X
{
get => _x;
set { _x = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}
public double X
{
get => _x;
set { _x = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}

public double Y
{
get => _y;
set { _y = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}
public double Y
{
get => _y;
set { _y = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}

public double Width
{
get => _width;
set { _width = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}
public double Width
{
get => _width;
set { _width = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}

public double Height
{
get => _height;
set { _height = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}
public double Height
{
get => _height;
set { _height = value; OnPropertyChanged(); OnPropertyChanged(nameof(Bounds)); }
}

public AbsoluteLayoutFlags LayoutFlags
{
get => _layoutFlags;
set { _layoutFlags = value; OnPropertyChanged(); }
}
public AbsoluteLayoutFlags LayoutFlags
{
get => _layoutFlags;
set { _layoutFlags = value; OnPropertyChanged(); }
}

public Color BackgroundColor
{
get => _backgroundColor;
set
{
if (_backgroundColor != value)
{
_backgroundColor = value;
OnPropertyChanged();
}
}
}
public Color BackgroundColor
{
get => _backgroundColor;
set
{
if (_backgroundColor != value)
{
_backgroundColor = value;
OnPropertyChanged();
}
}
}

public bool IsVisible
{
get => _isVisible;
set
{
if (_isVisible != value)
{
_isVisible = value;
OnPropertyChanged();
}
}
}
public bool IsVisible
{
get => _isVisible;
set
{
if (_isVisible != value)
{
_isVisible = value;
OnPropertyChanged();
}
}
}

public FlowDirection FlowDirection
{
get => _flowDirection;
set
{
if (_flowDirection != value)
{
_flowDirection = value;
OnPropertyChanged();
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public FlowDirection FlowDirection
{
get => _flowDirection;
set
{
if (_flowDirection != value)
{
_flowDirection = value;
OnPropertyChanged();
}
}
}

public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Loading