Skip to content

Commit

Permalink
Container finally fixed. Some dialog window changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CrackAndDie committed Feb 29, 2024
1 parent f2492ba commit f7c2919
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Hypocrite.Core/Container/LightContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public object Resolve(Type type, bool withInjections)

public object Resolve(Type type, string name, bool withInjections)
{
return Resolve(type, string.Empty, withInjections, out IContainerRegistration _);
return Resolve(type, name, withInjections, out IContainerRegistration _);
}

public object Resolve(Type type, string name, bool withInjections, out IContainerRegistration outRegistration)
Expand Down
6 changes: 3 additions & 3 deletions Hypocrite.DemoAvalonia/Extensions/DialogExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace Hypocrite.DemoAvalonia.Extensions
{
public static class DialogExtensions
{
public static void ShowMessageDialog(this IDialogService dialogService, string title, string message, DialogButtons buttons, Action<IDialogResult>? callback = null)
public static void ShowMessageDialog(this IDialogService dialogService, string title, string message, DialogButtons buttons, Action<IDialogResult> callback = null)
{
dialogService.ShowCustomDialog<MessageDialogView>(new { Title = title, Message = message, Buttons = buttons }, callback);
}

public static void ShowCustomDialog<DialogType>(this IDialogService dialogService, object? parameters = null, Action<IDialogResult>? callback = null)
public static void ShowCustomDialog<DialogType>(this IDialogService dialogService, object parameters = null, Action<IDialogResult> callback = null)
where DialogType : Control
{
if (Avalonia.Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
Expand All @@ -30,7 +30,7 @@ public static void ShowCustomDialog<DialogType>(this IDialogService dialogServic
}
}

private static IDialogParameters? ParseParameters(object? value)
private static IDialogParameters ParseParameters(object value)
{
if (value == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ protected override void OnKeyDown(Avalonia.Input.KeyEventArgs keyArgs)
[Notify]
public DialogButtons Buttons { get; set; }
[Notify]
public string? Title { get; set; }
public string Title { get; set; }
[Notify]
public string? Message { get; set; }
public string Message { get; set; }

[Notify]
public ICommand YesCommand { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace Hypocrite.DemoAvalonia.ViewModels.HeaderViewModels
public class LeftControlViewModel : ViewModelBase
{
[Injection]
IWindowProgressService? ProgressService { get; set; }
IWindowProgressService ProgressService { get; set; }
#region Commands
[Notify]
public ICommand? ShowDialogCommand { get; private set; }
public ICommand ShowDialogCommand { get; private set; }
#endregion

public override void OnViewAttached()
Expand Down
6 changes: 3 additions & 3 deletions Hypocrite.DemoAvalonia/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ public class MainPageViewModel : ViewModelBase
[Notify]
public Language SelectedLanguage { get; set; } = LocalizationManager.Languages.FirstOrDefault();
[Notify]
public IBrush? BindableBrush { get; set; }
public IBrush BindableBrush { get; set; }

[Injection]
private IThemeSwitcherService<ThemeType>? ThemeSwitcherService { get; set; }
private IThemeSwitcherService<ThemeType> ThemeSwitcherService { get; set; }

public string ChangeThemeTag => "MainPage.ChangeTheme";

public ObservableCollection<Language> Languages => LocalizationManager.Languages;

#region Commands
[Notify]
public ICommand? ChangeThemeCommand { get; private set; }
public ICommand ChangeThemeCommand { get; private set; }
#endregion

public override void OnViewAttached()
Expand Down
1 change: 0 additions & 1 deletion Hypocrite.DemoAvalonia/Views/DialogWindowView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public DialogWindowView()
InitializeComponent();
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
Owner = desktop.MainWindow;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
}
}
Expand Down
1 change: 0 additions & 1 deletion Hypocrite.DemoWpf/Views/DialogWindowView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public partial class DialogWindowView : Window, IDialogWindow
public DialogWindowView()
{
InitializeComponent();
Owner = Application.Current.MainWindow;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
}

Expand Down
5 changes: 4 additions & 1 deletion Hypocrite.Wpf/MVVM/ApplicationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ protected override Window CreateShell()
ev.GetEvent<PreviewDoneEvent>().Subscribe(OnPreviewDone);
return Container.Resolve<IPreviewWindow>() as Window;
}
return Container.Resolve<IBaseWindow>() as Window;
var window = Container.Resolve<IBaseWindow>() as Window;
Application.Current.MainWindow = window;
return window;
}

private void OnPreviewDone()
{
Application.Current.Dispatcher.Invoke(() =>
{
var window = Container.Resolve<IBaseWindow>() as Window;
Application.Current.MainWindow = window;
window.Show();
});
}
Expand Down

0 comments on commit f7c2919

Please sign in to comment.