Skip to content

Commit

Permalink
Fixes #485 by checking for all relevant widths and heights
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Oct 26, 2017
1 parent f2b6fe4 commit f891ef7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
During this fix `RibbonTabControl.GetFirstVisibleItem` was renamed to `RibbonTabControl.GetFirstVisibleAndEnabledItem`.
- [#473](../../issues/473) - RibbonWindow does not resize when Children resize and SizeToContent is used
- [#481](../../issues/481) - ToggleButton behaviour is wrong when GroupName is set
- [#485](../../issues/485) - InRibbonGallery broken when ItemsSource is empty

- ### Enhancements
- `LayoutTransform` and `RenderTransform` can now be used directly on `RibbonWindow` as this now gets forwarded to the first template child of the window. Have a look at `TestWindow` in the showcase application for an example on how to use it. This was added as the fix for [#430](../../issues/430).
Expand Down
24 changes: 24 additions & 0 deletions Fluent.Ribbon.Tests/Controls/InRibbonGalleryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Fluent.Tests.Controls
{
using Fluent.Tests.TestClasses;
using NUnit.Framework;

[TestFixture]
public class InRibbonGalleryTests
{
[Test]
public void Opening_DropDown_Should_Not_Throw_When_GalleryPanel_Has_No_Width()
{
var control = new InRibbonGallery
{
Width = 10,
Height = 30
};

using (new TestRibbonWindow(control))
{
Assert.That(() => control.IsDropDownOpen = true, Throws.Nothing);
}
}
}
}
1 change: 1 addition & 0 deletions Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</Compile>
<Compile Include="AssemblySetup.cs" />
<Compile Include="Controls\BackstageTests.cs" />
<Compile Include="Controls\InRibbonGalleryTests.cs" />
<Compile Include="Controls\QuickAccessToolBarTests.cs" />
<Compile Include="Controls\RibbonTests.cs" />
<Compile Include="Controls\RibbonTitleBarTests.cs" />
Expand Down
1 change: 1 addition & 0 deletions Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</Compile>
<Compile Include="AssemblySetup.cs" />
<Compile Include="Controls\BackstageTests.cs" />
<Compile Include="Controls\InRibbonGalleryTests.cs" />
<Compile Include="Controls\QuickAccessToolBarTests.cs" />
<Compile Include="Controls\RibbonTests.cs" />
<Compile Include="Controls\RibbonTitleBarTests.cs" />
Expand Down
1 change: 1 addition & 0 deletions Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.6.2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</Compile>
<Compile Include="AssemblySetup.cs" />
<Compile Include="Controls\BackstageTests.cs" />
<Compile Include="Controls\InRibbonGalleryTests.cs" />
<Compile Include="Controls\QuickAccessToolBarTests.cs" />
<Compile Include="Controls\RibbonTests.cs" />
<Compile Include="Controls\RibbonTitleBarTests.cs" />
Expand Down
16 changes: 12 additions & 4 deletions Fluent.Ribbon/Controls/InRibbonGallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -728,14 +728,22 @@ public bool IsSnapped

if (value
&& (int)this.ActualWidth > 0
&& (int)this.ActualHeight > 0)
&& (int)this.ActualHeight > 0
&& (int)this.galleryPanel.ActualWidth > 0
&& (int)this.galleryPanel.ActualHeight > 0)
{
// Render the freezed image
RenderOptions.SetBitmapScalingMode(this.snappedImage, BitmapScalingMode.NearestNeighbor);
var renderTargetBitmap = new RenderTargetBitmap((int)this.galleryPanel.ActualWidth,
(int)this.galleryPanel.ActualHeight, 96, 96,
PixelFormats.Pbgra32);

var renderTargetBitmap = new RenderTargetBitmap(
(int)this.galleryPanel.ActualWidth,
(int)this.galleryPanel.ActualHeight,
96,
96,
PixelFormats.Pbgra32);

renderTargetBitmap.Render(this.galleryPanel);

this.snappedImage.Source = renderTargetBitmap;
this.snappedImage.FlowDirection = this.FlowDirection;
this.snappedImage.Width = this.galleryPanel.ActualWidth;
Expand Down

0 comments on commit f891ef7

Please sign in to comment.