-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New : Start & End of regions are now displayed within the filter resu…
…lts. #375
- Loading branch information
Showing
5 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
Src/BlueDotBrigade.Weevil.Gui/Converters/RegionConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
namespace BlueDotBrigade.Weevil.Gui.Converters | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using BlueDotBrigade.Weevil.Data; | ||
using System.Windows.Data; | ||
using System.Windows; | ||
using BlueDotBrigade.Weevil.Gui.Filter; | ||
|
||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
public class RegionStringConverter : IMultiValueConverter | ||
{ | ||
/// <summary> | ||
/// Expects: | ||
/// values[0]: The current IRecord (the item in the ListView) | ||
/// values[1]: The parent FilterViewModel (the DataContext of the UserControl/Window) | ||
/// Returns a string indicating the record's region status: | ||
/// - "Start of Region" | ||
/// - "In Region" | ||
/// - "End of Region" | ||
/// - string.Empty (when the record isn't in any region) | ||
/// </summary> | ||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (values?.Length < 2) | ||
return string.Empty; | ||
|
||
var record = values[0] as IRecord; | ||
var viewModel = values[1] as FilterViewModel; | ||
|
||
if (record == null || viewModel == null) | ||
return string.Empty; | ||
|
||
// You can define your own logic: | ||
// e.g., if region is a single continuous block, you might define: | ||
// - starts with a region if ... | ||
// - ends with a region if ... | ||
// - or "in region" otherwise | ||
if (viewModel.RegionStartsWith(record)) | ||
{ | ||
return "Start of Region"; | ||
} | ||
else if (viewModel.RegionEndsWith(record)) | ||
{ | ||
return "End of Region"; | ||
} | ||
else if (viewModel.RegionContains(record)) | ||
{ | ||
return "In Region"; | ||
} | ||
|
||
return string.Empty; | ||
} | ||
|
||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters