diff --git a/samples/ControlCatalog/ViewModels/ApplicationViewModel.cs b/samples/ControlCatalog/ViewModels/ApplicationViewModel.cs index 6cd44eecaf..7eea7b0657 100644 --- a/samples/ControlCatalog/ViewModels/ApplicationViewModel.cs +++ b/samples/ControlCatalog/ViewModels/ApplicationViewModel.cs @@ -10,17 +10,17 @@ namespace ControlCatalog.ViewModels { ExitCommand = MiniCommand.Create(() => { - if(Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime) + if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime lifetime) { lifetime.Shutdown(); } }); - + ToggleCommand = MiniCommand.Create(() => { }); } public MiniCommand ExitCommand { get; } - + public MiniCommand ToggleCommand { get; } } } diff --git a/src/Avalonia.Controls/Platform/ITrayIconImpl.cs b/src/Avalonia.Controls/Platform/ITrayIconImpl.cs index 12a32ec64b..9768d149f0 100644 --- a/src/Avalonia.Controls/Platform/ITrayIconImpl.cs +++ b/src/Avalonia.Controls/Platform/ITrayIconImpl.cs @@ -1,5 +1,4 @@ using System; -using Avalonia.Controls; using Avalonia.Controls.Platform; #nullable enable @@ -21,7 +20,7 @@ namespace Avalonia.Platform /// /// Sets if the tray icon is visible or not. /// - void SetIsVisible (bool visible); + void SetIsVisible(bool visible); /// /// Gets the MenuExporter to allow native menus to be exported to the TrayIcon. diff --git a/src/Avalonia.Controls/TrayIcon.cs b/src/Avalonia.Controls/TrayIcon.cs index ad9a668cf2..6bfddfa877 100644 --- a/src/Avalonia.Controls/TrayIcon.cs +++ b/src/Avalonia.Controls/TrayIcon.cs @@ -30,22 +30,22 @@ namespace Avalonia.Controls } } - public TrayIcon () : this(PlatformManager.CreateTrayIcon()) + public TrayIcon() : this(PlatformManager.CreateTrayIcon()) { } - static TrayIcon () + static TrayIcon() { IconsProperty.Changed.Subscribe(args => { if (args.Sender is Application) { - if(args.OldValue.Value != null) + if (args.OldValue.Value != null) { RemoveIcons(args.OldValue.Value); } - if(args.NewValue.Value != null) + if (args.NewValue.Value != null) { args.NewValue.Value.CollectionChanged += Icons_CollectionChanged; } @@ -161,7 +161,7 @@ namespace Avalonia.Controls { base.OnPropertyChanged(change); - if(change.Property == IconProperty) + if (change.Property == IconProperty) { _impl?.SetIcon(Icon.PlatformImpl); } diff --git a/src/Avalonia.Native/TrayIconImpl.cs b/src/Avalonia.Native/TrayIconImpl.cs index 951bbc496e..abcc61d950 100644 --- a/src/Avalonia.Native/TrayIconImpl.cs +++ b/src/Avalonia.Native/TrayIconImpl.cs @@ -11,7 +11,7 @@ namespace Avalonia.Native internal class TrayIconImpl : ITrayIconImpl { private readonly IAvnTrayIcon _native; - + public TrayIconImpl(IAvaloniaNativeFactory factory) { _native = factory.CreateTrayIcon(); @@ -28,7 +28,7 @@ namespace Avalonia.Native public unsafe void SetIcon(IWindowIconImpl? icon) { - if(icon is null) + if (icon is null) { _native.SetIcon(null, IntPtr.Zero); } @@ -40,7 +40,7 @@ namespace Avalonia.Native var imageData = ms.ToArray(); - fixed(void* ptr = imageData) + fixed (void* ptr = imageData) { _native.SetIcon(ptr, new IntPtr(imageData.Length)); } diff --git a/src/Avalonia.X11/X11TrayIconImpl.cs b/src/Avalonia.X11/X11TrayIconImpl.cs index 70b4587b08..3469bd7bcf 100644 --- a/src/Avalonia.X11/X11TrayIconImpl.cs +++ b/src/Avalonia.X11/X11TrayIconImpl.cs @@ -53,7 +53,8 @@ namespace Avalonia.X11 public async void CreateTrayIcon() { - if (_connection is null) return; + if (_connection is null) + return; try { @@ -68,7 +69,8 @@ namespace Avalonia.X11 "DBUS: org.kde.StatusNotifierWatcher service is not available on this system. System Tray Icons will not work without it."); } - if (_statusNotifierWatcher is null) return; + if (_statusNotifierWatcher is null) + return; var pid = Process.GetCurrentProcess().Id; var tid = s_TrayIconInstanceId++; @@ -92,7 +94,8 @@ namespace Avalonia.X11 public async void DestroyTrayIcon() { - if (_connection is null) return; + if (_connection is null) + return; _connection.UnregisterObject(_statusNotifierItemDbusObj); await _connection.UnregisterServiceAsync(_sysTrayServiceName); _isActive = false; @@ -107,8 +110,10 @@ namespace Avalonia.X11 public void SetIcon(IWindowIconImpl? icon) { - if (_isDisposed) return; - if (!(icon is X11IconData x11icon)) return; + if (_isDisposed) + return; + if (!(icon is X11IconData x11icon)) + return; var w = (int)x11icon.Data[0]; var h = (int)x11icon.Data[1]; @@ -132,7 +137,8 @@ namespace Avalonia.X11 public void SetIsVisible(bool visible) { - if (_isDisposed || !_ctorFinished) return; + if (_isDisposed || !_ctorFinished) + return; if (visible & !_isActive) { @@ -147,7 +153,8 @@ namespace Avalonia.X11 public void SetToolTipText(string? text) { - if (_isDisposed || text is null) return; + if (_isDisposed || text is null) + return; _tooltipText = text; _statusNotifierItemDbusObj?.SetTitleAndTooltip(_tooltipText); } @@ -258,7 +265,8 @@ namespace Avalonia.X11 public void SetTitleAndTooltip(string? text) { - if (text is null) return; + if (text is null) + return; _backingProperties.Id = text; _backingProperties.Category = "ApplicationStatus"; diff --git a/src/Windows/Avalonia.Win32/Win32NativeToManagedMenuExporter.cs b/src/Windows/Avalonia.Win32/Win32NativeToManagedMenuExporter.cs index f1c5791359..fa6f9927b5 100644 --- a/src/Windows/Avalonia.Win32/Win32NativeToManagedMenuExporter.cs +++ b/src/Windows/Avalonia.Win32/Win32NativeToManagedMenuExporter.cs @@ -21,13 +21,13 @@ namespace Avalonia.Win32 { if (menuItem is NativeMenuItemSeparator) { - yield return new MenuItem { Header = "-" }; + yield return new MenuItem { Header = "-" }; } else if (menuItem is NativeMenuItem item) { var newItem = new MenuItem { Header = item.Header, Icon = item.Icon, Command = item.Command, CommandParameter = item.CommandParameter }; - if(item.Menu != null) + if (item.Menu != null) { newItem.Items = Populate(item.Menu); } @@ -43,7 +43,7 @@ namespace Avalonia.Win32 public IEnumerable? GetMenu() { - if(_nativeMenu != null) + if (_nativeMenu != null) { return Populate(_nativeMenu); }