Browse Source

Cleaned up implementation of ShowTaskbarIcon

Created property in Window to enable/disable the taskbar icon
pull/1146/head
Jurjen Biewenga 9 years ago
parent
commit
a12c4649cb
  1. 7
      src/Avalonia.Controls/Platform/IWindowImpl.cs
  2. 24
      src/Avalonia.Controls/Window.cs
  3. 21
      src/Gtk/Avalonia.Gtk/WindowImpl.cs
  4. 6
      src/Gtk/Avalonia.Gtk3/WindowImpl.cs
  5. 1
      src/Windows/Avalonia.Win32/WindowImpl.cs

7
src/Avalonia.Controls/Platform/IWindowImpl.cs

@ -31,7 +31,7 @@ namespace Avalonia.Platform
IDisposable ShowDialog();
/// <summary>
/// Enables of disables system window decorations (title bar, buttons, etc)
/// Enables or disables system window decorations (title bar, buttons, etc)
/// </summary>
void SetSystemDecorations(bool enabled);
@ -40,8 +40,9 @@ namespace Avalonia.Platform
/// </summary>
void SetIcon(IWindowIconImpl icon);
/// <summary>
/// Enables or disables the taskbar icon
/// </summary>
void ShowTaskbarIcon(bool value);
}
}

24
src/Avalonia.Controls/Window.cs

@ -61,11 +61,17 @@ namespace Avalonia.Controls
AvaloniaProperty.Register<Window, SizeToContent>(nameof(SizeToContent));
/// <summary>
/// Enables of disables system window decorations (title bar, buttons, etc)
/// Enables or disables system window decorations (title bar, buttons, etc)
/// </summary>
public static readonly StyledProperty<bool> HasSystemDecorationsProperty =
AvaloniaProperty.Register<Window, bool>(nameof(HasSystemDecorations), true);
/// <summary>
/// Enables or disables the taskbar icon
/// </summary>
public static readonly StyledProperty<bool> HasTaskbarIconProperty =
AvaloniaProperty.Register<Window, bool>(nameof(HasTaskbarIcon), true);
/// <summary>
/// Defines the <see cref="Title"/> property.
/// </summary>
@ -92,6 +98,8 @@ namespace Avalonia.Controls
HasSystemDecorationsProperty.Changed.AddClassHandler<Window>(
(s, e) => s.PlatformImpl?.SetSystemDecorations((bool) e.NewValue));
HasTaskbarIconProperty.Changed.AddClassHandler<Window>((w, e) => w.PlatformImpl?.ShowTaskbarIcon((bool)e.NewValue));
IconProperty.Changed.AddClassHandler<Window>((s, e) => s.PlatformImpl?.SetIcon(((WindowIcon)e.NewValue).PlatformImpl));
}
@ -152,7 +160,7 @@ namespace Avalonia.Controls
}
/// <summary>
/// Enables of disables system window decorations (title bar, buttons, etc)
/// Enables or disables system window decorations (title bar, buttons, etc)
/// </summary>
///
public bool HasSystemDecorations
@ -160,6 +168,16 @@ namespace Avalonia.Controls
get { return GetValue(HasSystemDecorationsProperty); }
set { SetValue(HasSystemDecorationsProperty, value); }
}
/// <summary>
/// Enables or disables the taskbar icon
/// </summary>
///
public bool HasTaskbarIcon
{
get { return GetValue(HasTaskbarIconProperty); }
set { SetValue(HasTaskbarIconProperty, value); }
}
/// <summary>
/// Gets or sets the minimized/maximized state of the window.

21
src/Gtk/Avalonia.Gtk/WindowImpl.cs

@ -6,11 +6,12 @@ using Gdk;
namespace Avalonia.Gtk
{
using Gtk = global::Gtk;
public class WindowImpl : TopLevelImpl, IWindowImpl
{
private Gtk.Window _window;
private Gtk.Window Window => _window ?? (_window = (Gtk.Window) Widget);
private Gtk.Window Window => _window ?? (_window = (Gtk.Window)Widget);
public WindowImpl(Gtk.WindowType type) : base(new PlatformHandleAwareWindow(type))
{
Init();
@ -29,8 +30,10 @@ namespace Avalonia.Gtk
_lastClientSize = ClientSize;
_lastPosition = Position;
}
private Size _lastClientSize;
private Point _lastPosition;
void OnConfigureEvent(object o, Gtk.ConfigureEventArgs args)
{
var evnt = args.Event;
@ -44,7 +47,7 @@ namespace Avalonia.Gtk
}
var newPosition = new Point(evnt.X, evnt.Y);
if (newPosition != _lastPosition)
{
PositionChanged(newPosition);
@ -107,10 +110,7 @@ namespace Avalonia.Gtk
Window.GetPosition(out x, out y);
return new Point(x, y);
}
set
{
Window.Move((int)value.X, (int)value.Y);
}
set { Window.Move((int)value.X, (int)value.Y); }
}
public IDisposable ShowDialog()
@ -128,9 +128,6 @@ namespace Avalonia.Gtk
Window.Icon = ((IconImpl)icon).Pixbuf;
}
public void ShowTaskbarIcon(bool value)
{
Window.SkipTaskbarHint = !value;
}
public void ShowTaskbarIcon(bool value) => Window.SkipTaskbarHint = !value;
}
}
}

6
src/Gtk/Avalonia.Gtk3/WindowImpl.cs

@ -60,10 +60,8 @@ namespace Avalonia.Gtk3
//Why do we even have that?
}
public void ShowTaskbarIcon(bool value)
{
Native.GtkWindowSetSkipTaskbarHint(GtkWidget, !value);
}
public void ShowTaskbarIcon(bool value) => Native.GtkWindowSetSkipTaskbarHint(GtkWidget, !value);
class EmptyDisposable : IDisposable
{

1
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -763,6 +763,7 @@ namespace Avalonia.Win32
else
style &= ~(UnmanagedMethods.WindowStyles.WS_EX_APPWINDOW);
//Toggle to make the styles stick
UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Hide);
UnmanagedMethods.SetWindowLong(_hwnd, -20, (uint)style);
UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Show);

Loading…
Cancel
Save