diff --git a/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj b/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj
index 87f03fea..05ea8133 100644
--- a/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj
+++ b/Dapplo.CaliburnMicro.Demo.Addon/Dapplo.CaliburnMicro.Demo.Addon.csproj
@@ -63,24 +63,18 @@
-
- ..\packages\Caliburn.Micro.3.0.1\lib\net45\System.Windows.Interactivity.dllTrue
-
-
-
-
-
+
diff --git a/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs b/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs
index 24f4210f..c599f1e3 100644
--- a/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs
+++ b/Dapplo.CaliburnMicro.Demo.Addon/Languages/IAddonTranslations.cs
@@ -26,12 +26,15 @@
#endregion
-namespace Dapplo.CaliburnMicro.Demo.Languages
+namespace Dapplo.CaliburnMicro.Demo.Addon.Languages
{
[Language("Addon1")]
public interface IAddonTranslations : ILanguage, INotifyPropertyChanged
{
[DefaultValue("Blub")]
string Addon { get; }
+
+ [DefaultValue("Can't touch me")]
+ string NotSelectableAddon { get; }
}
}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs
index f563e9cd..3599d250 100644
--- a/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs
+++ b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/AddonSettingsViewModel.cs
@@ -23,16 +23,18 @@
using System.ComponentModel.Composition;
using Caliburn.Micro;
-using Dapplo.CaliburnMicro.Demo.Interfaces;
+using Dapplo.CaliburnMicro.Configuration;
+using Dapplo.CaliburnMicro.Demo.Addon.Languages;
using Dapplo.CaliburnMicro.Demo.Languages;
+using Dapplo.CaliburnMicro.Demo.UseCases.Configuration;
using Dapplo.Utils.Extensions;
#endregion
namespace Dapplo.CaliburnMicro.Demo.Addon.ViewModels
{
- [Export(typeof(ISettingsControl))]
- public class AddonSettingsViewModel : Screen, ISettingsControl, IPartImportsSatisfiedNotification
+ [Export(typeof(IConfigScreen))]
+ public sealed class AddonSettingsViewModel : ConfigScreen, IPartImportsSatisfiedNotification
{
[Import]
public IAddonTranslations AddonTranslations { get; set; }
@@ -51,7 +53,10 @@ public void OnImportsSatisfied()
public void DoSomething()
{
- EventAggregator.PublishOnUIThread("Addon clicked");
+ EventAggregator.PublishOnUIThread("Addon button clicked");
}
+
+ public override int ParentId { get; } = (int)ConfigIds.Addons;
+ public override int Id { get; } = (int) (ConfigIds.Addons + 1);
}
}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/NotSelectableConfigViewModel.cs b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/NotSelectableConfigViewModel.cs
new file mode 100644
index 00000000..db6d5e24
--- /dev/null
+++ b/Dapplo.CaliburnMicro.Demo.Addon/ViewModels/NotSelectableConfigViewModel.cs
@@ -0,0 +1,55 @@
+// Dapplo - building blocks for desktop applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#region using
+
+using System.ComponentModel.Composition;
+using Caliburn.Micro;
+using Dapplo.CaliburnMicro.Configuration;
+using Dapplo.CaliburnMicro.Demo.Addon.Languages;
+using Dapplo.CaliburnMicro.Demo.Languages;
+using Dapplo.CaliburnMicro.Demo.UseCases.Configuration;
+using Dapplo.Utils.Extensions;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Demo.Addon.ViewModels
+{
+ [Export(typeof(IConfigScreen))]
+ public sealed class NotSelectableConfigViewModel : ConfigScreen, IPartImportsSatisfiedNotification
+ {
+ [Import]
+ public IAddonTranslations AddonTranslations { get; set; }
+
+ public void OnImportsSatisfied()
+ {
+ IsEnabled = false;
+ // automatically update the DisplayName
+ AddonTranslations.OnPropertyChanged(e =>
+ {
+ DisplayName = AddonTranslations.NotSelectableAddon;
+ }, nameof(IAddonTranslations.NotSelectableAddon));
+ }
+
+ public override int ParentId { get; } = (int)ConfigIds.Addons;
+ public override int Id { get; } = (int)(ConfigIds.Addons + 2);
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj b/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj
index 9ecc0f4c..bfd24559 100644
--- a/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj
+++ b/Dapplo.CaliburnMicro.Demo/Dapplo.CaliburnMicro.Demo.csproj
@@ -107,7 +107,7 @@
-
+
@@ -116,11 +116,14 @@
+
+
+
-
+
-
+
@@ -181,7 +184,7 @@
DesignerMSBuild:Compile
-
+ DesignerMSBuild:Compile
@@ -189,7 +192,7 @@
DesignerMSBuild:Compile
-
+ DesignerMSBuild:Compile
diff --git a/Dapplo.CaliburnMicro.Demo/Interfaces/ISettingsControl.cs b/Dapplo.CaliburnMicro.Demo/Languages/IConfigTranslations.cs
similarity index 80%
rename from Dapplo.CaliburnMicro.Demo/Interfaces/ISettingsControl.cs
rename to Dapplo.CaliburnMicro.Demo/Languages/IConfigTranslations.cs
index 73b8bb8f..df7d1c85 100644
--- a/Dapplo.CaliburnMicro.Demo/Interfaces/ISettingsControl.cs
+++ b/Dapplo.CaliburnMicro.Demo/Languages/IConfigTranslations.cs
@@ -21,13 +21,17 @@
#region using
-using Caliburn.Micro;
+using System.ComponentModel;
+using Dapplo.Config.Language;
#endregion
-namespace Dapplo.CaliburnMicro.Demo.Interfaces
+namespace Dapplo.CaliburnMicro.Demo.Languages
{
- public interface ISettingsControl : IHaveDisplayName
+ [Language("Config")]
+ public interface IConfigTranslations : ILanguage, INotifyPropertyChanged
{
+ string Ui { get; }
+ string Addons { get; }
}
}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml b/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml
index 9995d8ce..22841be7 100644
--- a/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml
+++ b/Dapplo.CaliburnMicro.Demo/Languages/language-de-DE.xml
@@ -8,6 +8,10 @@
EinstellungenSprache ändern
+
+ Benutzeroberfläche
+ Erweiterungen
+ BenutzernamePaswort
diff --git a/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml b/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml
index f979b298..d8afbece 100644
--- a/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml
+++ b/Dapplo.CaliburnMicro.Demo/Languages/language-en-US.xml
@@ -8,6 +8,10 @@
SettingsChange language
+
+ User interface
+ Addons
+ UsernamePassword
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ConfigIds.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ConfigIds.cs
new file mode 100644
index 00000000..65b108b2
--- /dev/null
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ConfigIds.cs
@@ -0,0 +1,48 @@
+#region Dapplo 2016 - GNU Lesser General Public License
+
+// Dapplo - building blocks for .NET applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration
+{
+ ///
+ /// Used to make it possible to add a ConfigScreen to a well defined parent node
+ ///
+ public enum ConfigIds
+ {
+ ///
+ /// The root ID
+ ///
+ Root = 0,
+
+ ///
+ /// UI related config screens should have this as parent
+ ///
+ Ui = 100,
+
+ ///
+ /// Config screens from addons should have this as parent
+ ///
+ Addons = 200
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/AddonConfigNodeViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/AddonConfigNodeViewModel.cs
new file mode 100644
index 00000000..8be83f89
--- /dev/null
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/AddonConfigNodeViewModel.cs
@@ -0,0 +1,56 @@
+// Dapplo - building blocks for desktop applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#region using
+
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.Threading.Tasks;
+using Caliburn.Micro;
+using Dapplo.CaliburnMicro.Configuration;
+using Dapplo.CaliburnMicro.Demo.Languages;
+using Dapplo.CaliburnMicro.Demo.Models;
+using Dapplo.Config.Language;
+using Dapplo.Utils.Extensions;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels
+{
+ [Export(typeof(IConfigScreen))]
+ public sealed class AddonConfigNodeViewModel : ConfigScreen, IPartImportsSatisfiedNotification
+ {
+ [Import]
+ public IConfigTranslations ConfigTranslations { get; set; }
+
+ public void OnImportsSatisfied()
+ {
+ // automatically update the DisplayName
+ ConfigTranslations.OnPropertyChanged(pcEvent =>
+ {
+ DisplayName = ConfigTranslations.Addons;
+ }, nameof(IConfigTranslations.Addons));
+ CanActivate = false;
+ }
+
+ public override int Id { get; } = (int) ConfigIds.Addons;
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/SettingsViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/ConfigViewModel.cs
similarity index 86%
rename from Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/SettingsViewModel.cs
rename to Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/ConfigViewModel.cs
index 2cf68595..d47d13ce 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/SettingsViewModel.cs
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/ConfigViewModel.cs
@@ -25,7 +25,7 @@
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Caliburn.Micro;
-using Dapplo.CaliburnMicro.Demo.Interfaces;
+using Dapplo.CaliburnMicro.Configuration;
using Dapplo.CaliburnMicro.Demo.Languages;
using Dapplo.CaliburnMicro.Demo.Models;
using Dapplo.CaliburnMicro.Demo.ViewModels;
@@ -43,12 +43,15 @@ namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels
/// It is a conductor where one item is active.
///
[Export]
- public class SettingsViewModel : Conductor.Collection.OneActive, IPartImportsSatisfiedNotification
+ public class ConfigViewModel : Config, IPartImportsSatisfiedNotification
{
private static readonly LogSource Log = new LogSource();
[Import]
- private ICoreTranslations CoreTranslations { get; set; }
+ public ICoreTranslations CoreTranslations { get; set; }
+
+ [Import]
+ public IConfigTranslations ConfigTranslations { get; set; }
[Import]
private CredentialsViewModel CredentialsVm { get; set; }
@@ -66,7 +69,7 @@ public class SettingsViewModel : Conductor.Collection.OneActiv
/// Get all settings controls, these are the items that are displayed.
///
[ImportMany]
- private IEnumerable SettingsControls { get; set; }
+ public override IEnumerable ConfigScreens { get; set; }
///
/// Used to show a "normal" dialog
@@ -85,7 +88,7 @@ public class SettingsViewModel : Conductor.Collection.OneActiv
/// And will make sure that the selected item is made visible.
///
///
- public void ActivateChildView(ISettingsControl view)
+ public void ActivateChildView(IConfigScreen view)
{
ActivateItem(view);
}
@@ -108,14 +111,6 @@ public async Task Dialog()
await Dialogcoordinator.ShowMessageAsync(this, "Message from VM", "MVVM based dialogs!");
}
- protected override void OnActivate()
- {
- base.OnActivate();
- // Add all the imported settings controls
- // TODO: Sort them for a tree view, somehow...
- Items.AddRange(SettingsControls);
- }
-
public void OnImportsSatisfied()
{
// automatically update the DisplayName
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageSettingsViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageConfigViewModel.cs
similarity index 89%
rename from Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageSettingsViewModel.cs
rename to Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageConfigViewModel.cs
index bab1a74c..c5cb5ca1 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageSettingsViewModel.cs
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/LanguageConfigViewModel.cs
@@ -25,7 +25,7 @@
using System.ComponentModel.Composition;
using System.Threading.Tasks;
using Caliburn.Micro;
-using Dapplo.CaliburnMicro.Demo.Interfaces;
+using Dapplo.CaliburnMicro.Configuration;
using Dapplo.CaliburnMicro.Demo.Languages;
using Dapplo.CaliburnMicro.Demo.Models;
using Dapplo.Config.Language;
@@ -35,8 +35,8 @@
namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels
{
- [Export(typeof(ISettingsControl))]
- public class LanguageSettingsViewModel : Screen, ISettingsControl, IPartImportsSatisfiedNotification
+ [Export(typeof(IConfigScreen))]
+ public sealed class LanguageConfigViewModel : ConfigScreen, IPartImportsSatisfiedNotification
{
public IDictionary AvailableLanguages => LanguageLoader.Current.AvailableLanguages;
@@ -74,5 +74,9 @@ public async Task ChangeLanguage()
EventAggregator.PublishOnUIThread($"Changing to language: {DemoConfiguration.Language}");
await LanguageLoader.Current.ChangeLanguageAsync(DemoConfiguration.Language).ConfigureAwait(false);
}
+
+ public override int ParentId { get; } = (int)ConfigIds.Ui;
+
+ public override int Id { get; } = (int) ConfigIds.Ui + 1;
}
}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/UiConfigNodeViewModel.cs b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/UiConfigNodeViewModel.cs
new file mode 100644
index 00000000..11cea4ee
--- /dev/null
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/ViewModels/UiConfigNodeViewModel.cs
@@ -0,0 +1,56 @@
+// Dapplo - building blocks for desktop applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#region using
+
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.Threading.Tasks;
+using Caliburn.Micro;
+using Dapplo.CaliburnMicro.Configuration;
+using Dapplo.CaliburnMicro.Demo.Languages;
+using Dapplo.CaliburnMicro.Demo.Models;
+using Dapplo.Config.Language;
+using Dapplo.Utils.Extensions;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Demo.UseCases.Configuration.ViewModels
+{
+ [Export(typeof(IConfigScreen))]
+ public sealed class UiConfigNodeViewModel : ConfigScreen, IPartImportsSatisfiedNotification
+ {
+ [Import]
+ public IConfigTranslations ConfigTranslations { get; set; }
+
+ public void OnImportsSatisfied()
+ {
+ // automatically update the DisplayName
+ ConfigTranslations.OnPropertyChanged(pcEvent =>
+ {
+ DisplayName = ConfigTranslations.Ui;
+ }, nameof(IConfigTranslations.Ui));
+ CanActivate = false;
+ }
+
+ public override int Id { get; } = (int) ConfigIds.Ui;
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/SettingsView.xaml b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/ConfigView.xaml
similarity index 50%
rename from Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/SettingsView.xaml
rename to Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/ConfigView.xaml
index dce5599a..cba71767 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/SettingsView.xaml
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/ConfigView.xaml
@@ -1,10 +1,13 @@
-
+ Width="500" Height="400">
+
+
+
@@ -15,20 +18,29 @@
-
+
-
+
-
+
+
+
+
-
+
-
+
+
+
+
+
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/LanguageSettingsView.xaml b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/LanguageConfigView.xaml
similarity index 93%
rename from Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/LanguageSettingsView.xaml
rename to Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/LanguageConfigView.xaml
index fc10a58c..9d0fbaed 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/LanguageSettingsView.xaml
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Configuration/Views/LanguageConfigView.xaml
@@ -1,4 +1,4 @@
-
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep1View.xaml b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep1View.xaml
index 84ea473d..18602c9d 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep1View.xaml
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep1View.xaml
@@ -2,10 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:Dapplo.CaliburnMicro.Demo.Views"
- mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300">
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d" d:DesignHeight="200" d:DesignWidth="200">
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep2View.xaml b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep2View.xaml
index 82c7a1c7..094a7b1a 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep2View.xaml
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep2View.xaml
@@ -2,10 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:Dapplo.CaliburnMicro.Demo.Views"
- mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300">
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep3View.xaml b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep3View.xaml
index 08ea0304..29ab8485 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep3View.xaml
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep3View.xaml
@@ -2,10 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:Dapplo.CaliburnMicro.Demo.Views"
- mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300">
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
diff --git a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep4View.xaml b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep4View.xaml
index 66effc80..874a95ee 100644
--- a/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep4View.xaml
+++ b/Dapplo.CaliburnMicro.Demo/UseCases/Wizard/Views/WizardStep4View.xaml
@@ -2,10 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:Dapplo.CaliburnMicro.Demo.Views"
- mc:Ignorable="d"
- d:DesignHeight="300" d:DesignWidth="300">
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
diff --git a/Dapplo.CaliburnMicro.Demo/ViewModels/TrayIconViewModel.cs b/Dapplo.CaliburnMicro.Demo/ViewModels/TrayIconViewModel.cs
index b6fd43b8..e8de4d47 100644
--- a/Dapplo.CaliburnMicro.Demo/ViewModels/TrayIconViewModel.cs
+++ b/Dapplo.CaliburnMicro.Demo/ViewModels/TrayIconViewModel.cs
@@ -56,7 +56,7 @@ public class TrayIconViewModel : Screen, ITrayIconViewModel, IHandle
[Import]
- public SettingsViewModel SettingsViewModel { get; set; }
+ public ConfigViewModel ConfigViewModel { get; set; }
public void Handle(string message)
{
@@ -72,7 +72,13 @@ public bool CanShowSomething()
public void Configure()
{
Log.Debug().WriteLine("Configure");
- WindowManager.ShowWindow(SettingsViewModel);
+ // TODO: Closing the ConfigViewModel also closes other windows, check / fix
+ if (WindowManager.ShowDialog(ConfigViewModel) == false)
+ {
+ // Lookup my tray icon
+ var trayIcon = TrayIconManager.GetTrayIconFor(this);
+ trayIcon.ShowBalloonTip("Cancelled", "You cancelled the configuration");
+ }
}
public void Exit()
diff --git a/Dapplo.CaliburnMicro.Demo/Views/NotificationExampleView.xaml b/Dapplo.CaliburnMicro.Demo/Views/NotificationExampleView.xaml
index 788d63c4..f9afac3d 100644
--- a/Dapplo.CaliburnMicro.Demo/Views/NotificationExampleView.xaml
+++ b/Dapplo.CaliburnMicro.Demo/Views/NotificationExampleView.xaml
@@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:Dapplo.CaliburnMicro.Demo.Views"
mc:Ignorable="d" Width="200" Height="40">
diff --git a/Dapplo.CaliburnMicro.Metro/MetroWindowManager.cs b/Dapplo.CaliburnMicro.Metro/MetroWindowManager.cs
index f0403667..8284c68b 100644
--- a/Dapplo.CaliburnMicro.Metro/MetroWindowManager.cs
+++ b/Dapplo.CaliburnMicro.Metro/MetroWindowManager.cs
@@ -22,15 +22,11 @@
#region using
using System;
-using System.Collections.Generic;
using System.ComponentModel.Composition;
-using System.IO;
using System.Linq;
-using System.Reflection;
using System.Windows;
using Caliburn.Micro;
using MahApps.Metro.Controls;
-using System.Windows.Media;
using MahApps.Metro.Controls.Dialogs;
using Dapplo.Log.Facade;
@@ -80,12 +76,7 @@ public MetroWindowManager()
/// Export the IDialogCoordinator of MahApps, so ViewModels can open MahApps dialogs
///
[Export]
- public IDialogCoordinator MahAppsDialogCoordinator {
- get
- {
- return DialogCoordinator.Instance;
- }
- }
+ public IDialogCoordinator MahAppsDialogCoordinator => DialogCoordinator.Instance;
///
/// Add a ResourceDictionary for the specified MahApps style
diff --git a/Dapplo.CaliburnMicro/Configuration/Config.cs b/Dapplo.CaliburnMicro/Configuration/Config.cs
new file mode 100644
index 00000000..7e02aa15
--- /dev/null
+++ b/Dapplo.CaliburnMicro/Configuration/Config.cs
@@ -0,0 +1,232 @@
+#region Dapplo 2016 - GNU Lesser General Public License
+
+// Dapplo - building blocks for .NET applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#endregion
+
+#region Usings
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Caliburn.Micro;
+using Dapplo.Log.Facade;
+using System.Collections.ObjectModel;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Configuration
+{
+ ///
+ /// This implements a Caliburn-Micro Config UI
+ ///
+ public abstract class Config : Conductor.Collection.OneActive, IConfig
+ where TConfigScreen : class, IConfigScreen
+ {
+ // ReSharper disable once StaticMemberInGenericType
+ private static readonly LogSource Log = new LogSource();
+
+ ///
+ /// This is called when the config needs to initialize stuff, it will call Initialize on every screen
+ ///
+ public virtual void Initialize()
+ {
+ Log.Verbose().WriteLine("Initializing config");
+
+ foreach (var configScreen in ConfigScreens)
+ {
+ configScreen.Initialize(this);
+ }
+ }
+
+ ///
+ /// This is called when the config needs to cleanup things, it will call Terminate on every screen
+ ///
+ public virtual void Terminate()
+ {
+ Log.Verbose().WriteLine("Terminating config");
+ foreach (var configScreen in ConfigScreens)
+ {
+ configScreen.Terminate();
+ }
+ }
+
+ ///
+ /// The TConfigScreen items of the config
+ ///
+ public virtual IEnumerable ConfigScreens { get; set; }
+
+ ///
+ /// This implements IConfig.ConfigScreens via ConfigScreens
+ ///
+ IEnumerable IConfig.ConfigScreens
+ {
+ get { return ConfigScreens; }
+ set { ConfigScreens = value as ICollection; }
+ }
+
+ ///
+ /// This implements IConfig.TreeItems via ConfigScreens
+ ///
+ public virtual ICollection TreeItems { get; } = new ObservableCollection();
+
+ ///
+ /// This return or sets the current config screen
+ ///
+ public virtual TConfigScreen CurrentConfigScreen
+ {
+ get { return ActiveItem; }
+ set { ActivateItem(value); }
+ }
+
+ ///
+ /// This implements IConfig.CurrentConfigScreen via CurrentConfigScreen
+ ///
+ IConfigScreen IConfig.CurrentConfigScreen
+ {
+ get { return CurrentConfigScreen; }
+ set { CurrentConfigScreen = value as TConfigScreen; }
+ }
+
+ ///
+ /// This will call TryClose with false if all IConfigScreen items are okay with closing
+ ///
+ public virtual void Cancel()
+ {
+ if (CanCancel)
+ {
+ TryClose(false);
+ }
+ }
+
+ ///
+ /// check every IConfigScreen if it can close
+ ///
+ public virtual bool CanCancel
+ {
+ get
+ {
+ var result = true;
+ CanClose(b => result = b);
+ return result;
+ }
+ }
+
+ ///
+ /// This will call TryClose with true if all IConfigScreen items are okay with closing
+ ///
+ public virtual void Ok()
+ {
+ if (CanOk)
+ {
+ TryClose(true);
+ }
+ }
+
+ ///
+ /// check every IConfigScreen if it can close
+ ///
+ public virtual bool CanOk
+ {
+ get
+ {
+ var result = true;
+ CanClose(b => result = b);
+ return result;
+ }
+ }
+
+ ///
+ /// Called to check whether or not this instance can close.
+ ///
+ /// The implementor calls this action with the result of the close check.
+ public override void CanClose(Action callback)
+ {
+ var result = true;
+ foreach (var configScreen in ConfigScreens)
+ {
+ configScreen.CanClose(canClose => result &= canClose);
+ }
+ callback(result);
+ }
+
+ ///
+ /// Tries to close this instance by asking its Parent to initiate shutdown or by asking its corresponding view to
+ /// close.
+ /// Also provides an opportunity to pass a dialog result to it's corresponding view.
+ ///
+ /// The dialog result.
+ public override void TryClose(bool? dialogResult = null)
+ {
+ // Terminate needs to be called before TryClose, otherwise our items are gone.
+ Terminate();
+ base.TryClose(dialogResult);
+ }
+
+ /// Called when activating.
+ protected override void OnActivate()
+ {
+ // Build a tree for the ConfigScreens
+ foreach (var configScreen in ConfigScreens)
+ {
+ Items.Add(configScreen);
+ if (configScreen.ParentId == 0)
+ {
+ TreeItems.Add(configScreen);
+ }
+ else
+ {
+ var parentScreen = ConfigScreens.FirstOrDefault(x => x.Id == configScreen.ParentId);
+ // Check if a parent was found, if not log a warning and place it in the root
+ if (parentScreen == null)
+ {
+ Log.Warn().WriteLine("ParentId {0} for config screen {1} not found, adding it to the root", configScreen.ParentId, configScreen.Id);
+ TreeItems.Add(configScreen);
+ }
+ else
+ {
+ parentScreen.ChildNodes.Add(configScreen);
+ }
+ }
+ }
+
+ Initialize();
+
+ base.OnActivate();
+ }
+
+ ///
+ /// Activates the specified config screen, and sends notify property changed events.
+ ///
+ /// The TConfigScreen to activate.
+ public override void ActivateItem(TConfigScreen configScreen)
+ {
+ if (configScreen.CanActivate)
+ {
+ base.ActivateItem(configScreen);
+ NotifyOfPropertyChange(nameof(CurrentConfigScreen));
+ NotifyOfPropertyChange(nameof(CanCancel));
+ NotifyOfPropertyChange(nameof(CanOk));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro/Configuration/ConfigScreen.cs b/Dapplo.CaliburnMicro/Configuration/ConfigScreen.cs
new file mode 100644
index 00000000..7346a042
--- /dev/null
+++ b/Dapplo.CaliburnMicro/Configuration/ConfigScreen.cs
@@ -0,0 +1,124 @@
+#region Dapplo 2016 - GNU Lesser General Public License
+
+// Dapplo - building blocks for .NET applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#endregion
+
+#region Usings
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Caliburn.Micro;
+using Dapplo.CaliburnMicro.Misc;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Configuration
+{
+ ///
+ /// A basic implementation of IConfigScreen
+ ///
+ public abstract class ConfigScreen : Screen, IConfigScreen
+ {
+ private bool _isEnabled = true;
+ private bool _canActivate = true;
+ private bool _isVisible = true;
+
+ #region ITreeNode
+ ///
+ /// Used to showing this inside a tree
+ ///
+ public virtual ITreeNode ParentNode { get; set; }
+
+ ///
+ /// Used to showing this inside a tree
+ ///
+ public virtual ICollection> ChildNodes { get; set; } = new ObservableCollection>();
+ #endregion
+
+ ///
+ /// The parent under which the IConfigScreen is shown, 0 is root
+ ///
+ public virtual int ParentId { get; }
+
+ ///
+ /// The Id of this config screen, is also used to order children of a parent
+ ///
+ public abstract int Id { get; }
+
+ ///
+ /// Do some general initialization, if needed
+ /// This is called when the config UI is initializing
+ ///
+ public virtual void Initialize(IConfig config)
+ {
+ }
+
+ ///
+ /// Terminate the config screen.
+ /// This is called when the parent config UI terminates, no matter if this config screen was shown
+ ///
+ public virtual void Terminate()
+ {
+ }
+
+ ///
+ /// Returns if the config screen can be activated
+ ///
+ public virtual bool CanActivate
+ {
+ get { return _canActivate; }
+ protected set
+ {
+ _canActivate = value;
+ NotifyOfPropertyChange(nameof(CanActivate));
+ }
+ }
+
+ ///
+ /// Returns if the config screen can be selected
+ ///
+ public virtual bool IsEnabled
+ {
+ get { return _isEnabled; }
+ protected set
+ {
+ _isEnabled = value;
+ NotifyOfPropertyChange(nameof(IsEnabled));
+ }
+ }
+
+ ///
+ /// Returns if the config screen is visible
+ ///
+ public virtual bool IsVisible
+ {
+ get { return _isVisible; }
+ protected set
+ {
+ _isVisible = value;
+ NotifyOfPropertyChange(nameof(IsVisible));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro/Configuration/IConfig.cs b/Dapplo.CaliburnMicro/Configuration/IConfig.cs
new file mode 100644
index 00000000..37180ded
--- /dev/null
+++ b/Dapplo.CaliburnMicro/Configuration/IConfig.cs
@@ -0,0 +1,101 @@
+#region Dapplo 2016 - GNU Lesser General Public License
+
+// Dapplo - building blocks for .NET applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#endregion
+
+#region Usings
+
+using System.Collections.Generic;
+using System.ComponentModel;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Configuration
+{
+ ///
+ /// Base interface for the IConfiguration
+ ///
+ public interface IConfig : INotifyPropertyChanged
+ {
+ ///
+ /// The config screens for the config UI
+ ///
+ IEnumerable ConfigScreens { get; set; }
+
+ ///
+ /// Returns the current config screen
+ ///
+ IConfigScreen CurrentConfigScreen { get; set; }
+
+ ///
+ /// The config screens for the config UI in the tree
+ ///
+ ICollection TreeItems { get; }
+
+ ///
+ /// Can the current config be cancelled?
+ ///
+ bool CanCancel { get; }
+
+ ///
+ /// Test if the config can be OKed
+ ///
+ bool CanOk { get; }
+
+ ///
+ /// Initialize will o.a. initialize and sort (tree) the config screens
+ ///
+ void Initialize();
+
+ ///
+ /// Terminate the config.
+ ///
+ void Terminate();
+
+ ///
+ /// Cancel the config
+ ///
+ void Cancel();
+
+ ///
+ /// Ok the config
+ ///
+ void Ok();
+ }
+
+ ///
+ /// This is the generic interface for a config implementation
+ ///
+ public interface IConfig : IConfig
+ {
+ ///
+ /// The IConfigScreen items of the config
+ ///
+ new IEnumerable ConfigScreens { get; }
+
+ ///
+ /// Returns the current config screen
+ ///
+ new TConfigScreen CurrentConfigScreen { get; }
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro/Configuration/IConfigScreen.cs b/Dapplo.CaliburnMicro/Configuration/IConfigScreen.cs
new file mode 100644
index 00000000..19b5ed9a
--- /dev/null
+++ b/Dapplo.CaliburnMicro/Configuration/IConfigScreen.cs
@@ -0,0 +1,85 @@
+#region Dapplo 2016 - GNU Lesser General Public License
+
+// Dapplo - building blocks for .NET applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#endregion
+
+#region Usings
+
+using Caliburn.Micro;
+using Dapplo.CaliburnMicro.Misc;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Configuration
+{
+ ///
+ /// Every element in the config UI should implement this
+ /// Some of the configuration functionality is covered in standard Caliburn.Micro interfaces
+ /// which are supplied by the interfaces which IScreen extends:
+ /// IHaveDisplayName: Covers the name and title of the config screen
+ /// INotifyPropertyChanged: Makes it possible that changes to e.g. the name are directly represented in the view
+ /// IActivate, IDeactivate: to know if the config screen is activated or deactivated
+ /// IGuardClose.CanClose: Prevents leaving the config screen
+ /// A default implementation is just to extend Screen from Caliburn.Micro
+ ///
+ public interface IConfigScreen : IScreen, ITreeNode
+ {
+ ///
+ /// This defines the Location in the tree, by specifying the Id of the parent, where the config screen is shown.
+ /// if the value is 0, or the parent can't be found, this item is placed into the root
+ ///
+ int ParentId { get; }
+
+ ///
+ /// The unique Id of this config screen, is also used to order children of a parent.
+ ///
+ int Id { get; }
+
+ ///
+ /// Returns if the config screen can be activated (when clicking on it)
+ ///
+ bool CanActivate { get; }
+
+ ///
+ /// Returns if the config screen can be selected (visible but not usable)
+ ///
+ bool IsEnabled { get; }
+
+ ///
+ /// Returns if the config screen is visible (not visible and not usable)
+ ///
+ bool IsVisible { get; }
+
+ ///
+ /// Do some general initialization, if needed
+ /// This is called when the config UI is initialized
+ ///
+ void Initialize(IConfig config);
+
+ ///
+ /// Terminate the config screen.
+ /// This is called when the parent config UI is terminated
+ ///
+ void Terminate();
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj b/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj
index b9135732..f092383d 100644
--- a/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj
+++ b/Dapplo.CaliburnMicro/Dapplo.CaliburnMicro.csproj
@@ -87,6 +87,11 @@
+
+
+
+
+
diff --git a/Dapplo.CaliburnMicro/Misc/ITreeNode.cs b/Dapplo.CaliburnMicro/Misc/ITreeNode.cs
new file mode 100644
index 00000000..fdcb7e31
--- /dev/null
+++ b/Dapplo.CaliburnMicro/Misc/ITreeNode.cs
@@ -0,0 +1,50 @@
+#region Dapplo 2016 - GNU Lesser General Public License
+
+// Dapplo - building blocks for .NET applications
+// Copyright (C) 2016 Dapplo
+//
+// For more information see: http://dapplo.net/
+// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
+//
+// This file is part of Dapplo.CaliburnMicro
+//
+// Dapplo.CaliburnMicro is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Dapplo.CaliburnMicro is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have a copy of the GNU Lesser General Public License
+// along with Dapplo.CaliburnMicro. If not, see .
+
+#endregion
+
+#region Usings
+
+using System.Collections.Generic;
+
+#endregion
+
+namespace Dapplo.CaliburnMicro.Misc
+{
+ ///
+ /// Interface for tree nodes
+ ///
+ ///
+ public interface ITreeNode
+ {
+ ///
+ /// The parent for this ITreeNode
+ ///
+ ITreeNode ParentNode { get; set; }
+
+ ///
+ /// The children for this ITreeNode
+ ///
+ ICollection> ChildNodes { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro/Wizard/IWizard.cs b/Dapplo.CaliburnMicro/Wizard/IWizard.cs
index fc72a393..dbd6179f 100644
--- a/Dapplo.CaliburnMicro/Wizard/IWizard.cs
+++ b/Dapplo.CaliburnMicro/Wizard/IWizard.cs
@@ -100,7 +100,7 @@ public interface IWizard : INotifyPropertyChanged
}
///
- /// This is the interface for a wizard implementation
+ /// This is the generic interface for a wizard implementation
///
public interface IWizard : IWizard
{
diff --git a/Dapplo.CaliburnMicro/Wizard/IWizardScreen.cs b/Dapplo.CaliburnMicro/Wizard/IWizardScreen.cs
index 17d740a0..5bc74ba5 100644
--- a/Dapplo.CaliburnMicro/Wizard/IWizardScreen.cs
+++ b/Dapplo.CaliburnMicro/Wizard/IWizardScreen.cs
@@ -32,7 +32,7 @@
namespace Dapplo.CaliburnMicro.Wizard
{
///
- /// Every Step in a wizard should implement this
+ /// Every screen in a wizard should implement this
/// Some of the wizard functionality is covered in standard Caliburn interfaces, which are supplied by the interfaces
/// which IScreen extends:
/// IHaveDisplayName: Covers the name and title of the Wizard screen
@@ -44,28 +44,29 @@ namespace Dapplo.CaliburnMicro.Wizard
public interface IWizardScreen : IScreen
{
///
- /// The order in which the screens are shown
+ /// The order in which the IWizardScreen ist shown
///
int Order { get; }
///
/// Do some general initialization, if needed
- /// This is called, no matter if the IWizardScreen is shown.
+ /// This is called when the parent wizard is initialized
///
void Initialize(IWizard parent);
///
- /// Cleanup the wizard screen
+ /// Terminate the wizard screen.
+ /// This is called when the parent wizard is terminated
///
void Terminate();
///
- /// Returns if the wizard screen can be selected
+ /// Returns if the wizard screen can be selected (visible but not usable)
///
bool IsEnabled { get; }
///
- /// Returns if the wizard screen is visible
+ /// Returns if the wizard screen is visible (not visible and not usable)
///
bool IsVisible { get; }
}
diff --git a/Dapplo.CaliburnMicro/Wizard/Wizard.cs b/Dapplo.CaliburnMicro/Wizard/Wizard.cs
index 360b24de..acfbf24f 100644
--- a/Dapplo.CaliburnMicro/Wizard/Wizard.cs
+++ b/Dapplo.CaliburnMicro/Wizard/Wizard.cs
@@ -25,6 +25,7 @@
#region Usings
+using System;
using System.Collections.Generic;
using System.Linq;
using Caliburn.Micro;
@@ -110,7 +111,7 @@ public override void ActivateItem(TWizardScreen item)
public virtual IEnumerable WizardScreens { get; set; }
///
- /// This implements IWizard.WizardScreens via WizardScreens
+ /// This implements IWizard.WizardScreens via ConfigScreens
///
IEnumerable IWizard.WizardScreens
{
@@ -134,7 +135,7 @@ public virtual TWizardScreen CurrentWizardScreen
}
///
- /// This implements IWizard.CurrentWizardScreen via CurrentWizardScreen
+ /// This implements IWizard.CurrentWizardScreen via CurrentConfigScreen
///
IWizardScreen IWizard.CurrentWizardScreen {
get
@@ -225,10 +226,7 @@ public virtual bool CanCancel
get
{
var result = true;
- foreach (var wizardScreen in WizardScreens.OrderBy(x => x.Order))
- {
- wizardScreen.CanClose(canClose => result &= canClose);
- }
+ CanClose(b => result = b);
return result;
}
}
@@ -247,6 +245,28 @@ public virtual void Finish()
///
/// check every IWizardScreen if it can close
///
- public virtual bool CanFinish => CanCancel;
+ public virtual bool CanFinish
+ {
+ get
+ {
+ var result = true;
+ CanClose(b => result = b);
+ return result;
+ }
+ }
+
+ ///
+ /// Called to check whether or not this instance can close.
+ ///
+ /// The implementor calls this action with the result of the close check.
+ public override void CanClose(Action callback)
+ {
+ var result = true;
+ foreach (var wizardScreen in WizardScreens.OrderBy(x => x.Order))
+ {
+ wizardScreen.CanClose(canClose => result &= canClose);
+ }
+ callback(result);
+ }
}
}
\ No newline at end of file
diff --git a/Dapplo.CaliburnMicro/Wizard/WizardScreen.cs b/Dapplo.CaliburnMicro/Wizard/WizardScreen.cs
index 35d30ad7..d0eb457c 100644
--- a/Dapplo.CaliburnMicro/Wizard/WizardScreen.cs
+++ b/Dapplo.CaliburnMicro/Wizard/WizardScreen.cs
@@ -55,7 +55,7 @@ protected set
///
/// Do some general initialization, if needed
- /// This is called, no matter if the IWizardScreen is shown.
+ /// This is called when the IWizard is initializing, no matter if the IWizardScreen is shown.
///
public virtual void Initialize(IWizard parent)
{
@@ -63,6 +63,7 @@ public virtual void Initialize(IWizard parent)
///
/// Cleanup the wizard screen
+ /// This is called when the IWizard terminates, no matter if the IWizardScreen was shown.
///
public virtual void Terminate()
{