From 12167dfea9254e3c22b76f8eabac0cbb37ebda1e Mon Sep 17 00:00:00 2001 From: "M. ter Woord" Date: Mon, 21 Aug 2017 18:22:04 +0200 Subject: [PATCH 01/35] Show descriptive error when no rendering or windowing subsystem found --- src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs b/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs index 9a54cdbab0..bae97f503d 100644 --- a/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs +++ b/src/Avalonia.DotNetFrameworkRuntime/AppBuilder.cs @@ -59,7 +59,11 @@ namespace Avalonia from attribute in assembly.GetCustomAttributes() where attribute.RequiredOS == os && CheckEnvironment(attribute.EnvironmentChecker) orderby attribute.Priority ascending - select attribute).First(); + select attribute).FirstOrDefault(); + if (windowingSubsystemAttribute == null) + { + throw new InvalidOperationException("No windowing subsystem found. Are you missing assembly references?"); + } var renderingSubsystemAttribute = (from assembly in RuntimePlatform.GetLoadedAssemblies() from attribute in assembly.GetCustomAttributes() @@ -67,7 +71,12 @@ namespace Avalonia where attribute.RequiresWindowingSubsystem == null || attribute.RequiresWindowingSubsystem == windowingSubsystemAttribute.Name orderby attribute.Priority ascending - select attribute).First(); + select attribute).FirstOrDefault(); + + if (renderingSubsystemAttribute == null) + { + throw new InvalidOperationException("No rendering subsystem found. Are you missing assembly references?"); + } UseWindowingSubsystem(() => windowingSubsystemAttribute.InitializationType .GetRuntimeMethod(windowingSubsystemAttribute.InitializationMethod, Type.EmptyTypes).Invoke(null, null), From a16014f87559fb0ad64d8514358206f0a3f123c7 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 21 Aug 2017 13:04:16 -0500 Subject: [PATCH 02/35] Upgrade Moq to reduce build warnings --- build/Moq.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Moq.props b/build/Moq.props index 55242d922e..7de9b6b6ba 100644 --- a/build/Moq.props +++ b/build/Moq.props @@ -1,5 +1,5 @@  - + From 58b3ff90ab99743912d5ee7ab7ce21070f9e5da4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 21 Aug 2017 14:19:34 -0500 Subject: [PATCH 03/35] Reduce build warnings by setting a few flags and not using deprecated overloads. --- build/UnitTests.NetCore.targets | 19 ----------- .../Avalonia.HtmlRenderer.csproj | 1 + .../NativeUnsafeMethods.cs | 1 + .../AppHost/HostedAppModel.cs | 1 - .../Interop/UnmanagedMethods.cs | 4 +-- src/Windows/Avalonia.Win32/Win32Platform.cs | 2 +- src/Windows/Avalonia.Win32/WindowImpl.cs | 6 ++-- .../Avalonia.Input.UnitTests.csproj | 32 ------------------- .../Avalonia.Styling.UnitTests.csproj | 1 + 9 files changed, 8 insertions(+), 59 deletions(-) diff --git a/build/UnitTests.NetCore.targets b/build/UnitTests.NetCore.targets index 13bb4ed230..42da8e4ab1 100644 --- a/build/UnitTests.NetCore.targets +++ b/build/UnitTests.NetCore.targets @@ -3,25 +3,6 @@ false true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - MinimumRecommendedRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - MinimumRecommendedRules.ruleset - diff --git a/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj b/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj index f715217e42..e7822324a9 100644 --- a/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj +++ b/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj @@ -4,6 +4,7 @@ False False false + CS0436 true diff --git a/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs b/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs index ad8def369d..fbbf036b74 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs @@ -72,6 +72,7 @@ namespace Avalonia.LinuxFramebuffer FB_VBLANK_HAVE_VSYNC = 0x100 /* verical syncs can be detected */ } + [StructLayout(LayoutKind.Sequential)] unsafe struct fb_vblank { public VBlankFlags flags; /* FB_VBLANK flags */ __u32 count; /* counter of retraces since boot */ diff --git a/src/Windows/Avalonia.Designer/AppHost/HostedAppModel.cs b/src/Windows/Avalonia.Designer/AppHost/HostedAppModel.cs index a64304619a..b5d0687baa 100644 --- a/src/Windows/Avalonia.Designer/AppHost/HostedAppModel.cs +++ b/src/Windows/Avalonia.Designer/AppHost/HostedAppModel.cs @@ -86,7 +86,6 @@ namespace Avalonia.Designer.AppHost } double _currentScalingFactor = 1; - private string _color; private string _background; public event PropertyChangedEventHandler PropertyChanged; diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index d5a6f1a7a1..5473ef9bea 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -922,9 +922,7 @@ namespace Avalonia.Win32.Interop [StructLayout(LayoutKind.Sequential)] internal class MONITORINFO { -#pragma warning disable CS0618 // Type or member is obsolete - public int cbSize = Marshal.SizeOf(typeof(MONITORINFO)); -#pragma warning restore CS0618 // Type or member is obsolete + public int cbSize = Marshal.SizeOf(); public RECT rcMonitor = new RECT(); public RECT rcWork = new RECT(); public int dwFlags = 0; diff --git a/src/Windows/Avalonia.Win32/Win32Platform.cs b/src/Windows/Avalonia.Win32/Win32Platform.cs index 584a5ba39e..d8e9256156 100644 --- a/src/Windows/Avalonia.Win32/Win32Platform.cs +++ b/src/Windows/Avalonia.Win32/Win32Platform.cs @@ -167,7 +167,7 @@ namespace Avalonia.Win32 UnmanagedMethods.WNDCLASSEX wndClassEx = new UnmanagedMethods.WNDCLASSEX { - cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.WNDCLASSEX)), + cbSize = Marshal.SizeOf(), lpfnWndProc = _wndProcDelegate, hInstance = UnmanagedMethods.GetModuleHandle(null), lpszClassName = "AvaloniaMessageWindow " + Guid.NewGuid(), diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index feb7bdc2ee..4a30d48878 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -426,7 +426,7 @@ namespace Avalonia.Win32 case UnmanagedMethods.WindowsMessage.WM_DPICHANGED: var dpi = ToInt32(wParam) & 0xffff; - var newDisplayRect = (UnmanagedMethods.RECT)Marshal.PtrToStructure(lParam, typeof(UnmanagedMethods.RECT)); + var newDisplayRect = Marshal.PtrToStructure(lParam); Position = new Point(newDisplayRect.left, newDisplayRect.top); _scaling = dpi / 96.0; ScalingChanged?.Invoke(_scaling); @@ -494,7 +494,7 @@ namespace Avalonia.Win32 { var tm = new UnmanagedMethods.TRACKMOUSEEVENT { - cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.TRACKMOUSEEVENT)), + cbSize = Marshal.SizeOf(), dwFlags = 2, hwndTrack = _hwnd, dwHoverTime = 0, @@ -619,7 +619,7 @@ namespace Avalonia.Win32 UnmanagedMethods.WNDCLASSEX wndClassEx = new UnmanagedMethods.WNDCLASSEX { - cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.WNDCLASSEX)), + cbSize = Marshal.SizeOf(), style = 0, lpfnWndProc = _wndProcDelegate, hInstance = UnmanagedMethods.GetModuleHandle(null), diff --git a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj index 186d293b96..710a818bcd 100644 --- a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj +++ b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj @@ -3,35 +3,6 @@ net461;netcoreapp1.1 Library - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Avalonia.Input.UnitTests.XML - CS1591 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - @@ -48,7 +19,4 @@ - - - \ No newline at end of file diff --git a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj index 8dd8faf9db..3f9213b91f 100644 --- a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj +++ b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj @@ -2,6 +2,7 @@ net461;netcoreapp1.1 Library + CS0067 From 426cd8c9ddeee12685cea2e5e534b19f4e694dec Mon Sep 17 00:00:00 2001 From: Eli Arbel Date: Fri, 25 Aug 2017 12:55:36 +0300 Subject: [PATCH 04/35] ToolTip: IsOpen, Placement, Offset --- samples/ControlCatalog/Pages/ToolTipPage.xaml | 48 ++-- src/Avalonia.Controls/Primitives/Popup.cs | 26 +- src/Avalonia.Controls/ToolTip.cs | 236 ++++++++++++------ src/Avalonia.Controls/ToolTipService.cs | 98 ++++++++ 4 files changed, 300 insertions(+), 108 deletions(-) create mode 100644 src/Avalonia.Controls/ToolTipService.cs diff --git a/samples/ControlCatalog/Pages/ToolTipPage.xaml b/samples/ControlCatalog/Pages/ToolTipPage.xaml index 29df11510c..79114bc9de 100644 --- a/samples/ControlCatalog/Pages/ToolTipPage.xaml +++ b/samples/ControlCatalog/Pages/ToolTipPage.xaml @@ -1,22 +1,34 @@ - - ToolTip - A control which pops up a hint when a control is hovered + + ToolTip + A control which pops up a hint when a control is hovered - - - - - ToolTip - A control which pops up a hint when a control is hovered - - - Hover Here - + + + + + + ToolTip + A control which pops up a hint when a control is hovered + + + Hover Here + + + And Here + + - \ No newline at end of file diff --git a/src/Avalonia.Controls/Primitives/Popup.cs b/src/Avalonia.Controls/Primitives/Popup.cs index daea187a69..5cd3b22fc9 100644 --- a/src/Avalonia.Controls/Primitives/Popup.cs +++ b/src/Avalonia.Controls/Primitives/Popup.cs @@ -277,7 +277,7 @@ namespace Avalonia.Controls.Primitives { base.OnDetachedFromLogicalTree(e); _topLevel = null; - + if (_popupRoot != null) { ((ISetLogicalParent)_popupRoot).SetParent(null); @@ -327,34 +327,40 @@ namespace Avalonia.Controls.Primitives /// /// The popup's position in screen coordinates. protected virtual Point GetPosition() + { + return GetPosition(PlacementTarget ?? this.GetVisualParent(), PlacementMode, PopupRoot, + HorizontalOffset, VerticalOffset); + } + + internal static Point GetPosition(Control target, PlacementMode placement, PopupRoot popupRoot, double horizontalOffset, double verticalOffset) { var zero = default(Point); - var mode = PlacementMode; - var target = PlacementTarget ?? this.GetVisualParent(); + var mode = placement; if (target?.GetVisualRoot() == null) { mode = PlacementMode.Pointer; - } + } switch (mode) { case PlacementMode.Pointer: - if(PopupRoot != null) + if (popupRoot != null) { // Scales the Horizontal and Vertical offset to screen co-ordinates. - var screenOffset = new Point(HorizontalOffset * (PopupRoot as ILayoutRoot).LayoutScaling, VerticalOffset * (PopupRoot as ILayoutRoot).LayoutScaling); - return (((IInputRoot)PopupRoot)?.MouseDevice?.Position ?? default(Point)) + screenOffset; + var screenOffset = new Point(horizontalOffset * (popupRoot as ILayoutRoot).LayoutScaling, + verticalOffset * (popupRoot as ILayoutRoot).LayoutScaling); + return (((IInputRoot)popupRoot)?.MouseDevice?.Position ?? default(Point)) + screenOffset; } return default(Point); case PlacementMode.Bottom: - - return target?.PointToScreen(new Point(0 + HorizontalOffset, target.Bounds.Height + VerticalOffset)) ?? zero; + return target?.PointToScreen(new Point(0 + horizontalOffset, target.Bounds.Height + verticalOffset)) ?? + zero; case PlacementMode.Right: - return target?.PointToScreen(new Point(target.Bounds.Width + HorizontalOffset, 0 + VerticalOffset)) ?? zero; + return target?.PointToScreen(new Point(target.Bounds.Width + horizontalOffset, 0 + verticalOffset)) ?? zero; default: throw new InvalidOperationException("Invalid value for Popup.PlacementMode"); diff --git a/src/Avalonia.Controls/ToolTip.cs b/src/Avalonia.Controls/ToolTip.cs index e1b69637af..e45f30f818 100644 --- a/src/Avalonia.Controls/ToolTip.cs +++ b/src/Avalonia.Controls/ToolTip.cs @@ -3,11 +3,7 @@ using System; using System.Reactive.Linq; -using System.Reactive.Subjects; using Avalonia.Controls.Primitives; -using Avalonia.Input; -using Avalonia.Threading; -using Avalonia.VisualTree; namespace Avalonia.Controls { @@ -29,29 +25,50 @@ namespace Avalonia.Controls AvaloniaProperty.RegisterAttached("Tip"); /// - /// The popup window used to display the active tooltip. + /// Defines the ToolTip.IsOpen attached property. /// - private static PopupRoot s_popup; + public static readonly AttachedProperty IsOpenProperty = + AvaloniaProperty.RegisterAttached("IsOpen"); /// - /// The control that the currently visible tooltip is attached to. + /// Defines the ToolTip.Placement property. /// - private static Control s_current; + public static readonly AttachedProperty PlacementProperty = + AvaloniaProperty.RegisterAttached("Placement", defaultValue: PlacementMode.Pointer); /// - /// Observable fired when a tooltip should be displayed for a control. The output from this - /// observable is throttled and calls when the time - /// period expires. + /// Defines the ToolTip.HorizontalOffset property. /// - private static readonly Subject s_show = new Subject(); + public static readonly AttachedProperty HorizontalOffsetProperty = + AvaloniaProperty.RegisterAttached("HorizontalOffset"); + + /// + /// Defines the ToolTip.VerticalOffset property. + /// + public static readonly AttachedProperty VerticalOffsetProperty = + AvaloniaProperty.RegisterAttached("VerticalOffset", 20); + + /// + /// Defines the ToolTip.ShowDelay property. + /// + public static readonly AttachedProperty ShowDelayProperty = + AvaloniaProperty.RegisterAttached("ShowDelay", 400); + + /// + /// Stores the curernt instance in the control. + /// + private static readonly AttachedProperty ToolTipProperty = + AvaloniaProperty.RegisterAttached("ToolTip"); + + private PopupRoot _popup; /// /// Initializes static members of the class. /// static ToolTip() { - TipProperty.Changed.Subscribe(TipChanged); - s_show.Throttle(TimeSpan.FromSeconds(0.5), AvaloniaScheduler.Instance).Subscribe(ShowToolTip); + TipProperty.Changed.Subscribe(ToolTipService.Instance.TipChanged); + IsOpenProperty.Changed.Subscribe(IsOpenChanged); } /// @@ -77,101 +94,160 @@ namespace Avalonia.Controls } /// - /// called when the property changes on a control. + /// Gets the value of the ToolTip.IsOpen attached property. /// - /// The event args. - private static void TipChanged(AvaloniaPropertyChangedEventArgs e) + /// The control to get the property from. + /// + /// A value indicating whether the tool tip is visible. + /// + public static bool GetIsOpen(Control element) { - var control = (Control)e.Sender; + return element.GetValue(IsOpenProperty); + } - if (e.OldValue != null) - { - control.PointerEnter -= ControlPointerEnter; - control.PointerLeave -= ControlPointerLeave; - } + /// + /// Sets the value of the ToolTip.IsOpen attached property. + /// + /// The control to get the property from. + /// A value indicating whether the tool tip is visible. + public static void SetIsOpen(Control element, bool value) + { + element.SetValue(IsOpenProperty, value); + } - if (e.NewValue != null) - { - control.PointerEnter += ControlPointerEnter; - control.PointerLeave += ControlPointerLeave; - } + /// + /// Gets the value of the ToolTip.Placement attached property. + /// + /// The control to get the property from. + /// + /// A value indicating how the tool tip is positioned. + /// + public static PlacementMode GetPlacement(Control element) + { + return element.GetValue(PlacementProperty); } /// - /// Shows a tooltip for the specified control. + /// Sets the value of the ToolTip.Placement attached property. /// - /// The control. - private static void ShowToolTip(Control control) + /// The control to get the property from. + /// A value indicating how the tool tip is positioned. + public static void SetPlacement(Control element, PlacementMode value) { - if (control != null && control.IsVisible && control.GetVisualRoot() != null) - { - var cp = (control.GetVisualRoot() as IInputRoot)?.MouseDevice?.GetPosition(control); + element.SetValue(PlacementProperty, value); + } - if (cp.HasValue && control.IsVisible && new Rect(control.Bounds.Size).Contains(cp.Value)) - { - var position = control.PointToScreen(cp.Value) + new Vector(0, 22); - - if (s_popup == null) - { - s_popup = new PopupRoot(); - s_popup.Content = new ToolTip(); - } - else - { - ((ISetLogicalParent)s_popup).SetParent(null); - } - - ((ISetLogicalParent)s_popup).SetParent(control); - ((ToolTip)s_popup.Content).Content = GetTip(control); - s_popup.Position = position; - s_popup.Show(); - - s_current = control; - } - } + /// + /// Gets the value of the ToolTip.HorizontalOffset attached property. + /// + /// The control to get the property from. + /// + /// A value indicating how the tool tip is positioned. + /// + public static double GetHorizontalOffset(Control element) + { + return element.GetValue(HorizontalOffsetProperty); + } + + /// + /// Sets the value of the ToolTip.HorizontalOffset attached property. + /// + /// The control to get the property from. + /// A value indicating how the tool tip is positioned. + public static void SetHorizontalOffset(Control element, double value) + { + element.SetValue(HorizontalOffsetProperty, value); + } + + /// + /// Gets the value of the ToolTip.VerticalOffset attached property. + /// + /// The control to get the property from. + /// + /// A value indicating how the tool tip is positioned. + /// + public static double GetVerticalOffset(Control element) + { + return element.GetValue(VerticalOffsetProperty); + } + + /// + /// Sets the value of the ToolTip.VerticalOffset attached property. + /// + /// The control to get the property from. + /// A value indicating how the tool tip is positioned. + public static void SetVerticalOffset(Control element, double value) + { + element.SetValue(VerticalOffsetProperty, value); } /// - /// Called when the pointer enters a control with an attached tooltip. + /// Gets the value of the ToolTip.ShowDelay attached property. /// - /// The event sender. - /// The event args. - private static void ControlPointerEnter(object sender, PointerEventArgs e) + /// The control to get the property from. + /// + /// A value indicating the time, in milliseconds, before a tool tip opens. + /// + public static int GetShowDelay(Control element) { - s_current = (Control)sender; - s_show.OnNext(s_current); + return element.GetValue(ShowDelayProperty); } /// - /// Called when the pointer leaves a control with an attached tooltip. + /// Sets the value of the ToolTip.ShowDelay attached property. /// - /// The event sender. - /// The event args. - private static void ControlPointerLeave(object sender, PointerEventArgs e) + /// The control to get the property from. + /// A value indicating the time, in milliseconds, before a tool tip opens. + public static void SetShowDelay(Control element, int value) { - var control = (Control)sender; + element.SetValue(ShowDelayProperty, value); + } + + private static void IsOpenChanged(AvaloniaPropertyChangedEventArgs e) + { + var control = (Control)e.Sender; - if (control == s_current) + if ((bool)e.NewValue) { - if (s_popup != null) + var tip = GetTip(control); + if (tip == null) return; + + var toolTip = control.GetValue(ToolTipProperty); + if (toolTip == null || (tip != toolTip && tip != toolTip.Content)) { - DisposeTooltip(); - s_show.OnNext(null); + toolTip?.Close(); + + toolTip = tip as ToolTip ?? new ToolTip { Content = tip }; + control.SetValue(ToolTipProperty, toolTip); } + + toolTip.Open(control); + } + else + { + var toolTip = control.GetValue(ToolTipProperty); + toolTip?.Close(); } } - private static void DisposeTooltip() + private void Open(Control control) { - if (s_popup != null) - { - // Clear the ToolTip's Content in case it has control content: this will - // reset its visual parent allowing it to be used again. - ((ToolTip)s_popup.Content).Content = null; + Close(); + + _popup = new PopupRoot { Content = this }; + ((ISetLogicalParent)_popup).SetParent(control); + _popup.Position = Popup.GetPosition(control, GetPlacement(control), _popup, + GetHorizontalOffset(control), GetVerticalOffset(control)); + _popup.Show(); + } - // Dispose of the popup. - s_popup.Dispose(); - s_popup = null; + private void Close() + { + if (_popup != null) + { + _popup.Content = null; + _popup.Hide(); + _popup = null; } } } diff --git a/src/Avalonia.Controls/ToolTipService.cs b/src/Avalonia.Controls/ToolTipService.cs new file mode 100644 index 0000000000..bfd7ef0f33 --- /dev/null +++ b/src/Avalonia.Controls/ToolTipService.cs @@ -0,0 +1,98 @@ +using System; +using Avalonia.Input; +using Avalonia.Threading; + +namespace Avalonia.Controls +{ + /// + /// Handeles interaction with controls. + /// + internal sealed class ToolTipService + { + public static ToolTipService Instance { get; } = new ToolTipService(); + + private DispatcherTimer _timer; + + private ToolTipService() { } + + /// + /// called when the property changes on a control. + /// + /// The event args. + internal void TipChanged(AvaloniaPropertyChangedEventArgs e) + { + var control = (Control)e.Sender; + + if (e.OldValue != null) + { + control.PointerEnter -= ControlPointerEnter; + control.PointerLeave -= ControlPointerLeave; + } + + if (e.NewValue != null) + { + control.PointerEnter += ControlPointerEnter; + control.PointerLeave += ControlPointerLeave; + } + } + + /// + /// Called when the pointer enters a control with an attached tooltip. + /// + /// The event sender. + /// The event args. + private void ControlPointerEnter(object sender, PointerEventArgs e) + { + StopTimer(); + + var control = (Control)sender; + var showDelay = ToolTip.GetShowDelay(control); + if (showDelay == 0) + { + Open(control); + } + else + { + StartShowTimer(showDelay, control); + } + } + + /// + /// Called when the pointer leaves a control with an attached tooltip. + /// + /// The event sender. + /// The event args. + private void ControlPointerLeave(object sender, PointerEventArgs e) + { + var control = (Control)sender; + Close(control); + } + + private void StartShowTimer(int showDelay, Control control) + { + _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(showDelay) }; + _timer.Tick += (o, e) => Open(control); + _timer.Start(); + } + + private void Open(Control control) + { + StopTimer(); + + ToolTip.SetIsOpen(control, true); + } + + private void Close(Control control) + { + StopTimer(); + + ToolTip.SetIsOpen(control, false); + } + + private void StopTimer() + { + _timer?.Stop(); + _timer = null; + } + } +} \ No newline at end of file From 5827f3c28428ab310745f79efca14eaa14bfa8e8 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 27 Aug 2017 16:22:34 +0200 Subject: [PATCH 05/35] Missed file from merge --- tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj index 52404e7ed2..99cf4e98d2 100644 --- a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj +++ b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj @@ -19,8 +19,7 @@ - - + \ No newline at end of file From 1cf3e6bfc6ef9d42c5212518b9e653bb9e8a46c0 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 2 Sep 2017 00:37:37 +0200 Subject: [PATCH 06/35] Use discard in TryGetResource. --- samples/ControlCatalog/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index f6894e4d8a..63f9ab1d0d 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -19,7 +19,7 @@ namespace ControlCatalog // so we must refer to this resource DLL statically. For // now I am doing that here. But we need a better solution!! var theme = new Avalonia.Themes.Default.DefaultTheme(); - theme.TryGetResource("Button", out var button); + theme.TryGetResource("Button", out _); AvaloniaXamlLoader.Load(this); } } From 814a3a5ee6fe1c0d753919c376b490cc0acbc1a9 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 2 Sep 2017 00:37:55 +0200 Subject: [PATCH 07/35] Make `IDictionary` members explicit. And use expression bodied members where possible. --- .../Collections/AvaloniaDictionary.cs | 57 +++++-------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/src/Avalonia.Base/Collections/AvaloniaDictionary.cs b/src/Avalonia.Base/Collections/AvaloniaDictionary.cs index 724442c5f2..b90dccf74e 100644 --- a/src/Avalonia.Base/Collections/AvaloniaDictionary.cs +++ b/src/Avalonia.Base/Collections/AvaloniaDictionary.cs @@ -52,15 +52,15 @@ namespace Avalonia.Collections /// public ICollection Values => _inner.Values; - public bool IsFixedSize => ((IDictionary)_inner).IsFixedSize; + bool IDictionary.IsFixedSize => ((IDictionary)_inner).IsFixedSize; ICollection IDictionary.Keys => ((IDictionary)_inner).Keys; ICollection IDictionary.Values => ((IDictionary)_inner).Values; - public bool IsSynchronized => ((IDictionary)_inner).IsSynchronized; + bool ICollection.IsSynchronized => ((IDictionary)_inner).IsSynchronized; - public object SyncRoot => ((IDictionary)_inner).SyncRoot; + object ICollection.SyncRoot => ((IDictionary)_inner).SyncRoot; /// /// Gets or sets the named resource. @@ -131,10 +131,7 @@ namespace Avalonia.Collections } /// - public bool ContainsKey(TKey key) - { - return _inner.ContainsKey(key); - } + public bool ContainsKey(TKey key) => _inner.ContainsKey(key); /// public void CopyTo(KeyValuePair[] array, int arrayIndex) @@ -143,21 +140,16 @@ namespace Avalonia.Collections } /// - public IEnumerator> GetEnumerator() - { - return _inner.GetEnumerator(); - } + public IEnumerator> GetEnumerator() => _inner.GetEnumerator(); /// public bool Remove(TKey key) { - TValue value; - - if (_inner.TryGetValue(key, out value)) + if (_inner.TryGetValue(key, out TValue value)) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Count")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]")); - + if (CollectionChanged != null) { var e = new NotifyCollectionChangedEventArgs( @@ -176,22 +168,13 @@ namespace Avalonia.Collections } /// - public bool TryGetValue(TKey key, out TValue value) - { - return _inner.TryGetValue(key, out value); - } + public bool TryGetValue(TKey key, out TValue value) => _inner.TryGetValue(key, out value); /// - IEnumerator IEnumerable.GetEnumerator() - { - return _inner.GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => _inner.GetEnumerator(); /// - void ICollection.CopyTo(Array array, int index) - { - ((ICollection)_inner).CopyTo(array, index); - } + void ICollection.CopyTo(Array array, int index) => ((ICollection)_inner).CopyTo(array, index); /// void ICollection>.Add(KeyValuePair item) @@ -212,28 +195,16 @@ namespace Avalonia.Collections } /// - void IDictionary.Add(object key, object value) - { - Add((TKey)key, (TValue)value); - } + void IDictionary.Add(object key, object value) => Add((TKey)key, (TValue)value); /// - bool IDictionary.Contains(object key) - { - return ((IDictionary)_inner).Contains(key); - } + bool IDictionary.Contains(object key) => ((IDictionary) _inner).Contains(key); /// - IDictionaryEnumerator IDictionary.GetEnumerator() - { - return ((IDictionary)_inner).GetEnumerator(); - } + IDictionaryEnumerator IDictionary.GetEnumerator() => ((IDictionary)_inner).GetEnumerator(); /// - void IDictionary.Remove(object key) - { - Remove((TKey)key); - } + void IDictionary.Remove(object key) => Remove((TKey)key); private void NotifyAdd(TKey key, TValue value) { From bf4bb7d54c2373e15cbfa30b97ad2d00b1e9fb18 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 2 Sep 2017 01:01:46 +0200 Subject: [PATCH 08/35] Added TryFindResource extension method. `FindResource` can be ambiguous because it returns `AvaloniaProperty.UnsetValue` in the case of a resource not being found, which is a valid resource value. `TryFindResource` removes this ambiguity. `FindResource` has been left in for API compatibility with other frameworks. --- .../Controls/ResourceProviderExtensions.cs | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs b/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs index c96e8ea7f3..1f25fa132d 100644 --- a/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs +++ b/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.Reactive; using System.Reactive.Linq; -using System.Text; namespace Avalonia.Controls { @@ -15,6 +13,23 @@ namespace Avalonia.Controls /// The resource key. /// The resource, or if not found. public static object FindResource(this IResourceNode control, string key) + { + if (control.TryFindResource(key, out var value)) + { + return value; + } + + return AvaloniaProperty.UnsetValue; + } + + /// + /// Tries to the specified resource by searching up the logical tree and then global styles. + /// + /// The control. + /// The resource key. + /// On return, contains the resource if found, otherwise null. + /// True if the resource was found; otherwise false. + public static bool TryFindResource(this IResourceNode control, string key, out object value) { Contract.Requires(control != null); Contract.Requires(key != null); @@ -25,16 +40,17 @@ namespace Avalonia.Controls { if (current is IResourceNode host) { - if (host.TryGetResource(key, out var value)) + if (host.TryGetResource(key, out value)) { - return value; + return true; } } current = current.ResourceParent; } - return AvaloniaProperty.UnsetValue; + value = null; + return false; } public static IObservable GetResourceObservable(this IResourceNode target, string key) From 31c9446429423aaea3451528781105da7a22f353 Mon Sep 17 00:00:00 2001 From: Eli Arbel Date: Sat, 2 Sep 2017 15:11:44 +0300 Subject: [PATCH 09/35] Improve demo --- samples/ControlCatalog/Pages/ToolTipPage.xaml | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/samples/ControlCatalog/Pages/ToolTipPage.xaml b/samples/ControlCatalog/Pages/ToolTipPage.xaml index 79114bc9de..5cf7fee4d1 100644 --- a/samples/ControlCatalog/Pages/ToolTipPage.xaml +++ b/samples/ControlCatalog/Pages/ToolTipPage.xaml @@ -4,13 +4,26 @@ ToolTip A control which pops up a hint when a control is hovered - - + + + Hover Here + + A control which pops up a hint when a control is hovered - Hover Here - - - And Here + ToolTip bottom placement - + \ No newline at end of file From 1d4aabb739f62142d61ca3aa14fee66eb5c125b8 Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Sun, 3 Sep 2017 19:39:32 +0200 Subject: [PATCH 10/35] Replaced Set/GetWindowLong with Set/GetWindowLongPtr for 64 bit support --- src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs | 4 ++-- src/Windows/Avalonia.Win32/WindowImpl.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index 5473ef9bea..a8c9ec101c 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -699,10 +699,10 @@ namespace Avalonia.Win32.Interop public static extern int GetSystemMetrics(SystemMetric smIndex); [DllImport("user32.dll", SetLastError = true)] - public static extern uint GetWindowLong(IntPtr hWnd, int nIndex); + public static extern uint GetWindowLongPtr(IntPtr hWnd, int nIndex); [DllImport("user32.dll", SetLastError = true)] - public static extern uint SetWindowLong(IntPtr hWnd, int nIndex, uint value); + public static extern uint SetWindowLongPtr(IntPtr hWnd, int nIndex, uint value); [DllImport("user32.dll", SetLastError = true)] public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 4a30d48878..4e67b47a36 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -66,8 +66,8 @@ namespace Avalonia.Win32 { get { - var style = UnmanagedMethods.GetWindowLong(_hwnd, -16); - var exStyle = UnmanagedMethods.GetWindowLong(_hwnd, -20); + var style = UnmanagedMethods.GetWindowLongPtr(_hwnd, -16); + var exStyle = UnmanagedMethods.GetWindowLongPtr(_hwnd, -20); var padding = new UnmanagedMethods.RECT(); if (UnmanagedMethods.AdjustWindowRectEx(ref padding, style, false, exStyle)) @@ -219,7 +219,7 @@ namespace Avalonia.Win32 return; } - var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLong(_hwnd, -16); + var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLongPtr(_hwnd, -16); style |= UnmanagedMethods.WindowStyles.WS_OVERLAPPEDWINDOW; @@ -235,7 +235,7 @@ namespace Avalonia.Win32 Rect newRect; var oldThickness = BorderThickness; - UnmanagedMethods.SetWindowLong(_hwnd, -16, (uint)style); + UnmanagedMethods.SetWindowLongPtr(_hwnd, -16, (uint)style); if (value) { From 8f006ff655d37687f3676dc6c83802a151196660 Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Sun, 3 Sep 2017 20:44:08 +0200 Subject: [PATCH 11/35] Added utility functions to pinvoke the correct function based on bitness --- .../Interop/UnmanagedMethods.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index a8c9ec101c..4f69e022e2 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -701,9 +701,39 @@ namespace Avalonia.Win32.Interop [DllImport("user32.dll", SetLastError = true)] public static extern uint GetWindowLongPtr(IntPtr hWnd, int nIndex); + [DllImport("user32.dll", SetLastError = true, EntryPoint = "GetWindowLong")] + public static extern uint GetWindowLong32b(IntPtr hWnd, int nIndex); + + public static uint GetWindowLong(IntPtr hWnd, int nIndex) + { + if(IntPtr.Size == 4) + { + return GetWindowLong32b(hWnd, nIndex); + } + else + { + return GetWindowLongPtr(hWnd, nIndex); + } + } + + [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLong")] + public static extern uint SetWindowLong32b(IntPtr hWnd, int nIndex, uint value); + [DllImport("user32.dll", SetLastError = true)] public static extern uint SetWindowLongPtr(IntPtr hWnd, int nIndex, uint value); + public static uint SetWindowLong(IntPtr hWnd, int nIndex, uint value) + { + if (IntPtr.Size == 4) + { + return SetWindowLong32b(hWnd, nIndex, value); + } + else + { + return SetWindowLongPtr(hWnd, nIndex, value); + } + } + [DllImport("user32.dll", SetLastError = true)] public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); From 7605909c79c4483530e611196b7ac5950a94df7b Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Sun, 3 Sep 2017 21:14:47 +0200 Subject: [PATCH 12/35] Made the pinvoke calls private Changed SetWindowLongPtr calls to SetWindowLong in Win32/WindowImpl --- src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs | 4 ++-- src/Windows/Avalonia.Win32/WindowImpl.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index 4f69e022e2..f58beadc0b 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -717,10 +717,10 @@ namespace Avalonia.Win32.Interop } [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLong")] - public static extern uint SetWindowLong32b(IntPtr hWnd, int nIndex, uint value); + private static extern uint SetWindowLong32b(IntPtr hWnd, int nIndex, uint value); [DllImport("user32.dll", SetLastError = true)] - public static extern uint SetWindowLongPtr(IntPtr hWnd, int nIndex, uint value); + private static extern uint SetWindowLongPtr(IntPtr hWnd, int nIndex, uint value); public static uint SetWindowLong(IntPtr hWnd, int nIndex, uint value) { diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 4e67b47a36..4a30d48878 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -66,8 +66,8 @@ namespace Avalonia.Win32 { get { - var style = UnmanagedMethods.GetWindowLongPtr(_hwnd, -16); - var exStyle = UnmanagedMethods.GetWindowLongPtr(_hwnd, -20); + var style = UnmanagedMethods.GetWindowLong(_hwnd, -16); + var exStyle = UnmanagedMethods.GetWindowLong(_hwnd, -20); var padding = new UnmanagedMethods.RECT(); if (UnmanagedMethods.AdjustWindowRectEx(ref padding, style, false, exStyle)) @@ -219,7 +219,7 @@ namespace Avalonia.Win32 return; } - var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLongPtr(_hwnd, -16); + var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLong(_hwnd, -16); style |= UnmanagedMethods.WindowStyles.WS_OVERLAPPEDWINDOW; @@ -235,7 +235,7 @@ namespace Avalonia.Win32 Rect newRect; var oldThickness = BorderThickness; - UnmanagedMethods.SetWindowLongPtr(_hwnd, -16, (uint)style); + UnmanagedMethods.SetWindowLong(_hwnd, -16, (uint)style); if (value) { From d278c5ddeb7c6851683b4a4ec62c9dec6a92ca17 Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Mon, 4 Sep 2017 17:07:22 +0200 Subject: [PATCH 13/35] Added ShowTaskbarIcon implementation --- samples/ControlCatalog/MainWindow.xaml.cs | 4 +++- src/Avalonia.Controls/Platform/IWindowImpl.cs | 4 ++++ src/Gtk/Avalonia.Gtk/WindowImpl.cs | 5 +++++ src/Gtk/Avalonia.Gtk3/Interop/Native.cs | 15 ++++++++++++++- src/Gtk/Avalonia.Gtk3/WindowImpl.cs | 6 ++++++ src/Windows/Avalonia.Win32/WindowImpl.cs | 17 +++++++++++++++++ 6 files changed, 49 insertions(+), 2 deletions(-) diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index 413794dfa2..ef86b1a434 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using System; namespace ControlCatalog { @@ -10,7 +11,8 @@ namespace ControlCatalog { this.InitializeComponent(); this.AttachDevTools(); - Renderer.DrawDirtyRects = Renderer.DrawFps = true; + //Renderer.DrawDirtyRects = Renderer.DrawFps = true; + PlatformImpl.ShowTaskbarIcon(false); } private void InitializeComponent() diff --git a/src/Avalonia.Controls/Platform/IWindowImpl.cs b/src/Avalonia.Controls/Platform/IWindowImpl.cs index 69b946346e..d56cdc4e19 100644 --- a/src/Avalonia.Controls/Platform/IWindowImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowImpl.cs @@ -39,5 +39,9 @@ namespace Avalonia.Platform /// Sets the icon of this window. /// void SetIcon(IWindowIconImpl icon); + + + + void ShowTaskbarIcon(bool value); } } diff --git a/src/Gtk/Avalonia.Gtk/WindowImpl.cs b/src/Gtk/Avalonia.Gtk/WindowImpl.cs index d8555b4e05..4c0eacbcf5 100644 --- a/src/Gtk/Avalonia.Gtk/WindowImpl.cs +++ b/src/Gtk/Avalonia.Gtk/WindowImpl.cs @@ -127,5 +127,10 @@ namespace Avalonia.Gtk { Window.Icon = ((IconImpl)icon).Pixbuf; } + + public void ShowTaskbarIcon(bool value) + { + Window.SkipTaskbarHint = !value; + } } } diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs index fb1a9955e3..c212807c6a 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs @@ -38,6 +38,9 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_widget_hide(GtkWidget gtkWidget); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate void gtk_widget_show(GtkWidget gtkWidget); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_icon(GtkWindow window, Pixbuf pixbuf); @@ -75,7 +78,6 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)] public delegate void gdk_window_resize(IntPtr gtkWindow, int width, int height); - [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_widget_realize(GtkWidget gtkWidget); @@ -86,6 +88,13 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_decorated(GtkWindow gtkWindow, bool decorated); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate void gtk_window_set_skip_taskbar_hint(GtkWindow gtkWindow, bool setting); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate void gtk_window_set_skip_pager_hint(GtkWindow gtkWindow, bool setting); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate bool gtk_window_get_skip_taskbar_hint(GtkWindow gtkWindow); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_get_size(GtkWindow gtkWindow, out int width, out int height); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] @@ -271,6 +280,9 @@ namespace Avalonia.Gtk3.Interop public static D.gtk_window_set_decorated GtkWindowSetDecorated; + public static D.gtk_window_set_skip_taskbar_hint GtkWindowSetSkipTaskbarHint; + public static D.gtk_window_set_skip_pager_hint GtkWindowSetSkipPagerHint; + public static D.gtk_window_get_skip_taskbar_hint GtkWindowGetSkipTaskbarHint; public static D.gtk_window_set_title GtkWindowSetTitle; public static D.gtk_application_new GtkApplicationNew; public static D.gtk_main_iteration GtkMainIteration; @@ -280,6 +292,7 @@ namespace Avalonia.Gtk3.Interop public static D.gtk_init GtkInit; public static D.gtk_window_present GtkWindowPresent; public static D.gtk_widget_hide GtkWidgetHide; + public static D.gtk_widget_show GtkWidgetShow; public static D.gdk_get_native_handle GetNativeGdkWindowHandle; public static D.gtk_widget_get_window GtkWidgetGetWindow; public static D.gtk_widget_get_scale_factor GtkWidgetGetScaleFactor; diff --git a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs b/src/Gtk/Avalonia.Gtk3/WindowImpl.cs index f083185a84..df834561d4 100644 --- a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/WindowImpl.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Gtk3.Interop; using Avalonia.Platform; +using System.Runtime.InteropServices; namespace Avalonia.Gtk3 { @@ -59,6 +60,11 @@ namespace Avalonia.Gtk3 //Why do we even have that? } + public void ShowTaskbarIcon(bool value) + { + Native.GtkWindowSetSkipTaskbarHint(GtkWidget, !value); + } + class EmptyDisposable : IDisposable { public void Dispose() diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 4a30d48878..bb2d4e808c 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -750,5 +750,22 @@ namespace Avalonia.Win32 return (int)(ptr.ToInt64() & 0xffffffff); } + + public void ShowTaskbarIcon(bool value) + { + var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLong(_hwnd, -20); + + style &= ~(UnmanagedMethods.WindowStyles.WS_VISIBLE); + + style |= UnmanagedMethods.WindowStyles.WS_EX_TOOLWINDOW; + if (value) + style |= UnmanagedMethods.WindowStyles.WS_EX_APPWINDOW; + else + style &= ~(UnmanagedMethods.WindowStyles.WS_EX_APPWINDOW); + + UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Hide); + UnmanagedMethods.SetWindowLong(_hwnd, -20, (uint)style); + UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Show); + } } } From 913149d093dc069cf62dd0bf54eeaf0ac262b7af Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Sep 2017 11:30:36 +0300 Subject: [PATCH 14/35] Switched to .NET Standard 2.0 --- appveyor.yml | 4 +- build.cake | 2 +- packages.cake | 60 +++++++++---------- .../ControlCatalog.NetCore.csproj | 2 +- samples/ControlCatalog/ControlCatalog.csproj | 2 +- .../Avalonia.Animation.csproj | 2 +- src/Avalonia.Base/Avalonia.Base.csproj | 2 +- .../Avalonia.Controls.csproj | 2 +- .../Avalonia.DesignerSupport.csproj | 2 +- .../Avalonia.Diagnostics.csproj | 2 +- .../Avalonia.DotNetCoreRuntime.csproj | 2 +- .../Avalonia.HtmlRenderer.csproj | 2 +- src/Avalonia.Input/Avalonia.Input.csproj | 2 +- .../Avalonia.Interactivity.csproj | 2 +- src/Avalonia.Layout/Avalonia.Layout.csproj | 2 +- .../Avalonia.Logging.Serilog.csproj | 2 +- .../Avalonia.ReactiveUI.csproj | 2 +- src/Avalonia.Styling/Avalonia.Styling.csproj | 2 +- .../Avalonia.Themes.Default.csproj | 2 +- src/Avalonia.Visuals/Avalonia.Visuals.csproj | 2 +- src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj | 2 +- .../Avalonia.LinuxFramebuffer.csproj | 2 +- .../Avalonia.Markup.Xaml.csproj | 2 +- .../Avalonia.Markup/Avalonia.Markup.csproj | 2 +- src/Skia/Avalonia.Skia/Avalonia.Skia.csproj | 2 +- .../Avalonia.Direct2D1.csproj | 2 +- .../Avalonia.Win32.NetStandard.csproj | 2 +- .../Avalonia.Base.UnitTests.csproj | 2 +- .../Avalonia.Controls.UnitTests.csproj | 2 +- .../Avalonia.Input.UnitTests.csproj | 2 +- .../Avalonia.Interactivity.UnitTests.csproj | 2 +- .../Avalonia.Layout.UnitTests.csproj | 2 +- .../Avalonia.Markup.UnitTests.csproj | 2 +- .../Avalonia.Markup.Xaml.UnitTests.csproj | 2 +- .../Avalonia.Skia.RenderTests.csproj | 2 +- .../Avalonia.Styling.UnitTests.csproj | 2 +- .../Avalonia.UnitTests.csproj | 6 +- .../Avalonia.Visuals.UnitTests.csproj | 2 +- 38 files changed, 70 insertions(+), 70 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7457a1d5bb..ca548b6b0a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,9 +17,9 @@ init: - ps: if (Test-Path env:nuget_address) {[System.IO.File]::AppendAllText("C:\Windows\System32\drivers\etc\hosts", "`n$($env:nuget_address)`tapi.nuget.org")} install: - if not exist gtk-sharp-2.12.26.msi appveyor DownloadFile http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.26.msi - - if not exist dotnet-1.0.1.exe appveyor DownloadFile https://go.microsoft.com/fwlink/?linkid=843448 -FileName "dotnet-1.0.1.exe" + - if not exist dotnet-2.0.0.exe appveyor DownloadFile https://download.microsoft.com/download/0/F/D/0FD852A4-7EA1-4E2A-983A-0484AC19B92C/dotnet-sdk-2.0.0-win-x64.exe -FileName "dotnet-2.0.0.exe" - ps: Start-Process -FilePath "msiexec" -ArgumentList "/i gtk-sharp-2.12.26.msi /quiet /qn /norestart" -Wait - - ps: Start-Process -FilePath "dotnet-1.0.1.exe" -ArgumentList "/quiet" -Wait + - ps: Start-Process -FilePath "dotnet-2.0.0.exe" -ArgumentList "/quiet" -Wait - cmd: set PATH=%programfiles(x86)%\GtkSharp\2.12\bin\;%PATH% before_build: - git submodule update --init diff --git a/build.cake b/build.cake index 4e18f23780..b7b349b12b 100644 --- a/build.cake +++ b/build.cake @@ -162,7 +162,7 @@ void RunCoreTest(string project, Parameters parameters, bool coreOnly = false) project = System.IO.Path.Combine(project, System.IO.Path.GetFileName(project)+".csproj"); Information("Running tests from " + project); DotNetCoreRestore(project); - var frameworks = new List(){"netcoreapp1.1"}; + var frameworks = new List(){"netcoreapp2.0"}; if(parameters.IsRunningOnWindows) frameworks.Add("net461"); foreach(var fw in frameworks) diff --git a/packages.cake b/packages.cake index 22a519802f..4d33a90908 100644 --- a/packages.cake +++ b/packages.cake @@ -43,7 +43,7 @@ public class Packages } } - //new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp1.0", Version = "4.3.0" }, + //new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp2.0", Version = "4.3.0" }, public Packages(ICakeContext context, Parameters parameters) { // NUGET NUSPECS @@ -186,12 +186,12 @@ public class Packages }; var coreLibrariesFiles = coreLibraries.Select((lib) => { - return (FilePath)context.File(lib[0] + lib[1] + "/bin/" + parameters.DirSuffix + "/netstandard1.3/" + lib[1] + lib[2]); + return (FilePath)context.File(lib[0] + lib[1] + "/bin/" + parameters.DirSuffix + "/netstandard2.0/" + lib[1] + lib[2]); }).ToList(); var coreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => { return new NuSpecContent { - Source = file.FullPath, Target = "lib/netstandard1.3" + Source = file.FullPath, Target = "lib/netstandard2.0" }; }); @@ -203,7 +203,7 @@ public class Packages var netcoreappCoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => { return new NuSpecContent { - Source = file.FullPath, Target = "lib/netcoreapp1.0" + Source = file.FullPath, Target = "lib/netcoreapp2.0" }; }); @@ -218,8 +218,8 @@ public class Packages var netCoreRuntimePlatformExtensions = new [] {".xml", ".dll"}; var netCoreRuntimePlatform = netCoreRuntimePlatformExtensions.Select(libSuffix => { return new NuSpecContent { - Source = ((FilePath)context.File("./src/Avalonia.DotNetCoreRuntime/bin/" + parameters.DirSuffix + "/netcoreapp1.0/Avalonia.DotNetCoreRuntime" + libSuffix)).FullPath, - Target = "lib/netcoreapp1.0" + Source = ((FilePath)context.File("./src/Avalonia.DotNetCoreRuntime/bin/" + parameters.DirSuffix + "/netcoreapp2.0/Avalonia.DotNetCoreRuntime" + libSuffix)).FullPath, + Target = "lib/netcoreapp2.0" }; }); @@ -238,15 +238,15 @@ public class Packages new NuSpecDependency() { Id = "Sprache", Version = SpracheVersion }, new NuSpecDependency() { Id = "System.Reactive", Version = SystemReactiveVersion }, //.NET Core - new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp1.0", Version = "4.3.0" }, - new NuSpecDependency() { Id = "Microsoft.Extensions.DependencyModel", TargetFramework = "netcoreapp1.0", Version = "1.1.0" }, - new NuSpecDependency() { Id = "NETStandard.Library", TargetFramework = "netcoreapp1.0", Version = "1.6.0" }, - new NuSpecDependency() { Id = "Splat", TargetFramework = "netcoreapp1.0", Version = SplatVersion }, - new NuSpecDependency() { Id = "Serilog", TargetFramework = "netcoreapp1.0", Version = SerilogVersion }, - new NuSpecDependency() { Id = "Sprache", TargetFramework = "netcoreapp1.0", Version = SpracheVersion }, - new NuSpecDependency() { Id = "System.Reactive", TargetFramework = "netcoreapp1.0", Version = SystemReactiveVersion }, + new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp2.0", Version = "4.3.0" }, + new NuSpecDependency() { Id = "Microsoft.Extensions.DependencyModel", TargetFramework = "netcoreapp2.0", Version = "1.1.0" }, + new NuSpecDependency() { Id = "NETStandard.Library", TargetFramework = "netcoreapp2.0", Version = "1.6.0" }, + new NuSpecDependency() { Id = "Splat", TargetFramework = "netcoreapp2.0", Version = SplatVersion }, + new NuSpecDependency() { Id = "Serilog", TargetFramework = "netcoreapp2.0", Version = SerilogVersion }, + new NuSpecDependency() { Id = "Sprache", TargetFramework = "netcoreapp2.0", Version = SpracheVersion }, + new NuSpecDependency() { Id = "System.Reactive", TargetFramework = "netcoreapp2.0", Version = SystemReactiveVersion }, } - .Deps(new string[]{null, "netcoreapp1.0"}, + .Deps(new string[]{null, "netcoreapp2.0"}, "System.ValueTuple", "System.ComponentModel.TypeConverter", "System.ComponentModel.Primitives", "System.Runtime.Serialization.Primitives", "System.Xml.XmlDocument", "System.Xml.ReaderWriter") .ToArray(), @@ -269,9 +269,9 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/netstandard1.3" } + new NuSpecContent { Source = "Avalonia.HtmlRenderer.dll", Target = "lib/netstandard2.0" } }, - BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix + "/netstandard1.3"), + BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix + "/netstandard2.0"), OutputDirectory = parameters.NugetRoot } }; @@ -331,7 +331,7 @@ public class Packages Files = new [] { new NuSpecContent { Source = "Avalonia.Win32/bin/" + parameters.DirSuffix + "/Avalonia.Win32.dll", Target = "lib/net45" }, - new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + parameters.DirSuffix + "/netstandard1.3/Avalonia.Win32.dll", Target = "lib/netstandard1.3" } + new NuSpecContent { Source = "Avalonia.Win32.NetStandard/bin/" + parameters.DirSuffix + "/netstandard2.0/Avalonia.Win32.dll", Target = "lib/netstandard2.0" } }, BasePath = context.Directory("./src/Windows"), OutputDirectory = parameters.NugetRoot @@ -352,9 +352,9 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/netstandard1.3" } + new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/netstandard2.0" } }, - BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix + "/netstandard1.3"), + BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix + "/netstandard2.0"), OutputDirectory = parameters.NugetRoot }, /////////////////////////////////////////////////////////////////////////////// @@ -386,9 +386,9 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard1.3" } + new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard2.0" } }, - BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix + "/netstandard1.3"), + BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix + "/netstandard2.0"), OutputDirectory = parameters.NugetRoot }, /////////////////////////////////////////////////////////////////////////////// @@ -418,18 +418,18 @@ public class Packages { new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion }, - new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version, TargetFramework="netcoreapp1.1" }, - new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion, TargetFramework="netcoreapp1.1" }, - new NuSpecDependency() { Id = "Avalonia.Skia.Linux.Natives", Version = SkiaSharpLinuxVersion, TargetFramework="netcoreapp1.1" }, + new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version, TargetFramework="netcoreapp2.0" }, + new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion, TargetFramework="netcoreapp2.0" }, + new NuSpecDependency() { Id = "Avalonia.Skia.Linux.Natives", Version = SkiaSharpLinuxVersion, TargetFramework="netcoreapp2.0" }, new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version, TargetFramework="net461" }, new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion, TargetFramework="net461" }, new NuSpecDependency() { Id = "Avalonia.Skia.Linux.Natives", Version = SkiaSharpLinuxVersion, TargetFramework="net461" } }, Files = new [] { - new NuSpecContent { Source = "Avalonia.Skia.dll", Target = "lib/netstandard1.3" } + new NuSpecContent { Source = "Avalonia.Skia.dll", Target = "lib/netstandard2.0" } }, - BasePath = context.Directory("./src/Skia/Avalonia.Skia/bin/" + parameters.DirSuffix + "/netstandard1.3"), + BasePath = context.Directory("./src/Skia/Avalonia.Skia/bin/" + parameters.DirSuffix + "/netstandard2.0"), OutputDirectory = parameters.NugetRoot }, /////////////////////////////////////////////////////////////////////////////// @@ -448,9 +448,9 @@ public class Packages new NuSpecDependency() { Id = "Avalonia.Skia", TargetFramework="net45", Version = parameters.Version }, new NuSpecDependency() { Id = "Avalonia.Gtk3", TargetFramework="net45", Version = parameters.Version }, //.NET Core - new NuSpecDependency() { Id = "Avalonia.Win32", TargetFramework="netcoreapp1.0", Version = parameters.Version }, - new NuSpecDependency() { Id = "Avalonia.Skia", TargetFramework="netcoreapp1.0", Version = parameters.Version }, - new NuSpecDependency() { Id = "Avalonia.Gtk3", TargetFramework="netcoreapp1.0", Version = parameters.Version } + new NuSpecDependency() { Id = "Avalonia.Win32", TargetFramework="netcoreapp2.0", Version = parameters.Version }, + new NuSpecDependency() { Id = "Avalonia.Skia", TargetFramework="netcoreapp2.0", Version = parameters.Version }, + new NuSpecDependency() { Id = "Avalonia.Gtk3", TargetFramework="netcoreapp2.0", Version = parameters.Version } }, Files = new NuSpecContent[] { @@ -488,7 +488,7 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.LinuxFramebuffer/bin/" + parameters.DirSuffix + "/netstandard1.3/Avalonia.LinuxFramebuffer.dll", Target = "lib/netstandard1.3" } + new NuSpecContent { Source = "Avalonia.LinuxFramebuffer/bin/" + parameters.DirSuffix + "/netstandard2.0/Avalonia.LinuxFramebuffer.dll", Target = "lib/netstandard2.0" } }, BasePath = context.Directory("./src/Linux/"), OutputDirectory = parameters.NugetRoot diff --git a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj index e0e848b91b..b308c59789 100644 --- a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj +++ b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp1.1 + netcoreapp2.0 diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index a75de098e8..99ddce0757 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 False false diff --git a/src/Avalonia.Animation/Avalonia.Animation.csproj b/src/Avalonia.Animation/Avalonia.Animation.csproj index 8f832dabcf..bafac2b261 100644 --- a/src/Avalonia.Animation/Avalonia.Animation.csproj +++ b/src/Avalonia.Animation/Avalonia.Animation.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.Base/Avalonia.Base.csproj b/src/Avalonia.Base/Avalonia.Base.csproj index 6906aed42b..58c510f483 100644 --- a/src/Avalonia.Base/Avalonia.Base.csproj +++ b/src/Avalonia.Base/Avalonia.Base.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false Avalonia diff --git a/src/Avalonia.Controls/Avalonia.Controls.csproj b/src/Avalonia.Controls/Avalonia.Controls.csproj index 037546b186..d999e3b74e 100644 --- a/src/Avalonia.Controls/Avalonia.Controls.csproj +++ b/src/Avalonia.Controls/Avalonia.Controls.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj b/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj index a68e8760f2..63cb8132a9 100644 --- a/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj +++ b/src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj b/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj index be3f397283..5cb56e0be1 100644 --- a/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj +++ b/src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj b/src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj index 36443ce6f3..5c72d433ce 100644 --- a/src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj +++ b/src/Avalonia.DotNetCoreRuntime/Avalonia.DotNetCoreRuntime.csproj @@ -1,6 +1,6 @@  - netcoreapp1.0 + netcoreapp2.0 false diff --git a/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj b/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj index f715217e42..0cbe318c9b 100644 --- a/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj +++ b/src/Avalonia.HtmlRenderer/Avalonia.HtmlRenderer.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 False False false diff --git a/src/Avalonia.Input/Avalonia.Input.csproj b/src/Avalonia.Input/Avalonia.Input.csproj index b5482ebce1..901f7b5675 100644 --- a/src/Avalonia.Input/Avalonia.Input.csproj +++ b/src/Avalonia.Input/Avalonia.Input.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj b/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj index 9d22de86b3..d683c77468 100644 --- a/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj +++ b/src/Avalonia.Interactivity/Avalonia.Interactivity.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.Layout/Avalonia.Layout.csproj b/src/Avalonia.Layout/Avalonia.Layout.csproj index d0260391d8..810a985e36 100644 --- a/src/Avalonia.Layout/Avalonia.Layout.csproj +++ b/src/Avalonia.Layout/Avalonia.Layout.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj b/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj index 9ac40cba07..b9fa2f208b 100644 --- a/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj +++ b/src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj index 22d815d786..835e2295e3 100644 --- a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj +++ b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 False false diff --git a/src/Avalonia.Styling/Avalonia.Styling.csproj b/src/Avalonia.Styling/Avalonia.Styling.csproj index 6bf37b522b..965b6d87e6 100644 --- a/src/Avalonia.Styling/Avalonia.Styling.csproj +++ b/src/Avalonia.Styling/Avalonia.Styling.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj index 4e980680d9..b4b200834b 100644 --- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj +++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Avalonia.Visuals/Avalonia.Visuals.csproj b/src/Avalonia.Visuals/Avalonia.Visuals.csproj index 127760d8ac..fe18b0e446 100644 --- a/src/Avalonia.Visuals/Avalonia.Visuals.csproj +++ b/src/Avalonia.Visuals/Avalonia.Visuals.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false Avalonia diff --git a/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj b/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj index 0f4b8c2e1b..b58a83b3d2 100644 --- a/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj +++ b/src/Gtk/Avalonia.Gtk3/Avalonia.Gtk3.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 False false diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj b/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj index 82da3ec090..c38cb0f114 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj +++ b/src/Linux/Avalonia.LinuxFramebuffer/Avalonia.LinuxFramebuffer.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 true diff --git a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj index 08ea6b6877..8f538b38a5 100644 --- a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj +++ b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 False false false diff --git a/src/Markup/Avalonia.Markup/Avalonia.Markup.csproj b/src/Markup/Avalonia.Markup/Avalonia.Markup.csproj index 3d16196b70..57552f852c 100644 --- a/src/Markup/Avalonia.Markup/Avalonia.Markup.csproj +++ b/src/Markup/Avalonia.Markup/Avalonia.Markup.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj b/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj index bae10e4d97..f5ed89d154 100644 --- a/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj +++ b/src/Skia/Avalonia.Skia/Avalonia.Skia.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false Avalonia.Skia Avalonia.Skia diff --git a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj index 4d656680b1..a84c373886 100644 --- a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj +++ b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 false diff --git a/src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj b/src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj index cedf3c4213..bae634b030 100644 --- a/src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj +++ b/src/Windows/Avalonia.Win32.NetStandard/Avalonia.Win32.NetStandard.csproj @@ -1,6 +1,6 @@  - netstandard1.3 + netstandard2.0 False false Avalonia.Win32 diff --git a/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj b/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj index c656801d90..8692cdef42 100644 --- a/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj +++ b/tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj b/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj index 957cdd7036..8b2f5093cf 100644 --- a/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj +++ b/tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj index 186d293b96..b2ca80e5b8 100644 --- a/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj +++ b/tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj b/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj index 86c9cf0617..78d2128478 100644 --- a/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj +++ b/tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj b/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj index 0950856dca..0020ff46d9 100644 --- a/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj +++ b/tests/Avalonia.Layout.UnitTests/Avalonia.Layout.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj b/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj index 3ccd3da044..5d3b04e24b 100644 --- a/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj +++ b/tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj b/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj index f6f8f6bcb0..a1f66d0c72 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.RenderTests/Avalonia.Skia.RenderTests.csproj b/tests/Avalonia.RenderTests/Avalonia.Skia.RenderTests.csproj index 134e89f2e5..370cfac6dd 100644 --- a/tests/Avalonia.RenderTests/Avalonia.Skia.RenderTests.csproj +++ b/tests/Avalonia.RenderTests/Avalonia.Skia.RenderTests.csproj @@ -6,7 +6,7 @@ - netcoreapp1.1 + netcoreapp2.0 bin\Skia\$(Configuration) false False diff --git a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj index 8dd8faf9db..4a2f2caf1b 100644 --- a/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj +++ b/tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 Library diff --git a/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj b/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj index 40023134fd..b04fd5d2bc 100644 --- a/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj +++ b/tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 false Library @@ -33,7 +33,7 @@ - + @@ -52,7 +52,7 @@ - + \ No newline at end of file diff --git a/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj b/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj index d35542b51f..6dc9e3324d 100644 --- a/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj +++ b/tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp1.1 + net461;netcoreapp2.0 From 39d5389b1f91d02ab60eefa6fedaac41188ca0cf Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Sep 2017 12:33:40 +0300 Subject: [PATCH 15/35] Fixed build issues --- src/Avalonia.Controls/DropDown.cs | 2 +- src/Avalonia.HtmlRenderer/Compat/Api.cs | 12 ------------ .../Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj | 1 + .../PortableXaml/portable.xaml.github | 2 +- .../PlatformSupport/StandardRuntimePlatform.cs | 2 +- .../Avalonia.Win32/Interop/UnmanagedMethods.cs | 2 +- 6 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.Controls/DropDown.cs b/src/Avalonia.Controls/DropDown.cs index 0b1371b10e..5349fb1ca7 100644 --- a/src/Avalonia.Controls/DropDown.cs +++ b/src/Avalonia.Controls/DropDown.cs @@ -120,7 +120,7 @@ namespace Avalonia.Controls /// protected override void OnPointerPressed(PointerPressedEventArgs e) { - if (!IsDropDownOpen && ((IVisual)e.Source).GetVisualRoot() != typeof(PopupRoot)) + if (!IsDropDownOpen && ((IVisual)e.Source).GetVisualRoot() is PopupRoot) { IsDropDownOpen = true; e.Handled = true; diff --git a/src/Avalonia.HtmlRenderer/Compat/Api.cs b/src/Avalonia.HtmlRenderer/Compat/Api.cs index 798b697277..d4f4c6abbe 100644 --- a/src/Avalonia.HtmlRenderer/Compat/Api.cs +++ b/src/Avalonia.HtmlRenderer/Compat/Api.cs @@ -4,18 +4,6 @@ using System.Text; namespace System.Net { - internal class AsyncCompletedEventArgs - { - public object UserState { get; set; } - public Exception Error { get; set; } - public bool Cancelled { get; set; } - - public AsyncCompletedEventArgs(Exception error, bool cancelled, object userState) - { - - } - } - class WebException : Exception { public object Response { get; set; } diff --git a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj index 8f538b38a5..99b62181d7 100644 --- a/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj +++ b/src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj @@ -94,6 +94,7 @@ + diff --git a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github index dfc5affa5d..eebf9dbb92 160000 --- a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github +++ b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/portable.xaml.github @@ -1 +1 @@ -Subproject commit dfc5affa5d8f4ddf5a7707e3202d5593519de640 +Subproject commit eebf9dbb9275ecc48c18ec24f6fbad8cb494857f diff --git a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs index e7402fb23c..092910a08f 100644 --- a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs +++ b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs @@ -12,7 +12,7 @@ namespace Avalonia.Shared.PlatformSupport internal partial class StandardRuntimePlatform : IRuntimePlatform { -#if NETCOREAPP1_0 +#if NETCOREAPP2_0 public void PostThreadPoolItem(Action cb) => ThreadPool.QueueUserWorkItem(_ => cb(), null); #else public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies(); diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index d5a6f1a7a1..1cc06af0d6 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -811,7 +811,7 @@ namespace Avalonia.Win32.Interop return SetClassLong64(hWnd, nIndex, dwNewLong); } -#if !NETSTANDARD && !NETSTANDARD1_3 +#if !NETSTANDARD && !NETSTANDARD2_0 [ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")] internal class FileOpenDialogRCW { } From 8621abc7248a72752a02215839eefa5bdac55ed6 Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Tue, 5 Sep 2017 12:44:42 +0200 Subject: [PATCH 16/35] Fixed potential null reference --- samples/ControlCatalog/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index ef86b1a434..4cd9b93828 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -12,7 +12,7 @@ namespace ControlCatalog this.InitializeComponent(); this.AttachDevTools(); //Renderer.DrawDirtyRects = Renderer.DrawFps = true; - PlatformImpl.ShowTaskbarIcon(false); + PlatformImpl?.ShowTaskbarIcon(false); } private void InitializeComponent() From 65b4cfb6ba5c01b2fcd58455a6cf2d76c0b3c9ae Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Sep 2017 13:48:03 +0300 Subject: [PATCH 17/35] Use new SDK for DotNetFrameworkRuntime --- .../Avalonia.DotNetFrameworkRuntime.csproj | 94 ++++--------------- .../Properties/AssemblyInfo.cs | 15 --- 2 files changed, 20 insertions(+), 89 deletions(-) delete mode 100644 src/Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs diff --git a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj b/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj index e2c866fe3d..e3db94fc1f 100644 --- a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj +++ b/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj @@ -1,75 +1,21 @@ - - - - - Debug - AnyCPU - {4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0} - Library - Properties - Avalonia.DotNetFrameworkRuntime - Avalonia.DotNetFrameworkRuntime - v4.6.1 - 512 - - - - true - full - false - bin\Debug\ - TRACE;DEBUG;FULLDOTNET - prompt - 4 - bin\Debug\Avalonia.DotNetFrameworkRuntime.xml - - - pdbonly - true - bin\Release\ - TRACE;FULLDOTNET - prompt - 4 - bin\Release\Avalonia.DotNetFrameworkRuntime.xml - true - - - - - - - - - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - {B09B78D8-9B26-48B0-9149-D64A2F120F3F} - Avalonia.Base - - - {D2221C82-4A25-4583-9B43-D791E3F6820C} - Avalonia.Controls - - - {eb582467-6abb-43a1-b052-e981ba910e3a} - Avalonia.Visuals - - - {f1baa01a-f176-4c6a-b39d-5b40bb1b148f} - Avalonia.Styling - - - - - + + + net461 + false + bin\$(Configuration)\Avalonia.DotNetFrameworkRuntime.xmlL + $(DefineConstants);FULLDOTNET + true + + + + Properties\SharedAssemblyInfo.cs + + + + + + + + + \ No newline at end of file diff --git a/src/Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs b/src/Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs deleted file mode 100644 index 3a91d50a24..0000000000 --- a/src/Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Avalonia.DotNetFrameworkRuntime")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4a1abb09-9047-4bd5-a4ad-a055e52c5ee0")] From 3ce69edb249cc8d30199be960a1af9b7f5e3b00f Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Sep 2017 14:43:05 +0300 Subject: [PATCH 18/35] fixed framework version --- build/XUnit.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/XUnit.props b/build/XUnit.props index d59cee6536..9d4d401743 100644 --- a/build/XUnit.props +++ b/build/XUnit.props @@ -9,7 +9,7 @@ - + From 4722e636c6aa0c377b6c7c015d1c05e5cd801aa8 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Sep 2017 14:52:15 +0300 Subject: [PATCH 19/35] Use dotnet 2.0.0 for travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a3c02eea58..6d7600c36b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - DOTNET_CLI_TELEMETRY_OPTOUT=1 mono: - latest -dotnet: 1.0.1 +dotnet: 2.0.0 script: - ./build.sh --target "Travis" --platform "Mono" --configuration "Release" notifications: From a9ef43f17905b20299907d55d2d32bd05084545a Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Sep 2017 15:03:23 +0300 Subject: [PATCH 20/35] Fixed paths --- packages.cake | 2 +- .../Avalonia.DotNetFrameworkRuntime.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages.cake b/packages.cake index 4d33a90908..9ae45d15bd 100644 --- a/packages.cake +++ b/packages.cake @@ -210,7 +210,7 @@ public class Packages var net45RuntimePlatformExtensions = new [] {".xml", ".dll"}; var net45RuntimePlatform = net45RuntimePlatformExtensions.Select(libSuffix => { return new NuSpecContent { - Source = ((FilePath)context.File("./src/Avalonia.DotNetFrameworkRuntime/bin/" + parameters.DirSuffix + "/Avalonia.DotNetFrameworkRuntime" + libSuffix)).FullPath, + Source = ((FilePath)context.File("./src/Avalonia.DotNetFrameworkRuntime/bin/" + parameters.DirSuffix + "/net461/Avalonia.DotNetFrameworkRuntime" + libSuffix)).FullPath, Target = "lib/net45" }; }); diff --git a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj b/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj index e3db94fc1f..181f5e3a1e 100644 --- a/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj +++ b/src/Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj @@ -2,7 +2,7 @@ net461 false - bin\$(Configuration)\Avalonia.DotNetFrameworkRuntime.xmlL + bin\$(Configuration)\Avalonia.DotNetFrameworkRuntime.xml $(DefineConstants);FULLDOTNET true From 017f8ee8b007e9858a7507d24c19f2a8ad67a9ba Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 5 Sep 2017 15:30:50 +0300 Subject: [PATCH 21/35] Specify osx_image --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6d7600c36b..52a400d19a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ os: - linux - osx dist: trusty +osx_image: xcode8.3 env: global: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 From a12c4649cbca6e5d729bdd22a55db171434a021d Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Tue, 5 Sep 2017 18:35:09 +0200 Subject: [PATCH 22/35] Cleaned up implementation of ShowTaskbarIcon Created property in Window to enable/disable the taskbar icon --- src/Avalonia.Controls/Platform/IWindowImpl.cs | 7 +++--- src/Avalonia.Controls/Window.cs | 24 ++++++++++++++++--- src/Gtk/Avalonia.Gtk/WindowImpl.cs | 21 +++++++--------- src/Gtk/Avalonia.Gtk3/WindowImpl.cs | 6 ++--- src/Windows/Avalonia.Win32/WindowImpl.cs | 1 + 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/Avalonia.Controls/Platform/IWindowImpl.cs b/src/Avalonia.Controls/Platform/IWindowImpl.cs index d56cdc4e19..37637b1624 100644 --- a/src/Avalonia.Controls/Platform/IWindowImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowImpl.cs @@ -31,7 +31,7 @@ namespace Avalonia.Platform IDisposable ShowDialog(); /// - /// Enables of disables system window decorations (title bar, buttons, etc) + /// Enables or disables system window decorations (title bar, buttons, etc) /// void SetSystemDecorations(bool enabled); @@ -40,8 +40,9 @@ namespace Avalonia.Platform /// void SetIcon(IWindowIconImpl icon); - - + /// + /// Enables or disables the taskbar icon + /// void ShowTaskbarIcon(bool value); } } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 46c625cc4c..37f7c6d47f 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -61,11 +61,17 @@ namespace Avalonia.Controls AvaloniaProperty.Register(nameof(SizeToContent)); /// - /// Enables of disables system window decorations (title bar, buttons, etc) + /// Enables or disables system window decorations (title bar, buttons, etc) /// public static readonly StyledProperty HasSystemDecorationsProperty = AvaloniaProperty.Register(nameof(HasSystemDecorations), true); - + + /// + /// Enables or disables the taskbar icon + /// + public static readonly StyledProperty HasTaskbarIconProperty = + AvaloniaProperty.Register(nameof(HasTaskbarIcon), true); + /// /// Defines the property. /// @@ -92,6 +98,8 @@ namespace Avalonia.Controls HasSystemDecorationsProperty.Changed.AddClassHandler( (s, e) => s.PlatformImpl?.SetSystemDecorations((bool) e.NewValue)); + HasTaskbarIconProperty.Changed.AddClassHandler((w, e) => w.PlatformImpl?.ShowTaskbarIcon((bool)e.NewValue)); + IconProperty.Changed.AddClassHandler((s, e) => s.PlatformImpl?.SetIcon(((WindowIcon)e.NewValue).PlatformImpl)); } @@ -152,7 +160,7 @@ namespace Avalonia.Controls } /// - /// Enables of disables system window decorations (title bar, buttons, etc) + /// Enables or disables system window decorations (title bar, buttons, etc) /// /// public bool HasSystemDecorations @@ -160,6 +168,16 @@ namespace Avalonia.Controls get { return GetValue(HasSystemDecorationsProperty); } set { SetValue(HasSystemDecorationsProperty, value); } } + + /// + /// Enables or disables the taskbar icon + /// + /// + public bool HasTaskbarIcon + { + get { return GetValue(HasTaskbarIconProperty); } + set { SetValue(HasTaskbarIconProperty, value); } + } /// /// Gets or sets the minimized/maximized state of the window. diff --git a/src/Gtk/Avalonia.Gtk/WindowImpl.cs b/src/Gtk/Avalonia.Gtk/WindowImpl.cs index 4c0eacbcf5..2c1826c509 100644 --- a/src/Gtk/Avalonia.Gtk/WindowImpl.cs +++ b/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; } -} +} \ No newline at end of file diff --git a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs b/src/Gtk/Avalonia.Gtk3/WindowImpl.cs index df834561d4..e6935c4f20 100644 --- a/src/Gtk/Avalonia.Gtk3/WindowImpl.cs +++ b/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 { diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index bb2d4e808c..b9e2151b8f 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/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); From cc04dc7c788985a9cb03268454992862555939f7 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 6 Sep 2017 00:31:21 +0300 Subject: [PATCH 23/35] Removed commented code --- packages.cake | 1 - 1 file changed, 1 deletion(-) diff --git a/packages.cake b/packages.cake index 9ae45d15bd..2c0298b669 100644 --- a/packages.cake +++ b/packages.cake @@ -43,7 +43,6 @@ public class Packages } } - //new NuSpecDependency() { Id = "System.Threading.ThreadPool", TargetFramework = "netcoreapp2.0", Version = "4.3.0" }, public Packages(ICakeContext context, Parameters parameters) { // NUGET NUSPECS From 284f0a75c79b62999b3e87b010edf88f9fd8b1df Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Wed, 6 Sep 2017 10:35:28 +0200 Subject: [PATCH 24/35] Uncommented DrawDirtyRects/DrawFps --- samples/ControlCatalog/MainWindow.xaml.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index 4cd9b93828..c2e8c0c082 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -11,8 +11,7 @@ namespace ControlCatalog { this.InitializeComponent(); this.AttachDevTools(); - //Renderer.DrawDirtyRects = Renderer.DrawFps = true; - PlatformImpl?.ShowTaskbarIcon(false); + Renderer.DrawDirtyRects = Renderer.DrawFps = true; } private void InitializeComponent() From c9fa06637f4ffe34e93500e841b08eb50b10f0c9 Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Wed, 6 Sep 2017 11:46:04 +0200 Subject: [PATCH 25/35] Cleaned up Native --- src/Gtk/Avalonia.Gtk3/Interop/Native.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs index c212807c6a..ba6a6ace92 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs @@ -90,10 +90,13 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_skip_taskbar_hint(GtkWindow gtkWindow, bool setting); - [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] - public delegate void gtk_window_set_skip_pager_hint(GtkWindow gtkWindow, bool setting); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate bool gtk_window_get_skip_taskbar_hint(GtkWindow gtkWindow); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate void gtk_window_set_skip_pager_hint(GtkWindow gtkWindow, bool setting); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] + public delegate bool gtk_window_get_skip_pager_hint(GtkWindow gtkWindow); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_get_size(GtkWindow gtkWindow, out int width, out int height); @@ -119,9 +122,6 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_dialog_add_button(GtkDialog raw, Utf8Buffer button_text, GtkResponseType response_id); - - - [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Cairo)] public delegate CairoSurface cairo_image_surface_create(int format, int width, int height); @@ -281,8 +281,9 @@ namespace Avalonia.Gtk3.Interop public static D.gtk_window_set_decorated GtkWindowSetDecorated; public static D.gtk_window_set_skip_taskbar_hint GtkWindowSetSkipTaskbarHint; - public static D.gtk_window_set_skip_pager_hint GtkWindowSetSkipPagerHint; public static D.gtk_window_get_skip_taskbar_hint GtkWindowGetSkipTaskbarHint; + public static D.gtk_window_set_skip_pager_hint GtkWindowSetSkipPagerHint; + public static D.gtk_window_get_skip_pager_hint GtkWindowGetSkipPagerHint; public static D.gtk_window_set_title GtkWindowSetTitle; public static D.gtk_application_new GtkApplicationNew; public static D.gtk_main_iteration GtkMainIteration; From 34e82c19fb7f48e07902a67a5a9bc860d420ea9a Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Wed, 6 Sep 2017 11:50:02 +0200 Subject: [PATCH 26/35] Win32 implementation now checks the previous ShowWindowCommand and sets it back to that after hiding. --- src/Windows/Avalonia.Win32/WindowImpl.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index b9e2151b8f..128e2a6338 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -763,10 +763,14 @@ 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); + WINDOWPLACEMENT windowPlacement = new WINDOWPLACEMENT(); + if (UnmanagedMethods.GetWindowPlacement(_hwnd, ref windowPlacement)) + { + //Toggle to make the styles stick + UnmanagedMethods.ShowWindow(_hwnd, ShowWindowCommand.Hide); + UnmanagedMethods.SetWindowLong(_hwnd, -20, (uint)style); + UnmanagedMethods.ShowWindow(_hwnd, windowPlacement.ShowCmd); + } } } } From b888cbb8652972b78095054dffb90deb5010db3f Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Wed, 6 Sep 2017 11:59:12 +0200 Subject: [PATCH 27/35] Fixed windowplacement failing due to incorrect length --- src/Windows/Avalonia.Win32/WindowImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 128e2a6338..72485379a7 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -763,7 +763,7 @@ namespace Avalonia.Win32 else style &= ~(UnmanagedMethods.WindowStyles.WS_EX_APPWINDOW); - WINDOWPLACEMENT windowPlacement = new WINDOWPLACEMENT(); + WINDOWPLACEMENT windowPlacement = UnmanagedMethods.WINDOWPLACEMENT.Default; if (UnmanagedMethods.GetWindowPlacement(_hwnd, ref windowPlacement)) { //Toggle to make the styles stick From 61e4e50d3120b6ccac553f233cbdb65d7bce3882 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 6 Sep 2017 13:28:19 +0300 Subject: [PATCH 28/35] Enable win32 file dialog functionality for .NET Standard build --- src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs | 6 ++---- src/Windows/Avalonia.Win32/SystemDialogImpl.cs | 9 +-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index 2d739f095d..e7401c19b9 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -841,14 +841,13 @@ namespace Avalonia.Win32.Interop return SetClassLong64(hWnd, nIndex, dwNewLong); } -#if !NETSTANDARD && !NETSTANDARD2_0 + [ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")] internal class FileOpenDialogRCW { } [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppv); -#endif [DllImport("user32.dll", SetLastError = true)] public static extern bool OpenClipboard(IntPtr hWndOwner); @@ -1183,7 +1182,7 @@ namespace Avalonia.Win32.Interop public int flagsEx; } } -#if !NETSTANDARD && !NETSTANDARD1_3 + [ComImport(), Guid("42F85136-DB7E-439C-85F1-E4075D135FC8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IFileDialog { @@ -1283,5 +1282,4 @@ namespace Avalonia.Win32.Interop uint Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder); } -#endif } diff --git a/src/Windows/Avalonia.Win32/SystemDialogImpl.cs b/src/Windows/Avalonia.Win32/SystemDialogImpl.cs index 4d8c375aaf..eef8a4d449 100644 --- a/src/Windows/Avalonia.Win32/SystemDialogImpl.cs +++ b/src/Windows/Avalonia.Win32/SystemDialogImpl.cs @@ -100,17 +100,14 @@ namespace Avalonia.Win32 var pofn = &ofn; // We should save the current directory to restore it later. -#if !NETSTANDARD var currentDirectory = Environment.CurrentDirectory; -#endif + var res = dialog is OpenFileDialog ? UnmanagedMethods.GetOpenFileName(new IntPtr(pofn)) : UnmanagedMethods.GetSaveFileName(new IntPtr(pofn)); // Restore the old current directory, since GetOpenFileName and GetSaveFileName change it after they're called -#if !NETSTANDARD Environment.CurrentDirectory = currentDirectory; -#endif if (!res) return null; @@ -155,9 +152,6 @@ namespace Avalonia.Win32 public Task ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { -#if NETSTANDARD - throw new NotImplementedException(); -#else return Task.Factory.StartNew(() => { string result = string.Empty; @@ -214,7 +208,6 @@ namespace Avalonia.Win32 return result; }); -#endif } } } From f330132dc3232ebd914a29d095a9a44e9f1f45c5 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 6 Sep 2017 14:40:46 +0300 Subject: [PATCH 29/35] Use CoCreateInstance for .NET Core compatibility --- src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs | 5 +++-- src/Windows/Avalonia.Win32/SystemDialogImpl.cs | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs index e7401c19b9..4fed7a34f4 100644 --- a/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs +++ b/src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs @@ -842,8 +842,9 @@ namespace Avalonia.Win32.Interop return SetClassLong64(hWnd, nIndex, dwNewLong); } - [ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")] - internal class FileOpenDialogRCW { } + [DllImport("ole32.dll", PreserveSig = true)] + internal static extern int CoCreateInstance(ref Guid clsid, + IntPtr ignore1, int ignore2, ref Guid iid, [MarshalAs(UnmanagedType.IUnknown), Out] out object pUnkOuter); [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)] diff --git a/src/Windows/Avalonia.Win32/SystemDialogImpl.cs b/src/Windows/Avalonia.Win32/SystemDialogImpl.cs index eef8a4d449..e08fecbbd9 100644 --- a/src/Windows/Avalonia.Win32/SystemDialogImpl.cs +++ b/src/Windows/Avalonia.Win32/SystemDialogImpl.cs @@ -157,7 +157,11 @@ namespace Avalonia.Win32 string result = string.Empty; var hWnd = parent?.Handle?.Handle ?? IntPtr.Zero; - var frm = (IFileDialog)(new UnmanagedMethods.FileOpenDialogRCW()); + var clsid = Guid.Parse("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7"); + var iid = Guid.Parse("42F85136-DB7E-439C-85F1-E4075D135FC8"); + + UnmanagedMethods.CoCreateInstance(ref clsid, IntPtr.Zero, 1, ref iid, out var unk); + var frm = (IFileDialog)unk; uint options; frm.GetOptions(out options); options |= (uint)(UnmanagedMethods.FOS.FOS_PICKFOLDERS | UnmanagedMethods.FOS.FOS_FORCEFILESYSTEM | UnmanagedMethods.FOS.FOS_NOVALIDATE | UnmanagedMethods.FOS.FOS_NOTESTFILECREATE | UnmanagedMethods.FOS.FOS_DONTADDTORECENT); From 0a77519906faf8833792087d5300f1c8a8e76c8d Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 6 Sep 2017 17:09:07 +0300 Subject: [PATCH 30/35] Update build.md --- docs/guidelines/build.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/guidelines/build.md b/docs/guidelines/build.md index 822496814b..0cf91d913a 100644 --- a/docs/guidelines/build.md +++ b/docs/guidelines/build.md @@ -80,10 +80,11 @@ mono ./samples/ControlCatalog.Desktop/bin/Debug/ControlCatalog.Desktop.exe ### Building Avalonia in MonoDevelop -Unless you have a very current version of monodevelop (6.1.x or newer), it is necessary to manually -restore the Nuget depdendencies as [mentioned above](#restore-nuget-packages). You must then -disable MonoDevelop's inbuilt NuGet package manager add-in by going to `Tools -> Add-in Manager` or -it will complain that a newer version of NuGet is needed. +Flatpak version will *NOT* work. Version from https://github.com/cra0zy/monodevelop-run-installer/ might work if you are very lucky. Make sure that you have the latest version of Mono (from alpha update channel) and .NET Core SDK. Make sure to follow `FrameworkPathOverride` workaround from https://github.com/dotnet/sdk/issues/335 + +### Building and running Avalonia in Rider + +For Linux/OSX you'll probably need to apply workaround from https://github.com/dotnet/sdk/issues/335 + +Just add `export FrameworkPathOverride=/usr/lib/mono/4.6.1-api` (or `export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api` for OSX) -Finally, select the `Debug | Mono` or `Release | Mono` build configuration and you should be good to -go! From d4048de9947ace1ca953670a555516f626bc4b4e Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 6 Sep 2017 15:58:28 +0300 Subject: [PATCH 31/35] Don't try to load library with path == null --- src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs b/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs index cf065b86dc..764cbfd6b6 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs @@ -104,14 +104,16 @@ namespace Avalonia.Gtk3.Interop var path = Custom?.Lookup(dll); if (path == null && Custom?.BasePath != null) path = Path.Combine(Custom.BasePath, name); - - try - { - return loader.LoadLibrary(path); - } - catch (Exception e) + if (path != null) { - exceptions.Add(e); + try + { + return loader.LoadLibrary(path); + } + catch (Exception e) + { + exceptions.Add(e); + } } throw new AggregateException("Unable to load " + dll, exceptions); } From b013caee699756394053328ed504799eb6b8ef97 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 6 Sep 2017 15:59:13 +0300 Subject: [PATCH 32/35] Add .idea to .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 1d74816204..5fa78979c3 100644 --- a/.gitignore +++ b/.gitignore @@ -159,6 +159,12 @@ $RECYCLE.BIN/ *.userprefs *.nugetreferenceswitcher + +################# +## Rider +################# +.idea + ################# ## Cake ################# From d1c85d7a3a06ec108359fc6110bd5b159f29aa34 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 6 Sep 2017 23:45:47 +0200 Subject: [PATCH 33/35] Prevent possible null ref warnings. --- .../MarkupExtensions/DynamicResourceExtension.cs | 2 +- .../MarkupExtensions/StaticResourceExtension.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs index 5e421b7e73..231778be09 100644 --- a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs +++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/DynamicResourceExtension.cs @@ -59,7 +59,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions private T GetAnchor(ITypeDescriptorContext context) where T : class { - var schemaContext = context.GetService()?.SchemaContext; + var schemaContext = context.GetService().SchemaContext; var ambientProvider = context.GetService(); var xamlType = schemaContext.GetXamlType(typeof(T)); diff --git a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/StaticResourceExtension.cs b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/StaticResourceExtension.cs index 4764677ede..9089a13656 100644 --- a/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/StaticResourceExtension.cs +++ b/src/Markup/Avalonia.Markup.Xaml/MarkupExtensions/StaticResourceExtension.cs @@ -29,7 +29,7 @@ namespace Avalonia.Markup.Xaml.MarkupExtensions public override object ProvideValue(IServiceProvider serviceProvider) { var context = (ITypeDescriptorContext)serviceProvider; - var schemaContext = context.GetService()?.SchemaContext; + var schemaContext = context.GetService().SchemaContext; var ambientProvider = context.GetService(); var resourceProviderType = schemaContext.GetXamlType(typeof(IResourceNode)); var ambientValues = ambientProvider.GetAllAmbientValues(resourceProviderType); From 743262ec1d7a56dee8cd1608717350547321f9cc Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Thu, 7 Sep 2017 10:43:19 +0200 Subject: [PATCH 34/35] Reformatted Native.D --- src/Gtk/Avalonia.Gtk3/Interop/Native.cs | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs index ba6a6ace92..ffc1d380a3 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs @@ -59,14 +59,17 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate IntPtr gtk_widget_get_screen(GtkWidget gtkWidget); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate IntPtr gtk_widget_set_double_buffered(GtkWidget gtkWidget, bool value); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate IntPtr gtk_widget_set_events(GtkWidget gtkWidget, uint flags); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)] public delegate int gdk_screen_get_height(IntPtr screen); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)] public delegate int gdk_screen_get_width(IntPtr screen); @@ -75,6 +78,7 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)] public delegate int gdk_window_get_origin(IntPtr gdkWindow, out int x, out int y); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gdk)] public delegate void gdk_window_resize(IntPtr gtkWindow, int width, int height); @@ -90,35 +94,46 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_skip_taskbar_hint(GtkWindow gtkWindow, bool setting); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate bool gtk_window_get_skip_taskbar_hint(GtkWindow gtkWindow); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_skip_pager_hint(GtkWindow gtkWindow, bool setting); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate bool gtk_window_get_skip_pager_hint(GtkWindow gtkWindow); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_get_size(GtkWindow gtkWindow, out int width, out int height); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_resize(GtkWindow gtkWindow, int width, int height); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_widget_set_size_request(GtkWidget widget, int width, int height); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_set_default_size(GtkWindow gtkWindow, int width, int height); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_get_position(GtkWindow gtkWindow, out int x, out int y); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_window_move(GtkWindow gtkWindow, int x, int y); [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate GtkFileChooser gtk_file_chooser_dialog_new(Utf8Buffer title, GtkWindow parent, GtkFileChooserAction action, IntPtr ignore); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public unsafe delegate GSList* gtk_file_chooser_get_filenames(GtkFileChooser chooser); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_file_chooser_set_select_multiple(GtkFileChooser chooser, bool allow); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_file_chooser_set_filename(GtkFileChooser chooser, Utf8Buffer file); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_dialog_add_button(GtkDialog raw, Utf8Buffer button_text, GtkResponseType response_id); @@ -215,7 +230,6 @@ namespace Avalonia.Gtk3.Interop [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gtk)] public delegate void gtk_clipboard_clear(IntPtr clipboard); - [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.GdkPixBuf)] public delegate IntPtr gdk_pixbuf_new_from_file(Utf8Buffer filename, out IntPtr error); @@ -238,21 +252,27 @@ namespace Avalonia.Gtk3.Interop public delegate bool gdk_pixbuf_save_to_bufferv(Pixbuf pixbuf, out IntPtr buffer, out IntPtr buffer_size, Utf8Buffer type, IntPtr option_keys, IntPtr option_values, out IntPtr error); - [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)] public delegate void g_object_unref(IntPtr instance); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)] public delegate void g_object_ref(GObject instance); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)] public delegate ulong g_signal_connect_object(GObject instance, Utf8Buffer signal, IntPtr handler, IntPtr userData, int flags); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gobject)] public delegate ulong g_signal_handler_disconnect(GObject instance, ulong connectionId); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)] public delegate ulong g_timeout_add(uint interval, timeout_callback callback, IntPtr data); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)] public delegate ulong g_free(IntPtr data); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Glib)] public unsafe delegate void g_slist_free(GSList* data); + [UnmanagedFunctionPointer(CallingConvention.Cdecl), GtkImport(GtkDll.Gio)] public delegate GInputStream g_memory_input_stream_new_from_data(IntPtr ptr, IntPtr len, IntPtr destroyCallback); @@ -328,8 +348,7 @@ namespace Avalonia.Gtk3.Interop public static D.gtk_clipboard_request_text GtkClipboardRequestText; public static D.gtk_clipboard_set_text GtkClipboardSetText; public static D.gtk_clipboard_clear GtkClipboardRequestClear; - - + public static D.gtk_im_multicontext_new GtkImMulticontextNew; public static D.gtk_im_context_filter_keypress GtkImContextFilterKeypress; public static D.gtk_im_context_set_client_window GtkImContextSetClientWindow; From 025d630f778be33a77b0bf2f8d5c9e0fa62ed307 Mon Sep 17 00:00:00 2001 From: Jurjen Biewenga Date: Thu, 7 Sep 2017 13:07:49 +0200 Subject: [PATCH 35/35] Renamed 'HasTaskbarIcon' to 'ShowInTaskbar' --- src/Avalonia.Controls/Window.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 37f7c6d47f..9c0245a714 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -69,8 +69,8 @@ namespace Avalonia.Controls /// /// Enables or disables the taskbar icon /// - public static readonly StyledProperty HasTaskbarIconProperty = - AvaloniaProperty.Register(nameof(HasTaskbarIcon), true); + public static readonly StyledProperty ShowInTaskbarProperty = + AvaloniaProperty.Register(nameof(ShowInTaskbar), true); /// /// Defines the property. @@ -98,7 +98,7 @@ namespace Avalonia.Controls HasSystemDecorationsProperty.Changed.AddClassHandler( (s, e) => s.PlatformImpl?.SetSystemDecorations((bool) e.NewValue)); - HasTaskbarIconProperty.Changed.AddClassHandler((w, e) => w.PlatformImpl?.ShowTaskbarIcon((bool)e.NewValue)); + ShowInTaskbarProperty.Changed.AddClassHandler((w, e) => w.PlatformImpl?.ShowTaskbarIcon((bool)e.NewValue)); IconProperty.Changed.AddClassHandler((s, e) => s.PlatformImpl?.SetIcon(((WindowIcon)e.NewValue).PlatformImpl)); } @@ -173,10 +173,10 @@ namespace Avalonia.Controls /// Enables or disables the taskbar icon /// /// - public bool HasTaskbarIcon + public bool ShowInTaskbar { - get { return GetValue(HasTaskbarIconProperty); } - set { SetValue(HasTaskbarIconProperty, value); } + get { return GetValue(ShowInTaskbarProperty); } + set { SetValue(ShowInTaskbarProperty, value); } } ///