Browse Source

Rename NativeMenuItem.Enabled to IsEnabled, and NeedsUpdateEvent to Opening event.

pull/3762/head
Dan Walmsley 7 years ago
parent
commit
68197f8858
  1. 2
      samples/ControlCatalog/MainWindow.xaml.cs
  2. 4
      src/Avalonia.Controls/NativeMenu.cs
  3. 14
      src/Avalonia.Controls/NativeMenuItem.cs
  4. 4
      src/Avalonia.FreeDesktop/DBusMenuExporter.cs
  5. 2
      src/Avalonia.Native/IAvnMenuItem.cs

2
samples/ControlCatalog/MainWindow.xaml.cs

@ -32,7 +32,7 @@ namespace ControlCatalog
var fileMenu = (NativeMenu.GetMenu(this).Items[0] as NativeMenuItem).Menu;
fileMenu.NeedsUpdate += (sender, e)=>
fileMenu.Opening += (sender, e)=>
{
fileMenu.Items.Clear();
fileMenu.Items.Add(new NativeMenuItem("Test 1"));

4
src/Avalonia.Controls/NativeMenu.cs

@ -18,7 +18,7 @@ namespace Avalonia.Controls
/// <summary>
/// Raised when the user clicks the menu and before its opened. Use this event to update the menu dynamically.
/// </summary>
public event EventHandler<EventArgs> NeedsUpdate;
public event EventHandler<EventArgs> Opening;
public NativeMenu()
{
@ -28,7 +28,7 @@ namespace Avalonia.Controls
void INativeMenuExporterEventsImplBridge.RaiseNeedsUpdate ()
{
NeedsUpdate?.Invoke(this, EventArgs.Empty);
Opening?.Invoke(this, EventArgs.Empty);
}
private void Validator(NativeMenuItemBase obj)

14
src/Avalonia.Controls/NativeMenuItem.cs

@ -9,7 +9,7 @@ namespace Avalonia.Controls
{
private string _header;
private KeyGesture _gesture;
private bool _enabled = true;
private bool _isEnabled = true;
private ICommand _command;
private bool _isChecked = false;
@ -112,18 +112,18 @@ namespace Avalonia.Controls
public static readonly StyledProperty<object> CommandParameterProperty =
Button.CommandParameterProperty.AddOwner<MenuItem>();
public static readonly DirectProperty<NativeMenuItem, bool> EnabledProperty =
AvaloniaProperty.RegisterDirect<NativeMenuItem, bool>(nameof(Enabled), o => o.Enabled, (o, v) => o.Enabled = v, true);
public static readonly DirectProperty<NativeMenuItem, bool> IsEnabledProperty =
AvaloniaProperty.RegisterDirect<NativeMenuItem, bool>(nameof(IsEnabled), o => o.IsEnabled, (o, v) => o.IsEnabled = v, true);
public bool Enabled
public bool IsEnabled
{
get => _enabled;
set => SetAndRaise(EnabledProperty, ref _enabled, value);
get => _isEnabled;
set => SetAndRaise(IsEnabledProperty, ref _isEnabled, value);
}
void CanExecuteChanged()
{
Enabled = _command?.CanExecute(null) ?? true;
IsEnabled = _command?.CanExecute(null) ?? true;
}
public bool HasClickHandlers => Clicked != null;

4
src/Avalonia.FreeDesktop/DBusMenuExporter.cs

@ -210,7 +210,7 @@ namespace Avalonia.FreeDesktop
return null;
if (item.Menu != null && item.Menu.Items.Count == 0)
return false;
if (item.Enabled == false)
if (item.IsEnabled == false)
return false;
return null;
}
@ -321,7 +321,7 @@ namespace Avalonia.FreeDesktop
if (item is NativeMenuItem menuItem)
{
if (menuItem?.Enabled == true)
if (menuItem?.IsEnabled == true)
menuItem.RaiseClick();
}
}

2
src/Avalonia.Native/IAvnMenuItem.cs

@ -44,7 +44,7 @@ namespace Avalonia.Native.Interop
{
if (item.Command != null || item.HasClickHandlers)
{
return item.Enabled;
return item.IsEnabled;
}
return false;

Loading…
Cancel
Save