Skip to content

Commit

Permalink
Merge branch 'hotfix/5.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ceo1647 committed Apr 4, 2024
2 parents 3f42ebd + 058f43e commit eebd921
Show file tree
Hide file tree
Showing 13 changed files with 1,649 additions and 156 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ Thumbs.db
Desktop.ini

# Cake - Uncomment if you are using it
tools/**
!tools/packages.config
build.cakeoverrides

# mstest test results
Expand Down Expand Up @@ -159,3 +157,6 @@ data/dsl/*.java
# Nodejs / NPM
node_modules
package-lock.json

!tools/**
!tools/packages.config
8 changes: 4 additions & 4 deletions src/Orc.Controls.Tests/Orc.Controls.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
<PackageReference Include="Fody" Version="6.8.0" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.1" PrivateAssets="all" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NUnit" Version="4.0.1" PrivateAssets="all" />
<PackageReference Include="NUnit" Version="4.1.0" PrivateAssets="all" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Orc.Automation.Tests" Version="5.0.0" />
<PackageReference Include="Orc.Automation.Tests" Version="5.0.1" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" PrivateAssets="all" />
<PackageReference Include="Verify.NUnit" Version="22.8.0" />
<PackageReference Include="Verify.NUnit" Version="23.7.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,7 @@ namespace Orc.Controls.Automation
[Orc.Automation.AutomationMethod]
public void SetItemCheckState(int index, bool isChecked) { }
}
[Orc.Automation.AutomatedControl(ControlTypeName="ListItem")]
[Orc.Automation.Control(ControlTypeName="ListItem")]
public class ColorLegendItemAutomationControl : Orc.Automation.Controls.ListItem
{
public ColorLegendItemAutomationControl(System.Windows.Automation.AutomationElement element) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
namespace Orc.Controls.Tests.UI
{
using NUnit.Framework;
using Orc.Automation.Tests;
namespace Orc.Controls.Tests.UI;

using System;
using System.Linq;
using NUnit.Framework;
using Orc.Automation.Tests;

public partial class ColorLegendTestFacts
public partial class ColorLegendTestFacts
{
[Test]
public void CorrectlySelectItem()
{
[Test]
public void CorrectlySelectItem()
{
var target = Target;
var target = Target;

const int itemIndex = 2;

var selectedItem = target.Items[itemIndex];

EventAssert.Raised(target, nameof(target.SelectionChanged), () => selectedItem.Select());

var model = target.Current;

var selectedSourceItems = (model.ItemsSource ?? Array.Empty<IColorLegendItem>())
.Where(x => x.IsSelected)
.ToArray();

const int itemIndex = 2;
Assert.That(selectedSourceItems, Has.Length.EqualTo(1));

EventAssert.Raised(target, nameof(target.SelectionChanged), () => target.Items[itemIndex].Select());
}
var selectedItemData = selectedSourceItems.Single();
Assert.That(selectedItem.Description, Is.EqualTo(selectedItemData.Description));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Orc.Controls.Automation;
using Orc.Automation;
using Orc.Automation.Controls;

[AutomatedControl(ControlTypeName = nameof(ControlType.ListItem))]
[Control(ControlTypeName = nameof(ControlType.ListItem))]
public class ColorLegendItemAutomationControl : ListItem
{
public ColorLegendItemAutomationControl(AutomationElement element)
Expand Down
18 changes: 14 additions & 4 deletions src/Orc.Controls/Controls/ColorLegend/Controls/ColorLegend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,13 @@ private void OnListBoxSelectionChanged(object sender, SelectionChangedEventArgs

try
{
SetCurrentValue(SelectedColorItemsProperty, GetSelectedList());
var selectedItems = GetSelectedList().ToList();
foreach (var item in FilteredItemsSource)
{
item.IsSelected = selectedItems.Contains(item);
}

SetCurrentValue(SelectedColorItemsProperty, selectedItems);
SelectionChanged?.Invoke(sender, e);
}
finally
Expand Down Expand Up @@ -602,13 +608,17 @@ public void SetSelectedList(IEnumerable<IColorLegendItem> selectedList)
protected IEnumerable<IColorLegendItem> GetFilteredItems()
{
var items = ItemsSource;
var filter = Filter;

if (items is null || string.IsNullOrEmpty(filter))
if (items is null)
{
return Array.Empty<IColorLegendItem>();
}

var filter = Filter;
if (string.IsNullOrEmpty(filter))
{
return items;
}

try
{
var regex = new Regex(filter.GetRegexStringFromSearchPattern(), RegexOptions.None, TimeSpan.FromSeconds(1));
Expand Down
2 changes: 1 addition & 1 deletion src/Orc.Controls/Orc.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<PackageReference Include="MethodTimer.Fody" Version="3.2.2" PrivateAssets="all" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.1" PrivateAssets="all" />
<PackageReference Include="Obsolete.Fody" Version="5.3.0" PrivateAssets="all" />
<PackageReference Include="Orc.Automation" Version="5.0.0" />
<PackageReference Include="Orc.Automation" Version="5.0.1" />
<PackageReference Include="Orc.FileSystem" Version="5.0.0" />
<PackageReference Include="Orc.Theming" Version="5.0.0" />
</ItemGroup>
Expand Down

0 comments on commit eebd921

Please sign in to comment.