Add project files.

This commit is contained in:
Daniel Clark
2022-11-01 15:26:08 +00:00
parent daa7b59f22
commit 7e4f880821
408 changed files with 16863 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
using System.Linq;
using System.Windows;
namespace TheXamlGuy.Framework.WPF
{
public class Route : IRoute
{
private readonly IRouteDescriptorCollection routes;
public Route(IRouteDescriptorCollection routes)
{
this.routes = routes;
}
public void AddRoute(string name, object route)
{
if (route is FrameworkElement frameworkElement)
{
void HandleUnloaded(object sender, RoutedEventArgs args)
{
if (routes.FirstOrDefault(x => x.Route == sender) is IRouteDescriptor descriptor)
{
routes.Remove(descriptor);
}
}
frameworkElement.Unloaded += HandleUnloaded;
}
if (routes.FirstOrDefault(x => x.Name == name) is IRouteDescriptor descriptor)
{
routes.Remove(descriptor);
}
routes.Add(new RouteDescriptor(name, route));
}
}
}