Skip to content

Commit a546057

Browse files
committed
wpf unload done
1 parent 826304d commit a546057

50 files changed

Lines changed: 683 additions & 802 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Lemon.ModuleNavigation.Avaloniaui/ContentRegion.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override void Activate(NavigationContext target)
4343
{
4444
if(Content is NavigationContext current)
4545
{
46-
if (target.TargetViewName == current.TargetViewName
46+
if (target.ViewName == current.ViewName
4747
&& !target.RequestNew)
4848
{
4949
return;
@@ -57,7 +57,7 @@ public override void DeActivate(string regionName)
5757
{
5858
if (Content is NavigationContext current)
5959
{
60-
if (current.TargetViewName == regionName)
60+
if (current.ViewName == regionName)
6161
{
6262
Contexts.Remove(current);
6363
Content = null;

src/Lemon.ModuleNavigation.Avaloniaui/ItemsRegion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public override void Activate(NavigationContext target)
8686
}
8787
public override void DeActivate(string viewName)
8888
{
89-
Contexts.Remove(Contexts.Last(c => c.TargetViewName == viewName));
89+
Contexts.Remove(Contexts.Last(c => c.ViewName == viewName));
9090
}
9191
public override void DeActivate(NavigationContext navigationContext)
9292
{

src/Lemon.ModuleNavigation.Avaloniaui/Region.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ private IDataTemplate CreateRegionDataTemplate()
3535
return null;
3636

3737
bool needNewView = context.RequestNew ||
38-
!_viewCache.TryGetValue(context.TargetViewName, out IView? view);
38+
!_viewCache.TryGetValue(context.ViewName, out IView? view);
3939

4040
if (needNewView)
4141
{
42-
view = context.ServiceProvider.GetRequiredKeyedService<IView>(context.TargetViewName);
43-
var navigationAware = context.ServiceProvider.GetRequiredKeyedService<INavigationAware>(context.TargetViewName);
42+
view = context.ServiceProvider.GetRequiredKeyedService<IView>(context.ViewName);
43+
var navigationAware = context.ServiceProvider.GetRequiredKeyedService<INavigationAware>(context.ViewName);
4444

4545
if (_current.TryTakeData(out var previousData))
4646
{
@@ -52,11 +52,11 @@ private IDataTemplate CreateRegionDataTemplate()
5252
view.DataContext = navigationAware;
5353
navigationAware.OnNavigatedTo(context);
5454
_current.SetData((view, navigationAware));
55-
_viewCache.TryAdd(context.TargetViewName, view);
55+
_viewCache.TryAdd(context.ViewName, view);
5656
}
5757
else
5858
{
59-
view = _viewCache[context.TargetViewName];
59+
view = _viewCache[context.ViewName];
6060
}
6161

6262
return view as Control;

src/Lemon.ModuleNavigation.Avaloniaui/TabRegion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public override void Activate(NavigationContext target)
8989
}
9090
public override void DeActivate(string viewName)
9191
{
92-
Contexts.Remove(Contexts.Last(c => c.TargetViewName == viewName));
92+
Contexts.Remove(Contexts.Last(c => c.ViewName == viewName));
9393
}
9494
public override void DeActivate(NavigationContext navigationContext)
9595
{

src/Lemon.ModuleNavigation.Sample/ViewModels/MainViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ await _dialogService.ShowDialog(content,
9696

9797
_regionManager.NavigationSubscribe<NavigationContext>(n =>
9898
{
99-
_logger.LogDebug($"Request to : {n.RegionName}.{n.TargetViewName}");
99+
_logger.LogDebug($"Request to : {n.RegionName}.{n.ViewName}");
100100
});
101101
_regionManager.NavigationSubscribe<IRegion>(r =>
102102
{

src/Lemon.ModuleNavigation.Sample/ViewModels/ViewAlphaViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Lemon.ModuleNavigation.Abstractions;
22
using Lemon.ModuleNavigation.Core;
3-
using Lemon.ModuleNavigation.Dialogs;
43
using Microsoft.Extensions.Logging;
54
using ReactiveUI;
65
using System;
Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,65 @@
11
using Lemon.ModuleNavigation.Abstractions;
22
using Lemon.ModuleNavigation.Core;
3-
using Lemon.ModuleNavigation.Dialogs;
43
using Microsoft.Extensions.Logging;
54
using ReactiveUI;
65
using System;
76
using System.Reactive;
87

9-
namespace Lemon.ModuleNavigation.Sample.ViewModels
8+
namespace Lemon.ModuleNavigation.Sample.ViewModels;
9+
10+
public class ViewBetaViewModel : SampleViewModelBase,
11+
IDialogAware,
12+
INavigationAware
1013
{
11-
public class ViewBetaViewModel: SampleViewModelBase,
12-
IDialogAware,
13-
INavigationAware
14+
private readonly ILogger _logger;
15+
public ViewBetaViewModel(ILogger<ViewBetaViewModel> logger)
1416
{
15-
private readonly ILogger _logger;
16-
public ViewBetaViewModel(ILogger<ViewBetaViewModel> logger)
17+
_logger = logger;
18+
CloseCommand = ReactiveCommand.Create(() =>
1719
{
18-
_logger = logger;
19-
CloseCommand = ReactiveCommand.Create(() =>
20+
var param = new DialogParameters
2021
{
21-
var param = new DialogParameters
22-
{
23-
{ "from", nameof(ViewAlphaViewModel) }
24-
};
25-
RequestClose?.Invoke(new DialogResult(ButtonResult.OK, param));
26-
});
27-
}
28-
private bool _isDialog = false;
29-
public bool IsDialog
22+
{ "from", nameof(ViewAlphaViewModel) }
23+
};
24+
RequestClose?.Invoke(new DialogResult(ButtonResult.OK, param));
25+
});
26+
}
27+
private bool _isDialog = false;
28+
public bool IsDialog
29+
{
30+
get => _isDialog;
31+
set
3032
{
31-
get => _isDialog;
32-
set
33-
{
34-
this.RaiseAndSetIfChanged(ref _isDialog, value);
35-
}
33+
this.RaiseAndSetIfChanged(ref _isDialog, value);
3634
}
37-
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
38-
public string Title => nameof(ViewAlphaViewModel);
39-
public event Action<IDialogResult>? RequestClose;
35+
}
36+
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
37+
public string Title => nameof(ViewAlphaViewModel);
38+
public event Action<IDialogResult>? RequestClose;
4039

41-
public void OnDialogClosed()
42-
{
43-
_logger.LogInformation("OnDialogClosed");
44-
}
40+
public void OnDialogClosed()
41+
{
42+
_logger.LogInformation("OnDialogClosed");
43+
}
4544

46-
public void OnDialogOpened(IDialogParameters? parameters)
47-
{
48-
_logger.LogInformation($"OnDialogOpened:{parameters?.ToString()}");
49-
IsDialog = true;
50-
}
45+
public void OnDialogOpened(IDialogParameters? parameters)
46+
{
47+
_logger.LogInformation($"OnDialogOpened:{parameters?.ToString()}");
48+
IsDialog = true;
49+
}
5150

52-
public void OnNavigatedTo(NavigationContext navigationContext)
53-
{
54-
55-
}
51+
public void OnNavigatedTo(NavigationContext navigationContext)
52+
{
5653

57-
public bool IsNavigationTarget(NavigationContext navigationContext)
58-
{
59-
return true;
60-
}
54+
}
55+
56+
public bool IsNavigationTarget(NavigationContext navigationContext)
57+
{
58+
return true;
59+
}
60+
61+
public void OnNavigatedFrom(NavigationContext navigationContext)
62+
{
6163

62-
public void OnNavigatedFrom(NavigationContext navigationContext)
63-
{
64-
65-
}
6664
}
6765
}

src/Lemon.ModuleNavigation.Wpf/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[assembly: XmlnsPrefix("https://github.com/NeverMorewd/Lemon.ModuleNavigation", "lm")]
55
[assembly: XmlnsDefinition("https://github.com/NeverMorewd/Lemon.ModuleNavigation", "Lemon.ModuleNavigation")]
66
[assembly: XmlnsDefinition("https://github.com/NeverMorewd/Lemon.ModuleNavigation", "Lemon.ModuleNavigation.Wpf")]
7+
[assembly: XmlnsDefinition("https://github.com/NeverMorewd/Lemon.ModuleNavigation", "Lemon.ModuleNavigation.Wpf.Regions")]
78
[assembly:ThemeInfo(
89
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
910
//(used if a resource is not found in the page,

src/Lemon.ModuleNavigation.Wpf/ContentRegion.cs

Lines changed: 0 additions & 123 deletions
This file was deleted.

src/Lemon.ModuleNavigation.Wpf/DialogService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Lemon.ModuleNavigation.Abstractions;
2-
using Lemon.ModuleNavigation.Dialogs;
2+
using Lemon.ModuleNavigation.Core;
33
using Microsoft.Extensions.DependencyInjection;
44
using System.Windows;
55

0 commit comments

Comments
 (0)