Browse Source

fix formatting

pull/6560/head
Takoooooo 4 years ago
parent
commit
afd7203087
  1. 6
      samples/ControlCatalog/ViewModels/ApplicationViewModel.cs
  2. 3
      src/Avalonia.Controls/Platform/ITrayIconImpl.cs
  3. 10
      src/Avalonia.Controls/TrayIcon.cs
  4. 6
      src/Avalonia.Native/TrayIconImpl.cs
  5. 24
      src/Avalonia.X11/X11TrayIconImpl.cs
  6. 6
      src/Windows/Avalonia.Win32/Win32NativeToManagedMenuExporter.cs

6
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; }
}
}

3
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
/// <summary>
/// Sets if the tray icon is visible or not.
/// </summary>
void SetIsVisible (bool visible);
void SetIsVisible(bool visible);
/// <summary>
/// Gets the MenuExporter to allow native menus to be exported to the TrayIcon.

10
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);
}

6
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));
}

24
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";

6
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<MenuItem>? GetMenu()
{
if(_nativeMenu != null)
if (_nativeMenu != null)
{
return Populate(_nativeMenu);
}

Loading…
Cancel
Save