-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AvailableFor layer filter for selectors
- Loading branch information
1 parent
b1e03c9
commit d94638e
Showing
11 changed files
with
229 additions
and
9 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
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
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
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 |
---|---|---|
|
@@ -25,5 +25,7 @@ public interface IInteractive | |
void HoveringBegin(MapInfo? mapInfo); | ||
|
||
void HoveringEnd(); | ||
|
||
void Cancel(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,19 +1,89 @@ | ||
using Mapsui.Interactivity.Interfaces; | ||
using Mapsui.Layers; | ||
|
||
namespace Mapsui.Interactivity | ||
{ | ||
internal class SelectorBuilder : ISelectorBuilder | ||
{ | ||
private readonly Func<IInteractive> _builder; | ||
private IList<string>? _availableLayers; | ||
private readonly IList<ILayer> _dirtyLayers = new List<ILayer>(); | ||
|
||
public SelectorBuilder(Func<IInteractive> builder) | ||
{ | ||
_builder = builder; | ||
} | ||
|
||
internal LayerCollection? Layers { get; set; } | ||
|
||
public ISelectorBuilder AvailableFor(ILayer[] layers) | ||
{ | ||
_availableLayers = layers.Select(s => s.Name).ToList(); | ||
|
||
return this; | ||
} | ||
|
||
public ISelectorBuilder AvailableFor(ILayer layer) | ||
{ | ||
_availableLayers = new List<string>() { layer.Name }; | ||
|
||
return this; | ||
} | ||
|
||
public ISelectorBuilder AttachTo(LayerCollection layers) | ||
{ | ||
Layers = layers; | ||
|
||
return this; | ||
} | ||
|
||
public ISelectorBuilder AttachTo(IMap map) | ||
{ | ||
Layers = map.Layers; | ||
|
||
return this; | ||
} | ||
|
||
public ISelector Build() | ||
{ | ||
return (ISelector)_builder.Invoke(); | ||
var selector = (ISelector)_builder.Invoke(); | ||
|
||
if (_availableLayers != null && Layers != null) | ||
{ | ||
foreach (var item in Layers) | ||
{ | ||
if (_availableLayers.Contains(item.Name) == true) | ||
{ | ||
if (item.IsMapInfoLayer == false) | ||
{ | ||
item.IsMapInfoLayer = true; | ||
|
||
_dirtyLayers.Add(item); | ||
} | ||
} | ||
else | ||
{ | ||
if (item.IsMapInfoLayer == true) | ||
{ | ||
item.IsMapInfoLayer = false; | ||
|
||
_dirtyLayers.Add(item); | ||
} | ||
} | ||
} | ||
} | ||
|
||
selector.Canceling.Subscribe(s => | ||
{ | ||
foreach (var item in _dirtyLayers) | ||
{ | ||
item.IsMapInfoLayer = !item.IsMapInfoLayer; | ||
} | ||
|
||
_dirtyLayers.Clear(); | ||
}); | ||
|
||
return selector; | ||
} | ||
} | ||
} |
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
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